guanghu/tests/smoke/fix-ai-chat-empty-body-v3.spec.ts
冰朔 8739805f99
Some checks failed
Auto-update PR branches / Update open PR branches (push) Has been cancelled
CI / Frontend Static Quality Checks (push) Has been cancelled
CI / Frontend Tests & Coverage (push) Has been cancelled
CI / Rust Tests & Quality Checks (push) Has been cancelled
CI / Linux build verification (push) Has been cancelled
Release (Alpha) / Compute alpha version (push) Has been cancelled
Release (Alpha) / Build release artifacts (push) Has been cancelled
Release (Alpha) / GitHub Release (alpha) (push) Has been cancelled
Release (Alpha) / Update docs and release pages (push) Has been cancelled
Deploy docs / Build VitePress site (push) Has been cancelled
Deploy docs / Deploy to GitHub Pages (push) Has been cancelled
光湖开源源码快照 · Tolaria AGPL 分叉基线 · 独立更新链
2026-07-05 17:45:16 +08:00

41 lines
1.8 KiB
TypeScript

import { test, expect } from '@playwright/test'
import { installMockAiAgent } from './helpers'
test.describe('AI chat empty body fix — no regression', () => {
test.beforeEach(async ({ page }) => {
await installMockAiAgent(page)
await page.route('**/api/vault/ping', route => route.fulfill({ status: 503 }))
await page.goto('/', { waitUntil: 'domcontentloaded' })
await expect(page.locator('[data-testid="note-list-container"]')).toBeVisible({ timeout: 5_000 })
})
test('AI panel opens, note is selected, message can be sent and response renders', async ({ page }) => {
// Select a note so the AI panel has context
const noteItem = page.locator('.app__note-list .cursor-pointer').first()
await noteItem.click()
// Verify editor has content (note body is loaded)
const editor = page.locator('.bn-editor')
await expect(editor).toBeVisible({ timeout: 3000 })
// Open the AI panel from the editor toolbar
await page.getByRole('button', { name: 'Open the AI panel' }).click()
await expect(page.getByTestId('ai-workspace')).toBeVisible({ timeout: 3000 })
await expect(page.getByTestId('ai-panel')).toBeVisible({ timeout: 3000 })
await expect(page.getByTestId('ai-workspace-target-trigger')).toBeVisible()
await expect(page.getByTestId('ai-workspace-permission-trigger')).toBeVisible()
// Send a message
const input = page.getByTestId('agent-input')
await expect(input).toBeVisible()
await input.fill('What does this note contain?')
await page.getByTestId('agent-send').click()
// Wait for mock AI response to render (mock returns fixed text after 300ms)
await expect(page.getByTestId('ai-message').first()).toBeVisible({ timeout: 5000 })
// Verify the response text is rendered (mock includes wikilinks)
await expect(page.getByTestId('ai-message').first()).not.toBeEmpty()
})
})