From 85d5a12169770dd52c218eb31c65f822e3c4dfc7 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 24 Nov 2026 11:15:34 -0800 Subject: [PATCH 1/2] fix(e2e): isolate markdown-viewer checks from a deleted fixture and WebKit's cancelled RSC fetches --- apps/sim/scripts/test-markdown-viewer-e2e.ts | 42 +++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/apps/sim/scripts/test-markdown-viewer-e2e.ts b/apps/sim/scripts/test-markdown-viewer-e2e.ts index 516ee6dcd41..3e1bafd0ce5 100644 --- a/apps/sim/scripts/test-markdown-viewer-e2e.ts +++ b/apps/sim/scripts/test-markdown-viewer-e2e.ts @@ -187,6 +187,19 @@ async function check(name: string, run: () => Promise, page?: Page) { } } +/** + * WebKit rejects a fetch the page cancels by navigating away, such as a Next.js RSC prefetch, with + * "... due to access control checks.", and the router leaves that rejection unhandled. For a + * same-origin RSC request that is a cancellation, never an access failure. + */ +function isCancelledRscFetch(message: string): boolean { + return ( + message.endsWith(' due to access control checks.') && + message.includes(`${base.host}/`) && + message.includes('_rsc=') + ) +} + async function wideTableProof(page: Page) { const table = page.locator('.rich-markdown-prose table').filter({ hasText: 'Option Alpha' }) await expect(table).toBeVisible({ timeout: 120_000 }) @@ -392,11 +405,24 @@ async function editLastCell(page: Page, marker: string) { await expect(page.locator('.rich-markdown-prose[contenteditable="true"]')).toBeFocused() await page.keyboard.press('ArrowLeft') await page.keyboard.press('Shift+ArrowRight') - await expect - .poll(() => page.evaluate(() => getSelection()?.toString().trim() ?? ''), { - message: 'Keyboard selection did not select text', + try { + await expect + .poll(() => page.evaluate(() => getSelection()?.toString().trim() ?? '')) + .not.toBe('') + } catch { + // Rare in WebKit and not reproduced yet: name where the caret and focus ended up. + const state = await page.evaluate(() => { + const selection = getSelection() + return { + anchorText: selection?.anchorNode?.textContent?.slice(0, 40) ?? null, + anchorOffset: selection?.anchorOffset ?? null, + focusOffset: selection?.focusOffset ?? null, + rangeCount: selection?.rangeCount ?? 0, + activeElement: document.activeElement?.className ?? null, + } }) - .not.toBe('') + throw new Error(`Keyboard selection did not select text: ${JSON.stringify(state)}`) + } await proveToolbar(page, page.getByRole('toolbar', { name: 'Text formatting' })) await page.keyboard.press('ArrowRight') } @@ -565,6 +591,9 @@ async function provePastePersistence(page: Page, browserName: string) { ) } finally { try { + // An editor left open on the file refetches it after the delete, and the next check on this + // page would record that 404 as its own browser error. + await page.goto('about:blank') await request(`/api/workspaces/${workspaceId}/files/${pastedFileId}`, undefined, 'DELETE') } finally { await sql`delete from public_share where id=${pastedShareId}` @@ -972,7 +1001,10 @@ try { { name: 'better-auth.session_token', value: cookie, url: base.origin }, ]) const page = await context.newPage() - page.on('pageerror', (error) => errors.push(`${browserName}: ${error.message}`)) + page.on('pageerror', (error) => { + if (browserName === 'webkit' && isCancelledRscFetch(error.message)) return + errors.push(`${browserName}: ${error.message}`) + }) for (const width of widths) { await page.setViewportSize({ width, height: 1000 }) await page.goto(new URL(`/f/${shareToken}`, base).href, { From 032e4d8677efb27eee5b4aa7c9472bab6f3460d1 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 24 Nov 2026 11:31:39 -0800 Subject: [PATCH 2/2] fix(e2e): match cancelled RSC fetches by parsed origin and keep a failed paste proof's page --- apps/sim/scripts/test-markdown-viewer-e2e.ts | 26 +++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/sim/scripts/test-markdown-viewer-e2e.ts b/apps/sim/scripts/test-markdown-viewer-e2e.ts index 3e1bafd0ce5..67deaa7ad0c 100644 --- a/apps/sim/scripts/test-markdown-viewer-e2e.ts +++ b/apps/sim/scripts/test-markdown-viewer-e2e.ts @@ -187,17 +187,23 @@ async function check(name: string, run: () => Promise, page?: Page) { } } +const CANCELLED_FETCH = / due to access control checks\.$/ + /** * WebKit rejects a fetch the page cancels by navigating away, such as a Next.js RSC prefetch, with - * "... due to access control checks.", and the router leaves that rejection unhandled. For a + * " due to access control checks.", and the router leaves that rejection unhandled. For a * same-origin RSC request that is a cancellation, never an access failure. */ function isCancelledRscFetch(message: string): boolean { - return ( - message.endsWith(' due to access control checks.') && - message.includes(`${base.host}/`) && - message.includes('_rsc=') - ) + if (!CANCELLED_FETCH.test(message)) return false + // WebKit names the request as `/host:port/path?query`, without its scheme. + const target = message.replace(CANCELLED_FETCH, '').split(' ').pop() ?? '' + try { + const url = new URL(target.startsWith('/') ? `${base.protocol}/${target}` : target) + return url.origin === base.origin && url.searchParams.has('_rsc') + } catch { + return false + } } async function wideTableProof(page: Page) { @@ -445,6 +451,7 @@ async function provePastePersistence(page: Page, browserName: string) { const pastedShareToken = generateShortId() const readPasteSource = async () => (await request(`/api/files/public/${pastedShareToken}/content`)).text() + let proved = false try { await sql`insert into public_share (id, resource_type, resource_id, entity_type, entity_id, workspace_id, created_by, token) values (${pastedShareId}, 'file', ${pastedFileId}, 'workspace', ${workspaceId}, ${workspaceId}, ${userId}, ${pastedShareToken})` await page.goto(new URL(`/workspace/${workspaceId}/files/${pastedFileId}`, base).href, { @@ -589,11 +596,12 @@ async function provePastePersistence(page: Page, browserName: string) { afterLocalEdit.includes(`${marker} measure
`), 'External update lost the pasted table' ) + proved = true } finally { try { - // An editor left open on the file refetches it after the delete, and the next check on this - // page would record that 404 as its own browser error. - await page.goto('about:blank') + // Leave the file before deleting it, or the open editor refetches it and the next check on + // this page records that 404 as its own. A failed proof keeps the page for its screenshot. + if (proved) await page.goto('about:blank') await request(`/api/workspaces/${workspaceId}/files/${pastedFileId}`, undefined, 'DELETE') } finally { await sql`delete from public_share where id=${pastedShareId}`