Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

2.7 KB
Raw Blame
import { defineConfig } from '@playwright/test';
import { ONE_LAUNCH_AND_ITS_READINESS_VERDICT_MS } from './tests/smoke/_helpers/launch-desktop';

/**
 * Desktop-package Playwright config.
 *
 * Scopes to `tests/smoke/*.e2e.ts` — Electron-launch + URL-scheme + packaged-
 * build smoke tests. Runs independently from `packages/app`'s Playwright config
 * (which exercises the React editor in a Chromium renderer) because the app
 * config relies on a Vite dev server fixture while desktop tests drive a real
 * Electron binary.
 *
 * Expected invocation: `cd packages/desktop && pnpm exec playwright test
 * tests/smoke/` after the electron-vite build has produced `out/main/index.js`
 * (via `pnpm run build:desktop` from the repo root). The `cd` is load-bearing:
 * `@playwright/test` is a `packages/desktop` devDependency, so running
 * `pnpm exec playwright` at the workspace root fails resolving the binary.
 *
 * Individual tests guard against "built output missing" with a `test.skip` +
 * structured reason so CI runs without a pre-build are informative rather than
 * silently red.
 */

export default defineConfig({
  testDir: './tests/smoke',
  testMatch: /.*\.e2e\.ts$/,
  timeout: process.env.CI ? 150_000 : ONE_LAUNCH_AND_ITS_READINESS_VERDICT_MS,
  retries: process.env.CI ? 2 : 0,
  failOnFlakyTests: false,
  // Fail-fast diagnostic when src/ is newer than out/. The smoke harness
  // launches `out/main/index.js` directly; if out/ is stale, tests run
  // against a phantom version of the app and produce failures unrelated to
  // the actual source. CI is unaffected (build runs immediately before
  // tests). See _helpers/stale-build-guard.ts for the rationale.
  globalSetup: './tests/smoke/_helpers/stale-build-guard.ts',
  // One worker — Electron launches are expensive, and these smokes don't
  // parallelize meaningfully (they poke at OS-level URL scheme dispatch).
  workers: 1,
  fullyParallel: false,
  // `html` reporter generates `playwright-report/`, one of the two trees CI
  // uploads. Without it the workflow's `if-no-files-found: ignore` silently
  // skips that upload. It does NOT by itself decide whether an attachment
  // lands as a file — the carrier does, and
  // `tests/smoke/_helpers/electron-stderr.ts` owns that rule.
  // `open: never` suppresses the auto-open browser tab during local runs.
  // `json` writes machine-readable run stats so the desktop-smoke job can assert
  // the gate isn't vacuous (a whole-suite env-skip reads green but asserts
  // nothing). Parsed by the CI vacuity control.
  reporter: [
    ['list'],
    ['html', { open: 'never' }],
    ['json', { outputFile: 'test-results/desktop-smoke-results.json' }],
  ],
  use: {
    // No baseURL — these tests don't hit HTTP.
    trace: 'retain-on-failure',
  },
});