feat(w2): ship v1.3.0 project pack UI, preload, and E2E
Wire .novel/.novel-all export-import through modals, settings backup, and home bulk export with progress IPC. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { mkdtempSync, rmSync, existsSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
import { test, expect } from '@playwright/test'
|
||||
import {
|
||||
launchApp,
|
||||
skipOnboarding,
|
||||
createBookAndOpenEditor,
|
||||
ensureChapterEditor,
|
||||
openExportModal,
|
||||
dismissCockpitIfOpen
|
||||
} from './helpers'
|
||||
|
||||
test.describe('Pack export/import', () => {
|
||||
let userDataDir: string
|
||||
let packPath: string
|
||||
|
||||
test.beforeEach(() => {
|
||||
userDataDir = mkdtempSync(join(tmpdir(), 'bilin-e2e-pack-'))
|
||||
packPath = join(userDataDir, 'roundtrip.novel')
|
||||
})
|
||||
|
||||
test.afterEach(() => {
|
||||
if (userDataDir && existsSync(userDataDir)) {
|
||||
try {
|
||||
rmSync(userDataDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 })
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('E2E-PACK-01: export .novel and re-import via UI', async () => {
|
||||
const app = await launchApp(userDataDir, {
|
||||
BILIN_E2E_PACK_SAVE: packPath,
|
||||
BILIN_E2E_PACK_IMPORT_FILE: packPath
|
||||
})
|
||||
const page = await app.firstWindow()
|
||||
await skipOnboarding(page)
|
||||
await createBookAndOpenEditor(page, 'Pack Roundtrip')
|
||||
await ensureChapterEditor(page)
|
||||
|
||||
const editor = page.locator('.ProseMirror')
|
||||
await editor.click()
|
||||
await editor.pressSequentially('项目包导出导入测试正文。')
|
||||
await page.keyboard.press('Control+S')
|
||||
await expect(page.getByText('已保存')).toBeVisible({ timeout: 10_000 })
|
||||
|
||||
await openExportModal(page)
|
||||
await page.getByTestId('export-kind-select').selectOption('novel')
|
||||
await page.getByTestId('export-novel-btn').click()
|
||||
await expect(page.getByText(/已导出/)).toBeVisible({ timeout: 15_000 })
|
||||
|
||||
await page.evaluate(async (dest) => {
|
||||
const list = await window.electronAPI.book.list()
|
||||
if (!list.ok || !list.data?.length) throw new Error('no books')
|
||||
await window.electronAPI.book.delete(list.data[0].id)
|
||||
}, packPath)
|
||||
|
||||
await page.getByRole('button', { name: /笔临|Bilin/i }).first().click()
|
||||
await expect(page.locator('#home-page')).toBeVisible({ timeout: 10_000 })
|
||||
|
||||
await page.getByTestId('home-import-book').click()
|
||||
await expect(page.getByTestId('import-book-modal')).toBeVisible()
|
||||
await page.getByTestId('import-pick-file').click()
|
||||
await expect(page.getByTestId('import-pack-hint')).toBeVisible({ timeout: 10_000 })
|
||||
await page.getByTestId('import-execute-btn').click()
|
||||
await expect(page.locator('#editor-layout')).toBeVisible({ timeout: 30_000 })
|
||||
await dismissCockpitIfOpen(page)
|
||||
await expect(page.locator('.chapter-item')).toHaveCount(1, { timeout: 15_000 })
|
||||
|
||||
await app.close()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user