Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

📍 test: Add Deployed Smoke Profile (#16135)

Danny Avila50d46a38a55e
diff --git a/e2e/README.md b/e2e/README.md
index cdae3a7521..8ac787dec9 100644
--- a/e2e/README.md
+++ b/e2e/README.md
@@ -2,6 +2,40 @@
The mock e2e profile is the safest default for generated tests. It starts LibreChat with `e2e/config/librechat.e2e.yaml`, injects an in-process fake LLM (via `LIBRECHAT_TEST_RUN_HOOK`), creates an authenticated e2e user, and avoids real provider credentials.
+## Deployed-instance smoke test
+
+The deployed profile exercises an existing LibreChat deployment without starting another app or
+database. It uses the deployment's configured model provider and persists a real conversation, so
+run it only with a dedicated test account in an environment where that traffic is expected.
+
+First, create Playwright storage state by signing in through the deployment's normal login flow:
+
+```sh
+npx playwright codegen \
+ --save-storage=e2e/storageState.json \
+ https://librechat.example.com/c/new
+```
+
+Close codegen after sign-in, then run the smoke test:
+
+```sh
+E2E_BASE_URL=https://librechat.example.com \
+ npm run e2e:deployed
+```
+
+The storage-state file contains session credentials. The default path is ignored by Git; do not
+commit it or include it in test artifacts.
+
+Set `E2E_STORAGE_STATE` when the auth file is mounted elsewhere. If the account has no default
+model, set `E2E_DEPLOYED_MODEL` to the exact configured model label. `E2E_DEPLOYED_PROMPT` can
+replace the short default prompt, and `E2E_IGNORE_HTTPS_ERRORS=true` supports deployments using a
+self-signed certificate.
+
+The profile deliberately has no global setup, database access, or web server. It verifies the
+authenticated shell, sends one real prompt, reloads the resulting conversation, and deletes only
+the conversation created by that run through LibreChat's authenticated API. Keep deterministic
+provider behavior and destructive database fixtures in the mock profile instead.
+
## Stream Stores and Shards
The mock profile uses the in-memory generation stream store by default. To exercise the same browser scenarios through a real Redis job store and pub/sub transport, start Redis on port 6379 and run:
diff --git a/e2e/playwright.config.deployed.ts b/e2e/playwright.config.deployed.ts
new file mode 100644
index 0000000000..414fcd4f09
--- /dev/null
+++ b/e2e/playwright.config.deployed.ts
@@ -0,0 +1,54 @@
+import { defineConfig, devices } from '@playwright/test';
+import fs from 'fs';
+import path from 'path';
+
+const rawBaseURL = process.env.E2E_BASE_URL?.trim();
+if (!rawBaseURL) {
+ throw new Error('[e2e:deployed] E2E_BASE_URL is required.');
+}
+
+const parsedBaseURL = new URL(rawBaseURL);
+if (!['http:', 'https:'].includes(parsedBaseURL.protocol)) {
+ throw new Error('[e2e:deployed] E2E_BASE_URL must use http or https.');
+}
+parsedBaseURL.pathname = parsedBaseURL.pathname.replace(/\/?$/, '/');
+
+const storageState = path.resolve(
+ process.env.E2E_STORAGE_STATE ?? path.join(__dirname, 'storageState.json'),
+);
+if (!fs.existsSync(storageState)) {
+ throw new Error(
+ `[e2e:deployed] Auth state was not found at ${storageState}. ` +
+ 'Set E2E_STORAGE_STATE to a Playwright storage-state file.',
+ );
+}
+
+export default defineConfig({
+ testDir: 'specs/deployed/',
+ outputDir: 'specs/.test-results/deployed',
+ fullyParallel: false,
+ forbidOnly: !!process.env.CI,
+ /** Refresh tokens may rotate during a run, invalidating the original storage state. */
+ retries: 0,
+ workers: 1,
+ reporter: [['list'], ['html', { outputFolder: 'playwright-report/deployed', open: 'never' }]],
+ use: {
+ baseURL: parsedBaseURL.toString(),
+ storageState,
+ headless: process.env.E2E_HEADED !== 'true',
+ ignoreHTTPSErrors: process.env.E2E_IGNORE_HTTPS_ERRORS === 'true',
+ screenshot: 'only-on-failure',
+ /** Refresh responses contain real account credentials and must not be recorded. */
+ trace: 'off',
+ video: 'retain-on-failure',
+ },
+ expect: {
+ timeout: 15_000,
+ },
+ projects: [
+ {
+ name: 'chromium',
+ use: { ...devices['Desktop Chrome'] },
+ },
+ ],
+});
diff --git a/e2e/specs/deployed/smoke.spec.ts b/e2e/specs/deployed/smoke.spec.ts
new file mode 100644
index 0000000000..7176a6e699
--- /dev/null
+++ b/e2e/specs/deployed/smoke.spec.ts
@@ -0,0 +1,306 @@
+import { expect, test } from '@playwright/test';
+import type { Page } from '@playwright/test';
+
+const baseURL = new URL(process.env.E2E_BASE_URL as string);
+baseURL.pathname = baseURL.pathname.replace(/\/?$/, '/');
+
+const newChatURL = new URL('c/new', baseURL);
+const configuredModel = process.env.E2E_DEPLOYED_MODEL?.trim();
+const prompt = process.env.E2E_DEPLOYED_PROMPT?.trim() || 'Reply with exactly DEPLOYED_E2E_OK.';
+
+type PersistedMessage = {
+ messageId?: string;
+ parentMessageId?: string;
+ isCreatedByUser?: boolean;
+ unfinished?: boolean;
+ error?: boolean;
+ endpoint?: string;
+ thread_id?: string;
+ text?: string;
+ content?: Array<{ type?: string }>;
+};
+
+async function selectConfiguredModel(page: Page) {
+ const modelSelector = page.getByTestId('model-selector-button');
+ const selectorIsVisible = await modelSelector
+ .waitFor({ state: 'visible', timeout: 5_000 })
+ .then(() => true)
+ .catch(() => false);
+
+ if (!selectorIsVisible) {
+ if (configuredModel) {
+ throw new Error(
+ '[e2e:deployed] E2E_DEPLOYED_MODEL cannot be applied because this deployment hides model selection.',
+ );
+ }
+ return;
+ }
+
+ if (configuredModel) {
+ if ((await modelSelector.textContent())?.trim() === configuredModel) {
+ return;
+ }
+ await modelSelector.click();
+ await page.locator('#model-search').fill(configuredModel);
+ await page.getByRole('option', { name: configuredModel, exact: true }).first().click();
+ await expect(modelSelector).toContainText(configuredModel);
+ }
+}
+
+function conversationIdFromURL(url: string) {
+ const match = new URL(url).pathname.match(/\/c\/([^/]+)\/?$/);
+ const conversationId = match?.[1];
+ return conversationId && conversationId !== 'new'
+ ? decodeURIComponent(conversationId)
+ : undefined;
+}
+
+async function loadAuthenticatedApp(page: Page) {
+ await page.addInitScript((appOrigin) => {
+ if (location.origin !== appOrigin) {
+ return;
+ }
+ /** The persistence probe must not inherit a dedicated account's temporary-chat default.
+ * These changes live only in this browser context; the storage-state file is never rewritten. */
+ localStorage.setItem('isTemporary', 'false');
+ localStorage.setItem('defaultTemporaryChat', 'false');
+ }, baseURL.origin);
+ await page.goto(newChatURL.toString(), { waitUntil: 'domcontentloaded' });
+
+ const input = page.getByTestId('text-input');
+ try {
+ await expect(input).toBeVisible({ timeout: 20_000 });
+ } catch (error) {
+ const currentURL = new URL(page.url());
+ if (currentURL.origin !== baseURL.origin || currentURL.pathname.includes('/login')) {
+ throw new Error(
+ `[e2e:deployed] Authentication state is missing or expired; the deployment redirected to ${currentURL.origin}.`,
+ { cause: error },
+ );
+ }
+ throw error;
+ }
+
+ expect(new URL(page.url()).origin).toBe(baseURL.origin);
+ await expect(page).toHaveURL(/\/c\/new\/?$/);
+ return input;
+}
+
+async function getAccessToken(page: Page) {
+ const result = await page.evaluate(async (appBaseURL) => {
+ const response = await fetch(new URL('api/auth/refresh', appBaseURL), {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({}),
+ });
+ const body = (await response.json().catch(() => null)) as { token?: string } | null;
+ return { ok: response.ok, status: response.status, token: body?.token };
+ }, baseURL.toString());
+
+ if (!result.ok || !result.token) {
+ throw new Error(
+ `[e2e:deployed] Token refresh failed before the persistence check (${result.status}).`,
+ );
+ }
+ return result.token;
+}
+
+async function getPersistedMessages(page: Page, conversationId: string, token: string) {
+ return page.evaluate(
+ async ({ appBaseURL, id, accessToken }) => {
+ const response = await fetch(new URL(`api/messages/${encodeURIComponent(id)}`, appBaseURL), {
+ credentials: 'include',
+ headers: { Authorization: `Bearer ${accessToken}` },
+ });
+ if (!response.ok) {
+ return { status: response.status };
+ }
+ return { status: response.status, messages: (await response.json()) as PersistedMessage[] };
+ },
+ { appBaseURL: baseURL.toString(), id: conversationId, accessToken: token },
+ );
+}
+
+async function deleteConversation(page: Page, conversationId: string) {
+ const result = await page.evaluate(
+ async ({ appBaseURL, id }) => {
+ const signal = AbortSignal.timeout(15_000);
+ const refreshResponse = await fetch(new URL('api/auth/refresh', appBaseURL), {
+ method: 'POST',
+ credentials: 'include',
+ signal,
+ });
+ if (!refreshResponse.ok) {
+ return { ok: false, step: 'refresh', status: refreshResponse.status };
+ }
+
+ const { token } = (await refreshResponse.json()) as { token?: string };
+ if (!token) {
+ return {
+ ok: false,
+ step: 'refresh-token',
+ status: refreshResponse.status,
+ };
+ }
+
+ const messagesResponse = await fetch(
+ new URL(`api/messages/${encodeURIComponent(id)}`, appBaseURL),
+ {
+ credentials: 'include',
+ headers: { Authorization: `Bearer ${token}` },
+ signal,
+ },
+ );
+ if (!messagesResponse.ok) {
+ return { ok: false, step: 'messages', status: messagesResponse.status };
+ }
+ const messages = (await messagesResponse.json()) as PersistedMessage[];
+ const latestMessageWithEndpoint = messages
+ .slice()
+ .reverse()
+ .find((message) => message.endpoint);
+ const latestMessageWithThread = messages
+ .slice()
+ .reverse()
+ .find((message) => message.thread_id);
+
+ const deleteResponse = await fetch(new URL('api/convos', appBaseURL), {
+ method: 'DELETE',
+ credentials: 'include',
+ headers: {
+ Authorization: `Bearer ${token}`,
+ 'Content-Type': 'application/json',
+ },
+ signal,
+ body: JSON.stringify({
+ arg: {
+ conversationId: id,
+ endpoint: latestMessageWithEndpoint?.endpoint,
+ thread_id: latestMessageWithThread?.thread_id,
+ source: 'e2e-deployed',
+ },
+ }),
+ });
+ return {
+ ok: deleteResponse.ok,
+ step: 'delete',
+ status: deleteResponse.status,
+ };
+ },
+ { appBaseURL: baseURL.toString(), id: conversationId },
+ );
+
+ if (!result.ok) {
+ throw new Error(
+ `[e2e:deployed] Conversation cleanup failed during ${result.step} (${result.status}).`,
+ );
+ }
+}
+
+let createdConversationId: string | undefined;
+
+test.describe('deployed LibreChat smoke', () => {
+ test.beforeEach(() => {
+ createdConversationId = undefined;
+ });
+
+ /** Hooks receive a separate timeout budget after a timed-out test, so cleanup still runs. */
+ test.afterEach(async ({ page }) => {
+ if (createdConversationId) {
+ await deleteConversation(page, createdConversationId);
+ }
+ });
+
+ test('loads the authenticated shell and persists a real conversation', async ({ page }) => {
+ test.setTimeout(240_000);
+ const input = await loadAuthenticatedApp(page);
+
+ await selectConfiguredModel(page);
+
+ const messageBodies = page.getByTestId('message-body');
+ const initialMessageCount = await messageBodies.count();
+ await input.fill(prompt);
+
+ const sendButton = page.getByTestId('send-button');
+ const canSubmit = await expect(sendButton)
+ .toBeEnabled({ timeout: 5_000 })
+ .then(() => true)
+ .catch(() => false);
+ if (!canSubmit) {
+ throw new Error(
+ '[e2e:deployed] The prompt cannot be submitted. Set E2E_DEPLOYED_MODEL when the account has no default model.',
+ );
+ }
+
+ await Promise.all([
+ page.waitForURL((url) => conversationIdFromURL(url.toString()) != null, {
+ timeout: 30_000,
+ }),
+ sendButton.click(),
+ ]);
+ createdConversationId = conversationIdFromURL(page.url());
+ expect(createdConversationId).toBeTruthy();
+
+ await expect(messageBodies.getByText(prompt, { exact: true })).toBeVisible();
+ let accessToken = await getAccessToken(page);
+ await expect
+ .poll(
+ async () => {
+ let result = await getPersistedMessages(
+ page,
+ createdConversationId as string,
+ accessToken,
+ );
+ if (result.status === 401) {
+ accessToken = await getAccessToken(page);
+ result = await getPersistedMessages(page, createdConversationId as string, accessToken);
+ }
+ if (!result.messages) {
+ return false;
+ }
+ const messages = result.messages;
+ const userMessageIds = new Set(
+ messages
+ .filter((message) => message.isCreatedByUser === true)
+ .map((message) => message.messageId),
+ );
+ const assistantMessages = messages.filter(
+ (message) =>
+ message.isCreatedByUser === false &&
+ message.parentMessageId != null &&
+ userMessageIds.has(message.parentMessageId),
+ );
+ return (
+ userMessageIds.size > 0 &&
+ assistantMessages.length > 0 &&
+ assistantMessages.every(
+ (message) =>
+ message.unfinished === false &&
+ message.error !== true &&
+ message.content?.some((part) => part.type === 'error') !== true,
+ )
+ );
+ },
+ {
+ timeout: 90_000,
+ intervals: [500, 1_000, 2_000],
+ message: 'assistant response should be durably finalized and error-free',
+ },
+ )
+ .toBe(true);
+ await expect
+ .poll(() => messageBodies.count(), { timeout: 10_000 })
+ .toBeGreaterThan(initialMessageCount + 1);
+ await expect(messageBodies.last()).not.toBeEmpty();
+ await expect(messageBodies.getByRole('alert')).toHaveCount(0);
+
+ await page.reload({ waitUntil: 'domcontentloaded' });
+ await expect(messageBodies.getByText(prompt, { exact: true })).toBeVisible({
+ timeout: 30_000,
+ });
+ await expect
+ .poll(() => messageBodies.count(), { timeout: 30_000 })
+ .toBeGreaterThan(initialMessageCount + 1);
+ });
+});
diff --git a/package.json b/package.json
index 7b88e6c75a..3e60ccc90b 100644
--- a/package.json
+++ b/package.json
@@ -92,6 +92,8 @@
"e2e:bombadil:steering:run": "cross-env BOMBADIL_SPECIFICATION=steering-lifecycle.specification.ts BOMBADIL_TIME_LIMIT=75s playwright test --config=e2e/playwright.config.bombadil.ts",
"e2e:mock:enforce": "npm run e2e:prepare && cross-env E2E_MODEL_SPECS_ENFORCE=true playwright test --config=e2e/playwright.config.mock.ts enforced-model-specs.spec.ts",
"e2e:mock:ci": "npm run e2e:prepare && playwright test --config=e2e/playwright.config.mock.ts",
+ "e2e:deployed": "playwright test --config=e2e/playwright.config.deployed.ts",
+ "e2e:deployed:headed": "cross-env E2E_HEADED=true playwright test --config=e2e/playwright.config.deployed.ts",
"e2e:debug": "npm run e2e:prepare && cross-env PWDEBUG=1 playwright test --config=e2e/playwright.config.local.ts",
"e2e:record": "npm run e2e:prepare && cross-env E2E_BASE_URL=http://localhost:3333 node e2e/setup/record.js",
"e2e:record:local": "npm run e2e:prepare && node e2e/setup/record.js --profile=local",