// The model button, the model sheet and the way on under a failed turn: // what a product offering "bring your own key" or an allowance used to build // for itself (Heidi, 2026-11-26). import { test } from "node:test"; import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { createElement as h } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { ChatMessage, ChatTurnError, ModelChip, ModelSheet, DEFAULT_MODEL_SHEET_LABELS, chatTurnFailure, } from "../dist/react/index.js"; const vendors = [ { id: "openrouter", label: "OpenRouter", keyUrl: "https://openrouter.ai/keys", keyHint: "sk-or-…", modelExample: "vendor/model", }, { id: "groq", label: "Groq", keyUrl: "https://console.groq.com/keys" }, ]; const sheet = (props) => renderToStaticMarkup( h(ModelSheet, { open: true, onClose() {}, vendors, current: null, check: async () => ({ ok: false }), onSave() {}, onClear() {}, ...props, }), ); test("the model button is there without a key, says whose model answers, and names the reader's own", () => { const free = renderToStaticMarkup(h(ModelChip, { model: null, label: "Model", onOpen() {} })); assert.match(free, /]*data-model-chip="free"/); assert.match(free, />Model { const html = sheet({ freeModels: ["free/one", "free/two"] }); assert.match(html, /]*class="ck-sheet"[^>]*aria-label="Connect your own model"/); assert.match(html, /