import { afterEach, expect, it } from "vitest"; import { modelStorageKey, readSavedModel, saveModel } from "../src/model-storage.js"; import type { ModelConnectionInput } from "@agent-studio/shared"; afterEach(() => localStorage.clear()); const config = { providerId: "test", modelId: "test", apiKey: "test-secret" } as ModelConnectionInput; it("never persists the API key", () => { saveModel(config); expect(localStorage.getItem(modelStorageKey)).not.toContain("test-secret"); expect(readSavedModel()?.apiKey).toBeUndefined(); expect(config.apiKey).toBe("test-secret"); }); it("removes keys from legacy saved configurations", () => { localStorage.setItem(modelStorageKey, JSON.stringify(config)); expect(readSavedModel()?.apiKey).toBeUndefined(); expect(localStorage.getItem(modelStorageKey)).not.toContain("test-secret"); });