mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
Adds an opt-in showOnLanding flag to model specs. When set, the chat landing shows the spec's label and description in place of the time-of-day greeting; specs without the flag are unaffected, so existing deployments see no behavior change. HTML-valued descriptions (inline icons + markup) render sanitized via the shared config-HTML sanitizer with a new media tag/attribute allowlist, both on the landing and in model selector items. Excludes e2e specs from the typed client lint block so staged e2e files no longer fail pre-commit with 'file not found in project'.
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { getPrimaryE2EUser } from '../../setup/users.mock';
|
|
import { NEW_CHAT_PATH, selectModelSpec } from './helpers';
|
|
|
|
/** Spec with `showOnLanding: true` and an HTML `description` in e2e/config/librechat.e2e.yaml. */
|
|
const BRANDED_SPEC = {
|
|
label: 'E2E Branded',
|
|
descriptionText: 'Branded answers',
|
|
descriptionIcon: '/assets/openai.svg',
|
|
};
|
|
|
|
/** The `softDefault: true` spec does not set `showOnLanding`, so it is unbranded. */
|
|
const UNBRANDED_SPEC_LABEL = 'E2E Soft Default';
|
|
|
|
test.describe('model spec branding on landing', () => {
|
|
test('branded spec replaces the greeting with its label and rendered description', async ({
|
|
page,
|
|
}) => {
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
await selectModelSpec(page, BRANDED_SPEC.label);
|
|
|
|
const main = page.getByRole('main');
|
|
await expect(main).toContainText(BRANDED_SPEC.label);
|
|
await expect(main).toContainText(BRANDED_SPEC.descriptionText);
|
|
await expect(main.locator(`img[src$="${BRANDED_SPEC.descriptionIcon}"]`)).toBeVisible();
|
|
|
|
const user = getPrimaryE2EUser();
|
|
await expect(main).not.toContainText(user.name);
|
|
});
|
|
|
|
test('unbranded spec keeps the personalized greeting', async ({ page }) => {
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
await selectModelSpec(page, UNBRANDED_SPEC_LABEL);
|
|
|
|
const user = getPrimaryE2EUser();
|
|
await expect(page.getByRole('main')).toContainText(user.name);
|
|
});
|
|
|
|
test('branded spec renders its description in the model selector', async ({ page }) => {
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
|
|
await page.getByRole('button', { name: 'Select a model' }).first().click();
|
|
const option = page.getByRole('option', { name: new RegExp(BRANDED_SPEC.label) });
|
|
await expect(option).toContainText(BRANDED_SPEC.descriptionText);
|
|
await expect(option.locator(`img[src$="${BRANDED_SPEC.descriptionIcon}"]`)).toBeVisible();
|
|
});
|
|
});
|