🧪 test: Release Route Handlers Before Mock Spec Contexts Close (#18064)

A route handler that calls `route.fetch()` can still be running when its test returns. Closing the browser context disposes the fetched response, the handler throws `Response has been disposed`, and Playwright reports that against a test whose assertions had all passed. With `failOnFlakyTests` on, that fails the shard.

Specs that answer requests through `route.fetch()` now take `test` from `e2e/specs/mock/fixtures.ts`. Its `context` fixture detaches the routes on the context and its pages with `unrouteAll({ behavior: 'ignoreErrors' })` before Playwright closes it; contexts a spec opens itself close through `closeContext`.

`ignoreErrors` rather than `wait`: a wait never ends for a handler parked on a promise the test leaves unsettled, and with two handlers in flight Playwright stops intercepting when the first finishes and continues the other request itself, so the second handler's `route.fulfill()` throws `Route is already handled!`.
This commit is contained in:
Danny Avila 2026-11-11 16:23:44 -05:00 • committed by GitHub
parent 947a370129
commit bbd4117928
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
70 changed files with 216 additions and 88 deletions

View file

@ -121,6 +121,17 @@ done
node .github/scripts/playwright-shards.mjs record --out e2e/timings.mock.json /tmp/e2e-reports/*
```
## Route handlers that fetch
A mock spec whose route handler calls `route.fetch()` takes `test` and `expect` from
`e2e/specs/mock/fixtures.ts` instead of `@playwright/test`. Closing a browser context disposes the
responses its handlers fetched, so a handler the app triggered just before the test returned
throws `Response has been disposed` and fails a test that had already passed, which
`failOnFlakyTests` turns into a failed shard. The fixture's `context` detaches the routes on the
context and its pages before Playwright closes it, and what a detached handler throws afterwards
is ignored. A context the spec opens itself with `browser.newContext()` closes through
`closeContext(context)` from the same module.
## Property-based browser testing
Bombadil explores randomized sequences across the core chat loop, message branches,

View file

@ -1,9 +1,9 @@
import { expect, test } from '@playwright/test';
import type { APIRequestContext } from '@playwright/test';
import type { User } from '../../types';
import { getSecondaryE2EUser } from '../../setup/users.mock';
import cleanupUser from '../../setup/cleanupUser';
import { NEW_CHAT_PATH } from './helpers';
import { expect, test } from './fixtures';
type AuthRecoveryTestEvent = {
type: string;

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import {
conversationRow,
@ -12,6 +11,7 @@ import {
sendMessageAndWaitForCompletion,
} from './helpers';
import { openSidebar } from './scenarios/sidebar';
import { expect, test } from './fixtures';
function uniqueLabel(prefix: string) {
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;

View file

@ -0,0 +1,77 @@
import type { Page, Route } from '@playwright/test';
import { closeContext, expect, test } from './fixtures';
const CONFIG_PATH = '/api/config';
/** Asks for the config from the page without waiting for the answer, as the app's own refetch does. */
async function requestConfig(page: Page) {
await page.evaluate((path) => {
void fetch(path);
}, CONFIG_PATH);
}
/**
* A handler that has fetched its response and reads the body only once `closed` settles, which is
* the order a handler racing the end of a test runs in. `failure` settles with what it threw.
*/
function readAfterClose(closed: Promise<void>) {
const fetched = Promise.withResolvers<void>();
const failure = Promise.withResolvers<unknown>();
const handler = async (route: Route) => {
const response = await route.fetch();
fetched.resolve();
await closed;
try {
await response.json();
} catch (error) {
failure.resolve(error);
throw error;
}
};
return { handler, fetched: fetched.promise, failure: failure.promise };
}
test.describe('route teardown', () => {
test('a handler reading its fetched response after the test context closed does not fail the test', async ({
page,
context,
}) => {
await page.goto(CONFIG_PATH);
const closed = Promise.withResolvers<void>();
context.on('close', () => closed.resolve());
const { handler, fetched } = readAfterClose(closed.promise);
await page.route(`**${CONFIG_PATH}`, handler);
await requestConfig(page);
await fetched;
});
test('a handler reading its fetched response after a spec-opened context closed does not fail the test', async ({
browser,
baseURL,
}) => {
const profile = await browser.newContext({ baseURL });
const page = await profile.newPage();
await page.goto(CONFIG_PATH);
const closed = Promise.withResolvers<void>();
const { handler, fetched, failure } = readAfterClose(closed.promise);
await page.route(`**${CONFIG_PATH}`, handler);
await requestConfig(page);
await fetched;
await closeContext(profile);
closed.resolve();
/** The handler did throw; only the report against this test is gone. */
expect(String(await failure)).toContain('Response has been disposed');
});
test('a handler that never returns does not hold the teardown', async ({ page }) => {
await page.goto(CONFIG_PATH);
const entered = Promise.withResolvers<void>();
await page.route(`**${CONFIG_PATH}`, () => {
entered.resolve();
return new Promise<void>(() => undefined);
});
await requestConfig(page);
await entered.promise;
});
});

View file

@ -0,0 +1,48 @@
import { test as base } from '@playwright/test';
import type { BrowserContext } from '@playwright/test';
/**
* Detaches every route on `context` and its pages, so a handler still running cannot fail the
* test once the context closes.
*
* Closing a context disposes the responses its handlers got from `route.fetch()`. A handler the
* app triggered just before the test returned is then still between `route.fetch()` and reading
* the body, throws `Response has been disposed`, and Playwright reports that against a test whose
* assertions had all passed. `route.fulfill()`, `continue()` and `abort()` are exempt: Playwright
* races those against the close itself.
*
* `ignoreErrors` rather than `wait`, for two reasons. A wait never ends for a handler parked on a
* promise the test leaves unsettled (a held response, a request left hanging on purpose). And
* with two handlers running, Playwright stops intercepting when the first one finishes and
* continues the other request itself, so the second handler's `route.fulfill()` throws
* `Route is already handled!`, a second way to fail the finished test.
*/
export async function releaseRoutes(context: BrowserContext): Promise<void> {
if (context.isClosed()) {
return;
}
const targets = [context, ...context.pages().filter((page) => !page.isClosed())];
/** Rejects only when its target closed underneath it, which leaves nothing to release. */
await Promise.all(
targets.map((target) => target.unrouteAll({ behavior: 'ignoreErrors' }).catch(() => undefined)),
);
}
/** Closes a context a spec opened itself, such as a second signed-out profile. */
export async function closeContext(context: BrowserContext): Promise<void> {
await releaseRoutes(context);
await context.close();
}
/**
* `test` for specs that answer requests through `route.fetch()`: the `context` fixture, and so
* `page` and every tab opened from it, releases its routes before Playwright closes it.
*/
export const test = base.extend({
context: async ({ context }, provide) => {
await provide(context);
await releaseRoutes(context);
},
});
export { expect } from '@playwright/test';

View file

@ -1,7 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { createHash } from 'node:crypto';
import { expect, test } from '@playwright/test';
import { encodeEphemeralAgentId } from 'librechat-data-provider';
import type { FrameLocator, Page, Response, Route } from '@playwright/test';
import {
@ -14,6 +13,7 @@ import {
sendMessage,
sendMessageAndWaitForCompletion,
} from './helpers';
import { expect, test } from './fixtures';
const MCP_SERVER_TITLE = 'E2E MCP App';
const LEGACY_FRAME_TITLE = 'MCP HTML Resource (Embedded Content)';

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import {
MOCK_ENDPOINTS,
@ -7,6 +6,7 @@ import {
selectMockEndpoint,
sendMessage,
} from './helpers';
import { expect, test } from './fixtures';
/**
* Creates a project from the all-projects page and returns its id.

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { TMessage } from 'librechat-data-provider';
import type { Page, Route } from '@playwright/test';
import type { AgentDetail } from './agents.helpers';
@ -14,6 +13,7 @@ import {
requestJson,
sendMessage,
} from './helpers';
import { expect, test } from './fixtures';
/** Last chunk streamed by the fake model's slow replies (160 chunks, 0-indexed). */
const SLOW_REPLY_LAST_CHUNK = 'chunk-159';

View file

@ -1,8 +1,8 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { installCodeMocks, openCodeChat, singleMachine } from './codeWorkspaceMocks';
import { openAgentBuilder } from '../agents.helpers';
import { probeStyle } from './style.helpers';
import { expect, test } from '../fixtures';
const RIGHT_EDGE_TOLERANCE = 6;

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import {
sendMessageAndWaitForCompletion,
@ -8,6 +7,7 @@ import {
NEW_CHAT_PATH,
} from '../helpers';
import { openSettings } from './ui-scale.helpers';
import { expect, test } from '../fixtures';
/**
* A deployment that sets `ANALYTICS_GTM_ID` used to load Google Tag Manager on

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getAccessToken, requestJson } from '../helpers';
import { expect, test } from '../fixtures';
import { openSidebar } from './sidebar';
/**

View file

@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { expect, test } from '../fixtures';
/**
* The sign-in form's floating-label field and submit button take their height and corner from

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH } from '../helpers';
import { expect, test } from '../fixtures';
/**
* The default user avatar's glyph is a graphical object under WCAG 1.4.11 (Non-text Contrast), so

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH, selectModelSpec } from '../helpers';
import { expect, test } from '../fixtures';
const AZURE = 'azureOpenAI';
const DECLARED = 'production-west';

View file

@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import type { ChannelLinkView } from 'librechat-data-provider';
import { appURL } from '../../../setup/authenticate';
import { openAgentBuilder } from '../agents.helpers';
import { expect, test } from '../fixtures';
import { openSidebar } from './sidebar';
test.use({ viewport: { width: 1280, height: 860 }, hasTouch: false, isMobile: false });

View file

@ -1,5 +1,4 @@
import { randomUUID } from 'node:crypto';
import { expect, test } from '@playwright/test';
import type { APIRequestContext, Locator, Page, Route } from '@playwright/test';
import type { User } from '../../../types';
import {
@ -12,6 +11,7 @@ import {
import { deleteConversations, withMongo } from '../db';
import { getE2EUser } from '../../../setup/user';
import cleanupUser from '../../../setup/cleanupUser';
import { expect, test } from '../fixtures';
test.describe.configure({ timeout: 120_000 });

View file

@ -1,8 +1,8 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { NEW_CHAT_PATH } from '../helpers';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { probeStyle } from './style.helpers';
import { expect, test } from '../fixtures';
/**
* The ClickHouse theme sets the radius, mono and shadow scales as well as its colours, so the

View file

@ -1,5 +1,4 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import type { IThemeRGB } from '../../../../packages/data-provider/src/themes/types';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
@ -8,6 +7,7 @@ import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';
import { deleteConversations, seedConversations, seedMessages, withMongo } from '../db';
import { getE2EUser } from '../../../setup/user';
import { themeValue } from './style.helpers';
import { expect, test } from '../fixtures';
/**
* `clickHouseTheme` is the reference theme that proves the engine repaints the

View file

@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { NEW_CHAT_PATH } from '../helpers';
import { expect, test } from '../fixtures';
/**
* A token refresh that never answers must not freeze the app: the deadline published in the

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import {
installCodeMocks,
@ -7,6 +6,7 @@ import {
singleMachine,
workspace,
} from './codeWorkspaceMocks';
import { expect, test } from '../fixtures';
const APPROVAL = '[data-testid="code-approval-mode"]';
const WORKSPACE = '[data-testid="code-workspace"]';

View file

@ -1,8 +1,8 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import { deleteConversations, deleteMessagesByConversation, seedConversations } from '../db';
import { expect, test } from '../fixtures';
/**
* Whether a conversation carries a footer decides where its composer sits, and

View file

@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import type { Browser, BrowserContext, Page } from '@playwright/test';
import { closeContext, expect, test } from '../fixtures';
/**
* Another app links into this one with its colour mode on the URL
@ -75,7 +75,7 @@ async function landsFresh(browser: Browser, context: BrowserContext, mode: Mode)
await expectSettled(page, mode);
expect(await storedMode(page)).toBe(mode);
} finally {
await profile.close();
await closeContext(profile);
}
}
@ -98,7 +98,7 @@ async function replacesStored(browser: Browser, context: BrowserContext, mode: M
await page.reload();
await expectSettled(page, mode);
} finally {
await profile.close();
await closeContext(profile);
}
}
@ -153,7 +153,7 @@ test.describe('colour-mode handoff', () => {
expect(await storedMode(page)).toBe('light');
}
} finally {
await profile.close();
await closeContext(profile);
}
});
});

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import {
messagesView,
@ -8,6 +7,7 @@ import {
sendMessage,
} from '../helpers';
import { probeStyle } from './style.helpers';
import { expect, test } from '../fixtures';
/**
* The composer's own controls (the Thinking pill and its effort rail, the palette rows and

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import {
messagesView,
MOCK_ENDPOINTS,
@ -6,6 +5,7 @@ import {
selectMockEndpoint,
sendMessage,
} from '../helpers';
import { expect, test } from '../fixtures';
test('Inspecting numeric reasoning preserves Auto and steering @scenario:inspecting-numeric-reasoning-preserves-auto-and-steering', async ({
page,

View file

@ -1,5 +1,4 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import {
@ -8,6 +7,7 @@ import {
seedConversations,
seedMessages,
} from '../db';
import { expect, test } from '../fixtures';
/**
* Opening a conversation from the welcome screen moves the composer down by the

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { openAgentBuilder } from '../agents.helpers';
import {
@ -11,6 +10,7 @@ import {
sendMessage,
sendMessageAndWaitForCompletion,
} from '../helpers';
import { expect, test } from '../fixtures';
const messageInput = (page: Page) => page.getByRole('textbox', { name: 'Message input' });
const slowRun = (label: string) => `E2E_SLOW_REPLY:${label}`;

View file

@ -1,8 +1,8 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import { deleteConversations, deleteMessagesByConversation, seedConversations } from '../db';
import { expect, test } from '../fixtures';
/**
* The footer is an absolutely positioned bar in a zero-height wrapper, so the

View file

@ -1,8 +1,8 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import { deleteConversations, deleteMessagesByConversation, seedConversations } from '../db';
import { expect, test } from '../fixtures';
/**
* The generic model disclaimer belongs to the welcome screen. A deployment's own

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page, Route } from '@playwright/test';
import { accountButton } from './ui-scale.helpers';
import { expect, test } from '../fixtures';
/**
* The Connected Accounts row in Settings > Account. The mock config has no pull request OAuth

View file

@ -1,5 +1,4 @@
import { resolve } from 'node:path';
import { expect, test } from '@playwright/test';
import { parseSessionHint, formatSessionHint, SESSION_HINT_COOKIE } from 'librechat-data-provider';
import type { SessionHint, ThemeDefinition } from 'librechat-data-provider';
import type { Page } from '@playwright/test';
@ -9,6 +8,7 @@ import {
} from '../../../../packages/api/src/html/theme';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { resolveTheme } from '../../../../packages/data-provider/src/themes/registry';
import { expect, test } from '../fixtures';
/**
* `interface.theme` exists only in the `/api/config` answer, so before this

View file

@ -1,10 +1,10 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';
import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';
import { getE2EUser } from '../../../setup/user';
import { themeValue } from './style.helpers';
import { expect, test } from '../fixtures';
/**
* `interface.theme` in librechat.yaml reaches the client through `/api/config`,

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import { expect, test } from '../fixtures';
/**
* Changing the registered address is offered only where it can actually

View file

@ -1,8 +1,8 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import { deleteConversations, deleteMessagesByConversation, seedConversations } from '../db';
import { expect, test } from '../fixtures';
/**
* The document says whether the deployment configured a footer, and the composer

View file

@ -1,8 +1,8 @@
import { randomUUID } from 'node:crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { MOCK_ENDPOINTS, NEW_CHAT_PATH, selectMockEndpoint } from '../helpers';
import type { MockEndpoint } from '../helpers';
import { expect, test } from '../fixtures';
import { openPanel } from './panels';
import { withMongo } from '../db';

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH, selectModelSpec } from '../helpers';
import { expect, test } from '../fixtures';
import { openPanel } from './panels';
const PROVIDER = 'Mock Provider A';

View file

@ -1,8 +1,8 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import type { AgentDetail } from '../agents.helpers';
import { MOCK_ENDPOINTS, NEW_CHAT_PATH, getAccessToken, requestJson } from '../helpers';
import { cleanupAgent, uniqueAgentName } from '../agents.helpers';
import { expect, test } from '../fixtures';
/**
* The welcome screen names the selected agent and carries the generic footer

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import type { AgentDetail } from '../agents.helpers';
import {
@ -11,6 +10,7 @@ import {
sendMessageAndWaitForCompletion,
} from '../helpers';
import { cleanupAgent, uniqueAgentName } from '../agents.helpers';
import { expect, test } from '../fixtures';
/**
* The chat chrome a deployment review asked for: what a response repeats from the header, what the

View file

@ -1,7 +1,6 @@
import path from 'node:path';
import { readdirSync } from 'node:fs';
import { randomUUID } from 'node:crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import type { SeedMessage } from '../db';
import {
@ -18,6 +17,7 @@ import {
deleteMessagesByConversation,
} from '../db';
import { getE2EUser } from '../../../setup/user';
import { expect, test } from '../fixtures';
/**
* The legacy MCP UI renderer, the App Bridge and the export helpers load on demand, each in a

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH, sendMessage } from '../helpers';
import { expect, test } from '../fixtures';
/**
* Lia, the welcome screen mascot: off until the user opts in from Settings, standing on the

View file

@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { NEW_CHAT_PATH } from '../helpers';
import { expect, test } from '../fixtures';
/**
* Colours that used to be literals in components now read roles: the default avatar's hairline

View file

@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { NEW_CHAT_PATH } from '../helpers';
import { expect, test } from '../fixtures';
/**
* The mobile drawer keeps one place for each control: new chat sits in the header strip beside

View file

@ -1,8 +1,8 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { openAgentBuilder, uniqueAgentName, cleanupAgent } from '../agents.helpers';
import { MOCK_ENDPOINTS, NEW_CHAT_PATH, getAccessToken, requestJson } from '../helpers';
import { expect, test } from '../fixtures';
import { openSidebar } from './sidebar';
/**

View file

@ -1,5 +1,4 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type {
APIRequestContext,
Browser,
@ -14,6 +13,7 @@ import {
enableTwoFactorFlag,
seedPasswordReset,
} from '../db';
import { closeContext, expect, test } from '../fixtures';
import { NEW_CHAT_PATH } from '../helpers';
import { getPrimaryE2EUser } from '../../../setup/users.mock';
@ -167,7 +167,9 @@ test.describe('passkeys', () => {
let context: BrowserContext | undefined;
test.afterEach(async () => {
await context?.close();
if (context) {
await closeContext(context);
}
context = undefined;
if (user) {
await deleteUserByEmail(user.email);

View file

@ -1,8 +1,8 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import { deleteConversations, deleteMessagesByConversation, seedConversations } from '../db';
import { expect, test } from '../fixtures';
/**
* A policy link is read where it is agreed to. Registration states the consent

View file

@ -1,9 +1,9 @@
import { randomUUID } from 'crypto';
import { ObjectId } from 'mongodb';
import type { APIRequestContext, Locator, Page, Response, Route } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { FileContext } from 'librechat-data-provider';
import { getE2EUser } from '../../../setup/user';
import { expect, test } from '../fixtures';
import { withMongo } from '../db';
import { escapeRegExp, getAccessToken, uniqueName } from '../helpers';
import { loginAdmin } from '../content-filters.helpers';

View file

@ -1,9 +1,9 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Locator, Page, Route } from '@playwright/test';
import { FileContext } from 'librechat-data-provider';
import { escapeRegExp, getAccessToken, uniqueName, NEW_CHAT_PATH } from '../helpers';
import { requestResult } from '../content-filters.helpers';
import { expect, test } from '../fixtures';
type Project = { id: string; name: string };

View file

@ -1,7 +1,7 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Page, Request } from '@playwright/test';
import { getAccessToken, requestJson } from '../helpers';
import { expect, test } from '../fixtures';
import { openPanel } from './panels';
/**

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import { FileSources } from 'librechat-data-provider';
import type {
TFile,
@ -10,6 +9,7 @@ import type { Page, Locator } from '@playwright/test';
import type { AgentSummary } from '../agents.helpers';
import { getAccessToken, requestJson, uniqueName } from '../helpers';
import { cleanupAgent } from '../agents.helpers';
import { expect, test } from '../fixtures';
import { openPanel } from './panels';
async function seedSchedules(page: Page, count: number) {

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { TStartupConfig } from 'librechat-data-provider';
import type { Browser, Page } from '@playwright/test';
import { closeContext, expect, test } from '../fixtures';
/**
* A deployment's policies are agreed to on the way in, so both ways in state
@ -90,7 +90,7 @@ test.describe('registration consent', () => {
await terms.focus();
await expect(terms).toBeFocused();
} finally {
await context.close();
await closeContext(context);
}
});
@ -108,7 +108,7 @@ test.describe('registration consent', () => {
await expect(page.locator(`a[href="${PRIVACY_URL}"]`)).toHaveCount(1);
await expect(page.getByText(/agree to the Terms of Service/i)).toHaveCount(0);
} finally {
await context.close();
await closeContext(context);
}
});
@ -123,7 +123,7 @@ test.describe('registration consent', () => {
await expect(page.getByRole('button', { name: 'Submit registration' })).toBeVisible();
await expect(page.getByText(/By continuing/i)).toHaveCount(0);
} finally {
await context.close();
await closeContext(context);
}
});
@ -144,7 +144,7 @@ test.describe('registration consent', () => {
await expect(page.getByText(/By continuing/i)).toHaveCount(0);
await expect(page.locator('a[href=""]')).toHaveCount(0);
} finally {
await context.close();
await closeContext(context);
}
});
@ -164,7 +164,7 @@ test.describe('registration consent', () => {
await expect(page.locator(`a[href="${PRIVACY_URL}"]`)).toHaveCount(1);
await expect(page.locator(`a[href="${TERMS_URL}"]`)).toHaveCount(1);
} finally {
await context.close();
await closeContext(context);
}
});
@ -188,7 +188,7 @@ test.describe('registration consent', () => {
await expect(page.locator(`a[href="${PRIVACY_URL}"]`)).toHaveCount(1);
await expect(page.locator(`a[href="${TERMS_URL}"]`)).toHaveCount(1);
} finally {
await context.close();
await closeContext(context);
}
});
@ -212,7 +212,7 @@ test.describe('registration consent', () => {
await expect(page.locator(`a[href="${PRIVACY_URL}"]`)).toHaveCount(1);
await expect(page.locator(`a[href="${TERMS_URL}"]`)).toHaveCount(1);
} finally {
await context.close();
await closeContext(context);
}
});
});

View file

@ -2,7 +2,6 @@ import { UNSEEN_REPLY_WATERMARK } from 'librechat-data-provider';
import fs from 'node:fs';
import { randomUUID } from 'node:crypto';
import mongoose from 'mongoose';
import { expect, test } from '@playwright/test';
import { createMethods, createModels } from '@librechat/data-schemas';
import { Constants } from 'librechat-data-provider';
import type { TMarkConversationUnreadResponse as MutationResult } from 'librechat-data-provider';
@ -18,6 +17,7 @@ import {
} from '../db';
import { getAccessToken, requestJson } from '../helpers';
import { openConversationMenu, openSidebar } from './sidebar';
import { expect, test } from '../fixtures';
type ReadState = Pick<
IConversation,

View file

@ -1,4 +1,4 @@
import { expect, test } from '@playwright/test';
import { expect, test } from '../fixtures';
/**
* The SAML sign-in button draws a generic key glyph. It used to be filled black, which vanished

View file

@ -1,5 +1,4 @@
import { randomUUID } from 'node:crypto';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import {
@ -8,6 +7,7 @@ import {
seedConversations,
seedMessages,
} from '../db';
import { expect, test } from '../fixtures';
import { messagesView } from '../helpers';
const ROOT_PARENT = '00000000-0000-0000-0000-000000000000';

View file

@ -1,8 +1,8 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { MOCK_ENDPOINTS, getAccessToken, requestJson } from '../helpers';
import { openAgentBuilder } from '../agents.helpers';
import { openSettings } from './ui-scale.helpers';
import { expect, test } from '../fixtures';
/**
* A segmented control keeps each label on one line, so without `wrap` a row of long

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';
@ -11,6 +10,7 @@ import {
NEW_CHAT_PATH,
} from '../helpers';
import { themeValue } from './style.helpers';
import { expect, test } from '../fixtures';
/**
* A shared link resolves its policy from the tenant that owns it, so the viewer's

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH } from '../helpers';
import { expect, test } from '../fixtures';
const SHAREPOINT_ORIGIN = 'https://contoso.sharepoint.example';
const DOWNLOAD_URL = 'https://download.example.test/secret-contract.pdf';

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type {
SlackWorkspace,
AgentChannel,
@ -8,6 +7,7 @@ import type { AgentDetail } from '../agents.helpers';
import { openAgentBuilder, cleanupAgent } from '../agents.helpers';
import { MOCK_ENDPOINTS, getAccessToken, requestJson } from '../helpers';
import { appURL } from '../../../setup/authenticate';
import { expect, test } from '../fixtures';
import { openSidebar } from './sidebar';
test.use({ viewport: { width: 1280, height: 960 }, hasTouch: false, isMobile: false });

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import { randomUUID } from 'node:crypto';
import type { Page } from '@playwright/test';
import type { SeedMessage } from '../db';
@ -11,6 +10,7 @@ import {
} from '../db';
import { MOCK_ENDPOINTS, selectMockEndpoint, sendMessage } from '../helpers';
import { getE2EUser } from '../../../setup/user';
import { expect, test } from '../fixtures';
const NO_PARENT = '00000000-0000-0000-0000-000000000000';
const STREAM_ROUTE = /\/api\/agents\/chat\/stream\//;

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import { randomUUID } from 'node:crypto';
import type { Page } from '@playwright/test';
import type { SeedMessage } from '../db';
@ -9,6 +8,7 @@ import {
deleteMessagesByConversation,
} from '../db';
import { getE2EUser } from '../../../setup/user';
import { expect, test } from '../fixtures';
const NO_PARENT = '00000000-0000-0000-0000-000000000000';

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import type { IThemeRGB } from '../../../../packages/data-provider/src/themes/types';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
@ -13,6 +12,7 @@ import {
} from '../helpers';
import { getE2EUser } from '../../../setup/user';
import { themeValue } from './style.helpers';
import { expect, test } from '../fixtures';
/**
* What the browser paints while a controlled theme arrives, and the roles that
@ -152,16 +152,6 @@ function paintRoles(page: Page) {
const rgb = (channels: string | undefined) => `rgb(${(channels ?? '').split(' ').join(', ')})`;
test.describe('controlled theme paint', () => {
/**
* The app asks for `/api/config` again once the session resolves, and that request can still be
* inside a `serveThemes` handler when a test body returns. Closing the context under it disposes
* the fetched response, which fails the finished test from the handler, so each test lets its
* handlers settle first.
*/
test.afterEach(async ({ page }) => {
await page.unrouteAll({ behavior: 'wait' });
});
test("a shared link's first frame of the conversation already wears the link tenant's theme @scenario:shared-link-first-frame-wears-link-theme", async ({
page,
}) => {

View file

@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { getE2EUser } from '../../../setup/user';
import { NEW_CHAT_PATH } from '../helpers';
import { expect, test } from '../fixtures';
/**
* The colors these tests read now live in `packages/client/src/theme/tokens.css` as

View file

@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH } from '../helpers';
import { themeValue } from './style.helpers';
import { expect, test } from '../fixtures';
/**
* A definition written for a newer frontend can name an appearance token this build does not

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { CodeSetupAttempt } from 'librechat-data-provider';
import type { Page, Route } from '@playwright/test';
import { expect, test } from '../fixtures';
/**
* Ordinary 2FA completes in the auth context. Safe destinations survive an unavailable store

View file

@ -1,10 +1,10 @@
import { randomUUID } from 'node:crypto';
import { expect, test } from '@playwright/test';
import type { Route } from '@playwright/test';
import type { TStartupConfig, TUser } from 'librechat-data-provider';
import { NEW_CHAT_PATH } from '../helpers';
import { seedConversations, seedMessages } from '../db';
import { loginAdmin } from '../content-filters.helpers';
import { expect, test } from '../fixtures';
/**
* Acceptance scenarios for deployment-wide 2FA enforcement. The mock harness starts the server

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import {
MOCK_ENDPOINTS,
@ -8,6 +7,7 @@ import {
sendMessage,
sendMessageAndWaitForCompletion,
} from '../helpers';
import { expect, test } from '../fixtures';
/**
* The artifacts pane can leave the side panel for a window of its own. The pane

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { randomUUID } from 'node:crypto';
import { getE2EUser } from '../../../setup/user';
@ -18,6 +17,7 @@ import {
sendMessageAndWaitForCompletion,
} from '../helpers';
import { openConversationMenu, openSidebar } from './sidebar';
import { expect, test } from '../fixtures';
const userEmail = getE2EUser().email;
const now = () => new Date();

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { TConversationTag } from 'librechat-data-provider';
import type { Locator, Page } from '@playwright/test';
import { expect, test } from '../fixtures';
import { uniqueName } from '../helpers';
import { openPanel } from './panels';

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { TStartupConfig } from 'librechat-data-provider';
import type { Page } from '@playwright/test';
import { getPrimaryE2EUser } from '../../setup/users.mock';
@ -11,6 +10,7 @@ import {
selectModelSpec,
sendMessage,
} from './helpers';
import { expect, test } from './fixtures';
/** Label of the `softDefault: true` spec in e2e/config/librechat.e2e.yaml. */
const SOFT_DEFAULT_LABEL = 'E2E Soft Default';

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import type { Page, Response } from '@playwright/test';
import type { CancelSteerParams } from '../../../client/src/data-provider/SSE/mutations';
import {
@ -13,6 +12,7 @@ import {
selectMockEndpoint,
sendMessage,
} from './helpers';
import { expect, test } from './fixtures';
/** Non-spec endpoint from e2e/config/librechat.e2e.yaml — the ephemeral MCP
* selection rides the no-spec path, mirroring mcp-ephemeral.spec.ts. */

View file

@ -1,4 +1,3 @@
import { expect, test } from '@playwright/test';
import { cleanupAgent, openAgentBuilder, uniqueAgentName } from './agents.helpers';
import {
getAccessToken,
@ -9,6 +8,7 @@ import {
MOCK_ENDPOINTS,
NEW_CHAT_PATH,
} from './helpers';
import { expect, test } from './fixtures';
for (const [theme, width] of [
['light', 1280],

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { TStartupConfig } from 'librechat-data-provider';
import { NEW_CHAT_PATH } from './helpers';
import { expect, test } from './fixtures';
/**
* Regression test for the framer-motion / Vite incompatibility that crashed the