E2E Fix integration test Twake Mail v0.18.4

E2E Fix integration test Twake Mail v0.18.4
This commit is contained in:
Dang Dat
2025-09-09 10:22:14 +07:00
committed by Dat H. Pham
parent fb53ba6568
commit c6ace7a9b5
29 changed files with 97 additions and 114 deletions
@@ -27,10 +27,11 @@ class ComposerUploadAttachmentAndInlineImageScenario extends BaseTestScenario {
final png = await preparingPngWithName(pngName);
await composerRobot.addAttachment(png);
await $.pumpAndSettle();
await _expectAttachment(pngName);
await composerRobot.addInline(png);
await $.pumpAndSettle();
_expectAttachment(pngName);
await _expectInline();
await composerRobot.addAttachment(png);
@@ -50,13 +51,11 @@ class ComposerUploadAttachmentAndInlineImageScenario extends BaseTestScenario {
);
}
void _expectAttachment(String pngName) {
return expect(
$(AttachmentItemComposerWidget)
.which<AttachmentItemComposerWidget>(
(widget) => widget.fileName.contains(pngName)
),
findsOneWidget,
Future<void> _expectAttachment(String pngName) async {
await expectViewVisible(
$(AttachmentItemComposerWidget).which<AttachmentItemComposerWidget>(
(widget) => widget.fileName.contains(pngName),
),
);
}
@@ -38,10 +38,10 @@ class ArchiveEmailScenario extends BaseTestScenario {
_expectEmailDetailedMoreButtonVisible();
await emailRobot.tapEmailDetailedMoreButton();
await $.pumpAndSettle(duration: const Duration(seconds: 2));
await $.pumpAndSettle(duration: const Duration(seconds: 1));
await emailRobot.tapArchiveMessageOptionInContextMenu();
await $.pumpAndSettle(duration: const Duration(seconds: 3));
await $.pumpAndSettle(duration: const Duration(seconds: 1));
await emailRobot.onTapBackButton();
await $.pumpAndSettle();
@@ -37,8 +37,9 @@ class DeleteEmailScenario extends BaseTestScenario {
await threadRobot.openEmailWithSubject(subject);
await $.pumpAndSettle();
await emailRobot.tapEmailDetailedMoreButton();
await emailRobot.tapEmailDetailedDeleteEmailButton();
await $.pumpAndSettle(duration: const Duration(seconds: 3));
await $.pumpAndSettle(duration: const Duration(seconds: 1));
_expectEmailViewInvisible();
@@ -52,7 +52,7 @@ class DisplayEmailAddressInfoDialogScenario extends BaseTestScenario {
Future<void> _expectEmailAddressInfoDialogVisible(
AppLocalizations appLocalizations,
) async {
await expectViewVisible($(appLocalizations.copy_email_address));
await expectViewVisible($(#copy_email_address));
await expectViewVisible($(appLocalizations.quickCreatingRule));
await expectViewVisible($(appLocalizations.compose_email));
}
@@ -1,6 +1,3 @@
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 '../../base/base_test_scenario.dart';
@@ -18,7 +15,6 @@ class MarkAsStarEmailScenario extends BaseTestScenario {
const emailUser = String.fromEnvironment('BASIC_AUTH_EMAIL');
final threadRobot = ThreadRobot($);
final emailRobot = EmailRobot($);
final imagePaths = ImagePaths();
await provisionEmail(
[
@@ -34,32 +30,29 @@ class MarkAsStarEmailScenario extends BaseTestScenario {
await threadRobot.openEmailWithSubject(subject);
await $.pumpAndSettle();
_expectEmailDetailedStarButtonVisible();
await emailRobot.tapEmailDetailedMoreButton();
await _expectEmailDetailedStarButtonVisible();
await emailRobot.tapEmailDetailedStarButton();
await $.pumpAndSettle(duration: const Duration(seconds: 2));
await _expectDisplayedStarIcon(imagePaths);
await $.pumpAndSettle(duration: const Duration(seconds: 1));
await emailRobot.tapEmailDetailedMoreButton();
await _expectDisplayedUnStarIcon();
await emailRobot.tapEmailDetailedStarButton();
await $.pumpAndSettle(duration: const Duration(seconds: 2));
await _expectDisplayedUnStarIcon(imagePaths);
await emailRobot.tapEmailDetailedUnstarButton();
await $.pumpAndSettle(duration: const Duration(seconds: 1));
await emailRobot.tapEmailDetailedMoreButton();
await _expectDisplayedStarIcon();
}
void _expectEmailDetailedStarButtonVisible() {
expect($(#email_detailed_star_button), findsOneWidget);
Future<void> _expectEmailDetailedStarButtonVisible() async {
await expectViewVisible($(#markAsStarred_action));
}
Future<void> _expectDisplayedStarIcon(ImagePaths imagePaths) async {
await expectViewVisible(
$(#email_detailed_star_button).which<TMailButtonWidget>(
(widget) => widget.icon == imagePaths.icStar),
);
Future<void> _expectDisplayedStarIcon() async {
await expectViewVisible($(#markAsStarred_action));
}
Future<void> _expectDisplayedUnStarIcon(ImagePaths imagePaths) async {
await expectViewVisible(
$(#email_detailed_star_button).which<TMailButtonWidget>(
(widget) => widget.icon == imagePaths.icUnStar),
);
Future<void> _expectDisplayedUnStarIcon() async {
await expectViewVisible($(#unMarkAsStarred_action));
}
}
@@ -38,6 +38,7 @@ class MoveEmailToFolderScenario extends BaseTestScenario {
await threadRobot.openEmailWithSubject(subject);
await $.pumpAndSettle();
await emailRobot.tapEmailDetailedMoreButton();
await emailRobot.tapEmailDetailedMoveEmailButton();
await $.pumpAndSettle(duration: const Duration(seconds: 2));
@@ -79,12 +79,15 @@ class ReplyEmailWithReplyToScenario extends BaseTestScenario {
}
Future<void> _expectToFieldContainReplyToEmailAddress() async {
expect(
$(RecipientComposerWidget).which<RecipientComposerWidget>((widget) =>
widget.prefix == PrefixEmailAddress.to &&
isMatchingEmailList(widget.listEmailAddress, {'emma-reply-to@example.com'})
).visible,
isTrue,
await expectViewVisible(
$(RecipientComposerWidget).which<RecipientComposerWidget>(
(widget) =>
widget.prefix == PrefixEmailAddress.to &&
isMatchingEmailList(
widget.listEmailAddress,
{'emma-reply-to@example.com'},
),
),
);
}
}
@@ -14,7 +14,7 @@ import '../robots/thread_robot.dart';
class ForwardEmailScenario extends BaseTestScenario {
static const String queryString = 'Fwd: Forward email to Bob';
static const String queryString = 'Forward email';
const ForwardEmailScenario(super.$);
@@ -21,7 +21,7 @@ class SaveAsTemplateScenario extends BaseTestScenario {
await _expectSaveToastSuccessVisible();
await composerRobot.addSubject('test subject');
await hideKeyboard();
await composerRobot.saveAsTemplate();
await _expectUpdateToastSuccessVisible();
@@ -42,12 +42,15 @@ class ThreadDetailReplyRealTimeUpdateScenario extends BaseTestScenario {
await composerRobot.grantContactPermission();
await composerRobot.addContent(replyContent);
await composerRobot.sendEmail(imagePaths);
await $.waitUntilVisible($(ThreadDetailCollapsedEmail));
expect(
$(ThreadDetailCollapsedEmail).which<ThreadDetailCollapsedEmail>((widget) {
return widget.preview.contains(replyContent);
}),
findsOneWidget,
);
await _expectNewCollapsedEmail(replyContent);
}
Future<void> _expectNewCollapsedEmail(String replyContent) async {
final collapsedEmail = $(ThreadDetailCollapsedEmail)
.which<ThreadDetailCollapsedEmail>((widget) {
return widget.preview.contains(replyContent);
});
await expectViewVisible(collapsedEmail);
}
}