Skip to content

test [nfc]: Remove WidgetTester type annotation from testWidgets tests. #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions test/widgets/action_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void main() {
await tester.pump(); // [MenuItemButton.onPressed] called in a post-frame callback: flutter/flutter@e4a39fa2e
}

testWidgets('success', (WidgetTester tester) async {
testWidgets('success', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand All @@ -122,7 +122,7 @@ void main() {
});
});

testWidgets('request has an error', (WidgetTester tester) async {
testWidgets('request has an error', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand Down Expand Up @@ -156,7 +156,7 @@ void main() {
await tester.pump(); // [MenuItemButton.onPressed] called in a post-frame callback: flutter/flutter@e4a39fa2e
}

testWidgets('star success', (WidgetTester tester) async {
testWidgets('star success', (tester) async {
final message = eg.streamMessage(flags: []);
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand All @@ -176,7 +176,7 @@ void main() {
});
});

testWidgets('unstar success', (WidgetTester tester) async {
testWidgets('unstar success', (tester) async {
final message = eg.streamMessage(flags: [MessageFlag.starred]);
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand All @@ -196,7 +196,7 @@ void main() {
});
});

testWidgets('star request has an error', (WidgetTester tester) async {
testWidgets('star request has an error', (tester) async {
final message = eg.streamMessage(flags: []);
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand All @@ -217,7 +217,7 @@ void main() {
expectedMessage: 'Invalid message(s)')));
});

testWidgets('unstar request has an error', (WidgetTester tester) async {
testWidgets('unstar request has an error', (tester) async {
final message = eg.streamMessage(flags: [MessageFlag.starred]);
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand Down Expand Up @@ -288,7 +288,7 @@ void main() {
check(contentController).not((it) => it.validationErrors.contains(ContentValidationError.quoteAndReplyInProgress));
}

testWidgets('in channel narrow', (WidgetTester tester) async {
testWidgets('in channel narrow', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: ChannelNarrow(message.streamId));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand All @@ -306,7 +306,7 @@ void main() {
valueBefore: valueBefore, message: message, rawContent: 'Hello world');
});

testWidgets('in topic narrow', (WidgetTester tester) async {
testWidgets('in topic narrow', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand All @@ -324,7 +324,7 @@ void main() {
valueBefore: valueBefore, message: message, rawContent: 'Hello world');
});

testWidgets('in DM narrow', (WidgetTester tester) async {
testWidgets('in DM narrow', (tester) async {
final message = eg.dmMessage(from: eg.selfUser, to: [eg.otherUser]);
await setupToMessageActionSheet(tester,
message: message, narrow: DmNarrow.ofMessage(message, selfUserId: eg.selfUser.userId));
Expand All @@ -343,7 +343,7 @@ void main() {
valueBefore: valueBefore, message: message, rawContent: 'Hello world');
});

testWidgets('request has an error', (WidgetTester tester) async {
testWidgets('request has an error', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand Down Expand Up @@ -372,13 +372,13 @@ void main() {
));
});

testWidgets('not offered in CombinedFeedNarrow (composing to reply is not yet supported)', (WidgetTester tester) async {
testWidgets('not offered in CombinedFeedNarrow (composing to reply is not yet supported)', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: const CombinedFeedNarrow());
check(findQuoteAndReplyButton(tester)).isNull();
});

testWidgets('not offered in MentionsNarrow (composing to reply is not yet supported)', (WidgetTester tester) async {
testWidgets('not offered in MentionsNarrow (composing to reply is not yet supported)', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: const MentionsNarrow());
check(findQuoteAndReplyButton(tester)).isNull();
Expand All @@ -399,7 +399,7 @@ void main() {
await tester.pump(); // [MenuItemButton.onPressed] called in a post-frame callback: flutter/flutter@e4a39fa2e
}

testWidgets('success', (WidgetTester tester) async {
testWidgets('success', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand Down Expand Up @@ -435,7 +435,7 @@ void main() {
matching: find.text(zulipLocalizations.successMessageTextCopied)));
});

testWidgets('request has an error', (WidgetTester tester) async {
testWidgets('request has an error', (tester) async {
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
Expand Down Expand Up @@ -496,7 +496,7 @@ void main() {
await tester.pump(); // [MenuItemButton.onPressed] called in a post-frame callback: flutter/flutter@e4a39fa2e
}

testWidgets('request succeeds; sharing succeeds', (WidgetTester tester) async {
testWidgets('request succeeds; sharing succeeds', (tester) async {
final mockSharePlus = setupMockSharePlus();
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
Expand All @@ -508,7 +508,7 @@ void main() {
check(mockSharePlus.sharedString).equals('Hello world');
});

testWidgets('request succeeds; sharing fails', (WidgetTester tester) async {
testWidgets('request succeeds; sharing fails', (tester) async {
final mockSharePlus = setupMockSharePlus();
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
Expand All @@ -524,7 +524,7 @@ void main() {
expectedTitle: 'Sharing failed')));
});

testWidgets('request has an error', (WidgetTester tester) async {
testWidgets('request has an error', (tester) async {
final mockSharePlus = setupMockSharePlus();
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));
Expand Down
18 changes: 9 additions & 9 deletions test/widgets/actions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void main() {
});


testWidgets('use is:unread optimization', (WidgetTester tester) async {
testWidgets('use is:unread optimization', (tester) async {
const narrow = CombinedFeedNarrow();
await prepare(tester);
connection.prepare(json: UpdateMessageFlagsForNarrowResult(
Expand All @@ -93,7 +93,7 @@ void main() {
});
});

testWidgets('pagination', (WidgetTester tester) async {
testWidgets('pagination', (tester) async {
// Check that `lastProcessedId` returned from an initial
// response is used as `anchorId` for the subsequent request.
final narrow = TopicNarrow.ofMessage(eg.streamMessage());
Expand Down Expand Up @@ -154,7 +154,7 @@ void main() {
}, skip: true, // TODO move this functionality inside markNarrowAsRead
);

testWidgets('on invalid response', (WidgetTester tester) async {
testWidgets('on invalid response', (tester) async {
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
final narrow = TopicNarrow.ofMessage(eg.streamMessage());
await prepare(tester);
Expand Down Expand Up @@ -184,7 +184,7 @@ void main() {
expectedMessage: zulipLocalizations.errorInvalidResponse);
});

testWidgets('CombinedFeedNarrow on legacy server', (WidgetTester tester) async {
testWidgets('CombinedFeedNarrow on legacy server', (tester) async {
const narrow = CombinedFeedNarrow();
await prepare(tester);
// Might as well test with oldUnreadsMissing: true.
Expand All @@ -204,7 +204,7 @@ void main() {
check(store.unreads).oldUnreadsMissing.isTrue();
});

testWidgets('ChannelNarrow on legacy server', (WidgetTester tester) async {
testWidgets('ChannelNarrow on legacy server', (tester) async {
final stream = eg.stream();
final narrow = ChannelNarrow(stream.streamId);
await prepare(tester);
Expand All @@ -220,7 +220,7 @@ void main() {
});
});

testWidgets('TopicNarrow on legacy server', (WidgetTester tester) async {
testWidgets('TopicNarrow on legacy server', (tester) async {
final narrow = TopicNarrow.ofMessage(eg.streamMessage());
await prepare(tester);
connection.zulipFeatureLevel = 154;
Expand All @@ -236,7 +236,7 @@ void main() {
});
});

testWidgets('DmNarrow on legacy server', (WidgetTester tester) async {
testWidgets('DmNarrow on legacy server', (tester) async {
final message = eg.dmMessage(from: eg.otherUser, to: [eg.selfUser]);
final narrow = DmNarrow.ofMessage(message, selfUserId: eg.selfUser.userId);
final unreadMsgs = eg.unreadMsgs(dms: [
Expand All @@ -259,7 +259,7 @@ void main() {
});
});

testWidgets('MentionsNarrow on legacy server', (WidgetTester tester) async {
testWidgets('MentionsNarrow on legacy server', (tester) async {
const narrow = MentionsNarrow();
final message = eg.streamMessage(flags: [MessageFlag.mentioned]);
final unreadMsgs = eg.unreadMsgs(mentions: [message.id]);
Expand All @@ -279,7 +279,7 @@ void main() {
});
});

testWidgets('catch-all api errors', (WidgetTester tester) async {
testWidgets('catch-all api errors', (tester) async {
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
const narrow = CombinedFeedNarrow();
await prepare(tester);
Expand Down
2 changes: 1 addition & 1 deletion test/widgets/autocomplete_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void main() {
check(avatarFinder.evaluate().length).equals(expected ? 1 : 0);
}

testWidgets('options appear, disappear, and change correctly', (WidgetTester tester) async {
testWidgets('options appear, disappear, and change correctly', (tester) async {
final user1 = eg.user(userId: 1, fullName: 'User One', avatarUrl: 'user1.png');
final user2 = eg.user(userId: 2, fullName: 'User Two', avatarUrl: 'user2.png');
final user3 = eg.user(userId: 3, fullName: 'User Three', avatarUrl: 'user3.png');
Expand Down
6 changes: 3 additions & 3 deletions test/widgets/clipboard_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ void main() {
check(await Clipboard.getData('text/plain')).isNotNull().text.equals(expected);
}

testWidgets('iOS', (WidgetTester tester) async {
testWidgets('iOS', (tester) async {
testBinding.deviceInfoResult = const IosDeviceInfo(systemVersion: '16.0');
await call(tester, text: 'asdf');
await checkClipboardText('asdf');
await checkSnackBar(tester, expected: true);
});

testWidgets('Android', (WidgetTester tester) async {
testWidgets('Android', (tester) async {
testBinding.deviceInfoResult = const AndroidDeviceInfo(sdkInt: 33, release: '13');
await call(tester, text: 'asdf');
await checkClipboardText('asdf');
await checkSnackBar(tester, expected: false);
});

testWidgets('Android <13', (WidgetTester tester) async {
testWidgets('Android <13', (tester) async {
testBinding.deviceInfoResult = const AndroidDeviceInfo(sdkInt: 32, release: '12');
await call(tester, text: 'asdf');
await checkClipboardText('asdf');
Expand Down
6 changes: 3 additions & 3 deletions test/widgets/content_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,15 @@ void main() {
testFontWeight('syntax highlighting: non-bold span',
expectedWght: 400,
content: plainContent(ContentExample.codeBlockHighlightedShort.html),
styleFinder: (WidgetTester tester) {
styleFinder: (tester) {
final root = tester.renderObject<RenderParagraph>(find.textContaining('class')).text;
return mergedStyleOfSubstring(root, 'class')!;
});

testFontWeight('syntax highlighting: bold span',
expectedWght: 700,
content: plainContent(ContentExample.codeBlockHighlightedShort.html),
styleFinder: (WidgetTester tester) {
styleFinder: (tester) {
final root = tester.renderObject<RenderParagraph>(find.textContaining('A')).text;
return mergedStyleOfSubstring(root, 'A')!;
});
Expand Down Expand Up @@ -986,7 +986,7 @@ void main() {
debugNetworkImageHttpClientProvider = null;
});

testWidgets('throws if no `PerAccountStoreWidget` ancestor', (WidgetTester tester) async {
testWidgets('throws if no `PerAccountStoreWidget` ancestor', (tester) async {
await tester.pumpWidget(
RealmContentNetworkImage(Uri.parse('https://zulip.invalid/path/to/image.png'), filterQuality: FilterQuality.medium));
check(tester.takeException()).isA<AssertionError>();
Expand Down
Loading