Files
orca/tests/e2e/tab-create-entry-file-paths.spec.ts
Jinjing 7a695c70f1 test(e2e): harden triaged CI failures (#14656)
* test(e2e): harden triaged failures

* test(e2e): ship relay bundle to reusable shards

* test(e2e): tolerate expected IPC closures in daemon shutdown

A normal client exit can close the IPC channel before the finish ack
lands. Distinguish this from real failures by checking error codes,
only throwing if forced cleanup occurred or the error is not an IPC
closure.

* rm doc

* test(e2e): return termination status from legacy close handler

- terminateLegacyCloseClient now returns a discriminated union indicating
  whether the process had already exited ('already-exited') or termination
  was actually attempted ('termination-attempted')
- Allows finishLegacyCloseClient to only set forcedCleanup when termination
  was genuinely needed, not when the process exited cleanly on its own

* test(e2e): fix dispatch contract and voice mic locator

Point the release E2E contract at the renamed build step, and assert the
relabeled microphone through the Voice pane combobox even when Radix
leaves the listbox open.

* test(e2e): add contract test for relay artifact dispatch

Validate that the relay artifact built in CI is properly uploaded,
downloaded, and passed via ORCA_RELAY_PATH to E2E test runs.

* Distinguish between terminated and already-exited processes

Detect when processes have already exited instead of always reporting
termination success. Return booleans from cleanup functions to indicate
whether they actually signalled a process, catch tree-capture failures
when the root process exits before recording completes, and use these
signals to return accurate exit status from termination handlers.

* test(e2e): stabilize file creation and voice microphone tests

Use stable locators (aria-autocomplete, named triggers) and add retry
logic to handle file scans and device events that can interfere with
listbox state. Increase timeouts to allow async operations to complete.

* Add retry logic for transient GitHub API errors in PR body updates

GitHub API occasionally returns transient 5xx errors. Retry up to 3 times
with exponential backoff (1s, 2s, 4s) to improve reliability during
temporary service disruptions. Export updatePullRequest and add sleepImpl
parameter for test injection.

* Add tab search result retention during typing

Keep search results on screen while the deferred query catches up with
the live query. Re-validates results against the current input without
dropping rows prematurely, ensuring the user can select from what they see.

* Add proper types to tab search mock

Replace `unknown` with concrete types (`OpenTabSearchResult`,
`OpenTabSearchEntries`, `SearchableWorkspaceTab`) and use type guards
for discriminated unions to improve test type safety.
2026-08-17 23:28:38 -07:00

77 lines
3.5 KiB
TypeScript

import { mkdirSync, writeFileSync } from 'node:fs'
import path from 'node:path'
import { expect, test } from './helpers/orca-app'
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
const relativeFilePath =
'packages/orca/src/renderer/src/components/navigation/worktree/secondary-nav/SecondaryNav.tsx'
test('new-tab file results prioritize the filename and reveal the full path on hover', async ({
orcaPage,
testRepoPath
}) => {
const filePath = path.join(testRepoPath, ...relativeFilePath.split('/'))
mkdirSync(path.dirname(filePath), { recursive: true })
writeFileSync(filePath, 'export const SecondaryNav = true\n')
await waitForSessionReady(orcaPage)
await waitForActiveWorktree(orcaPage)
await ensureTerminalVisible(orcaPage)
const newTab = orcaPage.getByRole('button', { name: 'New tab' })
// Why: aria-controls is only set after results exist, so it cannot be the
// open-state locator. aria-autocomplete is always on this input and is not
// translated copy.
const input = orcaPage.locator('input[role="combobox"][aria-autocomplete="list"]')
const row = orcaPage.locator('[role="option"]').filter({ hasText: 'Open file' }).first()
// Keyboard activation avoids the animated tab bar's pointer stability gate.
// Re-open and re-type until the file scan has produced an Open file row —
// the scan starts when the menu opens and can outlast a single fill.
await expect(async () => {
if ((await newTab.getAttribute('aria-expanded')) !== 'true') {
await newTab.press('Space')
}
await expect(input).toBeVisible({ timeout: 1_000 })
if ((await input.inputValue()) !== 'secondaryNav') {
await input.fill('secondaryNav')
}
await expect(row).toBeVisible({ timeout: 2_000 })
}).toPass({ timeout: 20_000 })
await expect(row).toContainText('SecondaryNav.tsx')
await expect(row).toContainText('packages/orca/src/renderer/src/components/navigation/')
const rowText = await row.textContent()
expect(rowText?.indexOf('SecondaryNav.tsx')).toBeLessThan(
rowText?.indexOf('packages/orca/src/renderer/src/components/navigation/') ?? -1
)
// The filename must survive intact; only the directory may be clipped, and the
// row itself must never spill past the dropdown.
const overflow = await row.evaluate((element) => {
const filename = element.querySelector(':scope > span:last-of-type > span:first-child')
return {
filenameClipped: filename ? filename.scrollWidth > filename.clientWidth : true,
rowClipped: element.scrollWidth > element.clientWidth
}
})
expect(overflow).toEqual({ filenameClipped: false, rowClipped: false })
// Two hovers on purpose: results stream in and remount the row, and Radix only
// opens on a pointermove it actually receives. A single hover can land before
// the remount and leave the cursor sitting still over a row that never saw it.
await row.hover({ position: { x: 20, y: 12 } })
await orcaPage.waitForTimeout(250)
await row.hover({ position: { x: 40, y: 12 } })
// Exact cursor placement is arithmetic, unit-tested via cursorTooltipOffsets.
// Asserting it here measured the app mid-reflow and was flaky; what E2E is
// uniquely good for is that the tooltip really opens with the whole path.
await expect(
orcaPage.locator('[data-slot="tooltip-content"]').filter({ hasText: relativeFilePath })
).toBeVisible()
const proofPath = process.env.ORCA_STA3424_PROOF_PATH
if (proofPath) {
await orcaPage.screenshot({ path: proofPath })
}
})