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:
@@ -30,9 +30,12 @@ async function skipOnboarding(page: Page): Promise<void> {
|
||||
|
||||
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()
|
||||
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 */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +48,7 @@ async function createAndOpenBook(page: Page, name: string): Promise<void> {
|
||||
}
|
||||
|
||||
async function ensureChapterEditor(page: Page): Promise<void> {
|
||||
await dismissCockpitIfOpen(page)
|
||||
const items = page.locator('.chapter-item')
|
||||
if ((await items.count()) === 0) {
|
||||
await page.getByRole('button', { name: '+ 新章' }).click()
|
||||
@@ -88,17 +92,18 @@ test.describe('Writing goals P5.3', () => {
|
||||
await createAndOpenBook(page, '目标测试书')
|
||||
await ensureChapterEditor(page)
|
||||
|
||||
await page.getByRole('button', { name: '设置' }).click()
|
||||
await page.locator('[data-testid="settings-daily-word-goal"]').fill('100')
|
||||
await page.getByRole('button', { name: '书籍' }).click()
|
||||
await page.getByTestId('topbar-settings').click()
|
||||
await expect(page.locator('#settings-page')).toBeVisible({ timeout: 10_000 })
|
||||
await page.locator('[data-testid="settings-daily-word-goal"]').fill('30')
|
||||
await page.getByRole('button', { name: '目标测试书' }).click()
|
||||
await ensureChapterEditor(page)
|
||||
|
||||
const editor = page.locator('.ProseMirror')
|
||||
await editor.click()
|
||||
await editor.pressSequentially(
|
||||
'这是一段用于测试每日写作目标达标的示例文字,需要足够长度才能触发字数统计与达标提醒通知。'
|
||||
'这是一段用于测试每日写作目标达标的示例文字,需要足够长度才能触发字数统计与达标提醒通知。继续书写更多内容以确保超过三十字的目标阈值。'
|
||||
)
|
||||
await page.waitForTimeout(1500)
|
||||
await page.waitForTimeout(2500)
|
||||
|
||||
await expect(page.locator('[data-testid="status-daily-goal"].goal-met')).toBeVisible({
|
||||
timeout: 15_000
|
||||
|
||||
Reference in New Issue
Block a user