From 593f538052bf017fb14a27930fb2eb99bb21d7f7 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Mon, 31 Jul 2023 17:49:54 -0700 Subject: [PATCH] test: Fix new action-sheet tests Like 38ed6c812, but for some tests that were still in PR-flight at the time and so didn't get that treatment. --- test/widgets/action_sheet_test.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/widgets/action_sheet_test.dart b/test/widgets/action_sheet_test.dart index 1299ef9f7d..40b41f46d7 100644 --- a/test/widgets/action_sheet_test.dart +++ b/test/widgets/action_sheet_test.dart @@ -238,14 +238,19 @@ void main() { TestZulipBinding.instance.reset(); }); + Future tapCopyButton(WidgetTester tester) async { + await tester.ensureVisible(find.byIcon(Icons.copy, skipOffstage: false)); + await tester.tap(find.byIcon(Icons.copy)); + await tester.pump(); // [MenuItemButton.onPressed] called in a post-frame callback: flutter/flutter@e4a39fa2e + } + testWidgets('success', (WidgetTester tester) async { final message = eg.streamMessage(); await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message)); final store = await TestZulipBinding.instance.globalStore.perAccount(eg.selfAccount.id); - await tester.ensureVisible(find.byIcon(Icons.copy, skipOffstage: false)); prepareRawContentResponseSuccess(store, message: message, rawContent: 'Hello world'); - await tester.tap(find.byIcon(Icons.copy)); + await tapCopyButton(tester); await tester.pump(Duration.zero); check(await Clipboard.getData('text/plain')).isNotNull().text.equals('Hello world'); }); @@ -255,9 +260,8 @@ void main() { await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message)); final store = await TestZulipBinding.instance.globalStore.perAccount(eg.selfAccount.id); - await tester.ensureVisible(find.byIcon(Icons.copy, skipOffstage: false)); prepareRawContentResponseError(store); - await tester.tap(find.byIcon(Icons.copy)); + await tapCopyButton(tester); await tester.pump(Duration.zero); // error arrives; error dialog shows await tester.tap(find.byWidget(checkErrorDialog(tester,