@@ -3,9 +3,26 @@ import {
33 homepageSetup ,
44 returningUserVisitsHomepageWaitForModel ,
55} from '../../tests/e2e/utils'
6+ import { TITLE_NOTES } from '../Notes/component'
67import { TITLE_APPS } from './component'
78
89
10+ /**
11+ * Assert `value` is not null.
12+ *
13+ * @template T
14+ * @param value
15+ * @param msg
16+ * @return value
17+ */
18+ function assertNotNull < T > ( value : T | null , msg : string ) : T {
19+ if ( ! value ) {
20+ throw new Error ( msg )
21+ }
22+ return value
23+ }
24+
25+
926const { beforeEach, describe} = test
1027/**
1128 * Migrated from cypress/e2e/apps/apps.cy.js
@@ -47,5 +64,58 @@ describe('AppsSideDrawer', () => {
4764 expect ( parseInt ( width ) ) . toBeGreaterThan ( MIN_FULLSCREEN_WIDTH )
4865 } )
4966 } )
67+
68+ test ( 'resizing Notes drawer does not push Apps off-screen' , async ( { page} ) => {
69+ // Open both Notes and Apps.
70+ await page . getByTestId ( 'control-button-notes' ) . click ( )
71+ await page . getByTestId ( 'control-button-apps' ) . click ( )
72+
73+ // Sanity: both titles visible.
74+ await expect ( page . getByTestId ( `PanelTitle-${ TITLE_NOTES } ` ) ) . toBeVisible ( )
75+ await expect ( page . getByTestId ( `PanelTitle-${ TITLE_APPS } ` ) ) . toBeVisible ( )
76+
77+ const notesDrawer = page . getByTestId ( 'NotesAndPropertiesDrawer' )
78+ const appsDrawer = page . getByTestId ( 'AppsDrawer' )
79+
80+ const handle = notesDrawer . getByTestId ( 'resize-handle-x' )
81+ const handleBox = assertNotNull (
82+ await handle . boundingBox ( ) ,
83+ 'Expected Notes resize handle to have a bounding box' ,
84+ )
85+ const viewerContainer = page . locator ( '#viewer-container' )
86+ const viewerBoxBefore = assertNotNull (
87+ await viewerContainer . boundingBox ( ) ,
88+ 'Expected viewer container to have a bounding box' ,
89+ )
90+
91+ // Drag left to widen Notes (this used to push Apps out of view).
92+ await page . mouse . move (
93+ handleBox . x + ( handleBox . width / 2 ) ,
94+ handleBox . y + ( handleBox . height / 2 ) ,
95+ )
96+ await page . mouse . down ( )
97+ const dragDistance = 250
98+ await page . mouse . move ( handleBox . x - dragDistance , handleBox . y + ( handleBox . height / 2 ) )
99+ await page . mouse . up ( )
100+
101+ // Apps should remain visible and inside the viewport.
102+ await expect ( page . getByTestId ( `PanelTitle-${ TITLE_APPS } ` ) ) . toBeVisible ( )
103+
104+ const appsBox = assertNotNull (
105+ await appsDrawer . boundingBox ( ) ,
106+ 'Expected Apps drawer to have a bounding box' ,
107+ )
108+ const vw = await page . evaluate ( ( ) => window . innerWidth )
109+ expect ( appsBox . x ) . toBeGreaterThanOrEqual ( 0 )
110+ expect ( appsBox . x + ( appsBox . width ) ) . toBeLessThanOrEqual ( vw + 1 )
111+
112+ // Viewer should not resize when drawers open/resize (drawers overlay the canvas).
113+ const viewerBoxAfter = assertNotNull (
114+ await viewerContainer . boundingBox ( ) ,
115+ 'Expected viewer container to have a bounding box after resize' ,
116+ )
117+ expect ( Math . abs ( viewerBoxAfter . width - viewerBoxBefore . width ) ) . toBeLessThanOrEqual ( 1 )
118+ expect ( Math . abs ( viewerBoxAfter . width - vw ) ) . toBeLessThanOrEqual ( 2 )
119+ } )
50120 } )
51121} )
0 commit comments