import path from 'path' import { mkdtempSync, rmSync, existsSync } from 'fs' import { join } from 'path' import { tmpdir } from 'os' import { test, expect } from '@playwright/test' import { launchApp, skipOnboarding } from './helpers' const ROOT = path.join(import.meta.dirname, '..') test.describe('Release smoke', () => { let userDataDir: string test.beforeEach(() => { userDataDir = mkdtempSync(join(tmpdir(), 'bilin-e2e-release-')) }) test.afterEach(() => { if (userDataDir && existsSync(userDataDir)) { try { rmSync(userDataDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 }) } catch { /* ignore */ } } }) test('E2E-RELEASE-01: app launches and shows home after onboarding skip', async () => { const app = await launchApp(userDataDir) const page = await app.firstWindow() await skipOnboarding(page) await expect(page.locator('#app')).toBeVisible({ timeout: 20_000 }) await expect(page.getByRole('button', { name: /新建书籍/ }).first()).toBeVisible({ timeout: 10_000 }) await app.close() }) test('E2E-RELEASE-02: create book opens editor without cockpit blocking', async () => { const app = await launchApp(userDataDir) const page = await app.firstWindow() await skipOnboarding(page) await page.getByRole('button', { name: /新建书籍/ }).first().click() await page.locator('.dialog-content input').first().fill('发布冒烟书') await page.getByRole('button', { name: '创建' }).click() await expect(page.locator('#editor-layout')).toBeVisible({ timeout: 15_000 }) const cockpit = page.locator('[data-testid="cockpit-modal"]') if (await cockpit.isVisible({ timeout: 5000 }).catch(() => false)) { await cockpit.locator('.modal-close').click() await expect(cockpit).toBeHidden({ timeout: 5000 }) } await page.getByRole('button', { name: '+ 新章' }).click() await expect(page.locator('.ProseMirror')).toBeVisible({ timeout: 10_000 }) await app.close() }) })