11import { expect , test } from '@playwright/test'
2- import { assertDefined } from 'src/utils/assert'
32import {
43 homepageSetup ,
54 returningUserVisitsHomepageWaitForModel ,
@@ -8,6 +7,22 @@ import {TITLE_NOTES} from '../Notes/component'
87import { TITLE_APPS } from './component'
98
109
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+
1126const { beforeEach, describe} = test
1227/**
1328 * Migrated from cypress/e2e/apps/apps.cy.js
@@ -63,7 +78,15 @@ describe('AppsSideDrawer', () => {
6378 const appsDrawer = page . getByTestId ( 'AppsDrawer' )
6479
6580 const handle = notesDrawer . getByTestId ( 'resize-handle-x' )
66- const handleBox = assertDefined ( await handle . boundingBox ( ) )
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+ )
6790
6891 // Drag left to widen Notes (this used to push Apps out of view).
6992 await page . mouse . move (
@@ -78,10 +101,21 @@ describe('AppsSideDrawer', () => {
78101 // Apps should remain visible and inside the viewport.
79102 await expect ( page . getByTestId ( `PanelTitle-${ TITLE_APPS } ` ) ) . toBeVisible ( )
80103
81- const appsBox = assertDefined ( await appsDrawer . boundingBox ( ) )
104+ const appsBox = assertNotNull (
105+ await appsDrawer . boundingBox ( ) ,
106+ 'Expected Apps drawer to have a bounding box' ,
107+ )
82108 const vw = await page . evaluate ( ( ) => window . innerWidth )
83109 expect ( appsBox . x ) . toBeGreaterThanOrEqual ( 0 )
84110 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 )
85119 } )
86120 } )
87121} )
0 commit comments