LibreChat/e2e/specs/mock/scenarios/sidebar.ts
Danny Avila 0fdabfe283
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Backend Unit Tests / backend (push) Blocked by required conditions
Channel Gateway / gateway (push) Waiting to run
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Frontend Unit Tests / frontend (push) Blocked by required conditions
Playwright E2E Tests / Codegraph select (push) Waiting to run
Playwright E2E Tests / e2e () (push) Blocked by required conditions
Playwright E2E Tests / MCP list_changed (replica count 1) (push) Blocked by required conditions
Playwright E2E Tests / MCP list_changed (replica count 2) (push) Blocked by required conditions
Playwright E2E Tests / MCP Apps (browser and server) (push) Waiting to run
Playwright E2E Tests / e2e (push) Blocked by required conditions
Main Promotion Policy Tests / Main promotion denial and fast-forward tests (push) Waiting to run
🧪 test: Close Three Timing Gaps Behind Intermittent Mock E2E Failures (#18067)
* 👋 test: Wait for the Header Selector Before Counting Agent Names on the Greeting Landing

The greeting scenario read how many header controls named the agent with a
one-shot `count()` and then expected the same number of mentions inside
`main`. The header selector takes the agent's name after the welcome screen
paints, so when the name landed between those two reads the first said 0 and
the second saw the selector's own label, which sits inside `main`. When both
reads ran before the name landed the check passed without the selector ever
naming the agent.

Wait for the selector to show the name, then expect that label to be the only
mention inside `main`.

* 🗂️ test: Keep the Sidebar Open When Chat History Is Already Showing

On desktop `openChatHistory` clicked the Chat History rail button
unconditionally. The rail button of the panel already showing collapses the
sidebar, and Chat History is the panel every document starts on, so after the
reload in the subagent activity scenario the helper closed the conversation
list it was meant to show. The assertions that follow only passed while the
list was still mounted during the collapse.

Open the sidebar first on both layouts and press the rail button only when
another panel is showing, the guard `openPanel` already uses.

* 🚦 test: Hold the Mock Suite Until the Server Reports Ready

Playwright starts the suite once the base URL answers, which the server does
as soon as it listens. It keeps initializing after that and refuses chat
starts and schedule writes with a 503 until `/readyz` turns 200, so a spec
that runs first against a slow start got `SCHEDULES_NOT_READY`. The
two-replica wrapper already waits on `/readyz` before exposing its proxy; the
single-process server had no such gate.

Poll `/readyz` in global setup before authenticating.
2026-11-11 17:54:25 -05:00

100 lines
4.2 KiB
TypeScript

import { expect } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
/** The first candidate that is actually painted, since the rail and the drawer publish the
* same controls and the off-canvas copy answers a plain locator first. */
async function firstVisible(candidates: Locator): Promise<Locator | null> {
const count = await candidates.count();
for (let index = 0; index < count; index++) {
const candidate = candidates.nth(index);
if (await candidate.isVisible().catch(() => false)) {
return candidate;
}
}
return null;
}
/**
* Mobile keeps the conversation list in a drawer; desktop has it expanded already.
*
* Settled on the close control being painted, by its accessible name rather than a test id.
* The mobile drawer stays mounted and slides, so a test id read reports the off-canvas copy as
* present before the expanded state commits, and both earlier readings sent this helper back
* with the list still hidden behind the pane.
*/
export async function openSidebar(page: Page) {
const isOpen = async () =>
(await firstVisible(page.getByRole('button', { name: 'Close sidebar' }))) !== null;
const settles = async (budgetMs: number) => {
const deadline = Date.now() + budgetMs;
while (Date.now() < deadline) {
if (await isOpen()) {
return true;
}
await page.waitForTimeout(100);
}
return isOpen();
};
/* One click is one toggle, and the opener sits in the pane the drawer marks inert for the
whole of its travel: clicking again before that travel finishes either lands on an inert
pane and is swallowed, or closes the drawer that was just opening. So each attempt gets the
transition to itself, and a second one exists only because the very first click of a run
can arrive while the shell is still settling. */
for (let attempt = 0; attempt < 3; attempt++) {
if (await isOpen()) {
return;
}
const opener = await firstVisible(page.getByRole('button', { name: 'Open sidebar' }));
await opener?.click({ timeout: 2_000 }).catch(() => undefined);
if (await settles(5_000)) {
return;
}
}
await expect.poll(isOpen, { timeout: 5_000 }).toBe(true);
}
/** At or below the app's own \`(max-width: 768px)\` the sidebar is a drawer whose panels sit
* behind a switcher menu; above it they are buttons on the rail. */
const NARROW_MAX_WIDTH = 768;
/**
* Shows the conversation list on either layout: the rail's Chat History panel on desktop, and
* on mobile the opened drawer switched to Chat History, which a previous panel (the agent
* builder, say) may have replaced.
*/
export async function openChatHistory(page: Page) {
await openSidebar(page);
const narrow = (page.viewportSize()?.width ?? Infinity) <= NARROW_MAX_WIDTH;
if (!narrow) {
/* The rail button of the panel already showing collapses the sidebar, so it is pressed
only to switch panels. */
const trigger = page.getByRole('button', { name: 'Chat History' });
if ((await trigger.getAttribute('aria-pressed')) !== 'true') {
await trigger.click();
}
return;
}
const switcher = page.getByTestId('panel-switcher-button');
if (!(await switcher.textContent())?.includes('Chat History')) {
await switcher.click();
await page.getByRole('menuitemcheckbox', { name: 'Chat History' }).click();
}
await expect(switcher).toContainText('Chat History');
}
/** The row mounts its real menu on the first mouse enter (`Convo.tsx`). Hovering is what a
* pointer device does, but the mobile drawer cannot always offer a hoverable row, and a real
* `hover()` then waits out the whole budget. The fallback dispatches `mouseover`, which is the
* native event React derives `onMouseEnter` from, and needs the row only to be attached. */
export async function openConversationMenu(row: Locator) {
const menu = row.getByRole('button', { name: 'Conversation Menu Options' });
if (!(await menu.isVisible().catch(() => false))) {
await row.hover({ timeout: 5_000 }).catch(() => undefined);
}
if (!(await menu.isVisible().catch(() => false))) {
await row.dispatchEvent('mouseover');
}
await expect(menu).toBeAttached();
await menu.dispatchEvent('click');
}