import path from "node:path"; import { execFileSync } from "node:child_process"; import { defineConfig, devices } from "@playwright/test"; function resolveChromePath(): string | undefined { if (process.env.CHROME_PATH) return process.env.CHROME_PATH; try { return execFileSync("which", ["google-chrome"], { encoding: "utf8" }).trim() || undefined; } catch { return undefined; } } const chromePath = resolveChromePath(); const testPort = Number.parseInt(process.env.WEB_TEST_PORT ?? "5189", 10) || 5189; const testOrigin = `http://127.0.0.1:${testPort}`; const archive = path.resolve(process.env.M6_BINARY_ARCHIVE ?? "../release/blender-web-offline.tar.gz"); export default defineConfig({ testDir: "tests/e2e", testMatch: "archive-offline.spec.ts", timeout: 180_000, expect: { timeout: 30_000 }, fullyParallel: false, workers: 1, reporter: [["list"]], use: { baseURL: testOrigin, ...devices["Desktop Chrome"], acceptDownloads: true, headless: true, launchOptions: { ...(chromePath ? { executablePath: chromePath } : {}), args: ["--no-sandbox", "--use-gl=swiftshader", "--enable-unsafe-swiftshader"], }, screenshot: "only-on-failure", trace: "retain-on-failure", }, webServer: { command: `node ../tools/web/archive-deployment-server.mjs --archive ${JSON.stringify(archive)} --port ${testPort}`, url: testOrigin, reuseExistingServer: false, timeout: 60_000, }, });