Skip to content

Commit fb4457c

Browse files
committed
app test: Make a prepare accept a list of accounts, instead of one
Also make it explicitly specify which account to log out in the list of accounts.
1 parent 0ffe337 commit fb4457c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

test/widgets/app_test.dart

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,21 @@ void main() {
319319
});
320320

321321
group('log out', () {
322-
Future<(Widget, Widget)> prepare(WidgetTester tester, {required Account account}) async {
323-
await setupChooseAccountPage(tester, accounts: [account]);
324-
325-
final findThreeDotsButton = find.descendant(
326-
of: find.widgetWithText(Card, eg.selfAccount.realmUrl.toString()),
322+
Future<(Widget, Widget)> prepare(WidgetTester tester, {
323+
required List<Account> accounts,
324+
required Account logoutAccount,
325+
}) async {
326+
assert(accounts.contains(logoutAccount));
327+
328+
await setupChooseAccountPage(tester, accounts: accounts);
329+
330+
final findAccountCard = find.ancestor(of: find.text(logoutAccount.realmUrl.toString()),
331+
matching: find.ancestor(of: find.text(logoutAccount.email),
332+
matching: find.byType(Card)));
333+
final findThreeDotsButton = find.descendant(of: findAccountCard,
327334
matching: find.byIcon(Icons.adaptive.more));
328335

336+
await tester.scrollUntilVisible(findThreeDotsButton, 50);
329337
await tester.tap(findThreeDotsButton);
330338
await tester.pump();
331339
await tester.tap(find.descendant(
@@ -338,14 +346,16 @@ void main() {
338346
}
339347

340348
testWidgets('user confirms logging out', (tester) async {
341-
final (actionButton, _) = await prepare(tester, account: eg.selfAccount);
349+
final (actionButton, _) = await prepare(tester,
350+
accounts: [eg.selfAccount], logoutAccount: eg.selfAccount);
342351
await tester.tap(find.byWidget(actionButton));
343352
await tester.pump(TestGlobalStore.removeAccountDuration);
344353
check(testBinding.globalStore).accounts.isEmpty();
345354
});
346355

347356
testWidgets('user cancels logging out', (tester) async {
348-
final (_, cancelButton) = await prepare(tester, account: eg.selfAccount);
357+
final (_, cancelButton) = await prepare(tester,
358+
accounts: [eg.selfAccount], logoutAccount: eg.selfAccount);
349359
await tester.tap(find.byWidget(cancelButton));
350360
await tester.pumpAndSettle();
351361
check(testBinding.globalStore).accounts.deepEquals([eg.selfAccount]);

0 commit comments

Comments
 (0)