feat: ship v1.1.0 writer toolkit with templates, import, export, and inspiration capture
Implement chapter templates, txt/md/docx import, submission export presets, and global inspiration shortcut. Split import handlers into a separate main bundle and fix EditorLayout setTarget loop that broke E2E. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { mkdtempSync, rmSync, existsSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
import { test, expect } from '@playwright/test'
|
||||
import { launchApp, skipOnboarding, ROOT, dismissCockpitIfOpen } from './helpers'
|
||||
|
||||
const FIXTURE = join(ROOT, 'tests/fixtures/import-three-chapters.txt')
|
||||
|
||||
test.describe('Import book', () => {
|
||||
let userDataDir: string
|
||||
|
||||
test.beforeEach(() => {
|
||||
userDataDir = mkdtempSync(join(tmpdir(), 'bilin-e2e-import-'))
|
||||
})
|
||||
|
||||
test.afterEach(() => {
|
||||
if (userDataDir && existsSync(userDataDir)) {
|
||||
try {
|
||||
rmSync(userDataDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 })
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('E2E-IMPORT-01: import txt creates book with multiple chapters', async () => {
|
||||
const app = await launchApp(userDataDir, { BILIN_E2E_IMPORT_FILE: FIXTURE })
|
||||
const page = await app.firstWindow()
|
||||
await skipOnboarding(page)
|
||||
|
||||
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-file-path')).not.toHaveValue(/未选择|No file/)
|
||||
await page.getByTestId('import-book-name').fill('导入E2E书')
|
||||
await page.getByTestId('import-preview-btn').click()
|
||||
await expect(page.getByTestId('import-preview')).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(3, { timeout: 15_000 })
|
||||
|
||||
await app.close()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user