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 '../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 {
|
||||
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();
|
||||
}
|
||||
|
||||
Future<void> openProfilesMenuItem() async {
|
||||
await $(#setting_profiles).tap();
|
||||
}
|
||||
|
||||
Future<void> switchOnThreadSetting() async {
|
||||
final threadSettingOn = $(ValueKey(AppLocalizations().thread))
|
||||
.$(#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($),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user