fix: show teacher introductions as standalone clickable bubbles

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

View File

@@ -65,7 +65,7 @@ for (const width of [375, 768, 1280, 1470]) {
await page.getByTestId('community-invitation').scrollIntoViewIfNeeded();
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width);
await expect(page.getByRole('button', { name: '去作品广场逛逛' })).toBeVisible();
await teachers.getByRole('button', { name: '先自己试试' }).click();
while (await teachers.count()) await teachers.getByRole('button', { name: /^收起.*的介绍$/ }).first().click();
await heading.scrollIntoViewIfNeeded();
const composer = page.getByTestId('coding-message-composer');
await expect(composer).toBeInViewport({ ratio: 1 });
@@ -125,7 +125,7 @@ for (const width of [1280, 1470]) {
}).toBeLessThan(2);
const inputBeforeDismiss = await composer.boundingBox();
const headingBeforeDismiss = await heading.boundingBox();
await teachers.getByRole('button', { name: '先自己试试' }).click();
while (await teachers.count()) await teachers.getByRole('button', { name: /^收起.*的介绍$/ }).first().click();
await expect(composer.getByRole('textbox')).toHaveValue('保留这份草稿');
expect(await composer.boundingBox()).toEqual(inputBeforeDismiss);
expect(await heading.boundingBox()).toEqual(headingBeforeDismiss);

View File

@@ -25,7 +25,6 @@ export function Layout() {
welcomes: new URLSearchParams(location.search).has('teachers') ? agents.flatMap((agent, index) => dismissed.includes(agent.teacher_id)
? [] : [{ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index }]) : [],
dismissWelcome: (id: string) => setDismissed(values => [...values, id]),
dismissWelcomes: () => setDismissed(['0', '1']),
} as ComponentProps<typeof TeacherCompanion>['companion'];
return <div className="flex h-screen">
{new URLSearchParams(location.search).has('sidebar') && <aside data-testid="project-sidebar" className="shrink-0 border-r p-4 text-sm" style={{ width: 210, background: '#f1f6fc' }}>我的项目</aside>}

View File

@@ -33,7 +33,6 @@ export function Layout() {
welcome: null, enabled: true, loading: false, checking: false, error: null,
welcomes: welcomeMode && !open ? agents.flatMap((agent, index) => dismissed.includes(agent.teacher_id) ? [] : [{ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index % 3 }]) : [],
dismissWelcome: (id: string) => setDismissed(ids => [...new Set([...ids, id])]),
dismissWelcomes: () => setDismissed(agents.map(agent => agent.teacher_id)),
refreshing, refreshStatus,
refresh: async () => {
setRefreshing(true);

View File

@@ -2221,6 +2221,9 @@ test('teacher introductions collapse after three operation replies and remain av
await page.evaluate(() => { window.location.hash = '/chat'; });
const introductions = page.getByTestId('teacher-welcomes');
await expect(introductions.locator('.teacher-welcome-card')).toHaveCount(2);
await expect(introductions).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)');
await expect(introductions.getByText('来认识一下')).toHaveCount(0);
await expect(introductions.getByRole('button', { name: '先自己试试' })).toHaveCount(0);
const startedAt = await page.evaluate(() => Date.now());
for (let round = 1; round <= 3; round++) {
for (const status of ['running', 'idle'] as const) {

View File

@@ -41,6 +41,10 @@ for (const width of [375, 768, 1280]) {
await page.goto(baseUrl + '?agents=3&welcomes');
const group = page.getByTestId('teacher-welcomes');
await expect(group.locator('.teacher-welcome-card')).toHaveCount(3);
await expect(group).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)');
await expect(group).toHaveCSS('box-shadow', 'none');
await expect(group.getByText('来认识一下')).toHaveCount(0);
await expect(group.getByRole('button', { name: '先自己试试' })).toHaveCount(0);
await expect(group).toBeInViewport({ ratio: 1 });
for (const card of await group.locator('.teacher-welcome-card').all()) {
await expect(card).toBeInViewport({ ratio: 1 });
@@ -53,12 +57,13 @@ for (const width of [375, 768, 1280]) {
await page.screenshot({ path: test.info().outputPath(`teacher-introductions-${width}.png`) });
await group.getByRole('button', { name: '收起智能体2的介绍' }).click();
await expect(group.locator('.teacher-welcome-card')).toHaveCount(2);
await group.getByRole('button', { name: '和智能体3聊聊' }).click();
await expect(page.locator('#coding-consultation-dock')).toHaveCount(0);
await group.getByRole('button', { name: '和智能体3聊聊' }).click({ position: { x: 8, y: 8 } });
await expect(page.getByRole('button', { name: '与智能体3聊天' })).toHaveAttribute('aria-pressed', 'true');
await expect(group).toHaveCount(0);
await page.getByRole('button', { name: '关闭智能体栏' }).click();
await expect(group.locator('.teacher-welcome-card')).toHaveCount(1);
await group.getByRole('button', { name: '先自己试试' }).click();
while (await group.count()) await group.getByRole('button', { name: /^收起.*的介绍$/ }).first().click();
await expect(group).toHaveCount(0);
});
}
@@ -75,7 +80,12 @@ test('many teacher introductions remain scrollable and honor reduced motion', as
await last.scrollIntoViewIfNeeded();
await expect(last).toBeInViewport({ ratio: 1 });
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(520);
await group.getByRole('button', { name: '先自己试试' }).click();
await last.focus();
await page.keyboard.press('Enter');
await expect(page.getByRole('button', { name: '与智能体8聊天' })).toHaveAttribute('aria-pressed', 'true');
await page.getByRole('button', { name: '关闭智能体栏' }).click();
await expect(group.locator('.teacher-welcome-card')).toHaveCount(7);
while (await group.count()) await group.getByRole('button', { name: /^收起.*的介绍$/ }).first().click();
await expect(group).toHaveCount(0);
});