Merge teacher composer and compact prompt UI into main
This commit is contained in:
@@ -29,7 +29,7 @@ test('retry stickers stay readable and preserve drafts in a 319px consultation',
|
||||
const panel = page.getByTestId('teacher-chat-panel');
|
||||
const retry = panel.locator('.consultation-retry');
|
||||
await expect(retry).toBeEnabled();
|
||||
await expect(retry).toHaveText('继续看看👀');
|
||||
await expect(retry).toHaveText('帮我整体看🧠');
|
||||
expect(await retry.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
|
||||
const [panelBounds, retryBounds] = await Promise.all([panel.boundingBox(), retry.boundingBox()]);
|
||||
expect(retryBounds!.x).toBeGreaterThanOrEqual(panelBounds!.x);
|
||||
@@ -41,7 +41,7 @@ test('retry stickers stay readable and preserve drafts in a 319px consultation',
|
||||
await expect(page.getByText('我们可以先从一个小地方开始。')).toBeVisible();
|
||||
await expect(input).toHaveValue('我还有一点自己的想法');
|
||||
expect(await page.evaluate(() => (window as unknown as { __teacherReplyInputs: unknown[] }).__teacherReplyInputs)).toEqual([
|
||||
{ requestId: expect.any(String), text: '继续看看👀', intent: 'suggestions', references: [], projectId: 'fixture', sourceConversationId: 'source' },
|
||||
{ requestId: expect.any(String), text: '帮我整体看🧠', intent: 'suggestions', references: [], projectId: 'fixture', sourceConversationId: 'source' },
|
||||
]);
|
||||
}
|
||||
});
|
||||
@@ -56,6 +56,28 @@ for (const width of [319, 508]) {
|
||||
await expect(shortcuts.first()).toHaveText('看看进展');
|
||||
await expect(shortcuts.nth(1)).toHaveText('解释代码');
|
||||
await expect(shortcuts.nth(1)).toBeEnabled();
|
||||
const row = panel.getByRole('group', { name: '快捷提问' });
|
||||
const composer = panel.locator('.consultation-composer');
|
||||
await expect(composer.locator('.consultation-hint')).toHaveCount(0);
|
||||
await expect(shortcuts.first()).toHaveCSS('font-size', await panel.getByTestId('teacher-reply').first().evaluate(el => getComputedStyle(el).fontSize));
|
||||
await expect(shortcuts.first()).toHaveCSS('font-weight', '400');
|
||||
await expect(shortcuts.first()).toHaveCSS('border-top-width', '0px');
|
||||
await expect(shortcuts.first()).not.toHaveCSS('box-shadow', 'none');
|
||||
expect((await row.boundingBox())!.y + (await row.boundingBox())!.height).toBeLessThan((await composer.boundingBox())!.y);
|
||||
await shortcuts.first().focus();
|
||||
await expect(shortcuts.first()).toHaveCSS('outline-style', 'solid');
|
||||
await expect(shortcuts.first()).toHaveCSS('cursor', 'pointer');
|
||||
await shortcuts.first().hover();
|
||||
await expect(shortcuts.first()).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, -1)');
|
||||
await page.mouse.down();
|
||||
await expect(shortcuts.first()).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, 1)');
|
||||
await page.mouse.move(0, 0);
|
||||
await page.mouse.up();
|
||||
await page.emulateMedia({ reducedMotion: 'reduce' });
|
||||
await shortcuts.first().hover();
|
||||
await expect(shortcuts.first()).toHaveCSS('transform', 'none');
|
||||
await page.mouse.move(0, 0);
|
||||
await page.emulateMedia({ reducedMotion: 'no-preference' });
|
||||
const form = (await panel.locator('form').boundingBox())!;
|
||||
expect(form.y + form.height).toBeLessThanOrEqual(800);
|
||||
expect(await panel.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
|
||||
@@ -118,13 +140,14 @@ for (const width of [319, 508]) {
|
||||
const send = page.getByRole('button', { name: '提问', exact: true });
|
||||
const sent = () => page.evaluate(() => (window as unknown as { __teacherReplyInputs: unknown[] }).__teacherReplyInputs);
|
||||
await expect(hint).toBeEnabled();
|
||||
await expect(hint).toHaveText('继续看看👀');
|
||||
await expect(hint).toHaveCSS('background-color', 'rgb(255, 242, 201)');
|
||||
await expect(hint).toHaveText('帮我整体看🧠');
|
||||
expect(await hint.evaluate(el => el.scrollWidth <= el.clientWidth && el.scrollHeight <= el.clientHeight)).toBe(true);
|
||||
await expect(hint).toHaveCSS('background-color', 'rgb(248, 230, 183)');
|
||||
const initialSend = (await send.boundingBox())!;
|
||||
const hintBounds = (await hint.boundingBox())!;
|
||||
expect(hintBounds.x).toBeLessThan(initialSend.x);
|
||||
expect(hintBounds.height).toBeGreaterThanOrEqual(44);
|
||||
expect(hintBounds.x + hintBounds.width).toBeLessThanOrEqual(initialSend.x);
|
||||
expect(hintBounds.height).toBe(30);
|
||||
expect(hintBounds.y + hintBounds.height).toBeLessThan((await page.locator('.consultation-composer').boundingBox())!.y);
|
||||
await page.getByTestId('teacher-chat-panel').screenshot({ path: test.info().outputPath(`composer-hint-${width}.png`) });
|
||||
expect(await sent()).toEqual([]);
|
||||
await input.fill('我想先自己说说');
|
||||
@@ -138,9 +161,9 @@ for (const width of [319, 508]) {
|
||||
expect(await sent()).toEqual([]);
|
||||
await hint.click();
|
||||
await expect(page.getByText('我们可以先从一个小地方开始。')).toBeVisible();
|
||||
expect(await sent()).toEqual([{ requestId: expect.any(String), text: '继续看看👀', intent: 'suggestions', references: [], projectId: 'fixture', sourceConversationId: 'source' }]);
|
||||
expect(await sent()).toEqual([{ requestId: expect.any(String), text: '帮我整体看🧠', intent: 'suggestions', references: [], projectId: 'fixture', sourceConversationId: 'source' }]);
|
||||
await expect(page.getByRole('button', { name: '我也说不清,你带我看看', exact: true })).toHaveCount(0);
|
||||
await expect(page.locator('.consultation-messages').getByRole('button', { name: '继续看看👀', exact: true })).toHaveCount(0);
|
||||
await expect(page.locator('.consultation-messages').getByRole('button', { name: '帮我整体看🧠', exact: true })).toHaveCount(0);
|
||||
const card = page.getByRole('button', { name: '可以从哪个小地方开始?' });
|
||||
await expect(card).toBeVisible();
|
||||
await input.fill('留着我自己的草稿');
|
||||
@@ -200,6 +223,10 @@ for (const width of [319, 508]) for (const kind of ['ordinary', 'ideas', 'struct
|
||||
await input.fill('保留我的草稿');
|
||||
const card = page.getByRole('button', { name: '有什么好玩的想法?' });
|
||||
await expect(card).toBeVisible();
|
||||
await expect(card).toHaveCSS('font-size', '14px');
|
||||
await expect(card).toHaveCSS('padding', '10px 12px');
|
||||
await expect(card.locator('svg')).toHaveCSS('width', '14px');
|
||||
expect((await card.boundingBox())!.height).toBeGreaterThanOrEqual(44);
|
||||
expect(await card.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
|
||||
await card.click();
|
||||
await expect(page.getByText('好,我们就从这一个问题聊起。')).toBeVisible();
|
||||
@@ -217,3 +244,20 @@ for (const width of [319, 508]) for (const kind of ['ordinary', 'ideas', 'struct
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
for (const width of [319, 508]) test(`teacher model selector and microphone fit the composer at ${width}px`, async ({ page }) => {
|
||||
await page.goto(`${url}?kind=rich-text&width=${width}`);
|
||||
const panel = page.getByTestId('teacher-chat-panel');
|
||||
const input = page.getByRole('textbox', { name: '向智能体提问' });
|
||||
await input.fill('语音和选模测试草稿');
|
||||
await panel.getByRole('button', { name: /老师模型/ }).click();
|
||||
await page.getByRole('menuitemradio', { name: 'test-second-model' }).click();
|
||||
await expect(input).toHaveValue('语音和选模测试草稿');
|
||||
await expect(panel.getByRole('button', { name: '语音输入' })).toBeVisible();
|
||||
expect(await panel.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
|
||||
const controls = panel.getByTestId('teacher-composer-runtime-controls');
|
||||
expect(await controls.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
|
||||
await panel.screenshot({ path: test.info().outputPath(`teacher-composer-${width}.png`) });
|
||||
await panel.getByRole('button', { name: '提问', exact: true }).click();
|
||||
expect(await page.evaluate(() => (window as unknown as { __teacherReplyInputs: Array<{modelId?: string}> }).__teacherReplyInputs.at(-1)?.modelId)).toBe('test-second-model');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user