TF-4068 Add E2E test for select identity as default
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
import 'package:core/presentation/views/text/text_field_builder.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../base/core_robot.dart';
|
||||||
|
import '../extensions/patrol_finder_extension.dart';
|
||||||
|
|
||||||
|
class IdentityCreatorRobot extends CoreRobot {
|
||||||
|
IdentityCreatorRobot(super.$);
|
||||||
|
|
||||||
|
Future<void> enterName(String name) async {
|
||||||
|
final finder = $(TextFieldBuilder).$(TextField);
|
||||||
|
final isTextFieldFocused = finder
|
||||||
|
.which<TextField>((view) => view.focusNode?.hasFocus ?? false)
|
||||||
|
.exists;
|
||||||
|
if (!isTextFieldFocused) {
|
||||||
|
await finder.tap();
|
||||||
|
}
|
||||||
|
await finder.enterTextWithoutTapAction(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> tapSaveIdentityButton() async {
|
||||||
|
await $.scrollUntilVisible(finder: $(#save_identity_button));
|
||||||
|
await $(#save_identity_button).tap();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
|||||||
|
|
||||||
import '../base/core_robot.dart';
|
import '../base/core_robot.dart';
|
||||||
import '../exceptions/mailbox/null_inbox_unread_count_exception.dart';
|
import '../exceptions/mailbox/null_inbox_unread_count_exception.dart';
|
||||||
import '../integration_test/exceptions/mailbox/null_quota_exception.dart';
|
import '../exceptions/mailbox/null_quota_exception.dart';
|
||||||
|
|
||||||
class MailboxMenuRobot extends CoreRobot {
|
class MailboxMenuRobot extends CoreRobot {
|
||||||
MailboxMenuRobot(super.$);
|
MailboxMenuRobot(super.$);
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:tmail_ui_user/features/manage_account/presentation/identities/widgets/identity_list_tile_builder.dart';
|
||||||
|
|
||||||
|
import '../base/core_robot.dart';
|
||||||
|
|
||||||
|
class ProfilesRobot extends CoreRobot {
|
||||||
|
ProfilesRobot(super.$);
|
||||||
|
|
||||||
|
Future<void> selectIdentityAsDefault(
|
||||||
|
String identityName,
|
||||||
|
ImagePaths imagePaths,
|
||||||
|
) async {
|
||||||
|
await $.scrollUntilVisible(finder: $(identityName));
|
||||||
|
|
||||||
|
await $(IdentityListTileBuilder)
|
||||||
|
.which<IdentityListTileBuilder>(
|
||||||
|
(widget) {
|
||||||
|
return widget.identity.name == identityName;
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.$(InkWell)
|
||||||
|
.tap();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> tapCreateNewIdentityButton() async {
|
||||||
|
await $(#create_new_identity_button).tap();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,10 @@ class SettingRobot extends CoreRobot {
|
|||||||
await $(#setting_preferences).tap();
|
await $(#setting_preferences).tap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> openProfilesMenuItem() async {
|
||||||
|
await $(#setting_profiles).tap();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> switchOnThreadSetting() async {
|
Future<void> switchOnThreadSetting() async {
|
||||||
final threadSettingOn = $(ValueKey(AppLocalizations().thread))
|
final threadSettingOn = $(ValueKey(AppLocalizations().thread))
|
||||||
.$(#setting_option_switch_on)
|
.$(#setting_option_switch_on)
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:tmail_ui_user/features/identity_creator/presentation/identity_creator_view.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
|
import '../../../base/base_test_scenario.dart';
|
||||||
|
import '../../../robots/identity_creator_robot.dart';
|
||||||
|
import '../../../robots/mailbox_menu_robot.dart';
|
||||||
|
import '../../../robots/profiles_robot.dart';
|
||||||
|
import '../../../robots/setting_robot.dart';
|
||||||
|
import '../../../robots/thread_robot.dart';
|
||||||
|
|
||||||
|
class CreateNewIdentityScenario extends BaseTestScenario {
|
||||||
|
final List<String>? identityNames;
|
||||||
|
|
||||||
|
const CreateNewIdentityScenario(super.$, {this.identityNames});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> runTestLogic() async {
|
||||||
|
final threadRobot = ThreadRobot($);
|
||||||
|
final mailboxMenuRobot = MailboxMenuRobot($);
|
||||||
|
final settingRobot = SettingRobot($);
|
||||||
|
final profilesRobot = ProfilesRobot($);
|
||||||
|
final identityCreatorRobot = IdentityCreatorRobot($);
|
||||||
|
final appLocalizations = AppLocalizations();
|
||||||
|
|
||||||
|
await threadRobot.openMailbox();
|
||||||
|
await _expectUserAvatarVisible();
|
||||||
|
|
||||||
|
await mailboxMenuRobot.openSetting();
|
||||||
|
await _expectSettingViewVisible(appLocalizations);
|
||||||
|
await $.pumpAndTrySettle();
|
||||||
|
await _expectProfilesMenuItemVisible();
|
||||||
|
|
||||||
|
await settingRobot.openProfilesMenuItem();
|
||||||
|
await $.pumpAndTrySettle();
|
||||||
|
await _expectCreateNewIdentityButtonVisible();
|
||||||
|
|
||||||
|
if (identityNames?.isNotEmpty == true) {
|
||||||
|
for (var name in identityNames!) {
|
||||||
|
await profilesRobot.tapCreateNewIdentityButton();
|
||||||
|
await _expectIdentityCreatorViewVisible();
|
||||||
|
await identityCreatorRobot.enterName(name);
|
||||||
|
await identityCreatorRobot.tapSaveIdentityButton();
|
||||||
|
await $.pumpAndTrySettle(duration: const Duration(seconds: 1));
|
||||||
|
await _expectIdentityVisible(name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await profilesRobot.tapCreateNewIdentityButton();
|
||||||
|
await _expectIdentityCreatorViewVisible();
|
||||||
|
await identityCreatorRobot.enterName('New Identity');
|
||||||
|
await identityCreatorRobot.tapSaveIdentityButton();
|
||||||
|
await $.pumpAndTrySettle(duration: const Duration(seconds: 1));
|
||||||
|
await _expectIdentityVisible('New Identity');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectUserAvatarVisible() => expectViewVisible($(#user_avatar));
|
||||||
|
|
||||||
|
Future<void> _expectSettingViewVisible(AppLocalizations appLocalizations) =>
|
||||||
|
expectViewVisible($(find.text(appLocalizations.settings)));
|
||||||
|
|
||||||
|
Future<void> _expectProfilesMenuItemVisible() async {
|
||||||
|
await expectViewVisible($(#setting_profiles));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectCreateNewIdentityButtonVisible() =>
|
||||||
|
expectViewVisible($(#create_new_identity_button));
|
||||||
|
|
||||||
|
Future<void> _expectIdentityCreatorViewVisible() =>
|
||||||
|
expectViewVisible($(IdentityCreatorView));
|
||||||
|
|
||||||
|
Future<void> _expectIdentityVisible(String name) async {
|
||||||
|
await expectViewVisible($(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:tmail_ui_user/features/manage_account/presentation/identities/widgets/identity_list_tile_builder.dart';
|
||||||
|
|
||||||
|
import '../../../base/base_test_scenario.dart';
|
||||||
|
import '../../../robots/profiles_robot.dart';
|
||||||
|
import 'create_new_identity_scenario.dart';
|
||||||
|
|
||||||
|
class SetIdentityAsDefaultScenario extends BaseTestScenario {
|
||||||
|
const SetIdentityAsDefaultScenario(super.$);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> runTestLogic() async {
|
||||||
|
final profilesRobot = ProfilesRobot($);
|
||||||
|
final imagePaths = ImagePaths();
|
||||||
|
final createNewIdentityScenario = CreateNewIdentityScenario(
|
||||||
|
$,
|
||||||
|
identityNames: ['Default Identity 1', 'Default Identity 2'],
|
||||||
|
);
|
||||||
|
await createNewIdentityScenario.runTestLogic();
|
||||||
|
await $.pumpAndTrySettle();
|
||||||
|
|
||||||
|
await profilesRobot.selectIdentityAsDefault(
|
||||||
|
'Default Identity 1',
|
||||||
|
imagePaths,
|
||||||
|
);
|
||||||
|
await $.pumpAndTrySettle();
|
||||||
|
_expectIdentityAsDefaultVisible('Default Identity 1', imagePaths);
|
||||||
|
|
||||||
|
await profilesRobot.selectIdentityAsDefault(
|
||||||
|
'Default Identity 2',
|
||||||
|
imagePaths,
|
||||||
|
);
|
||||||
|
await $.pumpAndTrySettle();
|
||||||
|
_expectIdentityAsDefaultVisible('Default Identity 2', imagePaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _expectIdentityAsDefaultVisible(String name, ImagePaths imagePaths) {
|
||||||
|
expect(
|
||||||
|
$(IdentityListTileBuilder)
|
||||||
|
.which<IdentityListTileBuilder>(
|
||||||
|
(widget) {
|
||||||
|
return widget.identity.name == name;
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.$(TMailButtonWidget)
|
||||||
|
.which<TMailButtonWidget>(
|
||||||
|
(widget) => widget.icon == imagePaths.icRadioSelected)
|
||||||
|
.exists,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import '../../../base/test_base.dart';
|
||||||
|
import '../../../scenarios/setting/identity/set_identity_as_default_scenario.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestBase().runPatrolTest(
|
||||||
|
description: 'Should see identity as default when select identity as default',
|
||||||
|
scenarioBuilder: ($) => SetIdentityAsDefaultScenario($),
|
||||||
|
);
|
||||||
|
}
|
||||||
+1
@@ -72,6 +72,7 @@ class IdentityCreatorFormBottomView extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ConfirmDialogButton(
|
return ConfirmDialogButton(
|
||||||
|
key: const Key('save_identity_button'),
|
||||||
label: actionType.getPositiveButtonTitle(appLocalizations),
|
label: actionType.getPositiveButtonTitle(appLocalizations),
|
||||||
backgroundColor: AppColor.primaryMain,
|
backgroundColor: AppColor.primaryMain,
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
|
|||||||
+1
@@ -22,6 +22,7 @@ class CreateNewIdentityButtonWidget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TMailButtonWidget(
|
return TMailButtonWidget(
|
||||||
|
key: const Key('create_new_identity_button'),
|
||||||
text: AppLocalizations.of(context).createNewIdentity,
|
text: AppLocalizations.of(context).createNewIdentity,
|
||||||
icon: imagePaths.icAddIdentity,
|
icon: imagePaths.icAddIdentity,
|
||||||
backgroundColor: AppColor.primaryMain,
|
backgroundColor: AppColor.primaryMain,
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class SettingsFirstLevelView extends GetWidget<SettingsController> {
|
|||||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||||
),
|
),
|
||||||
SettingFirstLevelTileBuilder(
|
SettingFirstLevelTileBuilder(
|
||||||
|
key: const Key('setting_profiles'),
|
||||||
AppLocalizations.of(context).profiles,
|
AppLocalizations.of(context).profiles,
|
||||||
AccountMenuItem.profiles.getIcon(controller.imagePaths),
|
AccountMenuItem.profiles.getIcon(controller.imagePaths),
|
||||||
subtitle: AppLocalizations.of(context).profilesSettingExplanation,
|
subtitle: AppLocalizations.of(context).profilesSettingExplanation,
|
||||||
|
|||||||
Reference in New Issue
Block a user