summaryrefslogtreecommitdiffhomepage
path: root/packages/app/e2e/projects/projects-close.spec.ts
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-04-02 14:17:28 -0400
committerGitHub <[email protected]>2026-04-02 18:17:28 +0000
commitc3ef69c8664ab84464d720f75eb9bf35289c1847 (patch)
treed7b1aa78355c39472804bdfbbd9db87722d0587b /packages/app/e2e/projects/projects-close.spec.ts
parent363891126c9b2a909db0e724eb6377bd3d12b38b (diff)
downloadopencode-c3ef69c8664ab84464d720f75eb9bf35289c1847.tar.gz
opencode-c3ef69c8664ab84464d720f75eb9bf35289c1847.zip
test(app): add a golden path for mocked e2e prompts (#20593)
Diffstat (limited to 'packages/app/e2e/projects/projects-close.spec.ts')
-rw-r--r--packages/app/e2e/projects/projects-close.spec.ts73
1 files changed, 34 insertions, 39 deletions
diff --git a/packages/app/e2e/projects/projects-close.spec.ts b/packages/app/e2e/projects/projects-close.spec.ts
index 9454d683f..75e6f2ce6 100644
--- a/packages/app/e2e/projects/projects-close.spec.ts
+++ b/packages/app/e2e/projects/projects-close.spec.ts
@@ -3,51 +3,46 @@ import { createTestProject, cleanupTestProject, openSidebar, clickMenuItem, open
import { projectSwitchSelector } from "../selectors"
import { dirSlug } from "../utils"
-test("closing active project navigates to another open project", async ({ page, withProject }) => {
+test("closing active project navigates to another open project", async ({ page, project }) => {
await page.setViewportSize({ width: 1400, height: 800 })
const other = await createTestProject()
const otherSlug = dirSlug(other)
try {
- await withProject(
- async ({ slug }) => {
- await openSidebar(page)
-
- const otherButton = page.locator(projectSwitchSelector(otherSlug)).first()
- await expect(otherButton).toBeVisible()
- await otherButton.click()
-
- await expect(page).toHaveURL(new RegExp(`/${otherSlug}/session`))
-
- const menu = await openProjectMenu(page, otherSlug)
-
- await clickMenuItem(menu, /^Close$/i, { force: true })
-
- await expect
- .poll(
- () => {
- const pathname = new URL(page.url()).pathname
- if (new RegExp(`^/${slug}/session(?:/[^/]+)?/?$`).test(pathname)) return "project"
- if (pathname === "/") return "home"
- return ""
- },
- { timeout: 15_000 },
- )
- .toMatch(/^(project|home)$/)
-
- await expect(page).not.toHaveURL(new RegExp(`/${otherSlug}/session(?:[/?#]|$)`))
- await expect
- .poll(
- async () => {
- return await page.locator(projectSwitchSelector(otherSlug)).count()
- },
- { timeout: 15_000 },
- )
- .toBe(0)
- },
- { extra: [other] },
- )
+ await project.open({ extra: [other] })
+ await openSidebar(page)
+
+ const otherButton = page.locator(projectSwitchSelector(otherSlug)).first()
+ await expect(otherButton).toBeVisible()
+ await otherButton.click()
+
+ await expect(page).toHaveURL(new RegExp(`/${otherSlug}/session`))
+
+ const menu = await openProjectMenu(page, otherSlug)
+ await clickMenuItem(menu, /^Close$/i, { force: true })
+
+ await expect
+ .poll(
+ () => {
+ const pathname = new URL(page.url()).pathname
+ if (new RegExp(`^/${project.slug}/session(?:/[^/]+)?/?$`).test(pathname)) return "project"
+ if (pathname === "/") return "home"
+ return ""
+ },
+ { timeout: 15_000 },
+ )
+ .toMatch(/^(project|home)$/)
+
+ await expect(page).not.toHaveURL(new RegExp(`/${otherSlug}/session(?:[/?#]|$)`))
+ await expect
+ .poll(
+ async () => {
+ return await page.locator(projectSwitchSelector(otherSlug)).count()
+ },
+ { timeout: 15_000 },
+ )
+ .toBe(0)
} finally {
await cleanupTestProject(other)
}