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:
+33
-15
@@ -27,9 +27,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 */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +50,9 @@ async function createCharacterSetting(page: Page, name: string): Promise<void> {
|
||||
await page.getByTestId('setting-name-input').fill(name)
|
||||
await page.locator('.dialog-content select').selectOption('character')
|
||||
await page.getByRole('button', { name: '创建' }).click()
|
||||
await expect(page.getByTestId(/setting-item-/)).toContainText(name, { timeout: 10_000 })
|
||||
await expect(page.getByTestId(/setting-item-/).filter({ hasText: name })).toBeVisible({
|
||||
timeout: 10_000
|
||||
})
|
||||
}
|
||||
|
||||
test.describe('Character graph P7', () => {
|
||||
@@ -75,11 +80,15 @@ test.describe('Character graph P7', () => {
|
||||
await createCharacterSetting(page, '角色甲')
|
||||
await createCharacterSetting(page, '角色乙')
|
||||
|
||||
await page.getByText('角色甲').click()
|
||||
await page.getByTestId(/setting-item-/).filter({ hasText: '角色甲' }).click()
|
||||
await expect(page.getByTestId('setting-relationships')).toBeVisible({ timeout: 10_000 })
|
||||
await page.getByTestId('setting-relationship-add').click()
|
||||
await page.locator('.setting-relationship-form select').selectOption({ label: '角色乙' })
|
||||
await page.locator('.setting-relationship-form input[type="text"]').fill('挚友')
|
||||
await expect(page.locator('.setting-relationship-form select')).toBeVisible({ timeout: 10_000 })
|
||||
await page.locator('.setting-relationship-form select').selectOption({ index: 1 })
|
||||
await expect(page.locator('.setting-relationship-form input.form-control')).toBeVisible({
|
||||
timeout: 10_000
|
||||
})
|
||||
await page.locator('.setting-relationship-form input.form-control').fill('挚友')
|
||||
await page.locator('.setting-relationship-form .btn-primary').click()
|
||||
await expect(page.getByTestId('setting-relationships')).toContainText('挚友')
|
||||
|
||||
@@ -98,21 +107,30 @@ test.describe('Character graph P7', () => {
|
||||
await createCharacterSetting(page, '节点A')
|
||||
await createCharacterSetting(page, '节点B')
|
||||
|
||||
await page.getByText('节点A').click()
|
||||
await page.getByTestId(/setting-item-/).filter({ hasText: '节点A' }).click()
|
||||
await page.getByTestId('setting-relationship-add').click()
|
||||
await page.locator('.setting-relationship-form select').selectOption({ label: '节点B' })
|
||||
await page.locator('.setting-relationship-form input[type="text"]').fill('同门')
|
||||
await expect(page.locator('.setting-relationship-form select')).toBeVisible({ timeout: 10_000 })
|
||||
await page.locator('.setting-relationship-form select').selectOption({ index: 1 })
|
||||
await expect(page.locator('.setting-relationship-form input.form-control')).toBeVisible({
|
||||
timeout: 10_000
|
||||
})
|
||||
await page.locator('.setting-relationship-form input.form-control').fill('同门')
|
||||
await page.locator('.setting-relationship-form .btn-primary').click()
|
||||
|
||||
await page.getByTestId('setting-open-graph').click()
|
||||
await expect(page.getByTestId('character-graph-cy')).toBeVisible({ timeout: 10_000 })
|
||||
const cyBox = await page.getByTestId('character-graph-cy').boundingBox()
|
||||
expect(cyBox).toBeTruthy()
|
||||
await page.getByTestId('character-graph-cy').click({
|
||||
position: { x: (cyBox!.width ?? 200) / 2, y: (cyBox!.height ?? 200) / 2 }
|
||||
await page.evaluate(() => {
|
||||
const el = document.querySelector('[data-testid="character-graph-cy"]') as HTMLElement & {
|
||||
__bilinCy?: { nodes: () => { trigger: (e: string) => void }[] }
|
||||
}
|
||||
const cy = el?.__bilinCy
|
||||
if (!cy) throw new Error('cytoscape not ready')
|
||||
const nodes = cy.nodes()
|
||||
if (!nodes.length) throw new Error('no graph nodes')
|
||||
nodes[0]!.trigger('tap')
|
||||
})
|
||||
await expect(page.getByTestId('character-graph-sidebar')).toContainText(/节点/, {
|
||||
timeout: 5000
|
||||
await expect(page.getByTestId('character-graph-sidebar')).toContainText(/节点A|节点B/, {
|
||||
timeout: 10_000
|
||||
})
|
||||
await app.close()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user