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,63 @@
|
||||
import path from 'path'
|
||||
import { _electron as electron, type ElectronApplication, type Page, expect } from '@playwright/test'
|
||||
|
||||
export const ROOT = path.join(import.meta.dirname, '..')
|
||||
|
||||
export async function launchApp(
|
||||
userDataDir: string,
|
||||
extraEnv: Record<string, string> = {}
|
||||
): Promise<ElectronApplication> {
|
||||
return electron.launch({
|
||||
args: [ROOT],
|
||||
env: { ...process.env, BILIN_E2E: '1', BILIN_E2E_USER_DATA: userDataDir, ...extraEnv }
|
||||
})
|
||||
}
|
||||
|
||||
export async function skipOnboarding(page: Page): Promise<void> {
|
||||
await page.waitForLoadState('domcontentloaded')
|
||||
await expect(page.locator('#app')).toBeVisible({ timeout: 20_000 })
|
||||
if (await page.getByText('欢迎使用笔临').isVisible()) {
|
||||
await page.getByRole('button', { name: '跳过' }).click()
|
||||
}
|
||||
}
|
||||
|
||||
export async function dismissCockpitIfOpen(page: Page): Promise<void> {
|
||||
const cockpit = page.locator('[data-testid="cockpit-modal"]')
|
||||
if (await cockpit.isVisible({ timeout: 3000 }).catch(() => false)) {
|
||||
await page.locator('[data-testid="cockpit-modal"] .modal-close').click()
|
||||
await expect(cockpit).toBeHidden({ timeout: 5000 })
|
||||
}
|
||||
}
|
||||
|
||||
export async function createBookAndOpenEditor(page: Page, name: string): Promise<void> {
|
||||
await page.getByRole('button', { name: /新建书籍/ }).first().click()
|
||||
await page.locator('.dialog-content input').first().fill(name)
|
||||
await page.getByRole('button', { name: '创建' }).click()
|
||||
await expect(page.locator('#editor-layout')).toBeVisible({ timeout: 15_000 })
|
||||
await dismissCockpitIfOpen(page)
|
||||
}
|
||||
|
||||
export async function ensureChapterEditor(page: Page): Promise<void> {
|
||||
const editor = page.locator('.ProseMirror')
|
||||
if (await editor.isVisible().catch(() => false)) return
|
||||
await page.getByRole('button', { name: '+ 新章' }).click()
|
||||
await expect(editor).toBeVisible({ timeout: 10_000 })
|
||||
}
|
||||
|
||||
export async function openInspirationModal(page: Page): Promise<void> {
|
||||
await page.keyboard.press('Control+Shift+I')
|
||||
const modal = page.getByTestId('inspiration-modal')
|
||||
if (!(await modal.isVisible().catch(() => false))) {
|
||||
await page.evaluate(() => window.dispatchEvent(new Event('bilin:e2e-capture-inspiration')))
|
||||
}
|
||||
await expect(modal).toBeVisible({ timeout: 10_000 })
|
||||
}
|
||||
|
||||
export async function openExportModal(page: Page): Promise<void> {
|
||||
await page.keyboard.press('Control+Shift+E')
|
||||
const modal = page.getByTestId('export-modal')
|
||||
if (!(await modal.isVisible().catch(() => false))) {
|
||||
await page.getByTestId('open-export').click()
|
||||
}
|
||||
await expect(modal).toBeVisible({ timeout: 10_000 })
|
||||
}
|
||||
Reference in New Issue
Block a user