import { describe, expect, it } from 'vitest'; import path from 'node:path'; import { buildPlaywrightRuntimeEnv, resolveYinianPlaywrightBrowsersPath, resolveYinianPlaywrightInstallLockPath, } from '@electron/utils/playwright-runtime'; describe('Playwright runtime env', () => { it('uses an app-scoped browser cache and disables package-time browser downloads by default', () => { const env = buildPlaywrightRuntimeEnv({}); expect(env.PLAYWRIGHT_BROWSERS_PATH).toBe(resolveYinianPlaywrightBrowsersPath()); expect(env.PLAYWRIGHT_BROWSERS_PATH).toContain(path.join('.openclaw', 'runtime', 'ms-playwright')); expect(env.PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD).toBe('1'); expect(env.YINIAN_PLAYWRIGHT_INSTALL_LOCK_PATH).toBe(resolveYinianPlaywrightInstallLockPath()); }); it('preserves explicit caller-provided Playwright env overrides', () => { const env = buildPlaywrightRuntimeEnv({ PLAYWRIGHT_BROWSERS_PATH: '/tmp/custom-browsers', PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '0', YINIAN_PLAYWRIGHT_INSTALL_LOCK_PATH: '/tmp/custom.lock', }); expect(env.PLAYWRIGHT_BROWSERS_PATH).toBe('/tmp/custom-browsers'); expect(env.PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD).toBe('0'); expect(env.YINIAN_PLAYWRIGHT_INSTALL_LOCK_PATH).toBe('/tmp/custom.lock'); }); });