feat(win-update-e2e): onboarding seed + fail-fast driving + failure diagnostics
- Seed a completed-onboarding profile into userData before launch so the fullscreen onboarding overlay stops blocking the terminal UI. - ensureTerminal(): create a terminal from a fresh profile rather than waiting for a pre-existing surface that never appears. - Wrap the whole run in try/catch/finally: a driving failure now captures a screenshot + DOM/store diagnostics and ALWAYS tears down (close app, uninstall), then force-exits — turning a 30-min CI job timeout into a ~2-min readable failure. Workflow uploads the diagnostics.
This commit is contained in:
@@ -116,6 +116,10 @@ jobs:
|
||||
- name: Run update-survival harness
|
||||
id: harness
|
||||
shell: pwsh
|
||||
env:
|
||||
# Why: on a driving failure the harness dumps a screenshot + DOM state
|
||||
# here so the actual post-onboarding UI is visible in the artifacts.
|
||||
ORCA_E2E_DIAG_DIR: artifacts/diag
|
||||
run: |
|
||||
$log = "artifacts/harness-output.log"
|
||||
node tools/win-update-e2e/run.mjs `
|
||||
@@ -130,6 +134,9 @@ jobs:
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: win-update-e2e-output
|
||||
path: artifacts/harness-output.log
|
||||
# Why: log + diagnostics only, never the multi-hundred-MB installers.
|
||||
path: |
|
||||
artifacts/harness-output.log
|
||||
artifacts/diag/**
|
||||
retention-days: 7
|
||||
if-no-files-found: warn
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
import { _electron as electron } from '@stablyai/playwright-test'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { mkdirSync, writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { seedCompletedOnboarding } from './onboarding-profile.mjs'
|
||||
|
||||
const NEW_TAB_BUTTON = { role: 'button', name: 'New tab' }
|
||||
const NEW_TERMINAL_ITEM = /New Terminal/i
|
||||
@@ -28,9 +31,13 @@ const XTERM_INPUT = '.xterm-helper-textarea'
|
||||
* Launch the installed Orca.exe. Pointing userDataDir at a harness-owned temp
|
||||
* dir isolates this run's daemon (its socket/token path becomes unique), so
|
||||
* daemon lookups never collide with other Orca installs/daemons on the box.
|
||||
* Seeds a completed-onboarding profile first so the fullscreen onboarding
|
||||
* overlay does not block the terminal UI on a fresh profile.
|
||||
*/
|
||||
export async function launchInstalledApp({ exePath, userDataDir, extraEnv = {} }) {
|
||||
const { ELECTRON_RUN_AS_NODE: _drop, ...cleanEnv } = process.env
|
||||
mkdirSync(userDataDir, { recursive: true })
|
||||
seedCompletedOnboarding(userDataDir)
|
||||
const app = await electron.launch({
|
||||
executablePath: exePath,
|
||||
args: [],
|
||||
@@ -47,12 +54,76 @@ export async function launchInstalledApp({ exePath, userDataDir, extraEnv = {} }
|
||||
return { app, page }
|
||||
}
|
||||
|
||||
/**
|
||||
* Best-effort diagnostics dump when driving fails: a screenshot, the visible
|
||||
* body text, and whether the e2e store is exposed (it is not in production
|
||||
* builds). Written under `dir` so CI can upload it and reveal the actual
|
||||
* post-launch DOM state. Never throws.
|
||||
*/
|
||||
export async function captureFailureDiagnostics(page, dir, label) {
|
||||
const out = {}
|
||||
try {
|
||||
mkdirSync(dir, { recursive: true })
|
||||
} catch {
|
||||
return out
|
||||
}
|
||||
try {
|
||||
await page.screenshot({
|
||||
path: path.join(dir, `${label}.png`),
|
||||
fullPage: false,
|
||||
timeout: 10_000
|
||||
})
|
||||
out.screenshot = `${label}.png`
|
||||
} catch {
|
||||
/* renderer may be unresponsive */
|
||||
}
|
||||
try {
|
||||
const info = await page.evaluate(() => ({
|
||||
hasStore: typeof window.__store,
|
||||
title: document.title,
|
||||
url: location.href,
|
||||
bodyText: (document.body?.innerText ?? '').slice(0, 4000),
|
||||
testIds: Array.from(document.querySelectorAll('[data-testid]'))
|
||||
.map((el) => el.getAttribute('data-testid'))
|
||||
.filter((v, i, a) => v && a.indexOf(v) === i)
|
||||
.slice(0, 80),
|
||||
buttons: Array.from(document.querySelectorAll('button,[role="button"]'))
|
||||
.map((el) => (el.getAttribute('aria-label') || el.textContent || '').trim())
|
||||
.filter((v, i, a) => v && a.indexOf(v) === i)
|
||||
.slice(0, 60)
|
||||
}))
|
||||
writeFileSync(path.join(dir, `${label}.json`), JSON.stringify(info, null, 2))
|
||||
out.info = info
|
||||
} catch {
|
||||
/* renderer may be unresponsive */
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** Wait until at least one terminal surface is mounted and interactive. */
|
||||
export async function waitForTerminalReady(page, timeoutMs = 60_000) {
|
||||
await page.waitForSelector(TERMINAL_SURFACE, { timeout: timeoutMs })
|
||||
await page.waitForSelector(XTERM_INPUT, { timeout: timeoutMs })
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the app to an interactive terminal from a freshly-launched (onboarding-
|
||||
* seeded) profile. If a terminal surface is already mounted, just wait for it;
|
||||
* otherwise wait for the app shell to be interactive (the New tab control is
|
||||
* visible, which also confirms the onboarding overlay is gone) and create one.
|
||||
*/
|
||||
export async function ensureTerminal(page, timeoutMs = 60_000) {
|
||||
if ((await page.locator(TERMINAL_SURFACE).count()) > 0) {
|
||||
await waitForTerminalReady(page, timeoutMs)
|
||||
return
|
||||
}
|
||||
await page
|
||||
.getByRole(NEW_TAB_BUTTON.role, { name: NEW_TAB_BUTTON.name })
|
||||
.first()
|
||||
.waitFor({ state: 'visible', timeout: timeoutMs })
|
||||
await createTerminalTab(page)
|
||||
}
|
||||
|
||||
/** Create a new terminal tab via the New tab menu. Returns the count after. */
|
||||
export async function createTerminalTab(page) {
|
||||
const before = await page.locator(SORTABLE_TAB).count()
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// A completed-onboarding persistence seed for a fresh packaged Orca profile.
|
||||
//
|
||||
// A first-run profile renders a fullscreen onboarding overlay (`fixed inset-0
|
||||
// z-[100]`) that intercepts every pointer event, and the telemetry notice
|
||||
// overlay for the existing-user cohort. Both block the harness from reaching a
|
||||
// terminal. The renderer shows onboarding only while `onboarding.closedAt ===
|
||||
// null` (src/renderer/src/components/onboarding/should-show-onboarding.ts), so
|
||||
// writing this object to `<userDataDir>/orca-data.json` BEFORE launch dismisses
|
||||
// it — the same mechanism the app's own E2E suite uses (tests/e2e/helpers/
|
||||
// e2e-completed-onboarding-profile.ts + orca-app.ts).
|
||||
//
|
||||
// The onboarding flow-version and final-step values mirror src/shared/constants
|
||||
// (ONBOARDING_FLOW_VERSION=4, ONBOARDING_FINAL_STEP=5 at time of writing); if the
|
||||
// app bumps the flow version, refresh these so a stale version does not re-arm
|
||||
// onboarding.
|
||||
|
||||
import { writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
const ONBOARDING_FLOW_VERSION = 4
|
||||
const ONBOARDING_FINAL_STEP = 5
|
||||
|
||||
/** The persisted profile object written to orca-data.json. */
|
||||
export function getCompletedOnboardingProfile() {
|
||||
return {
|
||||
settings: {
|
||||
telemetry: {
|
||||
optedIn: true,
|
||||
installId: '00000000-0000-4000-8000-000000000000',
|
||||
existedBeforeTelemetryRelease: false
|
||||
}
|
||||
},
|
||||
onboarding: {
|
||||
flowVersion: ONBOARDING_FLOW_VERSION,
|
||||
closedAt: 1,
|
||||
outcome: 'completed',
|
||||
lastCompletedStep: ONBOARDING_FINAL_STEP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Write the completed-onboarding profile into a userData dir before launch. */
|
||||
export function seedCompletedOnboarding(userDataDir) {
|
||||
writeFileSync(
|
||||
path.join(userDataDir, 'orca-data.json'),
|
||||
`${JSON.stringify(getCompletedOnboardingProfile(), null, 2)}\n`
|
||||
)
|
||||
}
|
||||
@@ -16,12 +16,13 @@ import { resolveInstaller, silentInstall, silentUninstall } from './installer-st
|
||||
import { backupInstallState, restoreInstallState } from './registry-shortcut-backup.mjs'
|
||||
import {
|
||||
launchInstalledApp,
|
||||
waitForTerminalReady,
|
||||
ensureTerminal,
|
||||
createTerminalTab,
|
||||
listTabIds,
|
||||
startMarker,
|
||||
readTerminalTextBestEffort,
|
||||
closeApp
|
||||
closeApp,
|
||||
captureFailureDiagnostics
|
||||
} from './app-driver.mjs'
|
||||
import { readDaemonPidFiles, findDaemonProcesses, isPidAlive } from './daemon-processes.mjs'
|
||||
import { startWatch } from './window-watch.mjs'
|
||||
@@ -107,37 +108,46 @@ async function main() {
|
||||
created
|
||||
}
|
||||
|
||||
// Isolated mode ALWAYS restores registry/shortcuts and tears down the test
|
||||
// install, whatever happens in the proof body. Non-isolated flow is unchanged:
|
||||
// teardown runs after a successful body only (a thrown body surfaces as FATAL).
|
||||
// Both paths ALWAYS tear down (close the app, kill the marker/watch, uninstall)
|
||||
// and, in isolated mode, restore registry/shortcuts — whatever happens in the
|
||||
// proof body. A driving failure captures diagnostics first, then surfaces as a
|
||||
// FATAL. Teardown in a finally is what keeps a driving hang from pinning the
|
||||
// Node process alive until the CI job timeout.
|
||||
const ctx = { session: null }
|
||||
if (isolated) {
|
||||
let passed = false
|
||||
try {
|
||||
passed = await runProof(ctx, runArgs)
|
||||
} finally {
|
||||
await isolatedTeardown({
|
||||
app: ctx.session?.app,
|
||||
created,
|
||||
userDataDir,
|
||||
installDir,
|
||||
manifest,
|
||||
runDir
|
||||
})
|
||||
const diagDir = process.env.ORCA_E2E_DIAG_DIR || path.join(runDir, 'diag')
|
||||
let passed = false
|
||||
try {
|
||||
passed = await runProof(ctx, runArgs)
|
||||
} catch (err) {
|
||||
console.error(`[win-update-e2e] FATAL: ${err.stack || err.message}`)
|
||||
if (ctx.session?.page) {
|
||||
const diag = await captureFailureDiagnostics(ctx.session.page, diagDir, 'driving-failure')
|
||||
log('diag', `captured -> ${diagDir} (store=${diag.info?.hasStore ?? 'n/a'})`)
|
||||
if (diag.info?.bodyText) {
|
||||
log('diag', `visible text: ${diag.info.bodyText.replace(/\s+/g, ' ').slice(0, 300)}`)
|
||||
}
|
||||
}
|
||||
return passed ? 0 : 1
|
||||
passed = false
|
||||
} finally {
|
||||
await (isolated
|
||||
? isolatedTeardown({
|
||||
app: ctx.session?.app,
|
||||
created,
|
||||
userDataDir,
|
||||
installDir,
|
||||
manifest,
|
||||
runDir
|
||||
})
|
||||
: teardown({
|
||||
app: ctx.session?.app,
|
||||
created,
|
||||
userDataDir,
|
||||
keepInstall: opts.keepInstall,
|
||||
hadPreexistingInstall,
|
||||
installedExePath: ctx.installedExePath ?? null,
|
||||
runDir
|
||||
}))
|
||||
}
|
||||
|
||||
const passed = await runProof(ctx, runArgs)
|
||||
await teardown({
|
||||
app: ctx.session?.app,
|
||||
created,
|
||||
userDataDir,
|
||||
keepInstall: opts.keepInstall,
|
||||
hadPreexistingInstall,
|
||||
installedExePath: ctx.installedExePath ?? null,
|
||||
runDir
|
||||
})
|
||||
return passed ? 0 : 1
|
||||
}
|
||||
|
||||
@@ -172,7 +182,9 @@ async function runProof(ctx, args) {
|
||||
// --- Base version: launch, create sessions, start marker, record daemon ---
|
||||
let session = await launchInstalledApp({ exePath: base.exePath, userDataDir })
|
||||
ctx.session = session
|
||||
await waitForTerminalReady(session.page)
|
||||
// A fresh profile has no terminal yet, so create/ensure one rather than
|
||||
// waiting for a pre-existing surface.
|
||||
await ensureTerminal(session.page)
|
||||
await createTerminalTab(session.page)
|
||||
const tabIds = await listTabIds(session.page)
|
||||
log('sessions', `tab ids: ${tabIds.join(', ')}`)
|
||||
@@ -217,7 +229,7 @@ async function runProof(ctx, args) {
|
||||
// --- Relaunch and gather post-update evidence ---
|
||||
session = await launchInstalledApp({ exePath: updated.exePath, userDataDir })
|
||||
ctx.session = session
|
||||
await waitForTerminalReady(session.page)
|
||||
await ensureTerminal(session.page)
|
||||
|
||||
const evidence = await gatherEvidence({
|
||||
profile: opts.expect,
|
||||
@@ -525,10 +537,13 @@ function delay(ms) {
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === import.meta.filename) {
|
||||
main()
|
||||
.then((code) => {
|
||||
process.exitCode = code
|
||||
// Why: force-exit. A launched Electron app or the window-watch child can
|
||||
// keep libuv handles open; without this the process lingers to the CI job
|
||||
// timeout instead of exiting when the run is logically done.
|
||||
process.exit(code)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('[win-update-e2e] FATAL:', err.stack || err.message)
|
||||
process.exitCode = 1
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user