Files
orca/tests/e2e/sidebar-collapse-per-key.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

63 lines
2.2 KiB
TypeScript

import type { Page } from '@stablyai/playwright-test'
import { test, expect } from './helpers/orca-app'
import { SIDEBAR_INPUTS_BUILD } from './helpers/sidebar-inputs-build'
import { waitForSessionReady } from './helpers/store'
async function setCollapsed(
page: Page,
key: string,
collapsed: boolean,
writer: string,
seq: number
) {
return page.evaluate((params) => window.api.runtime.call({ method: 'ui.setCollapsed', params }), {
key,
collapsed,
opId: { writer, seq }
})
}
function windowCollapsed(page: Page): Promise<string[]> {
return page.evaluate(() => [...(window.__store?.getState().collapsedGroups ?? [])].sort())
}
test.describe('switch on', () => {
test.skip(
!SIDEBAR_INPUTS_BUILD,
'ui.setCollapsed exists only in an ORCA_SIDEBAR_INPUTS=main build'
)
test('ui.setCollapsed changes one section without undoing the window or a newer writer', async ({
orcaPage
}) => {
await waitForSessionReady(orcaPage)
// The window folds a section through its own whole-set write.
await orcaPage.evaluate(() => window.__store?.getState().toggleCollapsedGroup('e2e:window'))
expect(await setCollapsed(orcaPage, 'e2e:phone', true, 'phone-a', 1)).toMatchObject({
ok: true,
result: { collapsed: true, applied: true }
})
await expect.poll(() => windowCollapsed(orcaPage)).toEqual(['e2e:phone', 'e2e:window'])
// Another writer unfolds it; phone A's retry of its already-applied fold must not undo that.
await setCollapsed(orcaPage, 'e2e:phone', false, 'phone-b', 1)
expect(await setCollapsed(orcaPage, 'e2e:phone', true, 'phone-a', 1)).toMatchObject({
ok: true,
result: { collapsed: false, applied: false }
})
await expect.poll(() => windowCollapsed(orcaPage)).toEqual(['e2e:window'])
})
})
test.describe('switch off', () => {
test.skip(SIDEBAR_INPUTS_BUILD, 'checks the shipped method set')
test('a switch-off build registers no ui.setCollapsed', async ({ orcaPage }) => {
await waitForSessionReady(orcaPage)
const response = await setCollapsed(orcaPage, 'e2e:phone', true, 'phone-a', 1)
expect(response).toMatchObject({ ok: false, error: { code: 'method_not_found' } })
expect(await windowCollapsed(orcaPage)).not.toContain('e2e:phone')
})
})