diff --git a/e2e/ui/fixture-server.mjs b/e2e/ui/fixture-server.mjs index d2f5bf3d..98debb57 100644 --- a/e2e/ui/fixture-server.mjs +++ b/e2e/ui/fixture-server.mjs @@ -23,6 +23,7 @@ const actions = new Set([ "@/actions/article-recovery", "@/actions/admin-media", ]); +const nodeStubs = path.join(root, "e2e/ui/node-stubs.mjs"); const bundle = await build({ entryPoints: [path.join(fixtures, "entry.tsx")], bundle: true, @@ -30,8 +31,13 @@ const bundle = await build({ outdir: path.join(root, "test-results/ui-fixture"), format: "iife", jsx: "automatic", - platform: "node", - alias: { "@": path.join(root, "src") }, + alias: { + "@": path.join(root, "src"), + "node:async_hooks": nodeStubs, + "node:crypto": nodeStubs, + "node:fs/promises": nodeStubs, + "node:path": nodeStubs, + }, define: { "process.env.NODE_ENV": '"production"' }, plugins: [ { diff --git a/e2e/ui/node-stubs.mjs b/e2e/ui/node-stubs.mjs new file mode 100644 index 00000000..5e79f001 --- /dev/null +++ b/e2e/ui/node-stubs.mjs @@ -0,0 +1,36 @@ +// Stubs for Node.js built-ins used by server-only modules that leak into the +// UI fixture bundle. These keep esbuild from failing on `node:*` imports +// while providing shape-compatible exports so the bundle stays loadable. + +export class AsyncLocalStorage { + enterWith(): void {} + exit(): void {} + getStore(): T | undefined { + return undefined; + } + run(store: T, work: () => U): U { + return work(); + } +} + +export function createHash(): { update(): { digest(): string } } { + return { + update: () => ({ + digest: () => "", + }), + }; +} + +export function randomUUID(): string { + return "00000000-0000-0000-0000-000000000000"; +} + +export async function readFile(): Promise { + return Buffer.alloc(0); +} + +export const path = { + join: (...parts: string[]): string => parts.join("/"), + resolve: (...parts: string[]): string => parts.join("/"), + sep: "/", +}; diff --git a/playwright.ui.config.ts b/playwright.ui.config.ts index 88c252ba..d2ab7c67 100644 --- a/playwright.ui.config.ts +++ b/playwright.ui.config.ts @@ -64,7 +64,7 @@ export default defineConfig({ webServer: { command: "node e2e/ui/fixture-server.mjs", url: `${baseURL}/health`, - timeout: 60000, + timeout: 120000, reuseExistingServer: true, env: { UI_TEST_PORT: String(port) }, },