test(app): stabilize migrated e2e suite

pull/20593/head
Kit Langton 2026-04-02 01:09:08 -04:00
parent 7f5307ff30
commit b782650dfe
5 changed files with 24 additions and 6 deletions

View File

@ -88,6 +88,21 @@ function clean(value: string | null) {
return (value ?? "").replace(/\u200B/g, "").trim()
}
async function visit(page: Page, url: string) {
let err: unknown
for (const _ of [0, 1, 2]) {
try {
await page.goto(url)
return
} catch (cause) {
err = cause
if (!String(cause).includes("ERR_CONNECTION_REFUSED")) throw cause
await new Promise((resolve) => setTimeout(resolve, 300))
}
}
throw err
}
async function promptSend(page: Page) {
return page
.evaluate(() => {
@ -279,7 +294,7 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
await seedStorage(page, { directory })
const gotoSession = async (sessionID?: string) => {
await page.goto(sessionPath(directory, sessionID))
await visit(page, sessionPath(directory, sessionID))
await waitSession(page, { directory, sessionID })
}
await use(gotoSession)
@ -349,7 +364,7 @@ function makeProject(
const gotoSession = async (sessionID?: string) => {
const cur = need()
await page.goto(sessionPath(cur.directory, sessionID))
await visit(page, sessionPath(cur.directory, sessionID))
await waitSession(page, { directory: cur.directory, sessionID, serverUrl: backend.url })
const current = sessionIDFromUrl(page.url())
if (current) trackSession(current)
@ -521,7 +536,7 @@ async function runProject<T>(
})
const gotoSession = async (sessionID?: string) => {
await page.goto(sessionPath(root, sessionID))
await visit(page, sessionPath(root, sessionID))
await waitSession(page, { directory: root, sessionID, serverUrl: url })
const current = sessionIDFromUrl(page.url())
if (current) trackSession(current)

View File

@ -34,6 +34,8 @@ test("dialog edit project updates name and startup script", async ({ page, proje
await expect
.poll(
async () => {
await page.reload()
await openSidebar(page)
const reopened = await open()
const value = await reopened.getByLabel("Name").inputValue()
const next = await reopened.getByLabel("Workspace startup script").inputValue()

View File

@ -12,6 +12,7 @@ import {
clickMenuItem,
confirmDialog,
openSidebar,
openProjectMenu,
openWorkspaceMenu,
resolveSlug,
setWorkspacesEnabled,
@ -19,7 +20,7 @@ import {
waitDir,
waitSlug,
} from "../actions"
import { dropdownMenuContentSelector, inlineInputSelector, workspaceItemSelector } from "../selectors"
import { inlineInputSelector, workspaceItemSelector } from "../selectors"
import { dirSlug } from "../utils"
async function setupWorkspaceTest(page: Page, project: { slug: string; trackDirectory: (directory: string) => void }) {

View File

@ -92,6 +92,7 @@ test("changing theme persists in localStorage", async ({ page, gotoSession }) =>
await select.locator('[data-slot="select-select-trigger"]').click()
const items = page.locator('[data-slot="select-select-item"]')
await expect(items.first()).toBeVisible()
const count = await items.count()
expect(count).toBeGreaterThan(1)

View File

@ -65,9 +65,8 @@ test("open sidebar project popover stays closed after clicking avatar", async ({
await projectButton.hover()
await expect(card.getByText(/recent sessions/i)).toBeVisible()
await page.mouse.down()
await projectButton.click()
await expect(card).toHaveCount(0)
await page.mouse.up()
await waitSession(page, { directory: other })
await expect(card).toHaveCount(0)