From dce5ebd83da1ab2fb613d063b8df5af8d95e00cb Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 5 Sep 2026 14:18:22 -0700 Subject: [PATCH] test: isolate native crash restoration and refresh stale fixtures (#18883) * test: isolate native crash restoration and seed current integration facts * test: await scoped GitLab preflight before URL transition checks --- tests/e2e/electron-home-isolation.spec.ts | 3 +- tests/e2e/feature-wall.spec.ts | 67 +++++++++++-------- .../github-url-smart-input-transition.spec.ts | 21 +++--- tests/e2e/helpers/electron-launch-args.ts | 4 ++ .../helpers/electron-launch-args.unit.test.ts | 13 +++- 5 files changed, 63 insertions(+), 45 deletions(-) diff --git a/tests/e2e/electron-home-isolation.spec.ts b/tests/e2e/electron-home-isolation.spec.ts index 65aa1b7dc10..2fae6f42eec 100644 --- a/tests/e2e/electron-home-isolation.spec.ts +++ b/tests/e2e/electron-home-isolation.spec.ts @@ -1,4 +1,5 @@ import type { ElectronApplication } from '@stablyai/playwright-test' +import { realpathSync } from 'node:fs' import path from 'node:path' import { expect, test } from './helpers/orca-app' @@ -23,7 +24,7 @@ async function readElectronHomeState(electronApp: ElectronApplication) { // HOME boundary and that real-home routing lands inside the disposable profile. test('isolates Electron and Codex from the developer home by default', async ({ electronApp }) => { const state = await readElectronHomeState(electronApp) - const expectedHome = path.join(state.userDataDir!, 'home') + const expectedHome = realpathSync.native(path.join(state.userDataDir!, 'home')) expect(state.appHome).toBe(expectedHome) expect(state.nodeHome).toBe(expectedHome) diff --git a/tests/e2e/feature-wall.spec.ts b/tests/e2e/feature-wall.spec.ts index 428ce5d7996..fb422ec8bf8 100644 --- a/tests/e2e/feature-wall.spec.ts +++ b/tests/e2e/feature-wall.spec.ts @@ -179,9 +179,40 @@ test.describe('Feature tour modal', () => { }) test('does not pre-check configured workflows until the user visits them', async ({ - orcaPage + orcaPage, + electronApp }) => { - await orcaPage.evaluate(() => { + await electronApp.evaluate( + ({ ipcMain }, preflightStatus) => { + ipcMain.removeHandler('preflight:check') + ipcMain.handle('preflight:check', () => preflightStatus) + ipcMain.removeHandler('linear:status') + ipcMain.handle('linear:status', () => ({ connected: false, viewer: null })) + ipcMain.removeHandler('jira:status') + ipcMain.handle('jira:status', () => ({ connected: false, viewer: null })) + }, + { + git: { installed: true }, + gh: { installed: true, authenticated: true }, + glab: { installed: false, authenticated: false }, + bitbucket: { configured: false, authenticated: false, account: null }, + azureDevOps: { + configured: false, + authenticated: false, + account: null, + baseUrl: null, + tokenConfigured: false + }, + gitea: { + configured: false, + authenticated: false, + account: null, + baseUrl: null, + tokenConfigured: false + } + } + ) + await orcaPage.evaluate(async () => { for (const key of [ 'orca.featureWall.visitedWorkflows.v1', 'orca.featureWall.visitedAgentSteps.v1', @@ -198,32 +229,12 @@ test.describe('Feature tour modal', () => { if (!store) { throw new Error('window.__store is not available') } - store.setState({ - preflightStatus: { - git: { installed: true }, - gh: { installed: true, authenticated: true }, - glab: { installed: false, authenticated: false }, - bitbucket: { configured: false, authenticated: false, account: null }, - azureDevOps: { - configured: false, - authenticated: false, - account: null, - baseUrl: null, - tokenConfigured: false - }, - gitea: { - configured: false, - authenticated: false, - account: null, - baseUrl: null, - tokenConfigured: false - } - }, - preflightStatusChecked: true, - preflightStatusLoading: false, - linearStatus: { connected: false, viewer: null }, - linearStatusChecked: true - }) + // Seed through the status actions so each result gets the current execution context. + await Promise.all([ + store.getState().refreshPreflightStatus({ force: true }), + store.getState().checkLinearConnection(true), + store.getState().checkJiraConnection() + ]) store.getState().openModal('feature-wall', { source: 'help_menu' }) }) diff --git a/tests/e2e/github-url-smart-input-transition.spec.ts b/tests/e2e/github-url-smart-input-transition.spec.ts index e078007bd78..f042c4ef676 100644 --- a/tests/e2e/github-url-smart-input-transition.spec.ts +++ b/tests/e2e/github-url-smart-input-transition.spec.ts @@ -203,6 +203,12 @@ async function installHeldGitLabLookup( __releaseGitLabUrlLookup?: () => void } fixture.__gitlabUrlLookupStarted = false + ipcMain.removeHandler('preflight:check') + ipcMain.handle('preflight:check', () => ({ + git: { installed: true }, + gh: { installed: true, authenticated: true }, + glab: { installed: true, authenticated: true } + })) ipcMain.removeHandler('gitlab:listMRs') ipcMain.handle('gitlab:listMRs', () => ({ items: [wrongItem], @@ -221,23 +227,12 @@ async function installHeldGitLabLookup( }, { wrongItem: GITLAB_WRONG_ITEM, targetItem: GITLAB_TARGET_ITEM } ) - await page.evaluate(() => { + await page.evaluate(async () => { const store = window.__store if (!store) { throw new Error('window.__store is not available') } - const state = store.getState() - if (!state.preflightStatusContextKey) { - throw new Error('preflight context is not ready') - } - store.setState({ - preflightStatus: { - git: state.preflightStatus?.git ?? { installed: true }, - gh: state.preflightStatus?.gh ?? { installed: true, authenticated: true }, - glab: { installed: true, authenticated: true } - }, - preflightStatusChecked: true - }) + await store.getState().refreshPreflightStatus({ force: true }) }) } diff --git a/tests/e2e/helpers/electron-launch-args.ts b/tests/e2e/helpers/electron-launch-args.ts index fc2ff1e81aa..9128a5fb551 100644 --- a/tests/e2e/helpers/electron-launch-args.ts +++ b/tests/e2e/helpers/electron-launch-args.ts @@ -7,6 +7,10 @@ export function getOrcaElectronLaunchArgs(mainPath: string, headful: boolean): s // these Chromium switches startup can block before the first renderer target. const keychainArgs = process.platform === 'darwin' ? ['--password-store=basic', '--use-mock-keychain'] : [] + if (process.platform === 'darwin') { + // Crash tests must not block later launches on AppKit's saved-window recovery dialog. + return [...keychainArgs, appPath, '-ApplePersistenceIgnoreState', 'YES'] + } if (headful || process.platform !== 'linux') { return [...keychainArgs, appPath] } diff --git a/tests/e2e/helpers/electron-launch-args.unit.test.ts b/tests/e2e/helpers/electron-launch-args.unit.test.ts index ed981951f14..636299fbc4e 100644 --- a/tests/e2e/helpers/electron-launch-args.unit.test.ts +++ b/tests/e2e/helpers/electron-launch-args.unit.test.ts @@ -8,10 +8,17 @@ describe('getOrcaElectronLaunchArgs', () => { const mainPath = join(root, 'out', 'main', 'index.js') const args = getOrcaElectronLaunchArgs(mainPath, true) - expect(args.at(-1)).toBe(root) if (process.platform === 'darwin') { - expect(args.slice(0, -1)).toEqual(['--password-store=basic', '--use-mock-keychain']) + expect(args).toEqual([ + '--password-store=basic', + '--use-mock-keychain', + root, + '-ApplePersistenceIgnoreState', + 'YES' + ]) + } else { + expect(args.at(-1)).toBe(root) } - expect(getOrcaElectronLaunchArgs(mainPath, false).at(-1)).toBe(root) + expect(getOrcaElectronLaunchArgs(mainPath, false)).toContain(root) }) })