Merge preview toolbar and icon-only teacher refresh

This commit is contained in:
鲨鱼辣椒 committed 2026-09-30 12:55:41 +08:00
commit 0a6ab29e9f
11 files changed
+334 -36

No files matched your search

+33 -1
View File
@@ -2612,6 +2612,29 @@ test('work tab prepares the page automatically and keeps the student draft throu
await expect(page.getByRole('button', { name: '收起作品', exact: true })).toHaveCount(0);
await expect(page.getByTestId('agent-browser-viewport')).toBeVisible();
await expect(page.getByText('正在打开你的作品…', { exact: true })).toHaveCount(0);
const workspaceToolbar = page.getByTestId('classroom-workspace-toolbar');
const tabs = workspaceToolbar.getByRole('tablist', { name: '当前工作' });
const browserToolbar = page.getByTestId('agent-browser-toolbar');
const address = browserToolbar.getByRole('textbox', { name: '网页地址' });
const workTab = tabs.getByRole('tab', { name: '作品', exact: true });
const chatTab = tabs.getByRole('tab', { name: '操作对话', exact: true });
await expect(workspaceToolbar.getByTestId('agent-browser-toolbar')).toHaveCount(1);
await expect(browserToolbar).toHaveAccessibleName('网页导航');
await expect(tabs.getByTestId('agent-browser-toolbar')).toHaveCount(0);
await expect(page.getByTestId('agent-browser-panel').getByTestId('agent-browser-toolbar')).toHaveCount(0);
const [tabsBounds, toolbarBounds] = await Promise.all([tabs.boundingBox(), browserToolbar.boundingBox()]);
expect(tabsBounds).not.toBeNull();
expect(toolbarBounds).not.toBeNull();
expect(toolbarBounds!.x).toBeGreaterThanOrEqual(tabsBounds!.x + tabsBounds!.width);
expect(Math.abs(toolbarBounds!.y + toolbarBounds!.height / 2 - tabsBounds!.y - tabsBounds!.height / 2)).toBeLessThanOrEqual(1);
await address.press('ArrowLeft');
await expect(address).toBeFocused();
await expect(workTab).toHaveAttribute('aria-selected', 'true');
await browserToolbar.getByRole('button', { name: '刷新网页', exact: true }).click();
await expect.poll(async () => (await readState(electronApp)).captured.filter((item) => item.path === '/api/agent-browser/navigate' && item.body?.action === 'reload').length).toBe(1);
await expect(browserToolbar.getByRole('button', { name: '刷新网页', exact: true })).toBeEnabled();
await expect(address).toHaveValue('http://127.0.0.1:4173/');
await page.screenshot({ path: test.info().outputPath('work-toolbar-with-tabs.png') });
// A manual address open must not permanently disable recovery checks.
await page.getByRole('textbox', { name: '网页地址' }).fill('http://127.0.0.1:4173/');
await page.getByRole('textbox', { name: '网页地址' }).press('Enter');
@@ -2632,8 +2655,17 @@ test('work tab prepares the page automatically and keeps the student draft throu
await expect(page.getByRole('button', { name: '刷新网页', exact: true })).toBeEnabled();
await expect(page.getByText('正在打开你的作品…', { exact: true })).toHaveCount(0);
await expect(page.getByText('开发浏览器已关闭。', { exact: true })).toHaveCount(0);
await page.getByRole('tab', { name: '操作对话', exact: true }).click();
await workTab.focus();
await workTab.press('ArrowLeft');
await expect(chatTab).toHaveAttribute('aria-selected', 'true');
await expect(chatTab).toBeFocused();
await expect(browserToolbar).toHaveCount(0);
await expect(composer).toHaveValue('还没有发出的想法');
await chatTab.press('ArrowRight');
await expect(workTab).toHaveAttribute('aria-selected', 'true');
await expect(workTab).toBeFocused();
await expect(workspaceToolbar.getByTestId('agent-browser-toolbar')).toBeVisible();
await expect(address).toHaveValue('http://127.0.0.1:4173/');
const requests = (await readState(electronApp)).captured;
const opens = requests.filter((request) => request.path === '/api/agent-browser/ensure-work');
expect(opens.length).toBeGreaterThanOrEqual(2);