import { mkdtempSync, rmSync, existsSync } from 'fs' import { join } from 'path' import { tmpdir } from 'os' import { test, expect } from '@playwright/test' import { launchApp, skipOnboarding, dismissCockpitIfOpen } from './helpers' test.describe('Pack export all', () => { let userDataDir: string let packAllPath: string test.beforeEach(() => { userDataDir = mkdtempSync(join(tmpdir(), 'bilin-e2e-pack-all-')) packAllPath = join(userDataDir, 'backup.novel-all') }) test.afterEach(() => { if (userDataDir && existsSync(userDataDir)) { try { rmSync(userDataDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 }) } catch { /* ignore */ } } }) test('E2E-ALL-03: home export all books', async () => { const app = await launchApp(userDataDir, { BILIN_E2E_PACK_SAVE: packAllPath }) const page = await app.firstWindow() await skipOnboarding(page) await page.getByRole('button', { name: /新建书籍/ }).first().click() await page.locator('.dialog-content input').first().fill('批量导出书A') await page.getByRole('button', { name: '创建' }).click() await expect(page.locator('#editor-layout')).toBeVisible({ timeout: 15_000 }) await dismissCockpitIfOpen(page) await page.getByRole('button', { name: /笔临|Bilin/i }).first().click() await expect(page.locator('#home-page')).toBeVisible({ timeout: 10_000 }) await page.getByTestId('home-export-all').click() await expect(page.getByTestId('export-all-modal')).toBeVisible() await page.getByTestId('export-all-pick').click() await expect(page.getByTestId('export-all-dest')).not.toHaveValue(/未选择|No destination/) await page.getByTestId('export-all-start').click() await expect(page.getByText(/已导出|exported/i)).toBeVisible({ timeout: 30_000 }) await app.close() }) })