Skip to content

Open source personal finance application

test(e2e): guard reka-ui inject against the prod build in CI

Ilya Komichevf02292957f10
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 505c5b5a..be8eb956 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,3 +18,25 @@ jobs:
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @finapp/app check:deps
+
+ e2e-prod:
+ name: reka-ui inject (prod build)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: pnpm/action-setup@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 24
+ cache: pnpm
+ - run: pnpm install --frozen-lockfile
+ - uses: actions/cache@v4
+ id: pw-cache
+ with:
+ path: ~/.cache/ms-playwright
+ key: pw-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ - if: steps.pw-cache.outputs.cache-hit != 'true'
+ run: pnpm --filter @finapp/app exec playwright install --with-deps chromium
+ - if: steps.pw-cache.outputs.cache-hit == 'true'
+ run: pnpm --filter @finapp/app exec playwright install-deps chromium
+ - run: pnpm --filter @finapp/app test:e2e:prod
diff --git a/CLAUDE.md b/CLAUDE.md
index b7303294..21896b56 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -11,10 +11,10 @@ Personal finance app. Nuxt 4, Vue 3, Pinia, @nuxt/ui v4 (Tailwind CSS v4), Supab
- `pnpm dev` - Nuxt dev server on port 3050
- Local backend (run once, in `app/`): `supabase start` (Postgres + Auth on :54321), then `docker exec -i supabase_db_app psql -U postgres -d postgres < supabase/powersync_setup.sql` (replication role + publication), then `docker compose -f powersync/docker-compose.yaml up -d` (PowerSync service on :8080)
-- `pnpm build` - SPA build
-- `pnpm generate` - static generation
+- `pnpm build` / `pnpm generate` - both run `nuxt generate` (static SPA, output `.output/public`)
- `pnpm lint` / `pnpm lint:fix` - ESLint
- `pnpm test` - Vitest
+- `pnpm test:e2e` - Playwright against the dev server; `pnpm test:e2e:prod` - Playwright against the prod build
- `pnpm docs:dev` / `pnpm docs:build` - docs site
## Deploy
diff --git a/app/playwright.config.ts b/app/playwright.config.ts
index 18c8490b..5c8852bc 100644
--- a/app/playwright.config.ts
+++ b/app/playwright.config.ts
@@ -11,6 +11,9 @@ export default defineConfig({
reporter: [['html', { open: 'never' }], ['list']],
retries: 0,
testDir: './tests/e2e',
+ // The reka-ui inject smoke test only means something against a production
+ // build; it runs via playwright.prod.config.ts, not this dev-server config.
+ testIgnore: /context-menu-smoke\.spec\.ts/,
use: {
baseURL: 'http://localhost:3050',
screenshot: 'only-on-failure',
diff --git a/app/playwright.prod.config.ts b/app/playwright.prod.config.ts
new file mode 100644
index 00000000..a3634dfa
--- /dev/null
+++ b/app/playwright.prod.config.ts
@@ -0,0 +1,27 @@
+import { defineConfig, devices } from '@playwright/test'
+import process from 'node:process'
+
+// Runs e2e against a real production build. The reka-ui chunk-duplication
+// inject regression only surfaces in the minified, code-split bundle - the
+// default config serves `pnpm dev`, which can't reproduce it.
+const port = Number(process.env.E2E_PORT) || 3050
+
+export default defineConfig({
+ projects: [{ name: 'demo', use: { ...devices['Desktop Chrome'] } }],
+ reporter: [['list']],
+ retries: 0,
+ testDir: './tests/e2e',
+ testMatch: /context-menu-smoke\.spec\.ts/,
+ use: {
+ baseURL: `http://localhost:${port}`,
+ trace: 'retain-on-failure',
+ },
+ webServer: {
+ command: `pnpm build && PORT=${port} node scripts/serve-static.mjs`,
+ reuseExistingServer: !process.env.CI,
+ stderr: 'pipe',
+ stdout: 'ignore',
+ timeout: 300_000,
+ url: `http://localhost:${port}`,
+ },
+})
diff --git a/app/scripts/serve-static.mjs b/app/scripts/serve-static.mjs
new file mode 100644
index 00000000..b51ab666
--- /dev/null
+++ b/app/scripts/serve-static.mjs
@@ -0,0 +1,42 @@
+import { readFile, stat } from 'node:fs/promises'
+import { createServer } from 'node:http'
+import { extname, join, normalize } from 'node:path'
+import process from 'node:process'
+import { fileURLToPath } from 'node:url'
+
+// Minimal SPA static server for the production build (`.output/public`),
+// mirroring Vercel's static hosting + index.html rewrite for the prod e2e run.
+
+const root = fileURLToPath(new URL('../.output/public/', import.meta.url))
+const port = Number(process.env.PORT) || 3050
+
+const types = {
+ '.css': 'text/css',
+ '.html': 'text/html',
+ '.ico': 'image/x-icon',
+ '.js': 'text/javascript',
+ '.json': 'application/json',
+ '.png': 'image/png',
+ '.svg': 'image/svg+xml',
+ '.wasm': 'application/wasm',
+ '.woff2': 'font/woff2',
+}
+
+async function send(res, path) {
+ const body = await readFile(path)
+ res.setHeader('content-type', types[extname(path)] ?? 'application/octet-stream')
+ res.end(body)
+}
+
+createServer(async (req, res) => {
+ const url = decodeURIComponent((req.url || '/').split('?')[0])
+ const filePath = normalize(join(root, url))
+ if (filePath.startsWith(root)) {
+ try {
+ if ((await stat(filePath)).isFile())
+ return await send(res, filePath)
+ }
+ catch {}
+ }
+ await send(res, join(root, 'index.html'))
+}).listen(port, () => console.log(`static server on http://localhost:${port}`))