mirror of
https://github.com/linagora/tmail-flutter.git
synced 2026-12-06 16:04:20 +00:00
* Patrol POC replace Firebase Test Lab with local Android emulator Replace GCloud auth, Firebase Test Lab, and ngrok with a local Android AVD via reactivecircus/android-emulator-runner on CI. The backend runs in Docker and is reachable from the emulator at the QEMU host alias 10.0.2.2. CI / scripts: - Remove Google Cloud auth, Firebase run step, and ngrok tunnel - Add KVM, Gradle, and AVD cache setup; shard tests across 4 parallel runners - Scripts: drop ngrok, point jmap.properties to 10.0.2.2, manage cleanup via trap - prebuild.sh: parallelize module builds, suppress noisy output - provisioning.sh: parallelize james-cli/curl calls, fix hardcoded container IP Backend reset for test isolation: - Add backend-reset-server.py: HTTP server that restarts tmail-backend and re-runs provisioning on POST /reset, so each test starts with a clean state - Add BackendResetClient.dart: Dart client called in patrolTearDown - Reduce visibleTimeout 30s → 10s; allow insecure connections in debug mode * Patrol POC fix flaky tests Replace fixed pumpAndSettle delays with waitUntilVisible/waitUntilExists so tests react to actual UI state rather than arbitrary timeouts. - Add PatrolFileExtensions.toFileInfo() and use it in composer robot/scenario utils - Guard MobileEditorWidget.dispose() under isIntegrationTesting to prevent teardown crash - Fix scroll direction (AxisDirection.down) in calendar attendee button scroll - Add scrollTo() before tap in label modal robot and edit-tag scenario - Wait on EmailTileBuilder (not label name) after email provisioning — more reliable - Inline image: wait for HtmlContentViewer to contain base64 data before asserting - Use native platform wait for inline image in upload scenario - Remove unnecessary Future.delayed and extra pumpAndSettle calls - Pre-select English before switching language to ensure deterministic starting state - Fix app_grid back-press sequence
185 lines
6.6 KiB
Dart
185 lines
6.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:core/presentation/resources/image_paths.dart';
|
|
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:model/email/prefix_email_address.dart';
|
|
import 'package:model/extensions/session_extension.dart';
|
|
import 'package:rich_text_composer/rich_text_composer.dart';
|
|
import 'package:tmail_ui_user/features/base/model/ui_keys.dart';
|
|
import 'package:tmail_ui_user/features/base/widget/popup_item_widget.dart';
|
|
import 'package:tmail_ui_user/features/composer/domain/state/download_image_as_base64_state.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/composer_view.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/view/mobile/mobile_editor_view.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/list_recipients_collapsed_widget.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/mobile/app_bar_composer_widget.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/mobile/from_composer_mobile_widget.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/recipient_composer_widget.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/recipient_suggestion_item_widget.dart';
|
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/subject_composer_widget.dart';
|
|
import 'package:tmail_ui_user/features/upload/domain/state/local_image_picker_state.dart';
|
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
|
|
|
import '../base/core_robot.dart';
|
|
import '../extensions/patrol_file_extensions.dart';
|
|
import '../extensions/patrol_finder_extension.dart';
|
|
|
|
class ComposerRobot extends CoreRobot {
|
|
ComposerRobot(super.$);
|
|
|
|
Future<void> expandRecipientsFields() async {
|
|
await $(RecipientsCollapsedComposerWidget).$(GestureDetector).tap();
|
|
}
|
|
|
|
Future<void> addRecipientIntoField({
|
|
required PrefixEmailAddress prefixEmailAddress,
|
|
required String email,
|
|
}) async {
|
|
final finder = $(RecipientComposerWidget).which<RecipientComposerWidget>(
|
|
(widget) => widget.prefix == prefixEmailAddress);
|
|
await finder.enterTextWithoutTapAction(email);
|
|
|
|
await $(RecipientSuggestionItemWidget)
|
|
.which<RecipientSuggestionItemWidget>(
|
|
(widget) => widget.emailAddress.email?.contains(email) ?? false)
|
|
.tap();
|
|
}
|
|
|
|
Future<void> addSubject(String subject) async {
|
|
final finder = $(SubjectComposerWidget);
|
|
final isTextFieldFocused = finder
|
|
.which<SubjectComposerWidget>(
|
|
(view) => view.focusNode?.hasFocus ?? false)
|
|
.exists;
|
|
if (!isTextFieldFocused) {
|
|
await finder.tap();
|
|
}
|
|
await $.pumpAndTrySettle();
|
|
await finder.enterTextWithoutTapAction(subject);
|
|
}
|
|
|
|
Future<void> addContent(String content) async {
|
|
ComposerController? composerController;
|
|
await $(ComposerView)
|
|
.which<ComposerView>((widget) {
|
|
composerController = widget.controller;
|
|
return true;
|
|
})
|
|
.$(MobileEditorView)
|
|
.$(HtmlEditor)
|
|
.$(InAppWebView)
|
|
.tap();
|
|
|
|
await composerController?.htmlEditorApi?.requestFocusLastChild();
|
|
|
|
await composerController?.htmlEditorApi?.insertHtml('$content <br><br>');
|
|
}
|
|
|
|
Future<void> sendEmail(ImagePaths imagePaths) async {
|
|
await $(const ValueKey(UiKeys.sendEmailButton)).tap();
|
|
}
|
|
|
|
Future<void> grantContactPermission() async {
|
|
if (await native
|
|
.isPermissionDialogVisible(timeout: const Duration(seconds: 5))) {
|
|
await native.grantPermissionWhenInUse();
|
|
}
|
|
}
|
|
|
|
Future<void> tapCloseComposer(ImagePaths imagePaths) async {
|
|
await $(AppBarComposerWidget)
|
|
.$(TMailButtonWidget)
|
|
.which<TMailButtonWidget>(
|
|
(widget) => widget.icon == imagePaths.icCancel)
|
|
.tap();
|
|
}
|
|
|
|
Future<void> tapSaveButtonOnSaveDraftConfirmDialog(
|
|
AppLocalizations appLocalizations) async {
|
|
await $(find.text(appLocalizations.save)).tap();
|
|
}
|
|
|
|
Future<void> tapMoreOptionOnAppBar() async {
|
|
await $(#composer_more_button).tap();
|
|
}
|
|
|
|
Future<void> tapMarkAsImportantPopupItemOnMenu() async {
|
|
await $(#mark_as_important_popup_item).tap();
|
|
}
|
|
|
|
Future<void> tapReadReceiptPopupItemOnMenu() async {
|
|
await $(#read_receipt_popup_item).tap();
|
|
}
|
|
|
|
Future<void> tapSaveAsDraftPopupItemOnMenu() async {
|
|
await $(#save_as_draft_popup_item).tap();
|
|
}
|
|
|
|
Future<void> tapToRecipientExpandButton() async {
|
|
await $(#prefix_to_recipient_expand_button).tap();
|
|
}
|
|
|
|
Future<void> tapCcRecipientExpandButton() async {
|
|
await $(#prefix_cc_recipient_expand_button).tap();
|
|
}
|
|
|
|
Future<void> tapFromFieldPopupMenu() async {
|
|
await $(FromComposerMobileWidget).$(InkWell).tap();
|
|
}
|
|
|
|
Future<void> saveAsTemplate() async {
|
|
await $(AppBarComposerWidget)
|
|
.$(TMailButtonWidget)
|
|
.which<TMailButtonWidget>(
|
|
(widget) => widget.icon == ImagePaths().icMore)
|
|
.tap();
|
|
await $(AppLocalizations().saveAsTemplate).tap();
|
|
}
|
|
|
|
Future<void> addAttachment(File file) async {
|
|
final controller = Get.find<ComposerController>();
|
|
final fileInfo = await file.toFileInfo();
|
|
controller.uploadController.justUploadAttachmentsAction(
|
|
uploadFiles: [
|
|
fileInfo,
|
|
],
|
|
uploadUri:
|
|
controller.mailboxDashBoardController.sessionCurrent!.getUploadUri(
|
|
controller.mailboxDashBoardController.accountId.value!,
|
|
jmapUrl: controller.dynamicUrlInterceptors.jmapUrl,
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> addInline(File file) async {
|
|
final controller = Get.find<ComposerController>();
|
|
final fileInfo = await file.toFileInfo();
|
|
controller.handleSuccessViewState(LocalImagePickerSuccess(fileInfo));
|
|
await controller.viewState.stream.firstWhere((state) => state.fold(
|
|
(failure) => false,
|
|
(success) => success is DownloadImageAsBase64Success,
|
|
));
|
|
}
|
|
|
|
Future<void> toggleReadReceipt() async {
|
|
await $(PopupItemWidget)
|
|
.which<PopupItemWidget>((widget) => widget.iconAction == ImagePaths().icReadReceipt)
|
|
.tap();
|
|
}
|
|
|
|
Future<void> addInlineImageFromFile(File file) async {
|
|
final controller = getBinding<ComposerController>();
|
|
final fileInfo = await file.toFileInfo();
|
|
|
|
controller?.handleSuccessViewState(LocalImagePickerSuccess(fileInfo));
|
|
}
|
|
|
|
Future<void> tapDiscardChanges() async {
|
|
await $(AppLocalizations().discardChanges).tap();
|
|
}
|
|
}
|