adf877861d
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>
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
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
|
|
} from './helpers'
|
|
|
|
test.describe('Export submission', () => {
|
|
let userDataDir: string
|
|
|
|
test.beforeEach(() => {
|
|
userDataDir = mkdtempSync(join(tmpdir(), 'bilin-e2e-export-'))
|
|
})
|
|
|
|
test.afterEach(() => {
|
|
if (userDataDir && existsSync(userDataDir)) {
|
|
try {
|
|
rmSync(userDataDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 })
|
|
} catch {
|
|
/* ignore */
|
|
}
|
|
}
|
|
})
|
|
|
|
test('E2E-EXPORT-01: copy submission format includes chapter heading', async () => {
|
|
const app = await launchApp(userDataDir)
|
|
const page = await app.firstWindow()
|
|
await skipOnboarding(page)
|
|
await createBookAndOpenEditor(page, '导出测试书')
|
|
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 expect(page.getByTestId('export-preview')).toContainText(/# 第\d+章/, { timeout: 10_000 })
|
|
await page.getByTestId('export-copy-clipboard').click()
|
|
await expect(page.getByText('已复制到剪贴板')).toBeVisible({ timeout: 10_000 })
|
|
|
|
await app.close()
|
|
})
|
|
})
|