From bf804ee25e9b01c7eab5f5bb40d86bfe60ff92af Mon Sep 17 00:00:00 2001 From: Dat Vu Date: Fri, 31 Jul 2026 09:17:17 +0700 Subject: [PATCH] TF-4738 Fix response view while drive picker loading display prevent drive picker (#4740) --- .github/workflows/analyze-test.yaml | 2 + .../drive_intent_message_handler_mixin.dart | 19 ++- .../view/drive_intent_skeleton_loader.dart | 15 +- .../drive_intent_web_view_modal_shell.dart | 71 +++++---- .../view/drive_intent_web_view_modal_web.dart | 48 +++--- ...ive_intent_message_handler_mixin_test.dart | 112 ++++++++++---- .../web_window_message_mixin_web_test.dart | 83 +++++++++++ .../drive_intent_skeleton_loader_test.dart | 60 ++++++++ ...rive_intent_web_view_modal_shell_test.dart | 141 ++++++++++++++++++ .../drive_intent_web_view_modal_web_test.dart | 73 +++++++++ 10 files changed, 545 insertions(+), 79 deletions(-) create mode 100644 workplace/test/presentation/mixin/web_window_message_mixin_web_test.dart create mode 100644 workplace/test/presentation/view/drive_intent_skeleton_loader_test.dart create mode 100644 workplace/test/presentation/view/drive_intent_web_view_modal_shell_test.dart create mode 100644 workplace/test/presentation/view/drive_intent_web_view_modal_web_test.dart diff --git a/.github/workflows/analyze-test.yaml b/.github/workflows/analyze-test.yaml index 47fb94b21..2e6590709 100644 --- a/.github/workflows/analyze-test.yaml +++ b/.github/workflows/analyze-test.yaml @@ -15,6 +15,8 @@ env: # "core"). Add more lines here as needed. CHROME_TEST_PATHS: | core/test/data/network/download/download_manager_test.dart + workplace/test/presentation/mixin/web_window_message_mixin_web_test.dart + workplace/test/presentation/view/drive_intent_web_view_modal_web_test.dart jobs: analyze-test: diff --git a/workplace/lib/presentation/mixin/drive_intent_message_handler_mixin.dart b/workplace/lib/presentation/mixin/drive_intent_message_handler_mixin.dart index 6cfc4310f..27d633f4d 100644 --- a/workplace/lib/presentation/mixin/drive_intent_message_handler_mixin.dart +++ b/workplace/lib/presentation/mixin/drive_intent_message_handler_mixin.dart @@ -42,8 +42,7 @@ mixin DriveIntentMessageHandlerMixin on State { void startLoading(DriveIntentLoader intentLoader) { // Starts the deadline immediately so a platform view that never becomes // ready (e.g. WebView/iframe init silently failing) still times out. - _readyTimeoutTimer?.cancel(); - _readyTimeoutTimer = Timer(readyTimeout, _handleReadyTimeout); + _restartReadyTimeout(); unawaited(_loadIntent(intentLoader)); } @@ -69,8 +68,22 @@ mixin DriveIntentMessageHandlerMixin on State { _finish(DrivePickOutcomeFailed(error)); } - void notifyPlatformViewReady() { + void _restartReadyTimeout() { + _readyTimeoutTimer?.cancel(); + _readyTimeoutTimer = Timer(readyTimeout, _handleReadyTimeout); + } + + void notifyPlatformViewReady({bool viewRecreated = false}) { _platformViewReady = true; + if (viewRecreated && _phase == _Phase.loadingPage) { + final intent = _resolvedIntent; + if (intent != null) { + // A replacement iframe needs the resolved URL and a fresh deadline. + _restartReadyTimeout(); + unawaited(_applyIntent(intent)); + } + return; + } _tryApplyIntent(); } diff --git a/workplace/lib/presentation/view/drive_intent_skeleton_loader.dart b/workplace/lib/presentation/view/drive_intent_skeleton_loader.dart index 01c4e30ee..296d8066a 100644 --- a/workplace/lib/presentation/view/drive_intent_skeleton_loader.dart +++ b/workplace/lib/presentation/view/drive_intent_skeleton_loader.dart @@ -32,7 +32,20 @@ class DriveIntentSkeletonLoader extends StatelessWidget { color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(6)), ), - child: mobile ? _buildMobile(context) : _buildWeb(), + // Table layout has no close slot (#4738). + child: mobile + ? _buildMobile(context) + : Stack( + children: [ + Positioned.fill(child: _buildWeb()), + if (closeButton != null) + Positioned( + top: 12, + right: 17, + child: closeButton!, + ), + ], + ), ); } diff --git a/workplace/lib/presentation/view/drive_intent_web_view_modal_shell.dart b/workplace/lib/presentation/view/drive_intent_web_view_modal_shell.dart index 4631b063d..91082191c 100644 --- a/workplace/lib/presentation/view/drive_intent_web_view_modal_shell.dart +++ b/workplace/lib/presentation/view/drive_intent_web_view_modal_shell.dart @@ -35,42 +35,51 @@ class DriveIntentWebViewModalShell extends StatelessWidget { Widget build(BuildContext context) { final closeButton = TMailButtonWidget.fromIcon( icon: closeIconPath, + width: 40, + height: 40, + iconSize: 24, iconColor: const Color(0xFF424244).withValues(alpha: 0.64), - padding: const EdgeInsets.all(12), + padding: const EdgeInsets.all(8), backgroundColor: Colors.transparent, - hoverColor: Colors.transparent, + hoverColor: const Color(0x14424244), onTapActionCallback: onClose, ); - return PointerInterceptor( - child: GestureDetector( - onTap: onBarrierTap ?? onClose, - behavior: HitTestBehavior.opaque, - child: Dialog( - backgroundColor: Colors.white, - insetPadding: insetPadding, - shape: shape, - constraints: constraints, - alignment: alignment, - child: GestureDetector( - onTap: () {}, - behavior: HitTestBehavior.opaque, - child: Stack( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - if (haveCloseButton) - Padding( - padding: const EdgeInsetsGeometry.directional(end: 17), - child: closeButton, - ), - Expanded(child: child), - ], + return GestureDetector( + onTap: onBarrierTap ?? onClose, + behavior: HitTestBehavior.opaque, + child: Dialog( + backgroundColor: Colors.white, + insetPadding: insetPadding, + shape: shape, + constraints: constraints, + alignment: alignment, + child: GestureDetector( + onTap: () {}, + behavior: HitTestBehavior.opaque, + child: Stack( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + if (haveCloseButton) + Padding( + padding: const EdgeInsetsGeometry.directional(end: 17), + child: closeButton, + ), + // Keep the iframe mounted across responsive changes (#4738). + Expanded( + key: const ValueKey('drive-shell-content'), + child: child, + ), + ], + ), + if (loadingWidget != null) + Positioned.fill( + child: PointerInterceptor( + child: loadingWidget!(closeButton), + ), ), - if (loadingWidget != null) - Positioned.fill(child: loadingWidget!(closeButton)), - ], - ), + ], ), ), ), diff --git a/workplace/lib/presentation/view/drive_intent_web_view_modal_web.dart b/workplace/lib/presentation/view/drive_intent_web_view_modal_web.dart index 9a1ca2d3a..e2a7fdbce 100644 --- a/workplace/lib/presentation/view/drive_intent_web_view_modal_web.dart +++ b/workplace/lib/presentation/view/drive_intent_web_view_modal_web.dart @@ -2,6 +2,7 @@ import 'package:core/presentation/utils/responsive_utils.dart'; import 'package:core/presentation/views/button/tmail_button_widget.dart'; import 'package:core/presentation/views/html_viewer/html_iframe_widget.dart'; import 'package:flutter/material.dart'; +import 'package:pointer_interceptor/pointer_interceptor.dart'; import 'package:universal_html/html.dart' as html; import 'package:workplace/data/model/workplace_intent_request.dart'; import 'package:workplace/domain/entity/workplace_intent.dart'; @@ -38,13 +39,14 @@ class _DriveIntentWebViewModalState extends State } Widget _loadingWidget({ - required bool show, required bool wideScreen, TMailButtonWidget? closeButton, }) { - if (!show) return const SizedBox(); if (wideScreen) { - return DriveIntentSkeletonLoader.table(imageAssets: widget.imageAssets); + return DriveIntentSkeletonLoader.table( + imageAssets: widget.imageAssets, + closeButton: closeButton, + ); } return DriveIntentSkeletonLoader.list( imageAssets: widget.imageAssets, @@ -57,6 +59,7 @@ class _DriveIntentWebViewModalState extends State super.initState(); // The modal owns its listener: bound to its own lifetime, not the opener's // (a context menu tile pops its route on tap and would tear it down early). + // Registered before the iframe can post its first ready message. startWindowMessageListener(_forwardMessage); startLoading(widget.intentLoader); } @@ -107,28 +110,37 @@ class _DriveIntentWebViewModalState extends State onBarrierTap: () { if (!showSkeleton) cancel(); }, - loadingWidget: (closeButton) => _loadingWidget( - show: showSkeleton, - wideScreen: isWideScreen, - closeButton: closeButton, - ), + loadingWidget: showSkeleton + ? (closeButton) => _loadingWidget( + wideScreen: isWideScreen, + closeButton: closeButton, + ) + : null, child: HtmlIframeWidget( key: const ValueKey('drive-intent-webview'), onIframeCreated: (iframe) { + final viewRecreated = _iframeElement != null && + !identical(_iframeElement, iframe); _iframeElement = iframe; - notifyPlatformViewReady(); + notifyPlatformViewReady(viewRecreated: viewRecreated); }, ), ); - return isWideScreen - ? shell - : SafeArea( - top: true, - left: false, - right: false, - bottom: false, - child: shell, - ); + // Keep the iframe ancestry stable across resize (#4738). + return Stack( + children: [ + Positioned.fill( + child: PointerInterceptor(child: const SizedBox.expand()), + ), + SafeArea( + top: !isWideScreen, + left: false, + right: false, + bottom: false, + child: shell, + ), + ], + ); } @override diff --git a/workplace/test/presentation/mixin/drive_intent_message_handler_mixin_test.dart b/workplace/test/presentation/mixin/drive_intent_message_handler_mixin_test.dart index 9badfbb5f..07c6cad0f 100644 --- a/workplace/test/presentation/mixin/drive_intent_message_handler_mixin_test.dart +++ b/workplace/test/presentation/mixin/drive_intent_message_handler_mixin_test.dart @@ -237,6 +237,31 @@ void _applyOrderingTests() { expect(state.outcomes, isEmpty); state.cancelReadyTimeoutForTesting(); }); + + testWidgets('recreated platform view reloads the intent while loading', + (tester) async { + final state = await _buildAndApply(tester); + + state.notifyPlatformViewReady(viewRecreated: true); + + expect(state.loadCalls, hasLength(2)); + expect(state.outcomes, isEmpty); + state.cancelReadyTimeoutForTesting(); + }); + + testWidgets('recreated platform view does not reload an interactive picker', + (tester) async { + final state = await _buildAndApply(tester); + state.onMessage( + raw: _encode({'type': 'intent-$_intentId:readyToUse'}), + origin: _origin, + ); + + state.notifyPlatformViewReady(viewRecreated: true); + + expect(state.loadCalls, hasLength(1)); + expect(state.outcomes, isEmpty); + }); } void _intentLoadFailureTests() { @@ -440,27 +465,38 @@ class _TimeoutTestState extends State<_TimeoutTestWidget> Widget build(BuildContext context) => const SizedBox.shrink(); } -void _readyTimeoutTests() { +Future<_TimeoutTestState> _buildTimeoutState( + WidgetTester tester, { + bool notifyReady = true, +}) async { + await tester.pumpWidget(const MaterialApp(home: _TimeoutTestWidget())); + final state = tester.state<_TimeoutTestState>(find.byType(_TimeoutTestWidget)); + state.startLoading(() => Future.value(_intent())); + await tester.pump(); + if (notifyReady) state.notifyPlatformViewReady(); + return state; +} + +void _expectTimeoutFailure(_TimeoutTestState state) { + expect(state.outcomes, hasLength(1)); + expect(state.outcomes.single, isA()); + expect( + (state.outcomes.single as DrivePickOutcomeFailed).error, + isA(), + ); +} + +void _readyTimeoutFiringTests() { testWidgets('fires Failed(DriveIntentTimeoutException) if ready never arrives', (tester) async { - await tester.pumpWidget(const MaterialApp(home: _TimeoutTestWidget())); - final state = tester.state<_TimeoutTestState>(find.byType(_TimeoutTestWidget)); - state.startLoading(() => Future.value(_intent())); - await tester.pump(); - state.notifyPlatformViewReady(); + final state = await _buildTimeoutState(tester); await tester.pump(const Duration(milliseconds: 60)); - expect(state.outcomes, hasLength(1)); - expect(state.outcomes.single, isA()); - expect((state.outcomes.single as DrivePickOutcomeFailed).error, isA()); + _expectTimeoutFailure(state); }); testWidgets('cancelled if readyToUse arrives before timeout', (tester) async { - await tester.pumpWidget(const MaterialApp(home: _TimeoutTestWidget())); - final state = tester.state<_TimeoutTestState>(find.byType(_TimeoutTestWidget)); - state.startLoading(() => Future.value(_intent())); - await tester.pump(); - state.notifyPlatformViewReady(); + final state = await _buildTimeoutState(tester); state.onMessage(raw: _encode({'type': 'intent-$_intentId:ready'}), origin: _origin); state.onMessage(raw: _encode({'type': 'intent-$_intentId:readyToUse'}), origin: _origin); @@ -470,31 +506,55 @@ void _readyTimeoutTests() { }); testWidgets('fires Failed(DriveIntentTimeoutException) if readyToUse never arrives, even after ready', (tester) async { - await tester.pumpWidget(const MaterialApp(home: _TimeoutTestWidget())); - final state = tester.state<_TimeoutTestState>(find.byType(_TimeoutTestWidget)); - state.startLoading(() => Future.value(_intent())); - await tester.pump(); - state.notifyPlatformViewReady(); + final state = await _buildTimeoutState(tester); state.onMessage(raw: _encode({'type': 'intent-$_intentId:ready'}), origin: _origin); await tester.pump(const Duration(milliseconds: 60)); - expect(state.outcomes, hasLength(1)); - expect((state.outcomes.single as DrivePickOutcomeFailed).error, isA()); + _expectTimeoutFailure(state); }); testWidgets('fires Failed(DriveIntentTimeoutException) if platform view never becomes ready', (tester) async { - await tester.pumpWidget(const MaterialApp(home: _TimeoutTestWidget())); - final state = tester.state<_TimeoutTestState>(find.byType(_TimeoutTestWidget)); - state.startLoading(() => Future.value(_intent())); + final state = await _buildTimeoutState(tester, notifyReady: false); await tester.pump(const Duration(milliseconds: 60)); - expect(state.outcomes, hasLength(1)); - expect((state.outcomes.single as DrivePickOutcomeFailed).error, isA()); + _expectTimeoutFailure(state); }); } +void _recreatedViewTimeoutTests() { + testWidgets('recreated platform view restarts the ready timeout', (tester) async { + final state = await _buildTimeoutState(tester); + + await tester.pump(const Duration(milliseconds: 40)); + state.notifyPlatformViewReady(viewRecreated: true); + await tester.pump(const Duration(milliseconds: 20)); + + expect(state.outcomes, isEmpty); + await tester.pump(const Duration(milliseconds: 40)); + expect(state.outcomes, hasLength(1)); + }); + + testWidgets('recreated platform view becomes interactive before its new timeout', (tester) async { + final state = await _buildTimeoutState(tester); + + await tester.pump(const Duration(milliseconds: 40)); + state.notifyPlatformViewReady(viewRecreated: true); + state.onMessage(raw: _encode({'type': 'intent-$_intentId:ready'}), origin: _origin); + state.onMessage(raw: _encode({'type': 'intent-$_intentId:readyToUse'}), origin: _origin); + + expect(state.showSkeleton, isFalse); + await tester.pump(const Duration(milliseconds: 60)); + expect(state.outcomes, isEmpty); + }); +} + +void _readyTimeoutTests() { + _readyTimeoutFiringTests(); + _recreatedViewTimeoutTests(); +} + void main() { group('DriveIntentMessageHandlerMixin', () { group('handshake messages', _handshakeMessageTests); diff --git a/workplace/test/presentation/mixin/web_window_message_mixin_web_test.dart b/workplace/test/presentation/mixin/web_window_message_mixin_web_test.dart new file mode 100644 index 000000000..6f513734c --- /dev/null +++ b/workplace/test/presentation/mixin/web_window_message_mixin_web_test.dart @@ -0,0 +1,83 @@ +@TestOn('chrome') + +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:universal_html/html.dart' as html; +import 'package:workplace/presentation/mixin/web_window_message_mixin.dart'; + +class _MessageListenerWidget extends StatefulWidget { + final void Function(String data, String? origin) onMessage; + + const _MessageListenerWidget({required this.onMessage}); + + @override + State<_MessageListenerWidget> createState() => _MessageListenerWidgetState(); +} + +class _MessageListenerWidgetState extends State<_MessageListenerWidget> + with WebWindowMessageMixin<_MessageListenerWidget> { + @override + void initState() { + super.initState(); + startWindowMessageListener(widget.onMessage); + } + + @override + void dispose() { + stopWindowMessageListener(); + super.dispose(); + } + + @override + Widget build(BuildContext context) => const SizedBox(); +} + +void main() { + testWidgets('forwards browser MessageEvents', (tester) async { + String? data; + String? origin; + await tester.pumpWidget(MaterialApp( + home: _MessageListenerWidget( + onMessage: (message, messageOrigin) { + data = message; + origin = messageOrigin; + }, + ), + )); + + html.window.dispatchEvent( + html.MessageEvent( + 'message', + data: jsonEncode({'type': 'intent-test:readyToUse'}), + origin: Uri.base.origin, + ), + ); + await tester.pump(); + + expect(data, jsonEncode({'type': 'intent-test:readyToUse'})); + expect(origin, Uri.base.origin); + }); + + testWidgets('stops forwarding messages after disposal', (tester) async { + var callCount = 0; + await tester.pumpWidget(MaterialApp( + home: _MessageListenerWidget( + onMessage: (_, __) => callCount++, + ), + )); + + await tester.pumpWidget(const SizedBox()); + html.window.dispatchEvent( + html.MessageEvent( + 'message', + data: jsonEncode({'type': 'intent-test:readyToUse'}), + origin: Uri.base.origin, + ), + ); + await tester.pump(); + + expect(callCount, 0); + }); +} diff --git a/workplace/test/presentation/view/drive_intent_skeleton_loader_test.dart b/workplace/test/presentation/view/drive_intent_skeleton_loader_test.dart new file mode 100644 index 000000000..5e707eff5 --- /dev/null +++ b/workplace/test/presentation/view/drive_intent_skeleton_loader_test.dart @@ -0,0 +1,60 @@ +import 'package:core/presentation/views/button/tmail_button_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:workplace/presentation/model/drive_intent_image_assets.dart'; +import 'package:workplace/presentation/view/drive_intent_skeleton_loader.dart'; + +const _closeButtonKey = ValueKey('close-button'); +const _skeletonKey = ValueKey('desktop-skeleton'); +const _imageAssets = DriveIntentImageAssets( + driveLogo: 'assets/images/twake-drive-logo.svg', + closeIcon: 'assets/images/ic_close.svg', + searchIcon: 'assets/images/ic_search_bar.svg', +); + +void main() { + testWidgets('desktop loading close button matches the design', (tester) async { + var closeCalls = 0; + final closeButton = TMailButtonWidget.fromIcon( + key: _closeButtonKey, + icon: _imageAssets.closeIcon, + width: 40, + height: 40, + iconSize: 24, + padding: const EdgeInsets.all(8), + backgroundColor: Colors.transparent, + onTapActionCallback: () => closeCalls++, + ); + + await tester.pumpWidget( + MaterialApp( + home: Center( + child: SizedBox( + key: _skeletonKey, + width: 800, + height: 500, + child: DriveIntentSkeletonLoader.table( + imageAssets: _imageAssets, + closeButton: closeButton, + ), + ), + ), + ), + ); + + final closeButtonFinder = find.byKey(_closeButtonKey); + final closeContainerFinder = find.descendant( + of: closeButtonFinder, + matching: find.byType(Container), + ); + final skeletonRect = tester.getRect(find.byKey(_skeletonKey)); + final closeRect = tester.getRect(closeContainerFinder); + + expect(closeRect.size, const Size(40, 40)); + expect(closeRect.top, skeletonRect.top + 12); + expect(closeRect.right, skeletonRect.right - 17); + + await tester.tap(closeContainerFinder); + expect(closeCalls, 1); + }); +} diff --git a/workplace/test/presentation/view/drive_intent_web_view_modal_shell_test.dart b/workplace/test/presentation/view/drive_intent_web_view_modal_shell_test.dart new file mode 100644 index 000000000..8950392f3 --- /dev/null +++ b/workplace/test/presentation/view/drive_intent_web_view_modal_shell_test.dart @@ -0,0 +1,141 @@ +import 'package:core/presentation/views/button/tmail_button_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pointer_interceptor/pointer_interceptor.dart'; +import 'package:workplace/presentation/view/drive_intent_web_view_modal_shell.dart'; + +const _closeIcon = 'assets/close.svg'; + +Widget _shell({ + required bool haveCloseButton, + required BoxConstraints constraints, + required EdgeInsets insetPadding, + Widget Function(TMailButtonWidget closeButton)? loadingWidget, + VoidCallback? onClose, +}) { + return MaterialApp( + home: _modalShell( + haveCloseButton: haveCloseButton, + constraints: constraints, + insetPadding: insetPadding, + loadingWidget: loadingWidget, + onClose: onClose, + ), + ); +} + +Widget _modalShell({ + required bool haveCloseButton, + required BoxConstraints constraints, + required EdgeInsets insetPadding, + Widget Function(TMailButtonWidget closeButton)? loadingWidget, + VoidCallback? onClose, +}) { + return DriveIntentWebViewModalShell( + closeIconPath: _closeIcon, + onClose: onClose ?? () {}, + haveCloseButton: haveCloseButton, + constraints: constraints, + insetPadding: insetPadding, + loadingWidget: loadingWidget, + child: const SizedBox.shrink(), + ); +} + +void main() { + group('DriveIntentWebViewModalShell', () { + _testLoadingOverlayIsClosable(); + _testLoadingOverlayCloseButtonCallback(); + _testCloseButtonHoverFeedback(); + _testNoPointerInterceptorWithoutLoadingOverlay(); + }); +} + +void _testLoadingOverlayIsClosable() { + testWidgets( + 'loading overlay is always closable — receives a close button', + (tester) async { + TMailButtonWidget? received; + await tester.pumpWidget( + _shell( + haveCloseButton: false, + constraints: const BoxConstraints(maxWidth: 800, maxHeight: 677), + insetPadding: const EdgeInsets.all(24), + loadingWidget: (closeButton) { + received = closeButton; + return closeButton; + }, + ), + ); + + expect(received, isNotNull); + expect(find.byWidget(received!), findsOneWidget); + expect( + find.ancestor( + of: find.byType(PointerInterceptor), + matching: find.byType(Positioned), + ), + findsOneWidget, + ); + }, + ); +} + +void _testLoadingOverlayCloseButtonCallback() { + testWidgets('loading overlay close button is wired to onClose', ( + tester, + ) async { + var closed = 0; + TMailButtonWidget? received; + await tester.pumpWidget( + _shell( + haveCloseButton: false, + constraints: const BoxConstraints(maxWidth: 800, maxHeight: 677), + insetPadding: const EdgeInsets.all(24), + onClose: () => closed++, + loadingWidget: (closeButton) { + received = closeButton; + return closeButton; + }, + ), + ); + + // Assert callback wiring without SVG hit-testing. + received!.onTapActionCallback!(); + expect(closed, 1); + }); +} + +void _testCloseButtonHoverFeedback() { + testWidgets('close button keeps Material hover feedback', (tester) async { + await tester.pumpWidget( + _shell( + haveCloseButton: true, + constraints: const BoxConstraints(maxWidth: 800, maxHeight: 677), + insetPadding: const EdgeInsets.all(24), + ), + ); + + final button = tester.widget( + find.byType(TMailButtonWidget), + ); + + expect(button.hoverColor, const Color(0x14424244)); + }); +} + +void _testNoPointerInterceptorWithoutLoadingOverlay() { + testWidgets('does not intercept pointers without a loading overlay', ( + tester, + ) async { + await tester.pumpWidget( + _shell( + haveCloseButton: false, + constraints: const BoxConstraints(maxWidth: 800, maxHeight: 677), + insetPadding: const EdgeInsets.all(24), + ), + ); + + expect(find.byType(PointerInterceptor), findsNothing); + }); +} diff --git a/workplace/test/presentation/view/drive_intent_web_view_modal_web_test.dart b/workplace/test/presentation/view/drive_intent_web_view_modal_web_test.dart new file mode 100644 index 000000000..a021ca3fb --- /dev/null +++ b/workplace/test/presentation/view/drive_intent_web_view_modal_web_test.dart @@ -0,0 +1,73 @@ +@TestOn('chrome') +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:workplace/data/model/workplace_intent_request.dart'; +import 'package:workplace/domain/entity/workplace_intent.dart'; +import 'package:workplace/presentation/model/drive_intent_image_assets.dart'; +import 'package:workplace/presentation/view/drive_intent_web_view_modal.dart'; + +const _imageAssets = DriveIntentImageAssets( + driveLogo: 'assets/images/twake-drive-logo.svg', + closeIcon: 'assets/images/ic_close.svg', + searchIcon: 'assets/images/ic_search_bar.svg', +); + +const _filePickerConfig = WorkplaceFilePickerConfigRequest( + sharingLink: WorkplaceActionConfigRequest(), + downloadLink: null, +); + +Widget _modal(Future intent) { + return MaterialApp( + home: DriveIntentWebViewModal( + intentLoader: () => intent, + filePickerConfig: _filePickerConfig, + imageAssets: _imageAssets, + ), + ); +} + +void main() { + testWidgets( + 'preserves the iframe platform view in both resize directions (#4738)', + (tester) async { + // The intent never resolves: the modal stays in its loading phase, which + // is exactly the window #4738 regresses in. The iframe lives in the shell + // regardless of the skeleton, so it is mounted throughout. + final intent = Completer(); + addTearDown(() { + tester.view.resetPhysicalSize(); + tester.view.resetDevicePixelRatio(); + }); + tester.view.devicePixelRatio = 1; + tester.view.physicalSize = const Size(1280, 800); + + await tester.pumpWidget(_modal(intent.future)); + await tester.pump(); + + // The flutter_test web embedder does not attach the real