mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
* refactor: Move Conversation Starters Into @librechat/chat With a Starter Button Variant The welcome screen's suggested first messages render through a package component built on a new starter Button variant instead of a raw button. The app keeps resolving which starters apply (agent, spec, assistant) and sends the chosen text. * test: Pin the Starter Variant Under the ClickHouse Reference Theme A starter takes its fill and ink from the theme roles in light and dark, so a theme that repaints the surface repaints the chip. * fix: Cap the Starter Width at the Call Site, Not in the Button Variant The Button primitive spec rejects fixed sizes in the variant recipe, so the 16rem cap moves to the package component that lays the chips out. * fix: Keep the Starter Stagger Ahead of the Unlayered Fade Rule The unlayered fade-in rule sets the animation shorthand, which resets the delay and fill mode a layered utility sets, so every chip animated at once. The variant now declares the whole animation in one utility, and the cap scenario asserts the computed delay and fill mode. * fix: Ship the Starter Fade From the Shared Tailwind Preset The starter variant referenced a keyframe that only the app stylesheet defines, so a host using the published preset would get no entrance. The keyframe and its staggered animation now live in the preset next to the loading dots, and the variant uses the animate-starter-in utility. * chore: Retest Against Current Dev
86 lines
3.6 KiB
TypeScript
86 lines
3.6 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { clickHouseTheme } from '../../../packages/client/src/theme/themes/clickhouse';
|
|
import { messagesView, NEW_CHAT_PATH, replyPrompt, replyText, selectModelSpec } from './helpers';
|
|
|
|
/** Spec with five `conversation_starters` in e2e/config/librechat.e2e.yaml; only four may render. */
|
|
const STARTER_SPEC_LABEL = 'E2E Starters';
|
|
const STARTER_PROMPTS = [
|
|
replyPrompt('starter'),
|
|
'Plan my week',
|
|
'Third starter prompt',
|
|
'Fourth starter prompt',
|
|
];
|
|
const STARTER_BEYOND_CAP = 'Fifth starter beyond the cap';
|
|
|
|
/** A spec without `conversation_starters`. */
|
|
const PLAIN_SPEC_LABEL = 'E2E Soft Default';
|
|
|
|
test.describe('model spec conversation starters', () => {
|
|
test('starter prompts render on the landing for a spec that defines them @scenario:spec-starters-render-up-to-the-cap', async ({
|
|
page,
|
|
}) => {
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
await selectModelSpec(page, STARTER_SPEC_LABEL);
|
|
|
|
for (const text of STARTER_PROMPTS) {
|
|
await expect(page.getByRole('button', { name: text })).toBeVisible();
|
|
}
|
|
await expect(page.getByRole('button', { name: STARTER_BEYOND_CAP })).toBeHidden();
|
|
|
|
/** The entrance is staggered by position: the unlayered `.fade-in` rule sets the animation
|
|
* shorthand, so a delay or fill mode that loses to it leaves every chip animating at once. */
|
|
const second = page.getByRole('button', { name: STARTER_PROMPTS[1], exact: true });
|
|
await expect(second).toHaveCSS('animation-delay', '0.075s');
|
|
await expect(second).toHaveCSS('animation-fill-mode', 'backwards');
|
|
});
|
|
|
|
test('a spec without starters shows none', async ({ page }) => {
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
await selectModelSpec(page, PLAIN_SPEC_LABEL);
|
|
|
|
for (const text of STARTER_PROMPTS) {
|
|
await expect(page.getByRole('button', { name: text })).toBeHidden();
|
|
}
|
|
});
|
|
|
|
test('clicking a starter submits it as the first message @scenario:clicking-a-starter-sends-it', async ({
|
|
page,
|
|
}) => {
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
await selectModelSpec(page, STARTER_SPEC_LABEL);
|
|
|
|
const prompt = replyPrompt('starter');
|
|
await page.getByRole('button', { name: prompt }).click();
|
|
|
|
await expect(messagesView(page).getByText(prompt)).toBeVisible({ timeout: 30000 });
|
|
await expect(messagesView(page).getByText(replyText('starter'))).toBeVisible({
|
|
timeout: 30000,
|
|
});
|
|
});
|
|
|
|
test('a starter takes its fill and ink from the theme in light and dark @scenario:starter-follows-the-reference-theme', async ({
|
|
page,
|
|
}) => {
|
|
await page.addInitScript((definition) => {
|
|
const mode = new URL(location.href).searchParams.get('e2eThemeMode');
|
|
if (mode) {
|
|
localStorage.setItem('color-theme', mode);
|
|
}
|
|
localStorage.setItem('theme-definition', JSON.stringify(definition));
|
|
localStorage.setItem('theme-source', 'definition');
|
|
}, clickHouseTheme);
|
|
|
|
for (const mode of ['light', 'dark'] as const) {
|
|
const colors = clickHouseTheme.modes[mode]?.colors ?? {};
|
|
const rgb = (key: string) => `rgb(${(colors[key] ?? '').split(' ').join(', ')})`;
|
|
await page.goto(`${NEW_CHAT_PATH}?e2eThemeMode=${mode}`, { timeout: 10000 });
|
|
await selectModelSpec(page, STARTER_SPEC_LABEL);
|
|
|
|
const starter = page.getByRole('button', { name: STARTER_PROMPTS[1], exact: true });
|
|
await expect(starter).toBeVisible();
|
|
await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse');
|
|
await expect(starter).toHaveCSS('background-color', rgb('rgb-surface-secondary'));
|
|
await expect(starter).toHaveCSS('color', rgb('rgb-text-secondary'));
|
|
}
|
|
});
|
|
});
|