| 1 | // Run: pnpm exec tsx src/__tests__/provider-failure-meta.test.ts |
| 2 | import assert from "node:assert/strict"; |
| 3 | |
| 4 | import { initialState, reducer } from "../lib/useController"; |
| 5 | |
| 6 | const started = reducer(initialState, { type: "event", e: { kind: "turn_started" } }); |
| 7 | const failed = reducer(started, { |
| 8 | type: "event", |
| 9 | e: { |
| 10 | kind: "turn_done", |
| 11 | err: "Deepseek2 · Chat Completions: Request endpoint not found (HTTP 404).", |
| 12 | detail: "Connection ID: deepseek-anthropic\nRequest path: /anthropic/v1/chat/completions", |
| 13 | diagnostic: { kind: "request", status: 404, providerId: "deepseek-anthropic", providerDisplayName: "Deepseek2", protocol: "openai", requestPath: "/anthropic/v1/chat/completions" }, |
| 14 | }, |
| 15 | }); |
| 16 | const notice = failed.items.find((item) => item.kind === "notice" && item.level === "warn"); |
| 17 | |
| 18 | assert.equal( |
| 19 | notice?.kind === "notice" ? notice.text : "", |
| 20 | "Deepseek2 · Chat Completions: Request endpoint not found (HTTP 404).", |
| 21 | "provider display identity stays in the primary live error", |
| 22 | ); |
| 23 | assert.equal( |
| 24 | notice?.kind === "notice" ? notice.detail : "", |
| 25 | "Connection ID: deepseek-anthropic\nRequest path: /anthropic/v1/chat/completions", |
| 26 | "stable provider id and sanitized path stay in live diagnostic details", |
| 27 | ); |
| 28 |