feat: 在顶栏并排展示下发智能体并直接切换
This commit is contained in:
1 parent
39b03a1628
commit
a10cf00015
15 files changed
+291
-59
No files matched your search
@@ -23,7 +23,7 @@ test.beforeAll(async () => {
|
||||
},
|
||||
configureServer(vite) {
|
||||
vite.middlewares.use((req, res, next) => {
|
||||
if (req.url !== '/') return next();
|
||||
if (req.url !== '/' && !req.url?.startsWith('/?')) return next();
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
res.end('<html><head><meta charset="utf-8"></head><body><div id="root"></div><script type="module" src="/tests/e2e/fixtures/teacher-preview-layout.tsx"></script></body></html>');
|
||||
});
|
||||
@@ -35,6 +35,30 @@ test.beforeAll(async () => {
|
||||
});
|
||||
test.afterAll(async () => { await server?.close(); });
|
||||
|
||||
for (const width of [520, 1000]) {
|
||||
test(`distributed agent tabs scroll inside the title bar at ${width}px`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 800 });
|
||||
await page.goto(baseUrl + '?agents=8');
|
||||
const tabs = page.getByRole('navigation', { name: '已下发智能体' });
|
||||
await expect(tabs.getByRole('button')).toHaveCount(8);
|
||||
await expect(page.getByRole('combobox', { name: '新话题使用的智能体' })).toHaveCount(0);
|
||||
const last = tabs.getByRole('button', { name: '与智能体8聊天' });
|
||||
await last.focus();
|
||||
await last.press('Enter');
|
||||
await expect(last).toHaveAttribute('aria-pressed', 'true');
|
||||
const bounds = await page.evaluate(() => {
|
||||
const strip = document.querySelector('.consultation-agent-tabs')!;
|
||||
const controls = document.querySelector('[data-testid="window-controls"]')!;
|
||||
return { right: strip.getBoundingClientRect().right, controlsLeft: controls.getBoundingClientRect().left,
|
||||
scroll: strip.scrollLeft, documentWidth: document.documentElement.scrollWidth };
|
||||
});
|
||||
expect(bounds.right).toBeLessThanOrEqual(bounds.controlsLeft);
|
||||
expect(bounds.documentWidth).toBeLessThanOrEqual(width);
|
||||
expect(bounds.scroll).toBeGreaterThan(0);
|
||||
await page.screenshot({ path: test.info().outputPath('distributed-agents-titlebar.png') });
|
||||
});
|
||||
}
|
||||
|
||||
async function geometry(page: Page) {
|
||||
return page.evaluate(() => {
|
||||
const box = (selector: string) => document.querySelector(selector)!.getBoundingClientRect();
|
||||
|
||||
Reference in new issue
Block a user