Skip to content

Commit 24fa970

Browse files
committed
fix(e2e): read the visible workspace shell while a streamed page arrives
On the production build, a query made mid-stream can also match the next segment's shell that React parks in a hidden <div id="S:n"> until it swaps it in, so the class-only locator hit a strict-mode violation in WebKit. Scope the shell to the visible element, and restore the tablet workflow-controls check #8950 skipped for the same cause.
1 parent a460964 commit 24fa970

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎apps/sim/scripts/test-mobile-e2e.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ async function seed(): Promise<string> {
263263
return encodeURIComponent(`${sessionToken}.${await makeSignature(sessionToken, authSecret)}`)
264264
}
265265

266+
/**
267+
* The rendered workspace content shell. While a streamed page is still arriving, React parks the
268+
* next segment's markup, shell included, in a hidden `<div id="S:n">` until it swaps it in, so the
269+
* class alone can match a second, hidden copy.
270+
*/
271+
function contentShell(page: Page): Locator {
272+
return page.locator('.workspace-content-shell').filter({ visible: true })
273+
}
274+
266275
async function visit(page: Page, route: string) {
267276
const path = `/workspace/${workspaceId}/${route}`
268277
const [response] = await Promise.all([
@@ -280,7 +289,7 @@ async function visit(page: Page, route: string) {
280289
new URL(page.url()).pathname.startsWith(`/workspace/${workspaceId}/`),
281290
'Session was rejected'
282291
)
283-
await expect(page.locator('.workspace-content-shell')).toBeVisible()
292+
await expect(contentShell(page)).toBeVisible()
284293
await expect(page.getByText('Application error', { exact: false })).toHaveCount(0)
285294
const contentByRoute: Record<string, Locator> = {
286295
home: page.getByRole('textbox', { name: 'Message', exact: true }),
@@ -337,7 +346,7 @@ async function expectNoOverflow(page: Page) {
337346
}
338347
)
339348
.toBeLessThanOrEqual(1)
340-
const shell = await page.locator('.workspace-content-shell').boundingBox()
349+
const shell = await contentShell(page).boundingBox()
341350
assert(shell && shell.width > 0 && shell.x >= -1, 'The content must have usable horizontal space')
342351
assert(
343352
shell.x + shell.width <= (page.viewportSize()?.width ?? 0) + 1,
@@ -717,7 +726,7 @@ async function exerciseViewport(
717726
timeout: 120_000,
718727
})
719728
await expect(sidebar).toBeHidden()
720-
await expect(page.locator('.workspace-content-shell')).toBeVisible()
729+
await expect(contentShell(page)).toBeVisible()
721730
await expect(
722731
page.getByRole('button', { name: `Actions for ${folderName}`, exact: true })
723732
).toBeVisible({ timeout: 120_000 })
@@ -1114,7 +1123,7 @@ async function exerciseViewport(
11141123
await expect
11151124
.poll(async () => {
11161125
const canvas = await page.locator('.react-flow').boundingBox()
1117-
const content = await page.locator('.workspace-content-shell').boundingBox()
1126+
const content = await contentShell(page).boundingBox()
11181127
return canvas && content ? canvas.width / content.width : 0
11191128
})
11201129
.toBeGreaterThan(0.95)

0 commit comments

Comments
 (0)