diff --git a/apps/admin/src/styles.css b/apps/admin/src/styles.css index 81d33c6..5fd531f 100644 --- a/apps/admin/src/styles.css +++ b/apps/admin/src/styles.css @@ -21,9 +21,15 @@ .llm-test-result.warn { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.1); } .llm-test-result.warn > strong { color: #8a4b04; } .llm-test-result.bad { border-color: rgba(213,0,0,.4); background: rgba(213,0,0,.06); } +/* A working connection whose endpoint reports no reasoning-token counter. It is + not a warning — it is simply unconfirmable from the usage block — so it gets a + neutral slate rather than the amber "still thinking" treatment. */ +.llm-test-result.neutral { border-color: rgba(71,85,105,.35); background: rgba(71,85,105,.06); } .llm-test-result > strong { font-size: 14px; font-weight: 800; color: var(--text); } .llm-test-result p { margin: 0; overflow-wrap: anywhere; } -.llm-test-result.warn > p:not(.feedback-error) { color: #4a4343; } +/* --muted (#8a8484) is only 3.67:1 on white, so body text in a verdict card is + darkened in every variant — this text explains the verdict, it is not decoration. */ +.llm-test-result > p:not(.feedback-error) { color: #4a4343; } .feedback-table { overflow-x: auto; } .feedback-table table { min-width: 680px; } .seg.activity-tabs { max-width: 100%; } diff --git a/apps/admin/src/views/Settings.tsx b/apps/admin/src/views/Settings.tsx index 53df67b..3c1c21d 100644 --- a/apps/admin/src/views/Settings.tsx +++ b/apps/admin/src/views/Settings.tsx @@ -121,28 +121,40 @@ export function Settings() { {testing &&

Sending one request to {model.trim() || 'the configured model'}…

} {/* The verdict stays on the page rather than in a toast: the latency and the reasoning-token line are the parts people need to read twice. */} - {testResult && ( -
{ + // Three states, not two. Our gateway reports no reasoning-token + // counter at all (`completion_tokens_details: {}`), so "null" is the + // normal healthy answer here — colouring it amber and saying "still + // thinking" would flag a working configuration as broken. + const unknown = testResult.ok && testResult.reasoning_tokens === null; + const tone = !testResult.ok ? 'bad' : testResult.reasoning_disabled ? 'good' : unknown ? 'neutral' : 'warn'; + return ( +
- {testResult.ok - ? testResult.reasoning_disabled + {!testResult.ok + ? 'Connection failed' + : testResult.reasoning_disabled ? `Connection works — replied in ${testResult.latency_ms} ms` - : 'Connection works, but the model is still thinking' - : 'Connection failed'} + : unknown + ? `Connection works — replied in ${testResult.latency_ms} ms` + : 'Connection works, but the model is still thinking'} {testResult.model &&

{testResult.model} at {testResult.endpoint}

} {testResult.error &&

{testResult.error}

} {testResult.warning &&

{testResult.warning}

} {testResult.ok && (

- Reasoning tokens: {testResult.reasoning_tokens === null ? 'not reported by this endpoint' : testResult.reasoning_tokens} + {testResult.reasoning_tokens === null + ? 'This endpoint does not report a reasoning-token count, so thinking cannot be confirmed from here — the request was still sent with thinking disabled.' + : `Reasoning tokens: ${testResult.reasoning_tokens}`} {testResult.content ? ` · reply: “${testResult.content.slice(0, 60)}”` : ''}

)}
- )} + ); + })()}
} diff --git a/apps/sidecar/src/feedback-api.js b/apps/sidecar/src/feedback-api.js index b883ce1..75da4e7 100644 --- a/apps/sidecar/src/feedback-api.js +++ b/apps/sidecar/src/feedback-api.js @@ -95,16 +95,29 @@ function createFeedbackApi({ supabaseFetch, supabaseUrl, serviceRoleKey, fetchIm if (typeof content !== 'string' || !content.trim()) { return { ...base, endpoint: config.endpoint, latency_ms: latency, error: 'LLM endpoint responded but the reply contained no message content' }; } - // The only honest signal that thinking is off (a 200 proves nothing — this - // endpoint ignores unknown fields). + // Three-state reasoning verdict, because all three shapes occur in the wild + // and they do not mean the same thing: + // reasoning_tokens === 0 -> the provider reports it, and thinking is off. + // reasoning_tokens > 0 -> thinking is still on; that IS a warning. + // key absent / details empty -> the provider does not report reasoning tokens + // at all. ai.lago.dev does exactly this (it answers + // `completion_tokens_details: {}`), so this is the normal case for us, not + // an edge case. Reading "not reported" as "still thinking" tells an admin + // that a working configuration is broken, which is a false alarm — so the + // warning is limited to tokens actually being reported. + // A 200 alone still proves nothing (this endpoint ignores unknown fields), so + // only a reported 0 asserts `reasoning_disabled`. const reasoningTokens = payload?.usage?.completion_tokens_details?.reasoning_tokens; + const reported = Number.isInteger(reasoningTokens); const reasoningDisabled = reasoningTokens === 0; return { ...base, ok: true, error: null, endpoint: config.endpoint, latency_ms: latency, reasoning_disabled: reasoningDisabled, - reasoning_tokens: Number.isInteger(reasoningTokens) ? reasoningTokens : null, + reasoning_tokens: reported ? reasoningTokens : null, content: safeProviderText(content, config.api_key).slice(0, 500), - warning: reasoningDisabled ? null : 'The connection works but reasoning tokens were reported, so thinking is still enabled — summaries will be slow and costly.', + warning: reported && !reasoningDisabled + ? 'The connection works but reasoning tokens were reported, so thinking is still enabled — summaries will be slow and costly.' + : null, }; } diff --git a/apps/sidecar/tests/feedback-api.test.js b/apps/sidecar/tests/feedback-api.test.js index e640cbf..1096a28 100644 --- a/apps/sidecar/tests/feedback-api.test.js +++ b/apps/sidecar/tests/feedback-api.test.js @@ -159,6 +159,29 @@ test('llm-test reports thinking still on without calling it a clean pass', async assert.match(verdict.warning, /thinking is still enabled/); }); +test('llm-test treats an unreported reasoning count as unknown, not as a warning', async () => { + // What ai.lago.dev actually answers: a usage block whose + // completion_tokens_details is EMPTY. Reading that as "still thinking" told + // admins their working gateway was misconfigured, so the verdict has to be ok + // with no warning and reasoning_tokens: null — null means "not reported", + // deliberately different from 0, which means "reported and off". + const shapes = [ + { label: 'empty details', usage: { completion_tokens: 2, completion_tokens_details: {} } }, + { label: 'no usage block', usage: undefined }, + { label: 'details absent', usage: { completion_tokens: 2 } }, + ]; + for (const shape of shapes) { + const { api } = fixture({ providerFetch: async () => new Response(JSON.stringify({ + choices: [{ message: { content: 'OK' } }], usage: shape.usage, + })) }); + const verdict = await api.handle(request(), '/llm-test'); + assert.equal(verdict.ok, true, shape.label); + assert.equal(verdict.reasoning_tokens, null, shape.label); + assert.equal(verdict.reasoning_disabled, false, shape.label); + assert.equal(verdict.warning, null, shape.label); + } +}); + test('llm-test answers ok:false for unconfigured settings, provider errors and blocked endpoints', async () => { const cases = [ { label: 'no settings stored', options: { noSettings: true }, match: /No LLM endpoint and model are configured/ }, diff --git a/docs/backend/feedback-ai.md b/docs/backend/feedback-ai.md index f1ae9a7..58a73bd 100644 --- a/docs/backend/feedback-ai.md +++ b/docs/backend/feedback-ai.md @@ -54,19 +54,25 @@ and 405 for `GET`), because the reason a connection fails is the useful part: ```json {"ok":true,"model":"Qwen3.8","endpoint":"https://ai.lago.dev/v1/chat/completions", - "latency_ms":412,"reasoning_disabled":true,"reasoning_tokens":0,"content":"OK", + "latency_ms":424,"reasoning_disabled":false,"reasoning_tokens":null,"content":"OK", "warning":null,"error":null} ``` - `reasoning_tokens` is the provider's own - `usage.completion_tokens_details.reasoning_tokens`, or **`null` when the - provider sent no `usage` block**. `null` is not "off"; `reasoning_disabled` is - `true` only when it is exactly `0`. + `usage.completion_tokens_details.reasoning_tokens`, or **`null` when the provider + does not report one** — no `usage` block, no `completion_tokens_details`, or an + empty one. `reasoning_disabled` is `true` only when the value is exactly `0`. +- `warning` is set **only when reasoning tokens are actually reported and are + non-zero**. "Not reported" is a distinct third state: `ai.lago.dev` answers + `completion_tokens_details: {}`, so treating an absent counter as a warning made + every healthy production connection look broken. The reply above is the real + production shape — the request went out with thinking disabled and came back in + 424 ms on 2 completion tokens; the counter simply is not exposed. - `ok` answers "would generating a summary work?" — transport, auth and parsing all fine. A working connection whose provider still reports reasoning tokens is - therefore `ok: true` with `reasoning_disabled: false` and a `warning`, so the + therefore `ok: true` with `reasoning_disabled: false` **and** a `warning`, so the honest signal about cost stays separate from the pass/fail answer. The Admin UI - colours that case amber, not green. + colours that case amber, not green; an unreported counter is neutral. - It never writes to the database, and the API key never appears in any field: provider error text is flattened, truncated to 300 characters and the stored key is replaced with `[redacted]` (a provider that echoes the Authorization header @@ -91,9 +97,16 @@ Both requests (summaries and the test) are built by one helper, deliberately not used. - `max_tokens` is accepted and ignored, so it is not sent. - **A `200 OK` proves nothing**: this endpoint ignores unknown fields entirely. - Only `usage.completion_tokens_details.reasoning_tokens === 0` is evidence. Reasoning *levels* are validated though — `reasoning_effort: "banana"` is an HTTP 400 `unsupported_value`, which is how the field was confirmed to be live. +- **But `reasoning_tokens === 0` is not always obtainable either.** Re-measured + against production after the deploy, a `"Reply with OK"` request returns + `usage.completion_tokens_details: {}` — the gateway reports the *absence* of the + counter, not a zero. Thinking is verifiably off there by other means (2 + completion tokens for a one-word reply, 424 ms), but the field cannot be asserted + from the response. So `/llm-test` treats "not reported" as its own state and does + not warn about it; asserting `reasoning_disabled: true` would be a claim the + provider does not support. The sidecar checks that the event exists and that a selected session belongs to it. It reads all feedback in ordered 500-row pages, selecting only `rating` and diff --git a/docs/frontend/admin-app.md b/docs/frontend/admin-app.md index 8892647..527de82 100644 --- a/docs/frontend/admin-app.md +++ b/docs/frontend/admin-app.md @@ -300,19 +300,24 @@ a verdict rather than an exception, so the UI can name the reason: | What you see | Meaning | |---|---| -| "Connection works — replied in 412 ms" | Endpoint, key and response parsing are all fine, and the provider reported **0 reasoning tokens**. | -| "Connection works, but the model is still thinking" | The transport is fine but reasoning tokens came back, so summaries will be slow and costly. The endpoint is ignoring the thinking-off fields. | -| "Connection failed" + one line of detail | No settings saved yet, a non-2xx from the provider (a wrong key reads as `HTTP 401: …`), an endpoint that failed validation, a timeout, or a reply with no content. | +| **Green** "Connection works — replied in 412 ms" | Endpoint, key and response parsing are fine, **and** the provider reported `reasoning_tokens: 0`. | +| **Neutral** "Connection works — replied in 424 ms", with "This endpoint does not report a reasoning-token count…" | The transport is fine; the provider simply does not return a reasoning counter. **This is the normal state for `ai.lago.dev`**, which answers `usage.completion_tokens_details: {}`. Thinking is still sent disabled; it just cannot be confirmed from the usage block. | +| **Amber** "Connection works, but the model is still thinking" | The transport is fine but non-zero reasoning tokens came back, so summaries will be slow and costly — the endpoint is ignoring the thinking-off fields. | +| **Red** "Connection failed" + one line of detail | No settings saved yet, a non-2xx from the provider (a wrong key reads as `HTTP 401: …`), an endpoint that failed validation, a timeout, or a reply with no content. | Three things are deliberate here: - The button is **disabled while the form has unsaved changes**. The key never reaches the browser, so a test can only ever exercise what is stored — being able to press it against half-typed values would report on the wrong endpoint. -- `reasoning_tokens: null` means the provider sent no `usage` block at all. It is - shown as "not reported by this endpoint", never as zero: **only `0` proves - thinking is off**, since these gateways answer `200 OK` while silently ignoring - fields they do not implement. +- The reasoning verdict is **three-state, not two**. `0` means "reported and + off"; `null` means "this provider does not report it"; only a reported + non-zero value raises the warning. Collapsing `null` into the warning was the + first implementation and it was wrong: measured against the production + gateway, which omits the counter entirely, every healthy connection showed a + "still thinking" warning. `null` is never displayed as zero — **only `0` + proves thinking is off**, because these gateways answer `200 OK` while + silently ignoring fields they do not implement. - The verdict is rendered on the page, not as a toast — the latency and the reasoning line are worth reading twice, and a toast expires. diff --git a/docs/releases/2026-10-19.md b/docs/releases/2026-10-19.md index 9d4bc6d..7c395b3 100644 --- a/docs/releases/2026-10-19.md +++ b/docs/releases/2026-10-19.md @@ -506,3 +506,65 @@ records that and the working alternative. **No backfill**: anyone whose points were erased by an off→on cycle before this stays low until an admin flips that toggle once — one OFF→ON now recomputes from the surviving `checkins` rows and puts them back, so the old damage is repairable from the UI. + +## Post-deploy: the connection test warned about a healthy gateway + +Deploying the migration made it worth running the new `/llm-test` path against the +**real** provider rather than trusting the earlier probe. Running the shipped +`buildChatCompletionsBody` + `llmFetch` inside the sidecar container against +`ai.lago.dev` returned: + +``` +body fields sent: ["chat_template_kwargs","messages","model","reasoning_effort","stream"] +reasoning_effort: none | chat_template_kwargs: {"enable_thinking":false} +http 200 latency_ms 424 +usage: {"prompt_tokens":15,"completion_tokens":2,"completion_tokens_details":{}, ...} +reply: "OK" +``` + +Thinking is off — a one-word reply cost **2 completion tokens** in **424 ms**, +against the ~235 reasoning tokens and ~3.5× latency measured when it was on. But +`completion_tokens_details` comes back **empty**, so +`reasoning_tokens` is `undefined`, not `0`. + +`testLlm` had `warning: reasoningDisabled ? null : '…thinking is still enabled'`, +and the Admin UI coloured anything not `reasoning_disabled` amber. So on the only +endpoint this deployment actually uses, **Validate AI connection would have told +the operator their working configuration was broken** — precisely the opposite of +what the button is for. + +### Fix — the verdict became three-state + +- **`reasoning_tokens === 0`** → `reasoning_disabled: true`, no warning (green). +- **no counter reported** (absent `usage`, absent `completion_tokens_details`, or + an empty one) → `reasoning_tokens: null`, `warning: null` (new neutral card). + The UI says the endpoint does not report the counter, so thinking cannot be + confirmed from here, while still noting the request was sent with thinking + disabled. It does **not** claim thinking is off, because the provider gives no + basis for that claim. +- **counter reported and non-zero** → amber + the warning, as before. + +`warning` is now gated on `reported && !reasoningDisabled`, and the Admin renders a +`neutral` variant. Only a reported `0` asserts `reasoning_disabled`. + +### Tests + +- Sidecar **34 → 35**: one test asserting all three unreported shapes (empty + details / no `usage` / no details key) each give `ok: true` with + `reasoning_tokens: null` **and no warning**. +- `e2e/tests/llm-connection-test.spec.ts` (**new, 6 tests**): green on reported 0; + the production shape (`null`) is **neutral, never amber**, its headline does not + contain "still thinking" and no warning element exists; amber + warning on 235; + red on `ok:false` with the provider error shown and the reasoning line absent; + the dirty-form lock (button disabled → re-enabled after reverting) and the + in-flight state (progress visible, button disabled, exactly one request, + `Bearer` token attached). + +### Also found + +Running the spec needed both dev servers, which an earlier `pkill -f "playwright +test"` had taken down as collateral (the pattern also matched their launch +shells). Every symptom was "the new feature is broken"; the cause was +`net::ERR_CONNECTION_REFUSED`. Lesson recorded here because it cost time twice: +**a mock-based suite failing wholesale on every assertion is an environment +problem, not a product problem** — check the server before debugging the code. diff --git a/e2e/tests/llm-connection-test.spec.ts b/e2e/tests/llm-connection-test.spec.ts new file mode 100644 index 0000000..21c8756 --- /dev/null +++ b/e2e/tests/llm-connection-test.spec.ts @@ -0,0 +1,156 @@ +import { test, expect, type Page, type Route } from '@playwright/test'; + +const adminUrl = process.env.CONVIVO_ADMIN_URL || 'http://localhost:3001'; +const eventId = 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa'; +const user = { id: '99999999-9999-4999-8999-999999999999', email: 'admin@appe.at', aud: 'authenticated', role: 'authenticated', app_metadata: {}, user_metadata: {} }; + +/** + * The "Validate AI connection" button in Settings. + * + * The verdict has three reasoning states and they must not be conflated, because + * the gateway in production (ai.lago.dev) answers with + * `completion_tokens_details: {}` — it reports NO reasoning counter at all. + * Treating "not reported" the same as "reported and non-zero" tells an admin that + * a working configuration is broken. So: 0 = green, absent = neutral with no + * warning, > 0 = amber with a warning. + */ + +const storedSettings = { endpoint: 'https://ai.lago.dev/v1/chat/completions', model: 'Qwen3.8', has_api_key: true }; + +type Verdict = Record; +type Harness = { + verdict: Verdict; + testCalls: { method: string; auth: string }[]; + settingsDelayMs: number; +}; + +const ok = (tokens: number | null | undefined): Verdict => ({ + ok: true, model: 'Qwen3.8', endpoint: storedSettings.endpoint, latency_ms: 424, + reasoning_disabled: tokens === 0, + reasoning_tokens: tokens === undefined ? null : tokens, + content: 'OK', warning: tokens !== null && tokens !== undefined && tokens > 0 + ? 'The connection works but reasoning tokens were reported, so thinking is still enabled — summaries will be slow and costly.' + : null, + error: null, +}); + +async function openAdmin(page: Page, h: Harness) { + const payload = Buffer.from(JSON.stringify({ sub: user.id, exp: Math.floor(Date.now() / 1000) + 3600 })).toString('base64url'); + const session = { user, access_token: `eyJhbGciOiJIUzI1NiJ9.${payload}.test`, refresh_token: 'r', expires_in: 3600, token_type: 'bearer' }; + await page.route('**/auth/v1/**', (r) => r.fulfill({ json: new URL(r.request().url()).pathname.endsWith('/user') ? user : session })); + await page.route('**/rest/v1/**', async (route: Route) => { + const u = new URL(route.request().url()); + const t = u.pathname.split('/').pop(); + if (t === 'contacts') return route.fulfill({ json: u.searchParams.has('email') ? { email: user.email, full_name: 'Admin User', is_admin: true } : [] }); + if (t === 'events') return route.fulfill({ json: u.searchParams.has('is_active') ? { id: eventId, name: 'Test Conf', is_active: true, badge_copies: 1 } : [{ id: eventId, name: 'Test Conf', is_active: true, badge_copies: 1 }] }); + return route.fulfill({ json: [] }); + }); + await page.route('**/sidecar/llm-settings', async (route: Route) => { + if (h.settingsDelayMs) await new Promise((r) => setTimeout(r, h.settingsDelayMs)); + return route.fulfill({ json: storedSettings }); + }); + await page.route('**/sidecar/llm-test', async (route: Route) => { + h.testCalls.push({ method: route.request().method(), auth: route.request().headers().authorization }); + return route.fulfill({ json: h.verdict }); + }); + await page.goto(`${adminUrl}/auth/callback#access_token=${session.access_token}&refresh_token=r&type=magiclink`); + await expect(page.locator('.nav')).toBeVisible(); + await page.locator('.nav').getByRole('button', { name: /Settings/ }).click(); + await expect(page.getByTestId('llm-test-button')).toBeVisible(); +} + +const result = (page: Page) => page.getByTestId('llm-test-result'); + +test('a reported zero reasoning token count reads as a clean pass', async ({ page }) => { + const h: Harness = { verdict: ok(0), testCalls: [], settingsDelayMs: 0 }; + await openAdmin(page, h); + await page.getByTestId('llm-test-button').click(); + await expect(result(page)).toBeVisible(); + await expect(result(page)).toHaveClass(/good/); + await expect(result(page)).not.toHaveClass(/warn|neutral|bad/); + await expect(page.getByTestId('llm-test-headline')).toContainText('Connection works'); + await expect(page.getByTestId('llm-test-headline')).toContainText('424 ms'); + await expect(page.getByTestId('llm-test-reasoning')).toContainText('Reasoning tokens: 0'); + await expect(page.getByTestId('llm-test-warning')).toHaveCount(0); +}); + +test('an endpoint that reports no reasoning counter is not flagged as a problem', async ({ page }) => { + // This is the production shape: usage present, completion_tokens_details empty. + const h: Harness = { verdict: ok(null), testCalls: [], settingsDelayMs: 0 }; + await openAdmin(page, h); + await page.getByTestId('llm-test-button').click(); + await expect(result(page)).toBeVisible(); + await expect(result(page)).toHaveClass(/neutral/); + await expect(result(page)).not.toHaveClass(/warn|bad/); + await expect(page.getByTestId('llm-test-headline')).toContainText('Connection works'); + await expect(page.getByTestId('llm-test-headline')).not.toContainText('still thinking'); + await expect(page.getByTestId('llm-test-warning')).toHaveCount(0); + // It must say it cannot confirm, rather than asserting thinking is off. + await expect(page.getByTestId('llm-test-reasoning')).toContainText('does not report a reasoning-token count'); +}); + +test('reported non-zero reasoning tokens stay amber with the warning', async ({ page }) => { + const h: Harness = { verdict: ok(235), testCalls: [], settingsDelayMs: 0 }; + await openAdmin(page, h); + await page.getByTestId('llm-test-button').click(); + await expect(result(page)).toHaveClass(/warn/); + await expect(page.getByTestId('llm-test-headline')).toContainText('still thinking'); + await expect(page.getByTestId('llm-test-warning')).toContainText('thinking is still enabled'); + await expect(page.getByTestId('llm-test-reasoning')).toContainText('Reasoning tokens: 235'); +}); + +test('a failed connection reports the provider error and stays usable', async ({ page }) => { + const h: Harness = { + verdict: { ok: false, model: 'Qwen3.8', endpoint: storedSettings.endpoint, latency_ms: 5000, reasoning_disabled: false, reasoning_tokens: null, content: '', warning: null, error: 'HTTP 503: upstream unavailable' }, + testCalls: [], settingsDelayMs: 0, + }; + await openAdmin(page, h); + await page.getByTestId('llm-test-button').click(); + await expect(result(page)).toHaveClass(/bad/); + await expect(page.getByTestId('llm-test-headline')).toContainText('Connection failed'); + await expect(page.getByTestId('llm-test-error')).toContainText('HTTP 503'); + // No result should render the reasoning line at all. + await expect(page.getByTestId('llm-test-reasoning')).toHaveCount(0); + await expect(page.getByTestId('llm-test-button')).toBeEnabled(); +}); + +test('the button waits for the request and is disabled while unsaved changes exist', async ({ page }) => { + const h: Harness = { verdict: ok(0), testCalls: [], settingsDelayMs: 0 }; + await openAdmin(page, h); + // Editing a stored field must block the test: the API key never reaches the + // browser, so only what is already saved can be exercised. + const endpoint = page.locator('#llm-endpoint'); + await expect(endpoint).toHaveValue(storedSettings.endpoint); + await endpoint.fill('https://example.test/v1/chat/completions'); + await expect(page.getByTestId('llm-test-dirty')).toBeVisible(); + await expect(page.getByTestId('llm-test-button')).toBeDisabled(); + + await endpoint.fill(storedSettings.endpoint); + await expect(page.getByTestId('llm-test-dirty')).toHaveCount(0); + await expect(page.getByTestId('llm-test-button')).toBeEnabled(); + + // In flight: progress shown, controls not double-clickable. + let release: (v: Verdict) => void = () => {}; + await page.unroute('**/sidecar/llm-test'); + await page.route('**/sidecar/llm-test', async (route: Route) => { + h.testCalls.push({ method: route.request().method(), auth: route.request().headers().authorization }); + await new Promise((res) => { release = res; }); + return route.fulfill({ json: h.verdict }); + }); + await page.getByTestId('llm-test-button').click(); + await expect(page.getByTestId('llm-test-progress')).toBeVisible(); + await expect(page.getByTestId('llm-test-button')).toBeDisabled(); + await release(ok(0)); + await expect(page.getByTestId('llm-test-progress')).toHaveCount(0); + await expect(result(page)).toBeVisible(); +}); + +test('the test is a POST carrying the admin token', async ({ page }) => { + const h: Harness = { verdict: ok(0), testCalls: [], settingsDelayMs: 0 }; + await openAdmin(page, h); + await page.getByTestId('llm-test-button').click(); + await expect(result(page)).toBeVisible(); + expect(h.testCalls).toHaveLength(1); + expect(h.testCalls[0].method).toBe('POST'); + expect(h.testCalls[0].auth).toMatch(/^Bearer /); +});