Skip to content

The agent that grows with you

fix(install-e2e): chat smoke waits for the app to show the mock model before sending

etherneta174341a8971
diff --git a/tests-js/scripts/desktop-chat-smoke.ts b/tests-js/scripts/desktop-chat-smoke.ts
index 455c776ca06..50dad628447 100644
--- a/tests-js/scripts/desktop-chat-smoke.ts
+++ b/tests-js/scripts/desktop-chat-smoke.ts
@@ -5,7 +5,7 @@ import path from 'node:path'
import { type ConsoleMessage, expect, type Locator, type Page } from '@playwright/test'
import { z } from 'zod'
-import { validateMockUrl } from './mock-provider-config.ts'
+import { MOCK_MODEL_ID, validateMockUrl } from './mock-provider-config.ts'
import { MOCK_REPLY } from './mock-server.ts'
export type ChatPhase = 'old' | 'new' | 'installed'
@@ -215,6 +215,34 @@ async function rendererEvidence(page: Page, consoleLines: readonly string[]): Pr
return ['--- renderer state ---', JSON.stringify(state, null, 2), '--- renderer console ---', ...consoleLines].join('\n')
}
+/** Apps prettify a model id ("mock-model" renders as "Mock Model"), so compare with case and separators folded. */
+function foldModelName(text: string): string {
+ return text.toLowerCase().replace(/[\s_-]+/g, ' ')
+}
+
+/**
+ * Wait until the page shows the seeded mock model. Older desktops keep the
+ * composer's model as renderer state and ship it as the session override on
+ * session.create, so a send before the configured model has loaded goes to the
+ * app's default provider and the mock never sees the prompt (v2026.7.1 sent to
+ * openrouter and got a 401). The name is searched in the page text rather than
+ * a selector because the chip's markup differs between app versions. An app
+ * that never renders the name proceeds after the timeout and the
+ * mock-received assertion still decides; the note lands in the renderer log.
+ */
+async function waitForMockModel(page: Page, notes: string[], timeoutMs: number = 30_000): Promise<void> {
+ const wanted = foldModelName(MOCK_MODEL_ID)
+
+ try {
+ await expect.poll(
+ async (): Promise<boolean> => foldModelName(await page.evaluate((): string => document.body.innerText)).includes(wanted),
+ { timeout: timeoutMs },
+ ).toBe(true)
+ } catch {
+ notes.push(`[smoke] the page never showed "${MOCK_MODEL_ID}" within ${timeoutMs}ms; sending anyway`)
+ }
+}
+
/** Lifecycle belongs to the caller, so this also runs inside the OLD update window. */
export async function runDesktopChatSmoke(page: Page, options: DesktopChatSmokeOptions): Promise<DesktopChatReceipt> {
const { phase, outDir, expectCommit } = options
@@ -246,6 +274,9 @@ export async function runDesktopChatSmoke(page: Page, options: DesktopChatSmokeO
try {
const composer = await waitForChatReady(page)
+
+ await waitForMockModel(page, consoleLines)
+
const identity = await readChatIdentity(page)
if (expectCommit) { assertChatCommit(identity, expectCommit, options.provenanceCommit) }
diff --git a/tests-js/scripts/mock-provider-config.ts b/tests-js/scripts/mock-provider-config.ts
index c63dfcfaeb4..5984ae17369 100644
--- a/tests-js/scripts/mock-provider-config.ts
+++ b/tests-js/scripts/mock-provider-config.ts
@@ -20,6 +20,9 @@ const configSchema = z.object({
//: it rather than stacking duplicates.
const MOCK_PROVIDER_NAME = 'Mock'
+/** The model id the seeded config selects; the chat smoke waits for the app to show it. */
+export const MOCK_MODEL_ID = 'mock-model'
+
export function validateMockUrl(value: string): string {
const url = new URL(value)
@@ -60,7 +63,7 @@ export function writeMockProviderConfig(
// environment. `providers:` stays untouched (a provider named 'mock' only
// resolved on trees that had registered such a profile, so older refs died
// with "Unknown provider 'mock'").
- model: { ...config.model, default: 'mock-model', provider: 'custom', base_url: `${url}/v1`, context_length: modelContextLength ?? 64000 },
+ model: { ...config.model, default: MOCK_MODEL_ID, provider: 'custom', base_url: `${url}/v1`, context_length: modelContextLength ?? 64000 },
providers: { ...config.providers },
custom_providers: [
...(config.custom_providers ?? []).filter(entry => entry?.name !== MOCK_PROVIDER_NAME),