TF-3622 Fix build E2E test for case deformed inlined image fail on CI

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-04-11 16:34:20 +07:00
committed by Dat H. Pham
parent 3248f44cf2
commit 6fb5e8cb79
3 changed files with 14 additions and 20 deletions
@@ -21,7 +21,7 @@ class DeformedInlinedImageScenario extends BaseTestScenario {
<br> <br>
<img <img
src="https://example.com/image.jpg" src="https://example.com/image.jpg"
style="width: 2000px; height: 200px;" style="width: 2000px;height: 200px;"
alt="inline-image-oversize-with-style"/> alt="inline-image-oversize-with-style"/>
<br> <br>
<img <img
@@ -32,7 +32,7 @@ class DeformedInlinedImageScenario extends BaseTestScenario {
<br> <br>
<img <img
src="https://example.com/image.jpg" src="https://example.com/image.jpg"
style="width: 2000px; height: 200px;" style="width: 2000px;height: 200px;"
width="2000" width="2000"
height="200" height="200"
alt="inline-image-oversize-with-style-and-width-attribute"/> alt="inline-image-oversize-with-style-and-width-attribute"/>
@@ -45,7 +45,7 @@ class DeformedInlinedImageScenario extends BaseTestScenario {
<br> <br>
<img <img
src="https://example.com/image.jpg" src="https://example.com/image.jpg"
style="width: 100px; height: 100px;" style="width: 100px;height: 100px;"
width="100" width="100"
height="100" height="100"
alt="inline-image-normal-size-with-style-and-width-attribute"/> alt="inline-image-normal-size-with-style-and-width-attribute"/>
@@ -105,13 +105,10 @@ class DeformedInlinedImageScenario extends BaseTestScenario {
.tap(); .tap();
expect(emailController, isNotNull); expect(emailController, isNotNull);
final webViewController = emailController final htmlContentViewKey = emailController?.htmlContentViewKey;
?.htmlContentViewKey expect(htmlContentViewKey, isNotNull);
?.currentState
?.webViewController;
expect(webViewController, isNotNull);
final result = await webViewController?.evaluateJavascript( final result = await htmlContentViewKey!.currentState!.webViewController.evaluateJavascript(
source: ''' source: '''
(function() { (function() {
const images = document.querySelectorAll('img'); const images = document.querySelectorAll('img');
@@ -144,8 +141,7 @@ class DeformedInlinedImageScenario extends BaseTestScenario {
expect(imgWidth, equals('100')); expect(imgWidth, equals('100'));
expect(imgHeight, equals('100')); expect(imgHeight, equals('100'));
} else if (imgAlt == 'inline-image-normal-size-with-style-and-width-attribute') { } else if (imgAlt == 'inline-image-normal-size-with-style-and-width-attribute') {
expect(imgStyle.contains('max-width: 100%;'), isFalse); expect(imgStyle.contains('width: 100px;height: 100px;'), isTrue);
expect(imgStyle.contains('width: 100px; height: 100px;'), isTrue);
expect(imgWidth, equals('100')); expect(imgWidth, equals('100'));
expect(imgHeight, equals('100')); expect(imgHeight, equals('100'));
} else { } else {
@@ -195,8 +195,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final currentEmailLoaded = Rxn<EmailLoaded>(); final currentEmailLoaded = Rxn<EmailLoaded>();
final isEmailContentClipped = RxBool(false); final isEmailContentClipped = RxBool(false);
final attendanceStatus = Rxn<AttendanceStatus>(); final attendanceStatus = Rxn<AttendanceStatus>();
final htmlContentViewKey = GlobalKey<HtmlContentViewState>();
GlobalKey<HtmlContentViewState>? htmlContentViewKey;
EmailId? _currentEmailId; EmailId? _currentEmailId;
Identity? _identitySelected; Identity? _identitySelected;
ButtonState? _printEmailButtonState; ButtonState? _printEmailButtonState;
@@ -244,9 +244,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void onInit() { void onInit() {
_registerObxStreamListener(); _registerObxStreamListener();
_listenDownloadAttachmentProgressState(); _listenDownloadAttachmentProgressState();
if (PlatformInfo.isIntegrationTesting) {
htmlContentViewKey = GlobalKey<HtmlContentViewState>();
}
super.onInit(); super.onInit();
} }
@@ -254,9 +251,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void onClose() { void onClose() {
_downloadProgressStateController.close(); _downloadProgressStateController.close();
_attachmentListScrollController.dispose(); _attachmentListScrollController.dispose();
if (PlatformInfo.isIntegrationTesting) {
htmlContentViewKey = null;
}
super.onClose(); super.onClose();
} }
@@ -447,7 +447,9 @@ class EmailView extends GetWidget<SingleEmailController> {
), ),
child: LayoutBuilder(builder: (context, constraints) { child: LayoutBuilder(builder: (context, constraints) {
return HtmlContentViewer( return HtmlContentViewer(
key: controller.htmlContentViewKey, key: PlatformInfo.isIntegrationTesting
? controller.htmlContentViewKey
: null,
contentHtml: allEmailContents, contentHtml: allEmailContents,
initialWidth: constraints.maxWidth, initialWidth: constraints.maxWidth,
direction: AppUtils.getCurrentDirection(context), direction: AppUtils.getCurrentDirection(context),
@@ -487,7 +489,9 @@ class EmailView extends GetWidget<SingleEmailController> {
), ),
child: LayoutBuilder(builder: (context, constraints) { child: LayoutBuilder(builder: (context, constraints) {
return HtmlContentViewer( return HtmlContentViewer(
key: controller.htmlContentViewKey, key: PlatformInfo.isIntegrationTesting
? controller.htmlContentViewKey
: null,
contentHtml: allEmailContents, contentHtml: allEmailContents,
initialWidth: constraints.maxWidth, initialWidth: constraints.maxWidth,
direction: AppUtils.getCurrentDirection(context), direction: AppUtils.getCurrentDirection(context),