Merge teacher composer actions into latest main

This commit is contained in:
鲨鱼辣椒
2026-09-29 23:36:05 +08:00
5 changed files with 95 additions and 15 deletions

View File

@@ -245,19 +245,26 @@ for (const width of [319, 508]) for (const kind of ['ordinary', 'ideas', 'struct
});
}
for (const width of [319, 508]) test(`teacher model selector and microphone fit the composer at ${width}px`, async ({ page }) => {
for (const width of [319, 508]) test(`teacher composer shows only microphone and send controls at ${width}px`, async ({ page }) => {
const savedModel = width === 508 ? 'test-second-model' : undefined;
await page.addInitScript((model) => {
localStorage.clear();
if (model) localStorage.setItem('makelore-teacher-model:fixture:coding-teacher:published', model);
}, savedModel);
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 input.fill('保留麦克风和发送按钮');
await expect(panel.getByRole('button', { name: /老师模型/ })).toHaveCount(0);
await expect(panel.getByRole('button', { name: '语音输入' })).toBeVisible();
await expect(panel.getByRole('button', { name: '提问', exact: true })).toBeEnabled();
expect(await panel.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
const controls = panel.getByTestId('teacher-composer-runtime-controls');
await expect(controls.getByRole('button')).toHaveCount(2);
await expect(controls).not.toContainText(/老师配置|模型默认|fixture|test-second-model/);
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');
expect(await page.evaluate(() => (window as unknown as { __teacherReplyInputs: Array<{text: string; modelId?: string}> }).__teacherReplyInputs.at(-1))).toMatchObject({ text: '保留麦克风和发送按钮' });
expect(await page.evaluate(() => (window as unknown as { __teacherReplyInputs: Array<{modelId?: string}> }).__teacherReplyInputs.at(-1)?.modelId)).toBe(savedModel);
});