Merge empty-work preview into main
This commit is contained in:
@@ -17,8 +17,17 @@ test.beforeAll(async () => {
|
||||
load(id) {
|
||||
if (id.endsWith('/src/lib/host-events.ts')) return 'export function subscribeHostEvent() { return () => {}; }';
|
||||
if (id.endsWith('/src/lib/host-api.ts')) return `
|
||||
const empty = new URLSearchParams(location.search).has('empty-work');
|
||||
const browser = { browserId: 'fixture', projectId: 'layout-fixture', state: 'attached', generation: 1, url: 'http://127.0.0.1:4173/', visible: true, bounds: null, eventCursor: 0 };
|
||||
export async function hostApiFetch(path) { return path.includes('ensure-work') ? { status: 'ready', browser } : { success: true, browser }; }
|
||||
const emptyBrowser = { ...browser, browserId: null, state: 'closed', url: '', visible: false };
|
||||
window.workPreviewChecks = 0;
|
||||
export async function hostApiFetch(path) {
|
||||
if (path.includes('ensure-work')) {
|
||||
window.workPreviewChecks += 1;
|
||||
return empty ? { status: 'empty' } : { status: 'ready', browser };
|
||||
}
|
||||
return { success: true, browser: empty ? emptyBrowser : browser };
|
||||
}
|
||||
`;
|
||||
},
|
||||
configureServer(vite) {
|
||||
@@ -35,6 +44,21 @@ test.beforeAll(async () => {
|
||||
});
|
||||
test.afterAll(async () => { await server?.close(); });
|
||||
|
||||
test('empty work shows a local hint without opening the teacher or polling', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1180, height: 720 });
|
||||
await page.clock.install();
|
||||
await page.goto(`${baseUrl}?quiet=1&empty-work=1`);
|
||||
await expect(page.getByTestId('agent-browser-viewport').getByRole('status')).toHaveText('还没有作品,快和老师聊聊吧');
|
||||
await expect(page.getByRole('button', { name: '回到操作对话' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: /再试一次|帮我检查并打开|重新打开作品/ })).toHaveCount(0);
|
||||
await expect(page.getByText('正在打开你的作品…')).toHaveCount(0);
|
||||
await expect(page.getByRole('alert')).toHaveCount(0);
|
||||
await expect(page.locator('#coding-consultation-dock')).toHaveCount(0);
|
||||
await page.clock.runFor(60_000);
|
||||
expect(await page.evaluate(() => (window as typeof window & { workPreviewChecks: number }).workPreviewChecks)).toBe(1);
|
||||
await page.screenshot({ path: test.info().outputPath('empty-work-hint.png') });
|
||||
});
|
||||
|
||||
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 });
|
||||
|
||||
Reference in New Issue
Block a user