From 0e95997dfd85b803dde6a16d2f1df0bc2ccf21b2 Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 10 Nov 2026 08:17:54 +0700 Subject: [PATCH] TF-5022 T-07 Add web e2e for stand-alone avatar switcher flows --- .../delegation_standalone_scenario_mixin.dart | 34 +++++ ...ract_account_switcher_assertion_robot.dart | 17 +++ .../abstract_account_switcher_robot.dart | 26 ++++ .../abstract/abstract_settings_robot.dart | 3 + .../web_account_switcher_assertion_robot.dart | 124 +++++++++++++++++ .../web/web_account_switcher_robot.dart | 125 ++++++++++++++++++ .../robots/web/web_settings_robot.dart | 6 + .../robots/web/web_thread_robot.dart | 6 + ...e_via_avatar_menu_standalone_scenario.dart | 25 ++++ ...box_failure_toast_standalone_scenario.dart | 33 +++++ ...ox_loading_dialog_standalone_scenario.dart | 24 ++++ ...delegated_mailbox_standalone_scenario.dart | 71 ++++++++++ ..._mine_via_avatar_menu_standalone_test.dart | 13 ++ ...mailbox_failure_toast_standalone_test.dart | 13 ++ ...ailbox_loading_dialog_standalone_test.dart | 13 ++ ...tch_delegated_mailbox_standalone_test.dart | 13 ++ ...patrol-web-integration-test-with-docker.sh | 3 +- ...-web-local-integration-test-with-docker.sh | 3 +- 18 files changed, 550 insertions(+), 2 deletions(-) create mode 100644 integration_test/mixin/delegation_standalone_scenario_mixin.dart create mode 100644 integration_test/robots/abstract/abstract_account_switcher_assertion_robot.dart create mode 100644 integration_test/robots/abstract/abstract_account_switcher_robot.dart create mode 100644 integration_test/robots/web/web_account_switcher_assertion_robot.dart create mode 100644 integration_test/robots/web/web_account_switcher_robot.dart create mode 100644 integration_test/scenarios/delegation/switch_back_to_mine_via_avatar_menu_standalone_scenario.dart create mode 100644 integration_test/scenarios/delegation/switch_delegated_mailbox_failure_toast_standalone_scenario.dart create mode 100644 integration_test/scenarios/delegation/switch_delegated_mailbox_loading_dialog_standalone_scenario.dart create mode 100644 integration_test/scenarios/delegation/switch_delegated_mailbox_standalone_scenario.dart create mode 100644 integration_test/tests/delegation/switch_back_to_mine_via_avatar_menu_standalone_test.dart create mode 100644 integration_test/tests/delegation/switch_delegated_mailbox_failure_toast_standalone_test.dart create mode 100644 integration_test/tests/delegation/switch_delegated_mailbox_loading_dialog_standalone_test.dart create mode 100644 integration_test/tests/delegation/switch_delegated_mailbox_standalone_test.dart diff --git a/integration_test/mixin/delegation_standalone_scenario_mixin.dart b/integration_test/mixin/delegation_standalone_scenario_mixin.dart new file mode 100644 index 000000000..8625f225d --- /dev/null +++ b/integration_test/mixin/delegation_standalone_scenario_mixin.dart @@ -0,0 +1,34 @@ +import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart'; +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; + +import '../base/base_test_scenario.dart'; +import '../robots/web/web_account_switcher_robot.dart'; + +/// Shared stand-alone web setup for T-07 account-switcher scenarios. +mixin DelegationStandaloneScenarioMixin on BaseTestScenario { + static const ownerAddress = 'alice@example.com'; + static const ownAddress = 'bob@example.com'; + + WebAccountSwitcherRobot get accountSwitcher => WebAccountSwitcherRobot($); + + /// Turns Delegation on in Preferences and returns to the mailbox chrome. + Future enableDelegationAndReturnToMailbox() async { + final l10n = AppLocalizations(); + final settingsRobot = robots.settingsRobot(); + final preferencesRobot = settingsRobot.preferencesRobot; + + await robots.commonRobot().waitForMailboxReady(); + await accountSwitcher.assertion.expectSwitcherInactive(); + + await robots.mailboxMenuRobot().openSetting(); + await settingsRobot.openSettingsDetail(AccountMenuItem.preferences); + await preferencesRobot.ensureDelegationPreferenceReady(); + await preferencesRobot.togglePreferenceOption(l10n.delegation); + await preferencesRobot.expectPreferenceOption( + l10n.delegation, + switchedOn: true, + ); + await settingsRobot.closeSettings(); + await robots.commonRobot().waitForMailboxReady(); + } +} diff --git a/integration_test/robots/abstract/abstract_account_switcher_assertion_robot.dart b/integration_test/robots/abstract/abstract_account_switcher_assertion_robot.dart new file mode 100644 index 000000000..cc9857340 --- /dev/null +++ b/integration_test/robots/abstract/abstract_account_switcher_assertion_robot.dart @@ -0,0 +1,17 @@ +abstract class AbstractAccountSwitcherAssertionRobot { + Future expectSwitcherInactive(); + + Future expectViewing(String ownerAddress); + + Future expectMenuShowsDelegated(String ownerAddress); + + Future expectSwitcherOnMine(); + + Future expectSwitchSettled(String ownerAddress); + + Future expectLoadingDialogVisible(String ownerAddress); + + Future expectLoadingDialogGone(); + + Future expectCouldNotOpenToast(String ownerAddress); +} diff --git a/integration_test/robots/abstract/abstract_account_switcher_robot.dart b/integration_test/robots/abstract/abstract_account_switcher_robot.dart new file mode 100644 index 000000000..c80efc820 --- /dev/null +++ b/integration_test/robots/abstract/abstract_account_switcher_robot.dart @@ -0,0 +1,26 @@ +import 'abstract_account_switcher_assertion_robot.dart'; + +abstract class AbstractAccountSwitcherRobot { + AbstractAccountSwitcherAssertionRobot get assertion; + + Future openMenu(); + + /// Opens the menu and picks a row by its visible address. + Future selectByAddress(String emailAddress); + + /// Picks a row when the avatar menu is already open (does not toggle the menu). + Future selectAddressWhenMenuOpen(String emailAddress); + + /// Opens the menu, picks [emailAddress], and waits for the loading dialog. + /// + /// Does not pump-and-settle after the tap so an in-flight switch stays visible. + Future selectByAddressAwaitingLoading(String emailAddress); + + Future tapCancelOnLoadingDialog(); + + /// Cancels an in-flight switch via the loading dialog Cancel, or via the + /// notifier during the show-delay window before the dialog appears. + Future cancelInFlightSwitch(); + + Future dismissViewingBanner(); +} diff --git a/integration_test/robots/abstract/abstract_settings_robot.dart b/integration_test/robots/abstract/abstract_settings_robot.dart index ee8bb05cf..2d64c927e 100644 --- a/integration_test/robots/abstract/abstract_settings_robot.dart +++ b/integration_test/robots/abstract/abstract_settings_robot.dart @@ -12,4 +12,7 @@ abstract class AbstractSettingsRobot { Future openSettingsDetail(AccountMenuItem accountMenuItem); Future leaveSettingsDetail(); + + /// Leave Settings back to the mailbox dashboard. + Future closeSettings(); } \ No newline at end of file diff --git a/integration_test/robots/web/web_account_switcher_assertion_robot.dart b/integration_test/robots/web/web_account_switcher_assertion_robot.dart new file mode 100644 index 000000000..da311047f --- /dev/null +++ b/integration_test/robots/web/web_account_switcher_assertion_robot.dart @@ -0,0 +1,124 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tmail_ui_user/features/base/model/ui_keys.dart'; +import 'package:tmail_ui_user/features/delegation/presentation/notifier/account_switch_notifier.dart'; +import 'package:tmail_ui_user/features/delegation/presentation/notifier/active_account_notifier.dart'; +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; + +import '../../base/core_robot.dart'; +import '../../utils/wait_for_condition.dart'; +import '../abstract/abstract_account_switcher_assertion_robot.dart'; + +class WebAccountSwitcherAssertionRobot extends CoreRobot + implements AbstractAccountSwitcherAssertionRobot { + WebAccountSwitcherAssertionRobot(super.$); + + ProviderContainer _appContainer() { + final element = $.tester.element(find.byType(MaterialApp)); + return ProviderScope.containerOf(element, listen: false); + } + + @override + Future expectSwitcherInactive() async { + await $.pumpAndTrySettle(); + // Mailbox chrome must be up so findsNothing is not vacuously true. + await $(const ValueKey(UiKeys.userAvatar)).waitUntilVisible(); + expect( + find.byKey(const ValueKey(UiKeys.viewingOwnerBanner)), + findsNothing, + ); + expect( + find.byKey(const ValueKey(UiKeys.accountSwitcherMenu)), + findsNothing, + ); + } + + @override + Future expectViewing(String ownerAddress) async { + final label = AppLocalizations().viewingOwnerMailbox(ownerAddress); + await $(const ValueKey(UiKeys.viewingOwnerBanner)).waitUntilVisible(); + await $(label).waitUntilVisible(); + } + + @override + Future expectMenuShowsDelegated(String ownerAddress) async { + await $(AppLocalizations().delegatedToYou).waitUntilVisible(); + await $(ownerAddress).waitUntilVisible(); + } + + @override + Future expectSwitcherOnMine() async { + await waitForCondition( + () { + final container = _appContainer(); + final active = container.read(activeAccountProvider); + return active != null && + !active.isDelegated && + !container.read(accountSwitchProvider).isSwitching; + }, + reason: 'showing mine and switch idle', + ); + } + + @override + Future expectSwitchSettled(String ownerAddress) async { + await waitForCondition( + () { + final container = _appContainer(); + if (container.read(accountSwitchProvider).isSwitching) return false; + final active = container.read(activeAccountProvider); + return active != null && active.ownerEmailAddress == ownerAddress; + }, + reason: 'switched to $ownerAddress and idle', + ); + await expectLoadingDialogGone(); + FocusManager.instance.primaryFocus?.unfocus(); + await $.pumpAndTrySettle(); + } + + @override + Future expectLoadingDialogVisible(String ownerAddress) async { + await waitForCondition( + () async { + // Zero show-delay opens the dialog on the next frame after switchStarted. + await $.pump(); + return $(const ValueKey(UiKeys.accountSwitchLoadingDialog)) + .evaluate() + .isNotEmpty; + }, + reason: 'account switch loading dialog visible', + ); + // Owner is inside Text.rich spans. find.text(owner) does not match that. + await $(const ValueKey(UiKeys.accountSwitchLoadingCancel)) + .waitUntilVisible(); + expect( + find.descendant( + of: find.byKey(const ValueKey(UiKeys.accountSwitchLoadingDialog)), + matching: find.textContaining(ownerAddress, findRichText: true), + ), + findsOneWidget, + reason: 'loading dialog copy names $ownerAddress', + ); + } + + @override + Future expectLoadingDialogGone() async { + await waitForCondition( + () => $(const ValueKey(UiKeys.accountSwitchLoadingDialog)) + .evaluate() + .isEmpty, + reason: 'account switch loading dialog closed', + ); + } + + @override + Future expectCouldNotOpenToast(String ownerAddress) async { + final message = + AppLocalizations().couldNotOpenOwnerMailbox(ownerAddress); + await waitForCondition( + () => $(message).evaluate().isNotEmpty, + reason: 'could not open mailbox toast visible', + ); + } +} diff --git a/integration_test/robots/web/web_account_switcher_robot.dart b/integration_test/robots/web/web_account_switcher_robot.dart new file mode 100644 index 000000000..0683d331e --- /dev/null +++ b/integration_test/robots/web/web_account_switcher_robot.dart @@ -0,0 +1,125 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:jmap_dart_client/jmap/account_id.dart'; +import 'package:linagora_design_flutter/linagora_design_flutter.dart'; +import 'package:model/extensions/session_extension.dart'; +import 'package:patrol/patrol.dart'; +import 'package:tmail_ui_user/features/base/model/ui_keys.dart'; +import 'package:tmail_ui_user/features/delegation/domain/extensions/session_delegation_extension.dart'; +import 'package:tmail_ui_user/features/delegation/presentation/notifier/account_switch_notifier.dart'; +import 'package:tmail_ui_user/features/delegation/presentation/notifier/active_account_notifier.dart'; + +import '../../base/core_robot.dart'; +import '../../utils/wait_for_condition.dart'; +import '../abstract/abstract_account_switcher_assertion_robot.dart'; +import '../abstract/abstract_account_switcher_robot.dart'; +import 'web_account_switcher_assertion_robot.dart'; + +/// Web stand-alone avatar menu. +class WebAccountSwitcherRobot extends CoreRobot + implements AbstractAccountSwitcherRobot { + @override + final AbstractAccountSwitcherAssertionRobot assertion; + + WebAccountSwitcherRobot(super.$) + : assertion = WebAccountSwitcherAssertionRobot($); + + bool get _isMenuOpen => + $(const ValueKey(UiKeys.accountSwitcherMenu)).evaluate().isNotEmpty; + + ProviderContainer _appContainer() { + final element = $.tester.element(find.byType(MaterialApp)); + return ProviderScope.containerOf(element, listen: false); + } + + AccountId _accountIdForAddress(String emailAddress) { + final session = _appContainer().read(activeAccountProvider)?.session; + if (session == null) { + throw StateError('no active session for account switcher select'); + } + if (session.getOwnEmailAddressOrEmpty() == emailAddress) { + return session.accountId; + } + for (final entry in session.delegatedAccounts) { + if (entry.value.name.value == emailAddress) return entry.key; + } + throw StateError('no account listed for $emailAddress'); + } + + Future _tapMenuItem( + String emailAddress, { + SettlePolicy? settlePolicy, + }) async { + final itemKey = LinagoraAccountMenu.itemKey(_accountIdForAddress(emailAddress)); + final row = $(const ValueKey(UiKeys.accountSwitcherMenu)).$(itemKey); + if (settlePolicy == null) { + await row.tap(); + } else { + await row.tap(settlePolicy: settlePolicy); + } + } + + @override + Future openMenu() async { + if (_isMenuOpen) return; + await $(const ValueKey(UiKeys.userAvatar)).tap(); + await $.pumpAndTrySettle(); + } + + @override + Future selectByAddress(String emailAddress) async { + await openMenu(); + await selectAddressWhenMenuOpen(emailAddress); + } + + @override + Future selectAddressWhenMenuOpen(String emailAddress) async { + await _tapMenuItem(emailAddress); + await $.pumpAndTrySettle(); + } + + @override + Future selectByAddressAwaitingLoading(String emailAddress) async { + await openMenu(); + // Keep the switch in flight: trySettle would wait out showDelay + load and + // hide the loading dialog before the assertion runs. + await _tapMenuItem(emailAddress, settlePolicy: SettlePolicy.noSettle); + await assertion.expectLoadingDialogVisible(emailAddress); + } + + @override + Future tapCancelOnLoadingDialog() async { + await $( + const ValueKey(UiKeys.accountSwitchLoadingCancel), + ).tap(settlePolicy: SettlePolicy.noSettle); + await assertion.expectLoadingDialogGone(); + } + + @override + Future cancelInFlightSwitch() async { + await waitForCondition( + () => _appContainer().read(accountSwitchProvider).isSwitching, + reason: 'account switch in flight', + ); + + final cancelButton = $( + const ValueKey(UiKeys.accountSwitchLoadingCancel), + ); + if (cancelButton.evaluate().isNotEmpty) { + await cancelButton.tap(settlePolicy: SettlePolicy.noSettle); + } else { + // Still inside SwitchLoadingDialogTiming.showDelay — same cancel as the + // dialog Cancel / Android back interceptor. + _appContainer().read(accountSwitchProvider.notifier).cancel(); + await $.pump(); + } + await assertion.expectLoadingDialogGone(); + } + + @override + Future dismissViewingBanner() async { + await $(const ValueKey(UiKeys.viewingOwnerBannerDismiss)).tap(); + await $.pumpAndTrySettle(); + } +} diff --git a/integration_test/robots/web/web_settings_robot.dart b/integration_test/robots/web/web_settings_robot.dart index 858e16975..3613b38bf 100644 --- a/integration_test/robots/web/web_settings_robot.dart +++ b/integration_test/robots/web/web_settings_robot.dart @@ -23,4 +23,10 @@ class WebSettingsRobot extends MobileSettingsRobot { // Web: the menu stays on screen, so leaving a detail means opening another one. await openSettingsDetail(AccountMenuItem.languageAndRegion); } + + /// Web desktop (incl. Workplace) uses the sidebar Back, not the mobile close. + @override + Future closeSettings() async { + await $(#back_to_dashboard_button).tap(); + } } diff --git a/integration_test/robots/web/web_thread_robot.dart b/integration_test/robots/web/web_thread_robot.dart index dbd01f96c..176e721b4 100644 --- a/integration_test/robots/web/web_thread_robot.dart +++ b/integration_test/robots/web/web_thread_robot.dart @@ -48,6 +48,12 @@ class WebThreadRobot extends ThreadRobot implements AbstractThreadRobot { viewport: WebThreadViewportRobot($), ); + @override + Future openComposer() async { + // ComposeButtonWidget wraps LinagoraSidebarPrimaryAction (no InkWell). + await $(const ValueKey(UiKeys.composeEmailPrimaryAction)).tap(); + } + @override Future openAppGrid() async { await $(const ValueKey(UiKeys.toggleAppGridButton)).tap(); diff --git a/integration_test/scenarios/delegation/switch_back_to_mine_via_avatar_menu_standalone_scenario.dart b/integration_test/scenarios/delegation/switch_back_to_mine_via_avatar_menu_standalone_scenario.dart new file mode 100644 index 000000000..93448e0ad --- /dev/null +++ b/integration_test/scenarios/delegation/switch_back_to_mine_via_avatar_menu_standalone_scenario.dart @@ -0,0 +1,25 @@ +import '../../base/base_test_scenario.dart'; +import '../../mixin/delegation_standalone_scenario_mixin.dart'; + +/// Switch to owner, then return to mine via the avatar menu (not Viewing ✕). +class SwitchBackToMineViaAvatarMenuStandaloneScenario extends BaseTestScenario + with DelegationStandaloneScenarioMixin { + const SwitchBackToMineViaAvatarMenuStandaloneScenario(super.$, super.robots); + + @override + Future runTestLogic() async { + final switcher = accountSwitcher; + const owner = DelegationStandaloneScenarioMixin.ownerAddress; + const mine = DelegationStandaloneScenarioMixin.ownAddress; + + await enableDelegationAndReturnToMailbox(); + + await switcher.selectByAddress(owner); + await switcher.assertion.expectSwitchSettled(owner); + + await switcher.openMenu(); + await switcher.assertion.expectMenuShowsDelegated(owner); + await switcher.selectAddressWhenMenuOpen(mine); + await switcher.assertion.expectSwitcherOnMine(); + } +} diff --git a/integration_test/scenarios/delegation/switch_delegated_mailbox_failure_toast_standalone_scenario.dart b/integration_test/scenarios/delegation/switch_delegated_mailbox_failure_toast_standalone_scenario.dart new file mode 100644 index 000000000..4a24317a9 --- /dev/null +++ b/integration_test/scenarios/delegation/switch_delegated_mailbox_failure_toast_standalone_scenario.dart @@ -0,0 +1,33 @@ +import '../../base/base_test_scenario.dart'; +import '../../mixin/delegation_standalone_scenario_mixin.dart'; + +/// Cancel mid-switch → "Couldn't open [Owner]'s mailbox" toast. +/// +/// Server-side failure is hard to force in Patrol web. Cancelling an in-flight +/// switch yields [AccountSwitchCancelled], which uses the same toast copy as +/// failed / timed-out opens (unit-tested in account_switch_failure_toast_test). +/// +/// Patrol web scripts set `ACCOUNT_SWITCH_LOADING_SHOW_DELAY_MS=0` so the +/// dialog appears even when local James finishes the load quickly. +class SwitchDelegatedMailboxFailureToastStandaloneScenario + extends BaseTestScenario with DelegationStandaloneScenarioMixin { + const SwitchDelegatedMailboxFailureToastStandaloneScenario( + super.$, + super.robots, + ); + + @override + Future runTestLogic() async { + final switcher = accountSwitcher; + const owner = DelegationStandaloneScenarioMixin.ownerAddress; + + await enableDelegationAndReturnToMailbox(); + + await switcher.selectByAddressAwaitingLoading(owner); + // cancelInFlightSwitch taps Cancel when painted, else cancels the notifier + // while still inside showDelay (zero-delay builds show sync, so Cancel wins). + await switcher.cancelInFlightSwitch(); + await switcher.assertion.expectCouldNotOpenToast(owner); + await switcher.assertion.expectSwitcherOnMine(); + } +} diff --git a/integration_test/scenarios/delegation/switch_delegated_mailbox_loading_dialog_standalone_scenario.dart b/integration_test/scenarios/delegation/switch_delegated_mailbox_loading_dialog_standalone_scenario.dart new file mode 100644 index 000000000..087cc7f56 --- /dev/null +++ b/integration_test/scenarios/delegation/switch_delegated_mailbox_loading_dialog_standalone_scenario.dart @@ -0,0 +1,24 @@ +import '../../base/base_test_scenario.dart'; +import '../../mixin/delegation_standalone_scenario_mixin.dart'; + +/// Asserts the switch loading dialog (and Cancel) appear while switching. +class SwitchDelegatedMailboxLoadingDialogStandaloneScenario + extends BaseTestScenario with DelegationStandaloneScenarioMixin { + const SwitchDelegatedMailboxLoadingDialogStandaloneScenario( + super.$, + super.robots, + ); + + @override + Future runTestLogic() async { + final switcher = accountSwitcher; + const owner = DelegationStandaloneScenarioMixin.ownerAddress; + + await enableDelegationAndReturnToMailbox(); + + await switcher.selectByAddressAwaitingLoading(owner); + await switcher.assertion.expectLoadingDialogVisible(owner); + // Let the switch finish. Dialog must dismiss once idle. + await switcher.assertion.expectSwitchSettled(owner); + } +} diff --git a/integration_test/scenarios/delegation/switch_delegated_mailbox_standalone_scenario.dart b/integration_test/scenarios/delegation/switch_delegated_mailbox_standalone_scenario.dart new file mode 100644 index 000000000..c170ad26a --- /dev/null +++ b/integration_test/scenarios/delegation/switch_delegated_mailbox_standalone_scenario.dart @@ -0,0 +1,71 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:tmail_ui_user/features/base/model/ui_keys.dart'; +import 'package:tmail_ui_user/features/composer/presentation/widgets/web/from_composer_drop_down_widget.dart'; +import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart'; + +import '../../base/base_test_scenario.dart'; +import '../../mixin/delegation_standalone_scenario_mixin.dart'; +import '../../utils/wait_for_condition.dart'; + +/// Bob has alice's mailbox delegated (reset-server seed). Stand-alone web only. +class SwitchDelegatedMailboxStandaloneScenario extends BaseTestScenario + with DelegationStandaloneScenarioMixin { + const SwitchDelegatedMailboxStandaloneScenario(super.$, super.robots); + + @override + Future runTestLogic() async { + final switcher = accountSwitcher; + + await enableDelegationAndReturnToMailbox(); + + await switcher.openMenu(); + await switcher.assertion.expectMenuShowsDelegated( + DelegationStandaloneScenarioMixin.ownerAddress, + ); + // Menu is already open. selectByAddress must not re-tap the avatar (the + // dismiss barrier makes userAvatar not hit-testable while the menu is up). + await switcher.selectAddressWhenMenuOpen( + DelegationStandaloneScenarioMixin.ownerAddress, + ); + await switcher.assertion.expectViewing( + DelegationStandaloneScenarioMixin.ownerAddress, + ); + await robots.commonRobot().waitForMailboxReady(); + await _waitForIdentityEmail( + DelegationStandaloneScenarioMixin.ownerAddress, + ); + + await robots.threadRobot().openComposer(); + await $(const ValueKey('prefix_to_recipient_from_button')).tap(); + await $(FromComposerDropDownWidget).waitUntilVisible(); + await waitForCondition( + () => $(FromComposerDropDownWidget) + .which( + (widget) => + widget.itemSelected?.email == + DelegationStandaloneScenarioMixin.ownerAddress, + ) + .evaluate() + .isNotEmpty, + reason: + 'composer From selection is ${DelegationStandaloneScenarioMixin.ownerAddress}', + ); + await $(const ValueKey(UiKeys.closeComposerButton)).tap(); + await $.pumpAndTrySettle(); + + await switcher.dismissViewingBanner(); + await switcher.assertion.expectSwitcherOnMine(); + } + + Future _waitForIdentityEmail(String email) async { + await waitForCondition( + () { + final dashboard = Get.find(); + return dashboard.listIdentities + .any((identity) => identity.email == email); + }, + reason: 'dashboard identities include $email', + ); + } +} diff --git a/integration_test/tests/delegation/switch_back_to_mine_via_avatar_menu_standalone_test.dart b/integration_test/tests/delegation/switch_back_to_mine_via_avatar_menu_standalone_test.dart new file mode 100644 index 000000000..493725e02 --- /dev/null +++ b/integration_test/tests/delegation/switch_back_to_mine_via_avatar_menu_standalone_test.dart @@ -0,0 +1,13 @@ +import '../../base/test_base.dart'; +import '../../models/test_tags.dart'; +import '../../scenarios/delegation/switch_back_to_mine_via_avatar_menu_standalone_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: + 'Should switch back to mine from the avatar menu while Viewing a delegated mailbox', + scenarioBuilder: ($, robots) => + SwitchBackToMineViaAvatarMenuStandaloneScenario($, robots), + tags: [TestTags.web], + ); +} \ No newline at end of file diff --git a/integration_test/tests/delegation/switch_delegated_mailbox_failure_toast_standalone_test.dart b/integration_test/tests/delegation/switch_delegated_mailbox_failure_toast_standalone_test.dart new file mode 100644 index 000000000..888090464 --- /dev/null +++ b/integration_test/tests/delegation/switch_delegated_mailbox_failure_toast_standalone_test.dart @@ -0,0 +1,13 @@ +import '../../base/test_base.dart'; +import '../../models/test_tags.dart'; +import '../../scenarios/delegation/switch_delegated_mailbox_failure_toast_standalone_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: + "Should toast Couldn't open owner's mailbox when the switch is cancelled", + scenarioBuilder: ($, robots) => + SwitchDelegatedMailboxFailureToastStandaloneScenario($, robots), + tags: [TestTags.web], + ); +} diff --git a/integration_test/tests/delegation/switch_delegated_mailbox_loading_dialog_standalone_test.dart b/integration_test/tests/delegation/switch_delegated_mailbox_loading_dialog_standalone_test.dart new file mode 100644 index 000000000..0335a95a6 --- /dev/null +++ b/integration_test/tests/delegation/switch_delegated_mailbox_loading_dialog_standalone_test.dart @@ -0,0 +1,13 @@ +import '../../base/test_base.dart'; +import '../../models/test_tags.dart'; +import '../../scenarios/delegation/switch_delegated_mailbox_loading_dialog_standalone_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: + 'Should show the account-switch loading dialog while opening a delegated mailbox', + scenarioBuilder: ($, robots) => + SwitchDelegatedMailboxLoadingDialogStandaloneScenario($, robots), + tags: [TestTags.web], + ); +} diff --git a/integration_test/tests/delegation/switch_delegated_mailbox_standalone_test.dart b/integration_test/tests/delegation/switch_delegated_mailbox_standalone_test.dart new file mode 100644 index 000000000..49995ddf6 --- /dev/null +++ b/integration_test/tests/delegation/switch_delegated_mailbox_standalone_test.dart @@ -0,0 +1,13 @@ +import '../../base/test_base.dart'; +import '../../models/test_tags.dart'; +import '../../scenarios/delegation/switch_delegated_mailbox_standalone_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: + 'Should switch to a delegated mailbox from the stand-alone avatar menu', + scenarioBuilder: ($, robots) => + SwitchDelegatedMailboxStandaloneScenario($, robots), + tags: [TestTags.web], + ); +} diff --git a/scripts/patrol-web-integration-test-with-docker.sh b/scripts/patrol-web-integration-test-with-docker.sh index c43ae4e08..0fd8827d6 100755 --- a/scripts/patrol-web-integration-test-with-docker.sh +++ b/scripts/patrol-web-integration-test-with-docker.sh @@ -159,7 +159,8 @@ patrol test -v \ --dart-define=ADDITIONAL_MAIL_RECIPIENT="$ALICE@$DOMAIN" \ --dart-define=BASIC_AUTH_EMAIL="$BOB@$DOMAIN" \ --dart-define=BASIC_AUTH_URL="$BASIC_AUTH_URL" \ - --dart-define=RESET_SERVER_URL="http://localhost:$RESET_PORT" 2>&1 \ + --dart-define=RESET_SERVER_URL="http://localhost:$RESET_PORT" \ + --dart-define=ACCOUNT_SWITCH_LOADING_SHOW_DELAY_MS=0 2>&1 \ | perl -MPOSIX -ne 'BEGIN { open(LOG, ">", shift) or die "$!\n"; select((select(LOG), $| = 1)[0]); $| = 1 } print LOG strftime("%T ", localtime), $_; print' "$PATROL_LOG" \ | perl scripts/ci-console-filter.pl "ci-logs/patrol-console.log.gz" TEST_EXIT_CODE=${PIPESTATUS[0]} diff --git a/scripts/patrol-web-local-integration-test-with-docker.sh b/scripts/patrol-web-local-integration-test-with-docker.sh index 20a0c878b..54dbb6e0e 100755 --- a/scripts/patrol-web-local-integration-test-with-docker.sh +++ b/scripts/patrol-web-local-integration-test-with-docker.sh @@ -67,4 +67,5 @@ patrol test -v \ --dart-define=ADDITIONAL_MAIL_RECIPIENT="$ALICE@$DOMAIN" \ --dart-define=BASIC_AUTH_EMAIL="$BOB@$DOMAIN" \ --dart-define=BASIC_AUTH_URL="$BASIC_AUTH_URL" \ - --dart-define=RESET_SERVER_URL="http://localhost:$RESET_PORT" \ No newline at end of file + --dart-define=RESET_SERVER_URL="http://localhost:$RESET_PORT" \ + --dart-define=ACCOUNT_SWITCH_LOADING_SHOW_DELAY_MS=0 \ No newline at end of file