Skip to content

Commit

Permalink
fix tests wip
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <zixuan@zulip.com>
  • Loading branch information
PIG208 committed Dec 30, 2024
1 parent 48316ed commit c77bbad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
22 changes: 11 additions & 11 deletions test/widgets/content_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void main() {
final expectedLaunchUrl = expectedVideo.hrefUrl;
await tester.tap(find.byIcon(Icons.play_arrow_rounded));
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse(expectedLaunchUrl), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse(expectedLaunchUrl), mode: LaunchMode.inAppBrowserView));
}

testWidgets('video preview for youtube embed', (tester) async {
Expand Down Expand Up @@ -754,7 +754,7 @@ void main() {
await tapText(tester, find.text('hello'));

final expectedLaunchMode = defaultTargetPlatform == TargetPlatform.iOS ?
LaunchMode.externalApplication : LaunchMode.platformDefault;
LaunchMode.externalApplication : LaunchMode.inAppBrowserView;
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('https://example/'), mode: expectedLaunchMode));
}, variant: const TargetPlatformVariant({TargetPlatform.android, TargetPlatform.iOS}));
Expand All @@ -772,19 +772,19 @@ void main() {

await tester.tapAt(base.translate(1*fontSize, 0)); // "fXo bar baz"
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.inAppBrowserView));

await tester.tapAt(base.translate(9*fontSize, 0)); // "foo bar bXz"
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('https://b/'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('https://b/'), mode: LaunchMode.inAppBrowserView));
});

testWidgets('link nested in other spans', (tester) async {
await prepare(tester,
'<p><strong><em><a href="https://a/">word</a></em></strong></p>');
await tapText(tester, find.text('word'));
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.inAppBrowserView));
});

testWidgets('link containing other spans', (tester) async {
Expand All @@ -797,27 +797,27 @@ void main() {

await tester.tapAt(base.translate(1*fontSize, 0)); // "tXo words"
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.inAppBrowserView));

await tester.tapAt(base.translate(6*fontSize, 0)); // "two woXds"
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.inAppBrowserView));
});

testWidgets('relative links are resolved', (tester) async {
await prepare(tester,
'<p><a href="/a/b?c#d">word</a></p>');
await tapText(tester, find.text('word'));
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('${eg.realmUrl}a/b?c#d'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('${eg.realmUrl}a/b?c#d'), mode: LaunchMode.inAppBrowserView));
});

testWidgets('link inside HeadingNode', (tester) async {
await prepare(tester,
'<h6><a href="https://a/">word</a></h6>');
await tapText(tester, find.text('word'));
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.inAppBrowserView));
});

testWidgets('error dialog if invalid link', (tester) async {
Expand All @@ -827,7 +827,7 @@ void main() {
await tapText(tester, find.text('word'));
await tester.pump();
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: Uri.parse('file:///etc/bad'), mode: LaunchMode.platformDefault));
.single.equals((url: Uri.parse('file:///etc/bad'), mode: LaunchMode.inAppBrowserView));
checkErrorDialog(tester, expectedTitle: 'Unable to open link');
});
});
Expand Down Expand Up @@ -871,7 +871,7 @@ void main() {
await tapText(tester, find.text('invalid'));
final expectedUrl = eg.realmUrl.resolve('/#narrow/stream/1-check/topic');
check(testBinding.takeLaunchUrlCalls())
.single.equals((url: expectedUrl, mode: LaunchMode.platformDefault));
.single.equals((url: expectedUrl, mode: LaunchMode.inAppBrowserView));
check(pushedRoutes).isEmpty();
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/widgets/profile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void main() {
await tester.tap(find.text(testUrl));
check(testBinding.takeLaunchUrlCalls()).single.equals((
url: Uri.parse(testUrl),
mode: LaunchMode.platformDefault,
mode: LaunchMode.inAppBrowserView,
));
});

Expand All @@ -191,7 +191,7 @@ void main() {
await tester.tap(find.text('externalValue'));
check(testBinding.takeLaunchUrlCalls()).single.equals((
url: Uri.parse('http://example/externalValue'),
mode: LaunchMode.platformDefault,
mode: LaunchMode.inAppBrowserView,
));
});

Expand Down
3 changes: 2 additions & 1 deletion test/widgets/theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void main() {
group('colorSwatchFor', () {
const baseColor = 0xff76ce90;

testWidgets('lightdark animation', (tester) async {
testWidgets('light-dark animation', (tester) async {
addTearDown(testBinding.reset);

final subscription = eg.subscription(eg.stream(), color: baseColor);
Expand All @@ -135,6 +135,7 @@ void main() {

await tester.pumpWidget(const TestZulipApp());
await tester.pump();
await tester.pump();

final element = tester.element(find.byType(Placeholder));
// Compares all the swatch's members; see [ColorSwatch]'s `operator ==`.
Expand Down

0 comments on commit c77bbad

Please sign in to comment.