fix: show teacher introductions as standalone clickable bubbles

This commit is contained in:
鲨鱼辣椒 committed 2026-09-29 17:16:37 +08:00
1 parent 2922f35e4b
commit 3a175101c9
11 files changed
+43 -26

No files matched your search

+7 -4
View File
@@ -193,10 +193,13 @@ describe('individual teacher introductions', () => {
api.catalog.mockResolvedValue({ items: agents });
await mount();
const group = screen.getByTestId('teacher-welcomes');
expect(within(group).queryByText('来认识一下')).not.toBeInTheDocument();
expect(within(group).queryByRole('button', { name: '先自己试试' })).not.toBeInTheDocument();
for (const agent of agents) expect(within(group).getByText(agent.definition.description)).toBeVisible();
expect(screen.queryByTestId('teacher-invitation')).not.toBeInTheDocument();
await act(async () => fireEvent.click(screen.getByRole('button', { name: '收起体验老师的介绍' })));
expect(within(group).queryByText('体验老师的自我介绍')).not.toBeInTheDocument();
expect(screen.queryByTestId('teacher-chat-panel')).not.toBeInTheDocument();
expect(within(group).getByText('方法老师的自我介绍')).toBeVisible();
expect(within(group).getByText('故事老师的自我介绍')).toBeVisible();
await advance();
@@ -217,7 +220,7 @@ describe('individual teacher introductions', () => {
expect(screen.getByRole('button', { name: '收起体验老师的介绍' })).toBeVisible();
await act(async () => next.rerender(<Harness projectId="other" />));
expect(screen.getByRole('button', { name: '收起方法老师的介绍' })).toBeVisible();
await act(async () => fireEvent.click(screen.getByRole('button', { name: '先自己试试' })));
for (const agent of agents) await act(async () => fireEvent.click(screen.getByRole('button', { name: `收起${agent.definition.name}的介绍` })));
expect(screen.queryByTestId('teacher-welcomes')).not.toBeInTheDocument();
await act(async () => next.rerender(<Harness />));
expect(screen.queryByRole('button', { name: '收起方法老师的介绍' })).not.toBeInTheDocument();
@@ -230,7 +233,7 @@ describe('individual teacher introductions', () => {
it('opens the clicked teacher and consumes only their introduction, preserving the others for later', async () => {
api.catalog.mockResolvedValue({ items: agents });
await mount();
await act(async () => fireEvent.click(screen.getByRole('button', { name: '和故事老师聊聊' })));
await act(async () => fireEvent.click(within(screen.getByTestId('teacher-welcomes')).getByText('故事老师的自我介绍')));
expect(screen.getByRole('button', { name: '与故事老师聊天' })).toHaveAttribute('aria-pressed', 'true');
expect(screen.getByTestId('teacher-chat-panel')).toHaveTextContent('故事老师的聊天欢迎语');
expect(screen.getByTestId('teacher-chat-panel')).not.toHaveTextContent('故事老师的自我介绍');
@@ -243,11 +246,11 @@ describe('individual teacher introductions', () => {
expect(api.sendConversation).not.toHaveBeenCalled();
});
it('introduces only newly delivered teachers after dismiss-all, without resetting seen replies or existing receipts on refresh', async () => {
it('introduces only newly delivered teachers after individually dismissing every introduction, without resetting seen replies or existing receipts on refresh', async () => {
localStorage.setItem('makelore-teacher-presence:kid:seen', JSON.stringify(['keep-seen']));
api.catalog.mockResolvedValue({ items: agents });
await mount();
await act(async () => fireEvent.click(screen.getByRole('button', { name: '先自己试试' })));
for (const agent of agents) await act(async () => fireEvent.click(screen.getByRole('button', { name: `收起${agent.definition.name}的介绍` })));
const added = { ...agents[0], teacher_id: 'new', definition: { ...agents[0].definition, config_id: 'new', name: '新老师', description: '', welcome_message: '新老师的云端欢迎语' } };
api.catalog.mockResolvedValue({ items: [...agents.map(agent => ({ ...agent, version: 2 })), added] });
await act(async () => fireEvent.click(screen.getByRole('button', { name: '刷新智能体' })));