mirror of
https://github.com/linagora/tmail-flutter.git
synced 2026-12-06 00:05:29 +00:00
TF-5022 T-09 Run the stand-alone account switcher e2e on Android and iOS through a shared AccountSwitcherRobot base
This commit is contained in:
1 parent
35c9d10fb1
commit
d675bfa950
26 files changed
+323
-217
No files matched your search
@@ -2,7 +2,9 @@ import 'package:patrol/patrol.dart';
|
||||
|
||||
import '../robots/abstract/abstract_hardware_keyboard_robot.dart';
|
||||
import '../robots/abstract/abstract_common_robot.dart';
|
||||
import '../robots/abstract/abstract_account_switcher_robot.dart';
|
||||
import '../robots/abstract/abstract_settings_robot.dart';
|
||||
import '../robots/mobile/mobile_account_switcher_robot.dart';
|
||||
import '../robots/mobile/mobile_common_robot.dart';
|
||||
import '../robots/abstract/abstract_app_grid_robot.dart';
|
||||
import '../robots/abstract/abstract_composer_robot.dart';
|
||||
@@ -60,6 +62,9 @@ class MobileRobotFactory implements RobotFactory {
|
||||
@override
|
||||
AbstractSearchRobot searchRobot() => MobileSearchRobot($);
|
||||
|
||||
@override
|
||||
AbstractAccountSwitcherRobot accountSwitcherRobot() => MobileAccountSwitcherRobot($);
|
||||
|
||||
@override
|
||||
AbstractSettingsRobot settingsRobot() => MobileSettingsRobot($);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../robots/abstract/abstract_login_robot.dart';
|
||||
import '../robots/abstract/abstract_mailbox_menu_robot.dart';
|
||||
import '../robots/abstract/abstract_rules_filter_creator_robot.dart';
|
||||
import '../robots/abstract/abstract_search_robot.dart';
|
||||
import '../robots/abstract/abstract_account_switcher_robot.dart';
|
||||
import '../robots/abstract/abstract_settings_robot.dart';
|
||||
import '../robots/abstract/abstract_thread_robot.dart';
|
||||
|
||||
@@ -23,6 +24,7 @@ abstract class RobotFactory {
|
||||
AbstractEmailRobot emailRobot();
|
||||
AbstractSearchRobot searchRobot();
|
||||
AbstractSettingsRobot settingsRobot();
|
||||
AbstractAccountSwitcherRobot accountSwitcherRobot();
|
||||
|
||||
/// Web only: real key presses. Null where no host keyboard is wired.
|
||||
AbstractHardwareKeyboardRobot? hardwareKeyboardRobot();
|
||||
|
||||
@@ -2,7 +2,9 @@ import 'package:patrol/patrol.dart';
|
||||
|
||||
import '../robots/abstract/abstract_hardware_keyboard_robot.dart';
|
||||
import '../robots/abstract/abstract_common_robot.dart';
|
||||
import '../robots/abstract/abstract_account_switcher_robot.dart';
|
||||
import '../robots/abstract/abstract_settings_robot.dart';
|
||||
import '../robots/web/web_account_switcher_robot.dart';
|
||||
import '../robots/web/web_common_robot.dart';
|
||||
import '../robots/web/web_email_robot.dart';
|
||||
import '../robots/abstract/abstract_app_grid_robot.dart';
|
||||
@@ -61,6 +63,9 @@ class WebRobotFactory implements RobotFactory {
|
||||
@override
|
||||
AbstractSearchRobot searchRobot() => WebSearchRobot($);
|
||||
|
||||
@override
|
||||
AbstractAccountSwitcherRobot accountSwitcherRobot() => WebAccountSwitcherRobot($);
|
||||
|
||||
@override
|
||||
AbstractSettingsRobot settingsRobot() => WebSettingsRobot($);
|
||||
|
||||
|
||||
@@ -2,14 +2,15 @@ import 'package:tmail_ui_user/features/manage_account/presentation/model/account
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../base/base_test_scenario.dart';
|
||||
import '../robots/web/web_account_switcher_robot.dart';
|
||||
import '../robots/abstract/abstract_account_switcher_robot.dart';
|
||||
|
||||
/// Shared stand-alone web setup for T-07 account-switcher scenarios.
|
||||
/// Shared setup of the stand-alone web and the Android and iOS app account-switcher scenarios.
|
||||
mixin DelegationStandaloneScenarioMixin on BaseTestScenario {
|
||||
static const ownerAddress = 'alice@example.com';
|
||||
static const ownAddress = 'bob@example.com';
|
||||
|
||||
WebAccountSwitcherRobot get accountSwitcher => WebAccountSwitcherRobot($);
|
||||
AbstractAccountSwitcherRobot get accountSwitcher =>
|
||||
robots.accountSwitcherRobot();
|
||||
|
||||
/// Turns Delegation on in Preferences and returns to the mailbox chrome.
|
||||
Future<void> enableDelegationAndReturnToMailbox() async {
|
||||
@@ -28,6 +29,7 @@ mixin DelegationStandaloneScenarioMixin on BaseTestScenario {
|
||||
l10n.delegation,
|
||||
switchedOn: true,
|
||||
);
|
||||
await settingsRobot.leaveSettingsDetail();
|
||||
await settingsRobot.closeSettings();
|
||||
await robots.commonRobot().waitForMailboxReady();
|
||||
}
|
||||
|
||||
@@ -22,5 +22,6 @@ abstract class AbstractAccountSwitcherRobot {
|
||||
/// notifier during the show-delay window before the dialog appears.
|
||||
Future<void> cancelInFlightSwitch();
|
||||
|
||||
Future<void> dismissViewingBanner();
|
||||
/// Shows `mine` again from the chrome of the shown delegated mailbox.
|
||||
Future<void> leaveDelegatedMailbox();
|
||||
}
|
||||
@@ -8,10 +8,10 @@ import 'package:tmail_ui_user/features/delegation/domain/extensions/session_dele
|
||||
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 '../base/core_robot.dart';
|
||||
import '../utils/wait_for_condition.dart';
|
||||
|
||||
/// Account lookup and switch-state waits shared by the web account switchers.
|
||||
/// Account lookup and switch-state waits shared by the account switchers.
|
||||
mixin AccountSwitchRobotMixin on CoreRobot {
|
||||
ProviderContainer appContainer() {
|
||||
final element = $.tester.element(find.byType(MaterialApp));
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/model/ui_keys.dart';
|
||||
import 'package:tmail_ui_user/features/delegation/presentation/notifier/active_account_notifier.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
||||
|
||||
import '../base/core_robot.dart';
|
||||
import '../utils/wait_for_condition.dart';
|
||||
import 'abstract/abstract_account_switcher_assertion_robot.dart';
|
||||
import 'account_switch_robot_mixin.dart';
|
||||
|
||||
/// Switch state, menu, loading dialog and toast checks shared by every platform.
|
||||
abstract class AccountSwitcherAssertionRobot extends CoreRobot
|
||||
with AccountSwitchRobotMixin
|
||||
implements AbstractAccountSwitcherAssertionRobot {
|
||||
AccountSwitcherAssertionRobot(super.$);
|
||||
|
||||
@override
|
||||
Future<void> expectMenuShowsDelegated(String ownerAddress) async {
|
||||
await $(AppLocalizations().delegatedToYou).waitUntilVisible();
|
||||
await $(ownerAddress).waitUntilVisible();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectSwitcherOnMine() async {
|
||||
await waitSwitchIdleOnMine();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectSwitchSettled(String ownerAddress) async {
|
||||
await waitSwitchIdleOn(ownerAddress);
|
||||
await expectLoadingDialogGone();
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
await $.pumpAndTrySettle();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectShownIdentitiesInclude(String email) async {
|
||||
await waitForCondition(
|
||||
() => Get.find<MailboxDashBoardController>()
|
||||
.listIdentities
|
||||
.any((identity) => identity.email == email),
|
||||
reason: 'dashboard identities include $email',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectUrlNamesShownAccount() async {
|
||||
await waitForCondition(
|
||||
() {
|
||||
final active = appContainer().read(activeAccountProvider);
|
||||
return active != null &&
|
||||
active.isDelegated &&
|
||||
_urlAccount() == active.accountId.id.value;
|
||||
},
|
||||
reason: 'the location bar names the shown delegated account',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectUrlNamesNoAccount() async {
|
||||
await waitForCondition(
|
||||
() => _urlAccount() == null,
|
||||
reason: 'the location bar names no account',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectUrlNamesOpenedFolder() async {
|
||||
await waitForCondition(
|
||||
() => Uri.base.queryParameters[RouteUtils.paramContext] != null,
|
||||
reason: 'the location bar names the opened folder',
|
||||
);
|
||||
}
|
||||
|
||||
String? _urlAccount() => Uri.base.queryParameters[RouteUtils.paramAccount];
|
||||
|
||||
@override
|
||||
Future<void> 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<void> expectLoadingDialogGone() => waitLoadingDialogGone();
|
||||
|
||||
@override
|
||||
Future<void> expectCouldNotOpenToast(String ownerAddress) async {
|
||||
final message =
|
||||
AppLocalizations().couldNotOpenOwnerMailbox(ownerAddress);
|
||||
await waitForCondition(
|
||||
() => $(message).evaluate().isNotEmpty,
|
||||
reason: 'could not open mailbox toast visible',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
|
||||
import 'package:patrol/patrol.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 '../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 'account_switch_robot_mixin.dart';
|
||||
|
||||
/// Account menu rows and the switch loading dialog, shared by every platform.
|
||||
abstract class AccountSwitcherRobot extends CoreRobot
|
||||
with AccountSwitchRobotMixin
|
||||
implements AbstractAccountSwitcherRobot {
|
||||
@override
|
||||
final AbstractAccountSwitcherAssertionRobot assertion;
|
||||
|
||||
AccountSwitcherRobot(super.$, this.assertion);
|
||||
|
||||
/// The open account menu.
|
||||
PatrolFinder get menu;
|
||||
|
||||
bool get isMenuOpen => menu.evaluate().isNotEmpty;
|
||||
|
||||
Future<void> _tapMenuItem(
|
||||
String emailAddress, {
|
||||
SettlePolicy? settlePolicy,
|
||||
}) async {
|
||||
final itemKey = LinagoraAccountMenu.itemKey(accountIdForAddress(emailAddress));
|
||||
final row = menu.$(itemKey);
|
||||
if (settlePolicy == null) {
|
||||
await row.tap();
|
||||
} else {
|
||||
await row.tap(settlePolicy: settlePolicy);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> selectByAddress(String emailAddress) async {
|
||||
await openMenu();
|
||||
await selectAddressWhenMenuOpen(emailAddress);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> selectAddressWhenMenuOpen(String emailAddress) async {
|
||||
await _tapMenuItem(emailAddress);
|
||||
await $.pumpAndTrySettle();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> 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<void> tapCancelOnLoadingDialog() async {
|
||||
await $(
|
||||
const ValueKey(UiKeys.accountSwitchLoadingCancel),
|
||||
).tap(settlePolicy: SettlePolicy.noSettle);
|
||||
await assertion.expectLoadingDialogGone();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> 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();
|
||||
}
|
||||
}
|
||||
@@ -77,10 +77,9 @@ class ComposerRecipientRobot extends CoreRobot
|
||||
await _field(prefix).$(TextField).tap();
|
||||
}
|
||||
|
||||
/// The expand chevron also reveals From on a narrow composer.
|
||||
@override
|
||||
Future<void> openFromField() async {
|
||||
await $(Key('prefix_${PrefixEmailAddress.to.name}_recipient_from_button')).tap();
|
||||
}
|
||||
Future<void> openFromField() => openCcField();
|
||||
|
||||
@override
|
||||
Future<void> openFirstRecipientMenu(PrefixEmailAddress prefix) async {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
|
||||
import 'package:tmail_ui_user/features/base/model/ui_keys.dart';
|
||||
|
||||
import '../account_switcher_assertion_robot.dart';
|
||||
|
||||
/// Compact switcher of the thread app bar, which has no Viewing banner.
|
||||
class MobileAccountSwitcherAssertionRobot
|
||||
extends AccountSwitcherAssertionRobot {
|
||||
MobileAccountSwitcherAssertionRobot(super.$);
|
||||
|
||||
@override
|
||||
Future<void> expectSwitcherInactive() async {
|
||||
await $.pumpAndTrySettle();
|
||||
// Thread app bar must be up so findsNothing is not vacuously true.
|
||||
await $(const ValueKey(UiKeys.mobileMailboxMenuButton)).waitUntilVisible();
|
||||
expect(find.byKey(LinagoraAccountSwitcher.chipKey), findsNothing);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectViewing(String ownerAddress) async {
|
||||
await waitSwitchIdleOn(ownerAddress);
|
||||
await $(LinagoraAccountSwitcher.chipKey).waitUntilVisible();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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/delegation/presentation/notifier/active_account_notifier.dart';
|
||||
|
||||
import '../account_switcher_robot.dart';
|
||||
import 'mobile_account_switcher_assertion_robot.dart';
|
||||
|
||||
/// Compact switcher of the thread app bar.
|
||||
class MobileAccountSwitcherRobot extends AccountSwitcherRobot {
|
||||
MobileAccountSwitcherRobot(PatrolIntegrationTester $)
|
||||
: super($, MobileAccountSwitcherAssertionRobot($));
|
||||
|
||||
@override
|
||||
PatrolFinder get menu => $(LinagoraAccountSwitcher.menuKey);
|
||||
|
||||
@override
|
||||
Future<void> openMenu() async {
|
||||
if (isMenuOpen) return;
|
||||
await $(LinagoraAccountSwitcher.chipKey).tap();
|
||||
await $.pumpAndTrySettle();
|
||||
}
|
||||
|
||||
/// No Viewing banner on the compact switcher: picks `mine` in its menu.
|
||||
@override
|
||||
Future<void> leaveDelegatedMailbox() async {
|
||||
final session = appContainer().read(activeAccountProvider)?.session;
|
||||
if (session == null) throw StateError('no active session to leave');
|
||||
await selectByAddress(session.getOwnEmailAddressOrEmpty());
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/model/ui_keys.dart';
|
||||
import 'package:tmail_ui_user/features/delegation/presentation/notifier/active_account_notifier.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
||||
|
||||
import '../../base/core_robot.dart';
|
||||
import '../../utils/wait_for_condition.dart';
|
||||
import '../abstract/abstract_account_switcher_assertion_robot.dart';
|
||||
import 'account_switch_robot_mixin.dart';
|
||||
import '../account_switcher_assertion_robot.dart';
|
||||
|
||||
class WebAccountSwitcherAssertionRobot extends CoreRobot
|
||||
with AccountSwitchRobotMixin
|
||||
implements AbstractAccountSwitcherAssertionRobot {
|
||||
/// Web stand-alone avatar menu and its Viewing banner.
|
||||
class WebAccountSwitcherAssertionRobot extends AccountSwitcherAssertionRobot {
|
||||
WebAccountSwitcherAssertionRobot(super.$);
|
||||
|
||||
@override
|
||||
@@ -38,102 +30,4 @@ class WebAccountSwitcherAssertionRobot extends CoreRobot
|
||||
await $(const ValueKey(UiKeys.viewingOwnerBanner)).waitUntilVisible();
|
||||
await $(label).waitUntilVisible();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectMenuShowsDelegated(String ownerAddress) async {
|
||||
await $(AppLocalizations().delegatedToYou).waitUntilVisible();
|
||||
await $(ownerAddress).waitUntilVisible();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectSwitcherOnMine() async {
|
||||
await waitSwitchIdleOnMine();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectSwitchSettled(String ownerAddress) async {
|
||||
await waitSwitchIdleOn(ownerAddress);
|
||||
await expectLoadingDialogGone();
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
await $.pumpAndTrySettle();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectShownIdentitiesInclude(String email) async {
|
||||
await waitForCondition(
|
||||
() => Get.find<MailboxDashBoardController>()
|
||||
.listIdentities
|
||||
.any((identity) => identity.email == email),
|
||||
reason: 'dashboard identities include $email',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectUrlNamesShownAccount() async {
|
||||
await waitForCondition(
|
||||
() {
|
||||
final active = appContainer().read(activeAccountProvider);
|
||||
return active != null &&
|
||||
active.isDelegated &&
|
||||
_urlAccount() == active.accountId.id.value;
|
||||
},
|
||||
reason: 'the location bar names the shown delegated account',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectUrlNamesNoAccount() async {
|
||||
await waitForCondition(
|
||||
() => _urlAccount() == null,
|
||||
reason: 'the location bar names no account',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectUrlNamesOpenedFolder() async {
|
||||
await waitForCondition(
|
||||
() => Uri.base.queryParameters[RouteUtils.paramContext] != null,
|
||||
reason: 'the location bar names the opened folder',
|
||||
);
|
||||
}
|
||||
|
||||
String? _urlAccount() => Uri.base.queryParameters[RouteUtils.paramAccount];
|
||||
|
||||
@override
|
||||
Future<void> 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<void> expectLoadingDialogGone() => waitLoadingDialogGone();
|
||||
|
||||
@override
|
||||
Future<void> expectCouldNotOpenToast(String ownerAddress) async {
|
||||
final message =
|
||||
AppLocalizations().couldNotOpenOwnerMailbox(ownerAddress);
|
||||
await waitForCondition(
|
||||
() => $(message).evaluate().isNotEmpty,
|
||||
reason: 'could not open mailbox toast visible',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
|
||||
import 'package:patrol/patrol.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 '../../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 'account_switch_robot_mixin.dart';
|
||||
import '../account_switcher_robot.dart';
|
||||
import 'web_account_switcher_assertion_robot.dart';
|
||||
|
||||
/// Web stand-alone avatar menu.
|
||||
class WebAccountSwitcherRobot extends CoreRobot
|
||||
with AccountSwitchRobotMixin
|
||||
implements AbstractAccountSwitcherRobot {
|
||||
class WebAccountSwitcherRobot extends AccountSwitcherRobot {
|
||||
WebAccountSwitcherRobot(PatrolIntegrationTester $)
|
||||
: super($, WebAccountSwitcherAssertionRobot($));
|
||||
|
||||
@override
|
||||
final AbstractAccountSwitcherAssertionRobot assertion;
|
||||
|
||||
WebAccountSwitcherRobot(super.$)
|
||||
: assertion = WebAccountSwitcherAssertionRobot($);
|
||||
|
||||
bool get _isMenuOpen =>
|
||||
$(const ValueKey(UiKeys.accountSwitcherMenu)).evaluate().isNotEmpty;
|
||||
|
||||
Future<void> _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);
|
||||
}
|
||||
}
|
||||
PatrolFinder get menu => $(const ValueKey(UiKeys.accountSwitcherMenu));
|
||||
|
||||
@override
|
||||
Future<void> openMenu() async {
|
||||
if (_isMenuOpen) return;
|
||||
if (isMenuOpen) return;
|
||||
await $(const ValueKey(UiKeys.userAvatar)).tap();
|
||||
await $.pumpAndTrySettle();
|
||||
}
|
||||
|
||||
/// Taps ✕ on the Viewing banner.
|
||||
@override
|
||||
Future<void> selectByAddress(String emailAddress) async {
|
||||
await openMenu();
|
||||
await selectAddressWhenMenuOpen(emailAddress);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> selectAddressWhenMenuOpen(String emailAddress) async {
|
||||
await _tapMenuItem(emailAddress);
|
||||
await $.pumpAndTrySettle();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> 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<void> tapCancelOnLoadingDialog() async {
|
||||
await $(
|
||||
const ValueKey(UiKeys.accountSwitchLoadingCancel),
|
||||
).tap(settlePolicy: SettlePolicy.noSettle);
|
||||
await assertion.expectLoadingDialogGone();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> 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<void> dismissViewingBanner() async {
|
||||
Future<void> leaveDelegatedMailbox() async {
|
||||
await $(const ValueKey(UiKeys.viewingOwnerBannerDismiss)).tap();
|
||||
await $.pumpAndTrySettle();
|
||||
}
|
||||
|
||||
@@ -13,4 +13,9 @@ class WebComposerRecipientRobot extends ComposerRecipientRobot {
|
||||
// of the expand chevron.
|
||||
await $(Key('prefix_${PrefixEmailAddress.to.name}${UiKeys.recipientCcButtonSuffix}')).tap();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> openFromField() async {
|
||||
await $(Key('prefix_${PrefixEmailAddress.to.name}_recipient_from_button')).tap();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../../base/core_robot.dart';
|
||||
import '../abstract/abstract_workplace_account_switcher_assertion_robot.dart';
|
||||
import 'account_switch_robot_mixin.dart';
|
||||
import '../account_switch_robot_mixin.dart';
|
||||
|
||||
class WebWorkplaceAccountSwitcherAssertionRobot extends CoreRobot
|
||||
with AccountSwitchRobotMixin
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:linagora_design_flutter/linagora_design_flutter.dart';
|
||||
import '../../base/core_robot.dart';
|
||||
import '../abstract/abstract_workplace_account_switcher_assertion_robot.dart';
|
||||
import '../abstract/abstract_workplace_account_switcher_robot.dart';
|
||||
import 'account_switch_robot_mixin.dart';
|
||||
import '../account_switch_robot_mixin.dart';
|
||||
import 'web_workplace_account_switcher_assertion_robot.dart';
|
||||
|
||||
/// Web Workplace account-switcher chip (#4977 §8).
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
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 ✕).
|
||||
/// Switch to owner, then return to mine via the switcher menu (not Viewing ✕).
|
||||
class SwitchBackToMineViaAvatarMenuStandaloneScenario extends BaseTestScenario
|
||||
with DelegationStandaloneScenarioMixin {
|
||||
const SwitchBackToMineViaAvatarMenuStandaloneScenario(super.$, super.robots);
|
||||
|
||||
+2
-2
@@ -3,11 +3,11 @@ 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
|
||||
/// Server-side failure is hard to force in Patrol. 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
|
||||
/// Patrol 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 {
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/delegation_standalone_scenario_mixin.dart';
|
||||
|
||||
/// Bob has alice's mailbox delegated (reset-server seed). Stand-alone web only.
|
||||
/// Bob has alice's mailbox delegated (reset-server seed). Stand-alone web and the Android and iOS app.
|
||||
class SwitchDelegatedMailboxStandaloneScenario extends BaseTestScenario
|
||||
with DelegationStandaloneScenarioMixin {
|
||||
const SwitchDelegatedMailboxStandaloneScenario(super.$, super.robots);
|
||||
@@ -36,9 +36,9 @@ class SwitchDelegatedMailboxStandaloneScenario extends BaseTestScenario
|
||||
DelegationStandaloneScenarioMixin.ownerAddress,
|
||||
);
|
||||
await composer.tapCloseComposer();
|
||||
await $.pumpAndTrySettle();
|
||||
await composer.expectComposerClosedDiscardingChanges();
|
||||
|
||||
await switcher.dismissViewingBanner();
|
||||
await switcher.leaveDelegatedMailbox();
|
||||
await switcher.assertion.expectSwitcherOnMine();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ class WebUrlNamesShownDelegatedAccountScenario extends BaseTestScenario
|
||||
await switcher.assertion.expectUrlNamesOpenedFolder();
|
||||
await switcher.assertion.expectUrlNamesShownAccount();
|
||||
|
||||
await switcher.dismissViewingBanner();
|
||||
await switcher.leaveDelegatedMailbox();
|
||||
await switcher.assertion.expectSwitcherOnMine();
|
||||
await switcher.assertion.expectUrlNamesNoAccount();
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,6 +8,6 @@ void main() {
|
||||
'Should switch back to mine from the avatar menu while Viewing a delegated mailbox',
|
||||
scenarioBuilder: ($, robots) =>
|
||||
SwitchBackToMineViaAvatarMenuStandaloneScenario($, robots),
|
||||
tags: [TestTags.web],
|
||||
tags: [TestTags.android, TestTags.ios, TestTags.web],
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -8,6 +8,6 @@ void main() {
|
||||
"Should toast Couldn't open owner's mailbox when the switch is cancelled",
|
||||
scenarioBuilder: ($, robots) =>
|
||||
SwitchDelegatedMailboxFailureToastStandaloneScenario($, robots),
|
||||
tags: [TestTags.web],
|
||||
tags: [TestTags.android, TestTags.ios, TestTags.web],
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -8,6 +8,6 @@ void main() {
|
||||
'Should show the account-switch loading dialog while opening a delegated mailbox',
|
||||
scenarioBuilder: ($, robots) =>
|
||||
SwitchDelegatedMailboxLoadingDialogStandaloneScenario($, robots),
|
||||
tags: [TestTags.web],
|
||||
tags: [TestTags.android, TestTags.ios, TestTags.web],
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,6 @@ void main() {
|
||||
'Should switch to a delegated mailbox from the stand-alone avatar menu',
|
||||
scenarioBuilder: ($, robots) =>
|
||||
SwitchDelegatedMailboxStandaloneScenario($, robots),
|
||||
tags: [TestTags.web],
|
||||
tags: [TestTags.android, TestTags.ios, TestTags.web],
|
||||
);
|
||||
}
|
||||
@@ -152,7 +152,8 @@ set -m
|
||||
--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="$BORE_RESET_URL" 2>&1 | tee "$CI_LOGS/patrol-build.log" | perl scripts/ci-console-filter.pl "ci-logs/patrol-build.log"
|
||||
--dart-define=RESET_SERVER_URL="$BORE_RESET_URL" \
|
||||
--dart-define=ACCOUNT_SWITCH_LOADING_SHOW_DELAY_MS=0 2>&1 | tee "$CI_LOGS/patrol-build.log" | perl scripts/ci-console-filter.pl "ci-logs/patrol-build.log"
|
||||
timing "Patrol/Gradle build end ($(( SECONDS - build_started ))s)"
|
||||
) &
|
||||
PATROL_BUILD_PID=$!
|
||||
|
||||
@@ -64,4 +64,5 @@ patrol test \
|
||||
--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://10.0.2.2:$RESET_PORT"
|
||||
--dart-define=RESET_SERVER_URL="http://10.0.2.2:$RESET_PORT" \
|
||||
--dart-define=ACCOUNT_SWITCH_LOADING_SHOW_DELAY_MS=0
|
||||
Reference in new issue
Block a user