Files
orca/tests/e2e/sidebar-creation-registry.spec.ts
Jinwoo HongandClaude 19e45b7921 feat(sidebar): the desktop window lists main's sidebar inputs behind the build switch (dark) (#30461)
* feat(sidebar): the desktop window lists main's sidebar inputs, with its own writes shown until main does (dark)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(sidebar): a newer write wins in the pending layer, created rows hold the stamped record, writes name their host (dark)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore(sidebar): move the focus-read allowance with the window list model it moved into (dark)

* perf(sidebar): main's sidebar feed publishes a change after a quiet spell at once, not 50 ms later (dark)

* test(e2e): the desktop reads-main spec skips on a switch-off build and waits for a frame after collapse

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-18 22:49:43 -04:00

65 lines
2.7 KiB
TypeScript

import { chmodSync, rmSync, writeFileSync } from 'node:fs'
import path from 'node:path'
import type { Page } from '@stablyai/playwright-test'
import { removeWorktreeViaStore } from './helpers/dead-terminal'
import { expect, test } from './helpers/orca-app'
import { SIDEBAR_INPUTS_BUILD } from './helpers/sidebar-inputs-build'
import { openSidebarWorkspaceComposer } from './helpers/sidebar-project-dialog'
import { getActiveWorktreeId, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
test.skip(!SIDEBAR_INPUTS_BUILD, 'main lists creations only in an ORCA_SIDEBAR_INPUTS=main build')
function readCreations(page: Page): Promise<{ pending: string[]; host: string[] }> {
return page.evaluate(async () => {
const response = await window.api.runtime.call({ method: 'sidebarInputs.workspaceCreations' })
const result: unknown = response.ok ? response.result : null
const creations: unknown =
result && typeof result === 'object' && 'creations' in result ? result.creations : null
return {
pending: Object.keys(window.__store!.getState().pendingWorktreeCreations),
host: creations && typeof creations === 'object' ? Object.keys(creations) : []
}
})
}
test('main lists a window create while it runs and drops it when the workspace lands', async ({
orcaPage,
testRepoPath
}) => {
test.setTimeout(120_000)
await waitForSessionReady(orcaPage)
const originalWorktreeId = await waitForActiveWorktree(orcaPage)
// Holds `git worktree add` in main long enough for two shadow comparisons.
const hookPath = path.join(testRepoPath, '.git', 'hooks', 'post-checkout')
writeFileSync(hookPath, '#!/bin/sh\nsleep 8\n')
chmodSync(hookPath, 0o755)
const name = `registry-${Date.now()}`
let createdId: string | null = null
try {
await openSidebarWorkspaceComposer(orcaPage)
const dialog = orcaPage.getByRole('dialog', { name: /Create (Workspace|Worktree)/i })
await dialog.getByPlaceholder(/Type a name/i).fill(name)
await dialog.getByRole('button', { name: /Create (Workspace|Worktree)/i }).click()
await expect
.poll(async () => {
const { pending, host } = await readCreations(orcaPage)
return pending.length === 1 && host.includes(pending[0])
})
.toBe(true)
await expect
.poll(async () => (await readCreations(orcaPage)).pending.length, { timeout: 30_000 })
.toBe(0)
expect((await readCreations(orcaPage)).host).toEqual([])
createdId = await getActiveWorktreeId(orcaPage)
expect(createdId).not.toBe(originalWorktreeId)
} finally {
rmSync(hookPath, { force: true })
if (createdId && createdId !== originalWorktreeId) {
await removeWorktreeViaStore(orcaPage, createdId)
}
}
})