Skip to content

Commit cb9a849

Browse files
chrisbobbegnprice
authored andcommittedMar 18, 2025·
content test: Test tap-link behavior when invalid URL
Thanks Zixuan for noticing we haven't been covering this: #1410 (comment)
1 parent 9201ae4 commit cb9a849

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎test/widgets/content_test.dart

+12-1
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,18 @@ void main() {
871871
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.inAppBrowserView));
872872
});
873873

874-
testWidgets('error dialog if invalid link', (tester) async {
874+
testWidgets('error dialog if invalid URL', (tester) async {
875+
await prepare(tester,
876+
'<p><a href="::invalid::">word</a></p>');
877+
await tapText(tester, find.text('word'));
878+
await tester.pump();
879+
check(testBinding.takeLaunchUrlCalls()).isEmpty();
880+
checkErrorDialog(tester,
881+
expectedTitle: 'Unable to open link',
882+
expectedMessage: 'Link could not be opened: ::invalid::');
883+
});
884+
885+
testWidgets('error dialog if platform cannot open link', (tester) async {
875886
await prepare(tester,
876887
'<p><a href="file:///etc/bad">word</a></p>');
877888
testBinding.launchUrlResult = false;

0 commit comments

Comments
 (0)
Please sign in to comment.