Merge teacher composer actions into latest main
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -1074,18 +1074,23 @@ describe('merged cloud teacher classroom', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('selects a teacher model for the next send and retains it after remount', async () => {
|
||||
it('hides teacher model details while preserving an existing choice across sends and remount', async () => {
|
||||
localStorage.setItem('makelore-teacher-model:signed-out:coding-teacher:published', 'other-model');
|
||||
const view = render(<TeacherChatPanel projectId="p" sourceId="c" />);
|
||||
await ready();
|
||||
const trigger = screen.getByRole('button', { name: /老师模型/ });
|
||||
fireEvent.keyDown(trigger, { key: 'Enter' });
|
||||
fireEvent.click(await screen.findByRole('menuitemradio', { name: 'other-model' }));
|
||||
expect(screen.queryByRole('button', { name: /老师模型/ })).not.toBeInTheDocument();
|
||||
expect(screen.getByTestId('teacher-composer-runtime-controls')).not.toHaveTextContent(/other-model|qwen|老师配置|模型默认/);
|
||||
fireEvent.change(screen.getByRole('textbox', { name: '向智能体提问' }), { target: { value: '我的想法' } });
|
||||
api.send.mockResolvedValue(first);
|
||||
fireEvent.click(screen.getByRole('button', { name: '提问' }));
|
||||
await waitFor(() => expect(api.send).toHaveBeenCalledWith('p/agent-topics', 'first', expect.objectContaining({ modelId: 'other-model', text: '我的想法' })));
|
||||
view.unmount();
|
||||
render(<TeacherChatPanel projectId="p" sourceId="c" />);
|
||||
await screen.findByRole('button', { name: /老师模型:other-model/ });
|
||||
await ready();
|
||||
expect(screen.queryByRole('button', { name: /老师模型/ })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '语音输入' })).toBeInTheDocument();
|
||||
fireEvent.change(screen.getByRole('textbox', { name: '向智能体提问' }), { target: { value: '继续聊聊' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: '提问' }));
|
||||
await waitFor(() => expect(api.send).toHaveBeenLastCalledWith('p/agent-topics', 'first', expect.objectContaining({ modelId: 'other-model', text: '继续聊聊' })));
|
||||
expect(api.models).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user