@@ -234,6 +234,7 @@ async function seed() {
234234 await tx `insert into workspace (id, project_id, name, owner_id, billed_account_user_id) values (${ id } , ${ alphaId } , ${ `Extension QA workspace ${ index + 1 } ` } , ${ owner } , ${ owner } )`
235235 await tx `insert into permissions (id, user_id, entity_type, entity_id, permission_type) values (${ generateId ( ) } , ${ owner } , 'workspace', ${ id } , 'admin')`
236236 }
237+ await tx `update workspace set created_at = '2020-01-01T00:00:00Z' where id = ${ alphaId } `
237238 await tx `insert into workflow (id, user_id, workspace_id, name, last_synced, created_at, updated_at) values (${ workflowId } , ${ owner } , ${ alphaId } , 'Extension QA workflow', now(), now(), now())`
238239 await tx `insert into "user" (id, name, email, email_verified, created_at, updated_at) values (${ otherUserId } , 'Other extension QA user', ${ `extension-other-${ otherUserId } @example.test` } , false, now(), now())`
239240 await tx `insert into project (id, name, owner_id) values (${ deniedId } , 'Inaccessible QA project', ${ otherUserId } )`
@@ -340,8 +341,26 @@ try {
340341 context . setDefaultNavigationTimeout ( 120_000 )
341342 let worker = context . serviceWorkers ( ) [ 0 ] ?? ( await context . waitForEvent ( 'serviceworker' ) )
342343 const extensionId = worker . url ( ) . split ( '/' ) [ 2 ]
343- const openPanel = async ( ) => {
344+ const setPageViewport = async ( page : Page , width : number , height : number ) => {
345+ await page . setViewportSize ( { width, height } )
346+ const session = await browserContext . newCDPSession ( page )
347+ try {
348+ const { windowId } = await session . send ( 'Browser.getWindowForTarget' )
349+ // OOPIF hit testing uses the native content bounds, including below the browser toolbar.
350+ await session . send ( 'Browser.setContentsSize' , { windowId, width, height } )
351+ } finally {
352+ await session . detach ( )
353+ }
354+ }
355+ const openPage = async ( ) => {
344356 const page = await browserContext . newPage ( )
357+ const viewport = page . viewportSize ( )
358+ assert ( viewport , 'Browser fixture must declare its viewport' )
359+ await setPageViewport ( page , viewport . width , viewport . height )
360+ return page
361+ }
362+ const openPanel = async ( ) => {
363+ const page = await openPage ( )
345364 await page . route ( '**/api/settings/voice' , ( route ) =>
346365 route . fulfill ( { json : { sttAvailable : true } } )
347366 )
@@ -393,17 +412,7 @@ try {
393412 }
394413 panel = await openPanel ( )
395414 let shell = panel
396- const setPanelViewport = async ( width : number , height : number ) => {
397- await shell . setViewportSize ( { width, height } )
398- const session = await browserContext . newCDPSession ( shell )
399- try {
400- const { windowId } = await session . send ( 'Browser.getWindowForTarget' )
401- // OOPIF hit testing uses the native content bounds, including below the browser toolbar.
402- await session . send ( 'Browser.setContentsSize' , { windowId, width, height } )
403- } finally {
404- await session . detach ( )
405- }
406- }
415+ const setPanelViewport = ( width : number , height : number ) => setPageViewport ( shell , width , height )
407416 await panel . goto ( `chrome-extension://${ extensionId } /sidepanel.html` )
408417 const frame = ( ) => {
409418 const app = shell . frames ( ) . find ( ( candidate ) => candidate . url ( ) . startsWith ( base . origin ) )
@@ -469,7 +478,7 @@ try {
469478 await navigate ( `${ base . origin } /extension/${ alphaId } ` )
470479 await expect ( frame ( ) . getByRole ( 'textbox' , { name : 'Message' , exact : true } ) ) . toBeVisible ( )
471480 }
472- let source = await context . newPage ( )
481+ let source = await openPage ( )
473482 await source . goto ( `${ fixtureOrigin } /page?private=QUERY_SECRET#FRAGMENT_SECRET` )
474483 const observeCaptureReceipts = ( ) =>
475484 shell . evaluate ( ( origin ) => {
@@ -796,7 +805,7 @@ try {
796805 await checkComposer (
797806 'The ordinary web composer accepts text selections and rejects links and remote images' ,
798807 async ( ) => {
799- const app = await browserContext . newPage ( )
808+ const app = await openPage ( )
800809 const remote = new URL ( '/ordinary-drop-image.png' , fixtureOrigin )
801810 const navigationAttempts : string [ ] = [ ]
802811 await browserContext . route ( remote . href , ( route ) => {
@@ -1512,12 +1521,12 @@ try {
15121521 async ( ) => {
15131522 const endpoint = `${ base . origin } /api/mothership/chat`
15141523 const received : Record < string , unknown > [ ] = [ ]
1515- const second = await browserContext . newPage ( )
1524+ const second = await openPage ( )
15161525 await second . goto ( `${ fixtureOrigin } /reference-second?private=DO_NOT_SEND#private` )
15171526 await second . locator ( 'article p' ) . evaluate ( ( el ) => {
15181527 el . textContent = 'Second active tab: JADE-231.'
15191528 } )
1520- const restricted = await browserContext . newPage ( )
1529+ const restricted = await openPage ( )
15211530 await restricted . goto ( `http://ungranted.localhost:${ fixtureAddress . port } /denied` )
15221531 await browserContext . route ( endpoint , ( route ) => {
15231532 if ( route . request ( ) . method ( ) !== 'POST' ) return route . continue ( )
@@ -1973,7 +1982,7 @@ try {
19731982 return animation
19741983 }
19751984 } )
1976- source = await browserContext . newPage ( )
1985+ source = await openPage ( )
19771986 await source . goto ( `${ fixtureOrigin } /page?private=QUERY_SECRET#FRAGMENT_SECRET` )
19781987 await shell . goto ( `chrome-extension://${ extensionId } /sidepanel.html` )
19791988 await observeCaptureReceipts ( )
@@ -2254,6 +2263,10 @@ try {
22542263 'A transient workspace-list refetch unmounted the picker'
22552264 )
22562265 assert . equal ( await scroller . evaluate ( ( element ) => element . scrollTop ) , scrollTop )
2266+ await expect ( choices . getByRole ( 'link' ) . last ( ) ) . toHaveAttribute (
2267+ 'href' ,
2268+ `/extension/${ alphaId } `
2269+ )
22572270 await screenshot ( 'workspace-picker-refetch-outage' )
22582271 await choices . getByRole ( 'link' , { name : 'Extension QA alpha' , exact : true } ) . click ( )
22592272 await expect ( frame ( ) . getByRole ( 'textbox' , { name : 'Message' , exact : true } ) ) . toBeVisible ( )
0 commit comments