Skip to content

Commit 9beab14

Browse files
committed
fix(files): await browser readiness and guard sharing fixture cleanup
1 parent 35958a8 commit 9beab14

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

‎apps/sim/scripts/files-e2e/sharing.ts‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,26 @@ export async function runSharingChecks({
9696
const browser = page.context().browser()
9797
assert(browser)
9898
const anonymous = await browser.newContext({ viewport: { width: 1200, height: 900 } })
99-
await anonymous.tracing.start({ screenshots: true, snapshots: true, sources: false })
100-
const publicGet = (path: string) =>
101-
anonymous.request.get(new URL(path, baseUrl).href, { timeout: 180_000 })
102-
const visitor = await anonymous.newPage()
103-
visitor.setDefaultTimeout(60_000)
104-
visitor.setDefaultNavigationTimeout(180_000)
105-
const browserErrors: string[] = []
106-
visitor.on('pageerror', (error) => browserErrors.push(error.message))
107-
let token = ''
108-
let shareId = ''
109-
const publicPath = () => `/api/files/public/${token}`
110-
const folderPath = () => `${publicPath()}/folder`
111-
const contentPath = (fileId: string) => `${publicPath()}/content?fileId=${fileId}`
112-
const anonymousJson = (path: string, expected = 200) =>
113-
json(path, { authenticated: false, expected })
114-
const updateShare = (body: Record<string, unknown>) => json(sharePath, { method: 'PUT', body })
115-
99+
let tracingStarted = false
116100
try {
101+
await anonymous.tracing.start({ screenshots: true, snapshots: true, sources: false })
102+
tracingStarted = true
103+
const publicGet = (path: string) =>
104+
anonymous.request.get(new URL(path, baseUrl).href, { timeout: 180_000 })
105+
const visitor = await anonymous.newPage()
106+
visitor.setDefaultTimeout(60_000)
107+
visitor.setDefaultNavigationTimeout(180_000)
108+
const browserErrors: string[] = []
109+
visitor.on('pageerror', (error) => browserErrors.push(error.message))
110+
let token = ''
111+
let shareId = ''
112+
const publicPath = () => `/api/files/public/${token}`
113+
const folderPath = () => `${publicPath()}/folder`
114+
const contentPath = (fileId: string) => `${publicPath()}/content?fileId=${fileId}`
115+
const anonymousJson = (path: string, expected = 200) =>
116+
json(path, { authenticated: false, expected })
117+
const updateShare = (body: Record<string, unknown>) => json(sharePath, { method: 'PUT', body })
118+
117119
await sql.begin(async (tx) => {
118120
const readerEmail = `files-reader-${readerId}@files-e2e.test`
119121
await tx`insert into "user" (id, name, email, normalized_email, email_verified, created_at, updated_at)
@@ -613,9 +615,11 @@ export async function runSharingChecks({
613615
)
614616
} finally {
615617
try {
616-
await anonymous.tracing.stop({
617-
path: join(reportDirectory, 'public-folder-browser-trace.zip'),
618-
})
618+
if (tracingStarted) {
619+
await anonymous.tracing.stop({
620+
path: join(reportDirectory, 'public-folder-browser-trace.zip'),
621+
})
622+
}
619623
} finally {
620624
try {
621625
await anonymous.close()

‎apps/sim/scripts/files-e2e/upload-lifecycle.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function runUploadLifecycleChecks(context: FilesE2EContext, directo
1313
waitUntil: 'domcontentloaded',
1414
})
1515
await page.locator('input[webkitdirectory]').waitFor({ state: 'attached' })
16-
await uploadMenuTrigger(page).waitFor()
16+
await uploadMenuTrigger(page).and(page.locator(':enabled')).waitFor()
1717

1818
await check(
1919
'cancel releases a delayed native directory read and permits a new upload',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ async function runNavigationChecks(page: Page) {
611611
const movedFolder = await createFolder('Move to ancestor', d)
612612
await page.setViewportSize({ width: 900, height: 800 })
613613
await page.goto(url(d), { waitUntil: 'domcontentloaded' })
614-
const source = page.locator(`[data-row-id="folder:${movedFolder}"]`)
614+
const source = page.locator(`[data-row-id="folder:${movedFolder}"][draggable="true"]`)
615615
await source.waitFor()
616616
const drag = await page.evaluateHandle(() => new DataTransfer())
617617
try {

0 commit comments

Comments
 (0)