fix(test): stabilize E2E cockpit flow and add LM Studio novel integration test

Harden cockpit dismiss timing and global settings navigation in E2E helpers, tune short-chapter AI prompts for local models, fix electron-updater CJS loading, and add a 10-chapter auto-writing integration test against LM Studio.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-09 14:03:19 +08:00
parent fe421ffc55
commit 8e5045b882
24 changed files with 425 additions and 70 deletions
+21 -5
View File
@@ -20,7 +20,19 @@ async function skipOnboarding(page: Page): Promise<void> {
}
}
async function dismissCockpitIfOpen(page: Page): Promise<void> {
const cockpit = page.locator('[data-testid="cockpit-modal"]')
try {
await cockpit.waitFor({ state: 'visible', timeout: 15_000 })
await cockpit.locator('.modal-close').click()
await expect(cockpit).toBeHidden({ timeout: 5000 })
} catch {
/* cockpit did not open */
}
}
async function ensureChapterEditor(page: Page): Promise<void> {
await dismissCockpitIfOpen(page)
await page.getByRole('button', { name: '+ 新章' }).click()
await expect(page.locator('.ProseMirror')).toBeVisible({ timeout: 10_000 })
}
@@ -30,6 +42,7 @@ async function openBookWithContent(page: Page): Promise<void> {
await page.locator('.dialog-content input').first().fill('交互测试书')
await page.getByRole('button', { name: '创建' }).click()
await expect(page.locator('#editor-layout')).toBeVisible({ timeout: 15_000 })
await dismissCockpitIfOpen(page)
await ensureChapterEditor(page)
const editor = page.locator('.ProseMirror')
await editor.click()
@@ -39,6 +52,7 @@ async function openBookWithContent(page: Page): Promise<void> {
}
test.describe('Interactive writing', () => {
test.describe.configure({ retries: 1 })
let userDataDir: string
test.beforeEach(() => {
@@ -63,13 +77,14 @@ test.describe('Interactive writing', () => {
await page.locator('.dialog-content input').first().fill('空书')
await page.getByRole('button', { name: '创建' }).click()
await expect(page.locator('#editor-layout')).toBeVisible({ timeout: 15_000 })
await dismissCockpitIfOpen(page)
await page.getByTestId('panel-tab-ai').click()
await expect(page.getByTestId('ai-mode-tab-interactive')).toBeDisabled({ timeout: 10_000 })
await app.close()
})
test('E2E-INT-01: interactive flow creates chapter', async () => {
test.setTimeout(300_000)
test.setTimeout(600_000)
const app = await launchApp(userDataDir)
const page = await app.firstWindow()
await skipOnboarding(page)
@@ -85,21 +100,21 @@ test.describe('Interactive writing', () => {
await page.getByTestId('interactive-confirm-plot').click()
const naming0 = page.getByTestId('naming-option-0')
const acceptBtn = page.getByTestId('interactive-accept-scene')
await expect(naming0.or(acceptBtn)).toBeVisible({ timeout: 120_000 })
await expect(naming0.or(acceptBtn)).toBeVisible({ timeout: 240_000 })
if (await naming0.isVisible()) {
await naming0.click()
await expect(acceptBtn).toBeVisible({ timeout: 120_000 })
await expect(acceptBtn).toBeVisible({ timeout: 240_000 })
}
await acceptBtn.click()
const finishBtn = page.getByTestId('interactive-finish-chapter')
await expect(finishBtn).toBeVisible({ timeout: 120_000 })
await expect(finishBtn).toBeEnabled({ timeout: 240_000 })
await finishBtn.click()
await expect(page.locator('.ProseMirror')).not.toBeEmpty({ timeout: 30_000 })
await app.close()
})
test('E2E-INT-03: restores flow after restart', async () => {
test.setTimeout(300_000)
test.setTimeout(600_000)
const app1 = await launchApp(userDataDir)
const page1 = await app1.firstWindow()
await skipOnboarding(page1)
@@ -129,6 +144,7 @@ test.describe('Interactive writing', () => {
await skipOnboarding(page2)
await page2.getByText('交互测试书').click()
await expect(page2.locator('#editor-layout')).toBeVisible({ timeout: 15_000 })
await dismissCockpitIfOpen(page2)
await page2.getByTestId('panel-tab-ai').click()
await expect(page2.getByTestId('ai-session-select')).not.toHaveValue('', { timeout: 10_000 })
await page2.getByTestId('ai-session-select').selectOption(sessionValue)