feat: manage Chromium installation in engine
Engine CI / test (push) Waiting to run

This commit is contained in:
2026-08-30 18:51:35 +08:00
parent fef7459650
commit e3b0b2d576
17 changed files with 139 additions and 3 deletions
+26
View File
@@ -10,8 +10,34 @@ import { joinBase, normalizeSiteBase } from '../scripts/lib/site-base.ts'
import { StaticOverflowAuditor, auditStaticDecks } from '../scripts/lib/static-overflow.ts'
import { hasPresenterToken, hashPresenterToken } from '../scripts/lib/token.ts'
import { auditBuiltDecks } from '../scripts/lib/overflow-audit.ts'
import { createBrowserInstallCommand } from '../scripts/lib/browser-install.ts'
import { resolveImageSource } from '../packages/slidev-theme-easy-jyy/utils/resolve-image.ts'
describe('browser installation', () => {
it('uses the Chromium-only Playwright CLI bundled with the engine', () => {
const command = createBrowserInstallCommand([])
expect(command.command).toBe(process.execPath)
expect(command.args.at(-3)).toMatch(/playwright-chromium[/\\]cli\.js$/)
expect(command.args.slice(-2)).toEqual(['install', 'chromium'])
})
it('supports Linux system dependency installation and rejects unknown options', () => {
expect(createBrowserInstallCommand(['--with-deps']).args.slice(-3)).toEqual([
'install',
'--with-deps',
'chromium',
])
expect(() => createBrowserInstallCommand(['--firefox'])).toThrow('不支持参数')
expect(() => createBrowserInstallCommand(['--with-deps', '--with-deps'])).toThrow('只能指定一次')
})
it('includes browser installation in generated CI workflows', async () => {
const source = await readFile(path.join(process.cwd(), 'scripts/init.ts'), 'utf8')
expect(source).toContain('pnpm exec easy-slides install-browser --with-deps')
})
})
function overflowingList(title: string, count: number) {
return `# ${title}\n\n${Array.from({ length: count }, (_, index) => `- ${index + 1} `).join('\n')}\n`
}