fix: render consultation replies and typed tool activity

This commit is contained in:
brother7 committed 2026-09-24 14:36:20 +08:00
1 parent a628860144
commit 97837cef90
19 files changed
+432 -35

No files matched your search

@@ -20,6 +20,34 @@ test.beforeAll(async () => {
await server.listen(); url = server.resolvedUrls!.local[0];
});
test.afterAll(async () => { await server?.close(); });
for (const width of [319, 508]) {
test(`rich replies keep code, tables and images inside the panel at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width: 1180, height: 800 });
const errors: string[] = [];
page.on('pageerror', error => errors.push(error.message));
await page.route('https://example.com/teacher-preview.png', route => route.fulfill({
contentType: 'image/svg+xml',
body: '<svg xmlns="http://www.w3.org/2000/svg" width="900" height="250"><rect width="900" height="250" fill="#ebeedf"/><text x="30" y="130" font-size="32">Flybot project preview</text></svg>',
}));
await page.goto(`${url}?kind=rich-text&width=${width}`);
const body = page.getByTestId('teacher-reply');
await expect(body.getByRole('heading', { name: '项目建议' })).toHaveCount(1);
await expect(body.getByRole('table')).toHaveCount(1);
await expect(body.locator('.katex')).toHaveCount(1);
await expect(body.getByRole('img', { name: '项目截图' })).toBeVisible();
await expect.poll(() => body.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
await expect.poll(() => page.locator('.consultation-messages').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
const raw = page.getByText('查看收到的原始内容');
await expect(raw.locator('..')).not.toHaveAttribute('open');
await raw.click();
await expect(raw.locator('..').locator('pre')).toContainText('"tool"');
const input = page.getByRole('textbox', { name: '向智能体提问' });
await expect(input).toBeVisible();
await page.locator('.consultation-messages').evaluate(el => { el.scrollTop = 0; });
await page.screenshot({ path: test.info().outputPath(`rich-reply-${width}.png`) });
expect(errors).toEqual([]);
});
}
for (const width of [319, 508]) for (const kind of ['ordinary', 'ideas', 'structure', 'flow', 'comparison']) {
test(`${kind} pins the current tool and composer at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width: 1180, height: 800 });