TF-4308 Add E2E tests for ChooseLabelModal and NoLabelYetWidget
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
+75
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:labels/labels.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/models/label_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/widgets/no_label_yet_widget.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/labels/label_list_view.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/provisioning_label_scenario_mixin.dart';
|
||||
import '../../robots/labels/choose_label_modal_robot.dart';
|
||||
import '../../robots/labels/create_label_modal_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class CreateLabelFromChooseLabelModalWithExistingLabelsScenario
|
||||
extends BaseTestScenario with ProvisioningLabelScenarioMixin {
|
||||
const CreateLabelFromChooseLabelModalWithExistingLabelsScenario(super.$);
|
||||
|
||||
@override
|
||||
Future<void> runTestLogic() async {
|
||||
const emailUser = String.fromEnvironment('BASIC_AUTH_EMAIL');
|
||||
expect(emailUser, isNotEmpty, reason: 'BASIC_AUTH_EMAIL must be set');
|
||||
|
||||
final threadRobot = ThreadRobot($);
|
||||
final chooseLabelModalRobot = ChooseLabelModalRobot($);
|
||||
final createLabelModalRobot = CreateLabelModalRobot($);
|
||||
|
||||
final labels = await provisionLabelsByDisplayNames(['Existing Label 1']);
|
||||
await $.pumpAndSettle();
|
||||
expect(labels, isNotEmpty, reason: 'Provisioning label failed');
|
||||
|
||||
final existingLabel = labels.first;
|
||||
|
||||
await provisionEmail(
|
||||
buildEmailsForLabel(
|
||||
label: existingLabel,
|
||||
toEmail: emailUser,
|
||||
count: 1,
|
||||
),
|
||||
requestReadReceipt: false,
|
||||
);
|
||||
await $.pumpAndSettle(duration: const Duration(seconds: 2));
|
||||
|
||||
await threadRobot.openMailbox();
|
||||
await expectViewVisible($(LabelListView));
|
||||
await $.native.pressBack();
|
||||
|
||||
await threadRobot.longPressEmailWithSubject(
|
||||
'Email 1 subject ${existingLabel.safeDisplayName}',
|
||||
);
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await threadRobot.tapLabelAsButton();
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
expect(chooseLabelModalRobot.isLabelListVisible, isTrue);
|
||||
expect($(NoLabelYetWidget).visible, isFalse);
|
||||
await expectViewVisible($(find.text(AppLocalizations().createALabel)));
|
||||
|
||||
await chooseLabelModalRobot.tapCreateALabelButton();
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await expectViewVisible($(#create_new_label_modal));
|
||||
|
||||
final uniqueSuffix = DateTime.now().microsecondsSinceEpoch;
|
||||
final newLabelName = 'New label from modal $uniqueSuffix';
|
||||
await createLabelModalRobot.enterNewLabelName(newLabelName);
|
||||
await createLabelModalRobot.tapPositiveActionButton(LabelActionType.create);
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await expectViewVisible(
|
||||
$(find.text(AppLocalizations().createLabelSuccessfullyMessage(newLabelName))),
|
||||
);
|
||||
await expectViewVisible($(newLabelName));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/models/label_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/widgets/no_label_yet_widget.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../models/provisioning_email.dart';
|
||||
import '../../robots/labels/choose_label_modal_robot.dart';
|
||||
import '../../robots/labels/create_label_modal_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class CreateLabelFromNoLabelYetWidgetScenario extends BaseTestScenario {
|
||||
const CreateLabelFromNoLabelYetWidgetScenario(super.$);
|
||||
|
||||
@override
|
||||
Future<void> runTestLogic() async {
|
||||
const emailUser = String.fromEnvironment('BASIC_AUTH_EMAIL');
|
||||
expect(emailUser, isNotEmpty, reason: 'BASIC_AUTH_EMAIL must be set');
|
||||
|
||||
final threadRobot = ThreadRobot($);
|
||||
final chooseLabelModalRobot = ChooseLabelModalRobot($);
|
||||
final createLabelModalRobot = CreateLabelModalRobot($);
|
||||
|
||||
await provisionEmail(
|
||||
[
|
||||
ProvisioningEmail(
|
||||
toEmail: emailUser,
|
||||
subject: 'Test email for create label from no-label widget',
|
||||
content: 'Content',
|
||||
),
|
||||
],
|
||||
requestReadReceipt: false,
|
||||
);
|
||||
await $.pumpAndSettle(duration: const Duration(seconds: 2));
|
||||
|
||||
await threadRobot.longPressEmailWithSubject(
|
||||
'Test email for create label from no-label widget',
|
||||
);
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await threadRobot.tapLabelAsButton();
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await expectViewVisible($(NoLabelYetWidget));
|
||||
|
||||
await chooseLabelModalRobot.tapCreateALabelButton();
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await expectViewVisible($(#create_new_label_modal));
|
||||
|
||||
final uniqueSuffix = DateTime.now().microsecondsSinceEpoch;
|
||||
final newLabelName = 'Label from no-label widget $uniqueSuffix';
|
||||
await createLabelModalRobot.enterNewLabelName(newLabelName);
|
||||
await createLabelModalRobot.tapPositiveActionButton(LabelActionType.create);
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await expectViewVisible(
|
||||
$(find.text(AppLocalizations().createLabelSuccessfullyMessage(newLabelName))),
|
||||
);
|
||||
expect(chooseLabelModalRobot.isLabelListVisible, isTrue);
|
||||
await expectViewVisible($(newLabelName));
|
||||
expect($(NoLabelYetWidget).visible, isFalse);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/widgets/no_label_yet_widget.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../models/provisioning_email.dart';
|
||||
import '../../robots/labels/choose_label_modal_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class DisplayNoLabelYetWidgetWhenOpenChooseLabelModalScenario
|
||||
extends BaseTestScenario {
|
||||
const DisplayNoLabelYetWidgetWhenOpenChooseLabelModalScenario(super.$);
|
||||
|
||||
@override
|
||||
Future<void> runTestLogic() async {
|
||||
const emailUser = String.fromEnvironment('BASIC_AUTH_EMAIL');
|
||||
expect(emailUser, isNotEmpty, reason: 'BASIC_AUTH_EMAIL must be set');
|
||||
|
||||
final threadRobot = ThreadRobot($);
|
||||
final chooseLabelModalRobot = ChooseLabelModalRobot($);
|
||||
|
||||
await provisionEmail(
|
||||
[
|
||||
ProvisioningEmail(
|
||||
toEmail: emailUser,
|
||||
subject: 'Test email for no-label modal',
|
||||
content: 'Content',
|
||||
),
|
||||
],
|
||||
requestReadReceipt: false,
|
||||
);
|
||||
await $.pumpAndSettle(duration: const Duration(seconds: 2));
|
||||
|
||||
await threadRobot.longPressEmailWithSubject('Test email for no-label modal');
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await threadRobot.tapLabelAsButton();
|
||||
await $.pumpAndTrySettle();
|
||||
|
||||
await _expectNoLabelYetWidgetVisible(chooseLabelModalRobot);
|
||||
}
|
||||
|
||||
Future<void> _expectNoLabelYetWidgetVisible(
|
||||
ChooseLabelModalRobot chooseLabelModalRobot,
|
||||
) async {
|
||||
await expectViewVisible($(NoLabelYetWidget));
|
||||
await expectViewVisible($(find.text(AppLocalizations().noLabelsYet)));
|
||||
await expectViewVisible($(find.text(AppLocalizations().createALabel)));
|
||||
expect(chooseLabelModalRobot.isLabelListVisible, isFalse);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user