From c3ef69c8664ab84464d720f75eb9bf35289c1847 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 2 Apr 2026 14:17:28 -0400 Subject: test(app): add a golden path for mocked e2e prompts (#20593) --- .../e2e/sidebar/sidebar-popover-actions.spec.ts | 85 ++++++++++------------ 1 file changed, 38 insertions(+), 47 deletions(-) (limited to 'packages/app/e2e/sidebar') diff --git a/packages/app/e2e/sidebar/sidebar-popover-actions.spec.ts b/packages/app/e2e/sidebar/sidebar-popover-actions.spec.ts index 1317d2bb6..05a129a61 100644 --- a/packages/app/e2e/sidebar/sidebar-popover-actions.spec.ts +++ b/packages/app/e2e/sidebar/sidebar-popover-actions.spec.ts @@ -48,70 +48,61 @@ test("collapsed sidebar popover stays open when archiving a session", async ({ p } }) -test("open sidebar project popover stays closed after clicking avatar", async ({ page, withProject }) => { +test("open sidebar project popover stays closed after clicking avatar", async ({ page, project }) => { await page.setViewportSize({ width: 1400, height: 800 }) const other = await createTestProject() const slug = dirSlug(other) try { - await withProject( - async () => { - await openSidebar(page) - - const project = page.locator(projectSwitchSelector(slug)).first() - const card = page.locator('[data-component="hover-card-content"]') - - await expect(project).toBeVisible() - await project.hover() - await expect(card.getByText(/recent sessions/i)).toBeVisible() - - await page.mouse.down() - await expect(card).toHaveCount(0) - await page.mouse.up() - - await waitSession(page, { directory: other }) - await expect(card).toHaveCount(0) - }, - { extra: [other] }, - ) + await project.open({ extra: [other] }) + await openSidebar(page) + + const projectButton = page.locator(projectSwitchSelector(slug)).first() + const card = page.locator('[data-component="hover-card-content"]') + + await expect(projectButton).toBeVisible() + await projectButton.hover() + await expect(card.getByText(/recent sessions/i)).toBeVisible() + + await projectButton.click() + await expect(card).toHaveCount(0) + + await waitSession(page, { directory: other }) + await expect(card).toHaveCount(0) } finally { await cleanupTestProject(other) } }) -test("open sidebar project switch activates on first tabbed enter", async ({ page, withProject }) => { +test("open sidebar project switch activates on first tabbed enter", async ({ page, project }) => { await page.setViewportSize({ width: 1400, height: 800 }) const other = await createTestProject() const slug = dirSlug(other) try { - await withProject( - async () => { - await openSidebar(page) - await defocus(page) - - const project = page.locator(projectSwitchSelector(slug)).first() - - await expect(project).toBeVisible() - - let hit = false - for (let i = 0; i < 20; i++) { - hit = await project.evaluate((el) => { - return el.matches(":focus") || !!el.parentElement?.matches(":focus") - }) - if (hit) break - await page.keyboard.press("Tab") - } - - expect(hit).toBe(true) - - await page.keyboard.press("Enter") - await waitSession(page, { directory: other }) - }, - { extra: [other] }, - ) + await project.open({ extra: [other] }) + await openSidebar(page) + await defocus(page) + + const projectButton = page.locator(projectSwitchSelector(slug)).first() + + await expect(projectButton).toBeVisible() + + let hit = false + for (let i = 0; i < 20; i++) { + hit = await projectButton.evaluate((el) => { + return el.matches(":focus") || !!el.parentElement?.matches(":focus") + }) + if (hit) break + await page.keyboard.press("Tab") + } + + expect(hit).toBe(true) + + await page.keyboard.press("Enter") + await waitSession(page, { directory: other }) } finally { await cleanupTestProject(other) } -- cgit v1.2.3