From bbd411792882e9ff923be2a95804a78656a37e48 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 11 Nov 2026 16:23:44 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20Release=20Route=20Handle?= =?UTF-8?q?rs=20Before=20Mock=20Spec=20Contexts=20Close=20(#18064)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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!`. --- e2e/README.md | 11 +++ e2e/specs/mock/auth.spec.ts | 2 +- .../mock/conversation-management.spec.ts | 2 +- e2e/specs/mock/fixtures.spec.ts | 77 +++++++++++++++++++ e2e/specs/mock/fixtures.ts | 48 ++++++++++++ e2e/specs/mock/mcp-apps.spec.ts | 2 +- e2e/specs/mock/projects.spec.ts | 2 +- e2e/specs/mock/queued-reveal.spec.ts | 2 +- .../scenarios/agent-builder-header.spec.ts | 2 +- .../mock/scenarios/analytics-consent.spec.ts | 2 +- .../scenarios/assistant-model-field.spec.ts | 2 +- .../mock/scenarios/auth-control-shape.spec.ts | 2 +- .../scenarios/avatar-glyph-contrast.spec.ts | 2 +- .../scenarios/azure-reasoning-effort.spec.ts | 2 +- .../channel-account-lifecycle.spec.ts | 2 +- .../mock/scenarios/chat-filter-menu.spec.ts | 2 +- .../scenarios/clickhouse-theme-shape.spec.ts | 2 +- .../mock/scenarios/clickhouse-theme.spec.ts | 2 +- .../scenarios/client-refresh-timeout.spec.ts | 2 +- .../scenarios/code-workspace-composer.spec.ts | 2 +- .../scenarios/cold-load-clearance.spec.ts | 2 +- .../mock/scenarios/color-mode-handoff.spec.ts | 8 +- .../mock/scenarios/composer-buttons.spec.ts | 2 +- .../composer-numeric-reasoning.spec.ts | 2 +- .../mock/scenarios/composer-position.spec.ts | 2 +- .../mock/scenarios/composer-redesign.spec.ts | 2 +- .../configured-footer-clearance.spec.ts | 2 +- .../mock/scenarios/configured-footer.spec.ts | 2 +- .../mock/scenarios/connected-accounts.spec.ts | 2 +- .../deployment-theme-first-paint.spec.ts | 2 +- .../mock/scenarios/deployment-theme.spec.ts | 2 +- .../scenarios/email-change-gating.spec.ts | 2 +- .../scenarios/footer-shell-answer.spec.ts | 2 +- .../scenarios/grouped-model-params.spec.ts | 2 +- .../mock/scenarios/haiku-parameters.spec.ts | 2 +- .../mock/scenarios/landing-greeting.spec.ts | 2 +- e2e/specs/mock/scenarios/launch-qa.spec.ts | 2 +- e2e/specs/mock/scenarios/lazy-mcp-ui.spec.ts | 2 +- e2e/specs/mock/scenarios/lia-mascot.spec.ts | 2 +- .../scenarios/literal-roles-theme.spec.ts | 2 +- .../scenarios/mobile-drawer-controls.spec.ts | 2 +- .../mock/scenarios/nested-popovers.spec.ts | 2 +- e2e/specs/mock/scenarios/passkeys.spec.ts | 6 +- .../scenarios/policy-links-placement.spec.ts | 2 +- .../mock/scenarios/project-files-ui.spec.ts | 2 +- .../mock/scenarios/projects-dialogs.spec.ts | 2 +- .../scenarios/prompt-row-permissions.spec.ts | 2 +- .../mock/scenarios/quieter-panels.spec.ts | 2 +- .../scenarios/registration-consent.spec.ts | 16 ++-- .../mock/scenarios/reply-read-state.spec.ts | 2 +- e2e/specs/mock/scenarios/saml-glyph.spec.ts | 2 +- .../scenarios/sandpack-empty-bundler.spec.ts | 2 +- .../mock/scenarios/segmented-wrap.spec.ts | 2 +- .../scenarios/share-deployment-theme.spec.ts | 2 +- .../scenarios/sharepoint-picker-logs.spec.ts | 2 +- .../mock/scenarios/slack-workspaces.spec.ts | 2 +- .../scenarios/subagent-late-files.spec.ts | 2 +- .../subagent-nested-mcp-apps.spec.ts | 2 +- e2e/specs/mock/scenarios/theme-paint.spec.ts | 12 +-- .../scenarios/theme-token-utilities.spec.ts | 2 +- .../theme-unknown-appearance.spec.ts | 2 +- .../scenarios/two-factor-deep-link.spec.ts | 2 +- .../scenarios/two-factor-required.spec.ts | 2 +- .../mock/scenarios/undocked-artifacts.spec.ts | 2 +- .../mock/scenarios/unseen-replies.spec.ts | 2 +- e2e/specs/mock/scenarios/wrapping.spec.ts | 2 +- e2e/specs/mock/soft-default.spec.ts | 2 +- e2e/specs/mock/steering.spec.ts | 2 +- e2e/specs/mock/tool-approval-modes.spec.ts | 2 +- e2e/specs/mock/two-factor.spec.ts | 2 +- 70 files changed, 216 insertions(+), 88 deletions(-) create mode 100644 e2e/specs/mock/fixtures.spec.ts create mode 100644 e2e/specs/mock/fixtures.ts diff --git a/e2e/README.md b/e2e/README.md index 4c59b0d7f2..73b64c26c9 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -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, diff --git a/e2e/specs/mock/auth.spec.ts b/e2e/specs/mock/auth.spec.ts index 7443a64fe9..6e5fb59a2b 100644 --- a/e2e/specs/mock/auth.spec.ts +++ b/e2e/specs/mock/auth.spec.ts @@ -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; diff --git a/e2e/specs/mock/conversation-management.spec.ts b/e2e/specs/mock/conversation-management.spec.ts index 0687f98d2f..871e7be701 100644 --- a/e2e/specs/mock/conversation-management.spec.ts +++ b/e2e/specs/mock/conversation-management.spec.ts @@ -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)}`; diff --git a/e2e/specs/mock/fixtures.spec.ts b/e2e/specs/mock/fixtures.spec.ts new file mode 100644 index 0000000000..8789262bcf --- /dev/null +++ b/e2e/specs/mock/fixtures.spec.ts @@ -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) { + const fetched = Promise.withResolvers(); + const failure = Promise.withResolvers(); + 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(); + 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(); + 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(); + await page.route(`**${CONFIG_PATH}`, () => { + entered.resolve(); + return new Promise(() => undefined); + }); + await requestConfig(page); + await entered.promise; + }); +}); diff --git a/e2e/specs/mock/fixtures.ts b/e2e/specs/mock/fixtures.ts new file mode 100644 index 0000000000..9470b5adb0 --- /dev/null +++ b/e2e/specs/mock/fixtures.ts @@ -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 { + 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 { + 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'; diff --git a/e2e/specs/mock/mcp-apps.spec.ts b/e2e/specs/mock/mcp-apps.spec.ts index f735cc2864..620cae4da9 100644 --- a/e2e/specs/mock/mcp-apps.spec.ts +++ b/e2e/specs/mock/mcp-apps.spec.ts @@ -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)'; diff --git a/e2e/specs/mock/projects.spec.ts b/e2e/specs/mock/projects.spec.ts index e9d637ba6a..20a7b901cb 100644 --- a/e2e/specs/mock/projects.spec.ts +++ b/e2e/specs/mock/projects.spec.ts @@ -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. diff --git a/e2e/specs/mock/queued-reveal.spec.ts b/e2e/specs/mock/queued-reveal.spec.ts index 6682bd3478..a415372db1 100644 --- a/e2e/specs/mock/queued-reveal.spec.ts +++ b/e2e/specs/mock/queued-reveal.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/agent-builder-header.spec.ts b/e2e/specs/mock/scenarios/agent-builder-header.spec.ts index fe5fd155b9..6eaee7cb42 100644 --- a/e2e/specs/mock/scenarios/agent-builder-header.spec.ts +++ b/e2e/specs/mock/scenarios/agent-builder-header.spec.ts @@ -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; diff --git a/e2e/specs/mock/scenarios/analytics-consent.spec.ts b/e2e/specs/mock/scenarios/analytics-consent.spec.ts index b4a5da59c3..a7212a41e6 100644 --- a/e2e/specs/mock/scenarios/analytics-consent.spec.ts +++ b/e2e/specs/mock/scenarios/analytics-consent.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/assistant-model-field.spec.ts b/e2e/specs/mock/scenarios/assistant-model-field.spec.ts index 9d444a3963..dfed1f0ab7 100644 --- a/e2e/specs/mock/scenarios/assistant-model-field.spec.ts +++ b/e2e/specs/mock/scenarios/assistant-model-field.spec.ts @@ -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'; /** diff --git a/e2e/specs/mock/scenarios/auth-control-shape.spec.ts b/e2e/specs/mock/scenarios/auth-control-shape.spec.ts index 0f93352c1c..f449bc2a2a 100644 --- a/e2e/specs/mock/scenarios/auth-control-shape.spec.ts +++ b/e2e/specs/mock/scenarios/auth-control-shape.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/avatar-glyph-contrast.spec.ts b/e2e/specs/mock/scenarios/avatar-glyph-contrast.spec.ts index 692e20cbf1..03896d75ca 100644 --- a/e2e/specs/mock/scenarios/avatar-glyph-contrast.spec.ts +++ b/e2e/specs/mock/scenarios/avatar-glyph-contrast.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/azure-reasoning-effort.spec.ts b/e2e/specs/mock/scenarios/azure-reasoning-effort.spec.ts index 398b08cd81..6b81ecc2c8 100644 --- a/e2e/specs/mock/scenarios/azure-reasoning-effort.spec.ts +++ b/e2e/specs/mock/scenarios/azure-reasoning-effort.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/channel-account-lifecycle.spec.ts b/e2e/specs/mock/scenarios/channel-account-lifecycle.spec.ts index 1984990c66..f123d5ea4a 100644 --- a/e2e/specs/mock/scenarios/channel-account-lifecycle.spec.ts +++ b/e2e/specs/mock/scenarios/channel-account-lifecycle.spec.ts @@ -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 }); diff --git a/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts b/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts index 94914bbe3d..fa1d0f49e0 100644 --- a/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts +++ b/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts @@ -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 }); diff --git a/e2e/specs/mock/scenarios/clickhouse-theme-shape.spec.ts b/e2e/specs/mock/scenarios/clickhouse-theme-shape.spec.ts index 1b9073456e..9eb496b218 100644 --- a/e2e/specs/mock/scenarios/clickhouse-theme-shape.spec.ts +++ b/e2e/specs/mock/scenarios/clickhouse-theme-shape.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts b/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts index 4aa260d44b..7687c1358c 100644 --- a/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts +++ b/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/client-refresh-timeout.spec.ts b/e2e/specs/mock/scenarios/client-refresh-timeout.spec.ts index 37a83a0b71..6f2e12ad01 100644 --- a/e2e/specs/mock/scenarios/client-refresh-timeout.spec.ts +++ b/e2e/specs/mock/scenarios/client-refresh-timeout.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/code-workspace-composer.spec.ts b/e2e/specs/mock/scenarios/code-workspace-composer.spec.ts index e66e411f17..7e5dcae718 100644 --- a/e2e/specs/mock/scenarios/code-workspace-composer.spec.ts +++ b/e2e/specs/mock/scenarios/code-workspace-composer.spec.ts @@ -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"]'; diff --git a/e2e/specs/mock/scenarios/cold-load-clearance.spec.ts b/e2e/specs/mock/scenarios/cold-load-clearance.spec.ts index 93a6d31bfa..e8ee6f0aab 100644 --- a/e2e/specs/mock/scenarios/cold-load-clearance.spec.ts +++ b/e2e/specs/mock/scenarios/cold-load-clearance.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/color-mode-handoff.spec.ts b/e2e/specs/mock/scenarios/color-mode-handoff.spec.ts index 711862a85c..0e275aa0c7 100644 --- a/e2e/specs/mock/scenarios/color-mode-handoff.spec.ts +++ b/e2e/specs/mock/scenarios/color-mode-handoff.spec.ts @@ -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); } }); }); diff --git a/e2e/specs/mock/scenarios/composer-buttons.spec.ts b/e2e/specs/mock/scenarios/composer-buttons.spec.ts index a39025e7af..3af264c349 100644 --- a/e2e/specs/mock/scenarios/composer-buttons.spec.ts +++ b/e2e/specs/mock/scenarios/composer-buttons.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/composer-numeric-reasoning.spec.ts b/e2e/specs/mock/scenarios/composer-numeric-reasoning.spec.ts index dcf6337890..009f87c1a2 100644 --- a/e2e/specs/mock/scenarios/composer-numeric-reasoning.spec.ts +++ b/e2e/specs/mock/scenarios/composer-numeric-reasoning.spec.ts @@ -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, diff --git a/e2e/specs/mock/scenarios/composer-position.spec.ts b/e2e/specs/mock/scenarios/composer-position.spec.ts index 35d9c80f76..31cbc158c8 100644 --- a/e2e/specs/mock/scenarios/composer-position.spec.ts +++ b/e2e/specs/mock/scenarios/composer-position.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/composer-redesign.spec.ts b/e2e/specs/mock/scenarios/composer-redesign.spec.ts index b3b0000082..0b198b5c6d 100644 --- a/e2e/specs/mock/scenarios/composer-redesign.spec.ts +++ b/e2e/specs/mock/scenarios/composer-redesign.spec.ts @@ -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}`; diff --git a/e2e/specs/mock/scenarios/configured-footer-clearance.spec.ts b/e2e/specs/mock/scenarios/configured-footer-clearance.spec.ts index 1ee0f6b205..29d746d617 100644 --- a/e2e/specs/mock/scenarios/configured-footer-clearance.spec.ts +++ b/e2e/specs/mock/scenarios/configured-footer-clearance.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/configured-footer.spec.ts b/e2e/specs/mock/scenarios/configured-footer.spec.ts index da6c409ced..bbb3803f59 100644 --- a/e2e/specs/mock/scenarios/configured-footer.spec.ts +++ b/e2e/specs/mock/scenarios/configured-footer.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/connected-accounts.spec.ts b/e2e/specs/mock/scenarios/connected-accounts.spec.ts index f2eb17c4ca..c08e972835 100644 --- a/e2e/specs/mock/scenarios/connected-accounts.spec.ts +++ b/e2e/specs/mock/scenarios/connected-accounts.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.ts b/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.ts index 14cb2191cf..be870b3245 100644 --- a/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.ts +++ b/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/deployment-theme.spec.ts b/e2e/specs/mock/scenarios/deployment-theme.spec.ts index eccaccd801..0b87380b2b 100644 --- a/e2e/specs/mock/scenarios/deployment-theme.spec.ts +++ b/e2e/specs/mock/scenarios/deployment-theme.spec.ts @@ -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`, diff --git a/e2e/specs/mock/scenarios/email-change-gating.spec.ts b/e2e/specs/mock/scenarios/email-change-gating.spec.ts index 2107d8e588..d1e6c06f3f 100644 --- a/e2e/specs/mock/scenarios/email-change-gating.spec.ts +++ b/e2e/specs/mock/scenarios/email-change-gating.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/footer-shell-answer.spec.ts b/e2e/specs/mock/scenarios/footer-shell-answer.spec.ts index 7768664036..3d5d932a1c 100644 --- a/e2e/specs/mock/scenarios/footer-shell-answer.spec.ts +++ b/e2e/specs/mock/scenarios/footer-shell-answer.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/grouped-model-params.spec.ts b/e2e/specs/mock/scenarios/grouped-model-params.spec.ts index 6a5e472f48..8f29407ad6 100644 --- a/e2e/specs/mock/scenarios/grouped-model-params.spec.ts +++ b/e2e/specs/mock/scenarios/grouped-model-params.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/haiku-parameters.spec.ts b/e2e/specs/mock/scenarios/haiku-parameters.spec.ts index 94bba4749a..c8570a9dbf 100644 --- a/e2e/specs/mock/scenarios/haiku-parameters.spec.ts +++ b/e2e/specs/mock/scenarios/haiku-parameters.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/landing-greeting.spec.ts b/e2e/specs/mock/scenarios/landing-greeting.spec.ts index 136f4da900..b7d9c80732 100644 --- a/e2e/specs/mock/scenarios/landing-greeting.spec.ts +++ b/e2e/specs/mock/scenarios/landing-greeting.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/launch-qa.spec.ts b/e2e/specs/mock/scenarios/launch-qa.spec.ts index b2b726b01a..d667268212 100644 --- a/e2e/specs/mock/scenarios/launch-qa.spec.ts +++ b/e2e/specs/mock/scenarios/launch-qa.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/lazy-mcp-ui.spec.ts b/e2e/specs/mock/scenarios/lazy-mcp-ui.spec.ts index 8656fd2072..ec406525e0 100644 --- a/e2e/specs/mock/scenarios/lazy-mcp-ui.spec.ts +++ b/e2e/specs/mock/scenarios/lazy-mcp-ui.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/lia-mascot.spec.ts b/e2e/specs/mock/scenarios/lia-mascot.spec.ts index 51be75cc77..bcd61b505b 100644 --- a/e2e/specs/mock/scenarios/lia-mascot.spec.ts +++ b/e2e/specs/mock/scenarios/lia-mascot.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/literal-roles-theme.spec.ts b/e2e/specs/mock/scenarios/literal-roles-theme.spec.ts index 055d4a18c7..f1bffea247 100644 --- a/e2e/specs/mock/scenarios/literal-roles-theme.spec.ts +++ b/e2e/specs/mock/scenarios/literal-roles-theme.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/mobile-drawer-controls.spec.ts b/e2e/specs/mock/scenarios/mobile-drawer-controls.spec.ts index 7cb3044be4..99107ec688 100644 --- a/e2e/specs/mock/scenarios/mobile-drawer-controls.spec.ts +++ b/e2e/specs/mock/scenarios/mobile-drawer-controls.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/nested-popovers.spec.ts b/e2e/specs/mock/scenarios/nested-popovers.spec.ts index 0aeebb6b52..85e521e234 100644 --- a/e2e/specs/mock/scenarios/nested-popovers.spec.ts +++ b/e2e/specs/mock/scenarios/nested-popovers.spec.ts @@ -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'; /** diff --git a/e2e/specs/mock/scenarios/passkeys.spec.ts b/e2e/specs/mock/scenarios/passkeys.spec.ts index dd804b3cce..7e133ee3ba 100644 --- a/e2e/specs/mock/scenarios/passkeys.spec.ts +++ b/e2e/specs/mock/scenarios/passkeys.spec.ts @@ -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); diff --git a/e2e/specs/mock/scenarios/policy-links-placement.spec.ts b/e2e/specs/mock/scenarios/policy-links-placement.spec.ts index 0cf881f504..2a0aca6424 100644 --- a/e2e/specs/mock/scenarios/policy-links-placement.spec.ts +++ b/e2e/specs/mock/scenarios/policy-links-placement.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/project-files-ui.spec.ts b/e2e/specs/mock/scenarios/project-files-ui.spec.ts index 45874cf0e2..864efb64c3 100644 --- a/e2e/specs/mock/scenarios/project-files-ui.spec.ts +++ b/e2e/specs/mock/scenarios/project-files-ui.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/projects-dialogs.spec.ts b/e2e/specs/mock/scenarios/projects-dialogs.spec.ts index 9f01f72493..a90342b1a2 100644 --- a/e2e/specs/mock/scenarios/projects-dialogs.spec.ts +++ b/e2e/specs/mock/scenarios/projects-dialogs.spec.ts @@ -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 }; diff --git a/e2e/specs/mock/scenarios/prompt-row-permissions.spec.ts b/e2e/specs/mock/scenarios/prompt-row-permissions.spec.ts index a87f1be4d0..46de06f8ee 100644 --- a/e2e/specs/mock/scenarios/prompt-row-permissions.spec.ts +++ b/e2e/specs/mock/scenarios/prompt-row-permissions.spec.ts @@ -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'; /** diff --git a/e2e/specs/mock/scenarios/quieter-panels.spec.ts b/e2e/specs/mock/scenarios/quieter-panels.spec.ts index 25d7141cd9..b4f2b6aad2 100644 --- a/e2e/specs/mock/scenarios/quieter-panels.spec.ts +++ b/e2e/specs/mock/scenarios/quieter-panels.spec.ts @@ -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) { diff --git a/e2e/specs/mock/scenarios/registration-consent.spec.ts b/e2e/specs/mock/scenarios/registration-consent.spec.ts index 9bc764a7b7..9b0aca010e 100644 --- a/e2e/specs/mock/scenarios/registration-consent.spec.ts +++ b/e2e/specs/mock/scenarios/registration-consent.spec.ts @@ -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); } }); }); diff --git a/e2e/specs/mock/scenarios/reply-read-state.spec.ts b/e2e/specs/mock/scenarios/reply-read-state.spec.ts index b177f7c898..4c7b96b0db 100644 --- a/e2e/specs/mock/scenarios/reply-read-state.spec.ts +++ b/e2e/specs/mock/scenarios/reply-read-state.spec.ts @@ -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, diff --git a/e2e/specs/mock/scenarios/saml-glyph.spec.ts b/e2e/specs/mock/scenarios/saml-glyph.spec.ts index 1b9b1aef75..5001c2bd28 100644 --- a/e2e/specs/mock/scenarios/saml-glyph.spec.ts +++ b/e2e/specs/mock/scenarios/saml-glyph.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/sandpack-empty-bundler.spec.ts b/e2e/specs/mock/scenarios/sandpack-empty-bundler.spec.ts index 264d8d17d8..8337db32a8 100644 --- a/e2e/specs/mock/scenarios/sandpack-empty-bundler.spec.ts +++ b/e2e/specs/mock/scenarios/sandpack-empty-bundler.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/segmented-wrap.spec.ts b/e2e/specs/mock/scenarios/segmented-wrap.spec.ts index e1d37dfa24..577daa0cc7 100644 --- a/e2e/specs/mock/scenarios/segmented-wrap.spec.ts +++ b/e2e/specs/mock/scenarios/segmented-wrap.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/share-deployment-theme.spec.ts b/e2e/specs/mock/scenarios/share-deployment-theme.spec.ts index 2b71c9d94f..dafb50af26 100644 --- a/e2e/specs/mock/scenarios/share-deployment-theme.spec.ts +++ b/e2e/specs/mock/scenarios/share-deployment-theme.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/sharepoint-picker-logs.spec.ts b/e2e/specs/mock/scenarios/sharepoint-picker-logs.spec.ts index c4bacf917a..2fe4381930 100644 --- a/e2e/specs/mock/scenarios/sharepoint-picker-logs.spec.ts +++ b/e2e/specs/mock/scenarios/sharepoint-picker-logs.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/slack-workspaces.spec.ts b/e2e/specs/mock/scenarios/slack-workspaces.spec.ts index 71f081ed00..90212dbda0 100644 --- a/e2e/specs/mock/scenarios/slack-workspaces.spec.ts +++ b/e2e/specs/mock/scenarios/slack-workspaces.spec.ts @@ -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 }); diff --git a/e2e/specs/mock/scenarios/subagent-late-files.spec.ts b/e2e/specs/mock/scenarios/subagent-late-files.spec.ts index 4f3e817ff5..655cbb5cbc 100644 --- a/e2e/specs/mock/scenarios/subagent-late-files.spec.ts +++ b/e2e/specs/mock/scenarios/subagent-late-files.spec.ts @@ -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\//; diff --git a/e2e/specs/mock/scenarios/subagent-nested-mcp-apps.spec.ts b/e2e/specs/mock/scenarios/subagent-nested-mcp-apps.spec.ts index 6b55706d93..90532967cf 100644 --- a/e2e/specs/mock/scenarios/subagent-nested-mcp-apps.spec.ts +++ b/e2e/specs/mock/scenarios/subagent-nested-mcp-apps.spec.ts @@ -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'; diff --git a/e2e/specs/mock/scenarios/theme-paint.spec.ts b/e2e/specs/mock/scenarios/theme-paint.spec.ts index c47447bef6..4824050e4e 100644 --- a/e2e/specs/mock/scenarios/theme-paint.spec.ts +++ b/e2e/specs/mock/scenarios/theme-paint.spec.ts @@ -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, }) => { diff --git a/e2e/specs/mock/scenarios/theme-token-utilities.spec.ts b/e2e/specs/mock/scenarios/theme-token-utilities.spec.ts index 343017e3fb..3620391376 100644 --- a/e2e/specs/mock/scenarios/theme-token-utilities.spec.ts +++ b/e2e/specs/mock/scenarios/theme-token-utilities.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.ts b/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.ts index 7bfd3ec4a0..5310865074 100644 --- a/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.ts +++ b/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/two-factor-deep-link.spec.ts b/e2e/specs/mock/scenarios/two-factor-deep-link.spec.ts index c7e0b46f62..4c8b04c717 100644 --- a/e2e/specs/mock/scenarios/two-factor-deep-link.spec.ts +++ b/e2e/specs/mock/scenarios/two-factor-deep-link.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/two-factor-required.spec.ts b/e2e/specs/mock/scenarios/two-factor-required.spec.ts index abe706d12f..d9ab1f78be 100644 --- a/e2e/specs/mock/scenarios/two-factor-required.spec.ts +++ b/e2e/specs/mock/scenarios/two-factor-required.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/undocked-artifacts.spec.ts b/e2e/specs/mock/scenarios/undocked-artifacts.spec.ts index eaf911bd42..8f668f6941 100644 --- a/e2e/specs/mock/scenarios/undocked-artifacts.spec.ts +++ b/e2e/specs/mock/scenarios/undocked-artifacts.spec.ts @@ -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 diff --git a/e2e/specs/mock/scenarios/unseen-replies.spec.ts b/e2e/specs/mock/scenarios/unseen-replies.spec.ts index 2e394626af..1737466b66 100644 --- a/e2e/specs/mock/scenarios/unseen-replies.spec.ts +++ b/e2e/specs/mock/scenarios/unseen-replies.spec.ts @@ -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(); diff --git a/e2e/specs/mock/scenarios/wrapping.spec.ts b/e2e/specs/mock/scenarios/wrapping.spec.ts index 7c8f1789c1..e9d8fee16d 100644 --- a/e2e/specs/mock/scenarios/wrapping.spec.ts +++ b/e2e/specs/mock/scenarios/wrapping.spec.ts @@ -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'; diff --git a/e2e/specs/mock/soft-default.spec.ts b/e2e/specs/mock/soft-default.spec.ts index 20b550abf7..9c91321ec7 100644 --- a/e2e/specs/mock/soft-default.spec.ts +++ b/e2e/specs/mock/soft-default.spec.ts @@ -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'; diff --git a/e2e/specs/mock/steering.spec.ts b/e2e/specs/mock/steering.spec.ts index d92c290474..cdbe1b082c 100644 --- a/e2e/specs/mock/steering.spec.ts +++ b/e2e/specs/mock/steering.spec.ts @@ -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. */ diff --git a/e2e/specs/mock/tool-approval-modes.spec.ts b/e2e/specs/mock/tool-approval-modes.spec.ts index 22c4b215b2..e6f720b6eb 100644 --- a/e2e/specs/mock/tool-approval-modes.spec.ts +++ b/e2e/specs/mock/tool-approval-modes.spec.ts @@ -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], diff --git a/e2e/specs/mock/two-factor.spec.ts b/e2e/specs/mock/two-factor.spec.ts index c8a1f2a208..9d6b8c38f2 100644 --- a/e2e/specs/mock/two-factor.spec.ts +++ b/e2e/specs/mock/two-factor.spec.ts @@ -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