import { test, expect } from './fixtures/electron'; test('the production local preview preflight isolates requests and cleans up its temporary renderers', async ({ electronApp }) => { const initialWebContentsCount = await electronApp.evaluate(({ webContents }) => webContents.getAllWebContents().length); const runPreflight = async (scenario: 'success' | 'external') => await electronApp.evaluate(async (_electron, value) => { const mainGlobal = globalThis as typeof globalThis & { __niancodeRunLocalPreviewPreflightE2E?: (scenario: 'success' | 'external') => Promise<{ ok: boolean; externalRequests: number; code?: string; }>; }; if (!mainGlobal.__niancodeRunLocalPreviewPreflightE2E) throw new Error('E2E preflight seam is unavailable'); return await mainGlobal.__niancodeRunLocalPreviewPreflightE2E(value); }, scenario); const blocked = await runPreflight('external'); expect(blocked).toEqual({ ok: false, externalRequests: 0, code: 'PUBLISH_PREFLIGHT_RUNTIME_ERROR', }); const result = await runPreflight('success'); expect(result).toEqual({ ok: true, externalRequests: 0 }); await expect.poll( async () => await electronApp.evaluate(({ webContents }) => webContents.getAllWebContents().length), ).toBe(initialWebContentsCount); });