Files
orca/tests/e2e/codex-account-switch-dismiss.spec.ts
OrcaWinandOrcaWin 8a7dcae3b9 test(e2e): update five stale or racy terminal and agent specs (#39982)
- profile-state restart: runNow now returns the saved pending row (#38217)
- codex account switch: click the backdrop clear of the sidebar seam strip (#38288)
- claude sidebar agent view: drop the removed subagent indicator check (#34558)
- IME preedit continuity: refit after changing the font, like font zoom
- agent send picker: bind local fixture panes to a live PTY so reattach keeps them

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-08 14:12:02 -08:00

83 lines
3.3 KiB
TypeScript

import { expect, test } from './helpers/orca-app'
import {
configureGoldenStubAgent,
getGoldenStubAgentLaunchEnv,
launchGoldenStubAgentFromNewTab
} from './helpers/golden-stub-agent'
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
import { waitForActivePanePtyId, waitForTerminalOutput } from './helpers/terminal'
test.use({ launchEnv: getGoldenStubAgentLaunchEnv() })
test('account switch actions return keyboard input to the terminal', async ({
orcaPage
}, testInfo) => {
await waitForSessionReady(orcaPage)
await waitForActiveWorktree(orcaPage)
await ensureTerminalVisible(orcaPage)
await configureGoldenStubAgent(orcaPage)
await launchGoldenStubAgentFromNewTab(orcaPage)
for (const action of ['outside', 'keep', 'escape', 'restart'] as const) {
const ptyId = await waitForActivePanePtyId(orcaPage)
await orcaPage.evaluate(
({ ptyId, action }) => {
const store = window.__store
if (!store) {
throw new Error('window.__store is unavailable')
}
store.getState().markCodexRestartNotices([
{
ptyId,
previousAccountLabel: 'Previous account',
nextAccountLabel: `Current account (${action})`
}
])
},
{ ptyId, action }
)
const dialog = orcaPage.getByRole('dialog').filter({ hasText: 'Account switched' })
await expect(dialog).toBeVisible()
await expect(dialog).toBeFocused()
if (action === 'outside') {
const cardText = await dialog.getByText(/Restart this session to use/).boundingBox()
const backdrop = await dialog.boundingBox()
if (!cardText || !backdrop) {
throw new Error('Account prompt has no rendered bounds')
}
// Why centered: the sidebar seam's resize and scrollbar strips overlap the pane's left edge.
const outside = { x: backdrop.width / 2, y: 8 }
await orcaPage.mouse.move(cardText.x + 8, cardText.y + 8)
await orcaPage.mouse.down()
await orcaPage.mouse.move(backdrop.x + outside.x, backdrop.y + outside.y)
await orcaPage.mouse.up()
await expect(dialog).toBeVisible()
await orcaPage.screenshot({ path: testInfo.outputPath('account-switched.png') })
await dialog.click({ position: outside })
} else if (action === 'escape') {
await orcaPage.keyboard.press('Escape')
} else {
await dialog
.getByRole('button', {
name: action === 'keep' ? 'Keep old account' : 'Restart',
exact: true
})
.click()
}
await expect(dialog).toHaveCount(0)
const input = orcaPage.locator('.xterm-helper-textarea:focus')
await expect(input).toHaveCount(1)
if (action === 'restart') {
// This check covers the focus handoff; process replacement is a separate contract.
break
}
// A printed reply proves input reached the process without an extra terminal click.
const marker = `ACCOUNT_SWITCH_${action.toUpperCase()}`
await orcaPage.keyboard.type(marker)
await orcaPage.keyboard.press('Enter')
await waitForTerminalOutput(orcaPage, `[GOLDEN_STUB_AGENT_SUBMITTED] ${marker}`, 20_000)
await expect(input).toHaveCount(1)
await orcaPage.screenshot({ path: testInfo.outputPath(`after-${action}.png`) })
}
})