Files
orca/tests/e2e/worktree-lineage-toggle-dialog.spec.ts
T
Neil 86ef00ad55 fix(projects): a project move names the row it moves; a paired server's twin by its SSH target (#30794)
* fix(projects): a project move names the row it moves; a paired server's twin by its SSH target

* fix(sidebar): pass the header's row without an assertion; e2e helpers and focus baseline follow the row-shaped move

* fix(sidebar): a header drop re-reads the dragged row and drops nothing if its group changed mid-drag

* fix(sidebar): read live repos through a stable store reader, not a ref written during render
2026-10-19 11:28:29 -07:00

89 lines
3.7 KiB
TypeScript

import { test, expect } from './helpers/orca-app'
import { waitForSessionReady, waitForActiveWorktree } from './helpers/store'
import { seedLineageScenario } from './worktree-lineage-state'
test.use({ launchEnv: { ORCA_BACKGROUND_LAUNCH: '1' } })
test('locally controlled project-group modal keeps child-toggle input', async ({
orcaPage,
electronApp
}, testInfo) => {
await waitForSessionReady(orcaPage)
await waitForActiveWorktree(orcaPage)
expect(
await electronApp.evaluate(({ BrowserWindow }) =>
BrowserWindow.getAllWindows().every((window) => !window.isVisible())
)
).toBe(true)
const family = await seedLineageScenario(orcaPage)
const groupId = await orcaPage.evaluate(async ({ parentId }) => {
const store = window.__store
if (!store) {
throw new Error('Missing store')
}
const parent = Object.values(store.getState().worktreesByRepo)
.flat()
.find((row) => row.id === parentId)
if (!parent) {
throw new Error('Missing parent')
}
const group = await store.getState().createProjectGroup('Shortcut dialog group', 'local')
if (!group) {
throw new Error('Missing project group')
}
const parentRepo = store.getState().repos.find((repo) => repo.id === parent.repoId)
if (!parentRepo) {
throw new Error('Missing parent repo')
}
await store.getState().moveProjectToGroup(parentRepo, group.id)
store.getState().setGroupBy('repo')
await store.getState().setKeybindingOverride('sidebar.childWorkspaces.toggle', ['Mod+Alt+H'])
window.addEventListener('keydown', (event) => {
if (event.code === 'KeyH') {
document.body.dataset.childToggleClaimed = String(event.defaultPrevented)
}
})
return group.id
}, family)
const group = orcaPage.locator(`[data-project-group-header-id="${groupId}"]`)
await expect(
orcaPage
.locator(
`[data-worktree-sidebar] [role="option"][data-worktree-id=${JSON.stringify(family.parentId)}]`
)
.first()
.getByRole('button', { name: 'Hide 1 child workspace' })
).toBeVisible()
await group.hover()
await group.getByRole('button', { name: /Group actions/i }).click()
// The menu is not a modal input owner.
await orcaPage.keyboard.press('ControlOrMeta+Alt+KeyH')
expect(await orcaPage.evaluate(() => window.__store?.getState().collapsedGroups.size)).toBe(1)
await orcaPage.keyboard.press('ControlOrMeta+Alt+KeyH')
expect(await orcaPage.evaluate(() => window.__store?.getState().collapsedGroups.size)).toBe(0)
await orcaPage.getByRole('menuitem', { name: /Delete/i }).click()
const dialog = orcaPage.getByRole('dialog', { name: 'Delete Project Group' })
await expect(dialog).toBeVisible()
await expect(dialog.getByRole('button', { name: 'Delete Group', exact: true })).toBeFocused()
expect(await orcaPage.evaluate(() => window.__store?.getState().activeModal)).toBe('none')
const before = await orcaPage.evaluate(() =>
[...(window.__store?.getState().collapsedGroups ?? [])].sort()
)
await orcaPage.keyboard.press('ControlOrMeta+Alt+KeyH')
const proof = testInfo.outputPath('local-modal-guard.png')
await orcaPage.screenshot({ path: proof })
await testInfo.attach('local-modal-guard', { path: proof, contentType: 'image/png' })
expect(
await orcaPage.evaluate(() => [...(window.__store?.getState().collapsedGroups ?? [])].sort())
).toEqual(before)
await expect(orcaPage.locator('body')).toHaveAttribute('data-child-toggle-claimed', 'false')
await dialog.getByRole('button', { name: 'Cancel', exact: true }).click()
await expect(
orcaPage
.locator(
`[data-worktree-sidebar] [role="option"][data-worktree-id=${JSON.stringify(family.childId)}]`
)
.first()
).toBeVisible()
})