Download web/src/lib/env-state.test.ts from SaylorTwift/hermes-agent: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/web/src/lib/env-state.test.ts
- Command line
-
hf download hf://SaylorTwift/hermes-agent/web/src/lib/env-state.test.ts
-
curl -L -o env-state.test.ts https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/web/src/lib/env-state.test.ts
1.21 kB
| import { describe, expect, it } from "vitest"; | |
| import type { EnvVarInfo } from "./api"; | |
| import { removeDeletedEnvVarFromState } from "./env-state"; | |
| function envVar(overrides: Partial<EnvVarInfo> = {}): EnvVarInfo { | |
| return { | |
| is_set: true, | |
| redacted_value: "secr...alue", | |
| description: "", | |
| url: null, | |
| category: "provider", | |
| is_password: true, | |
| tools: [], | |
| advanced: false, | |
| ...overrides, | |
| }; | |
| } | |
| describe("removeDeletedEnvVarFromState", () => { | |
| it("removes a deleted custom key from dashboard state", () => { | |
| const vars = { | |
| WHATSAPP_DEBUG: envVar({ category: "custom", custom: true }), | |
| OPENAI_API_KEY: envVar(), | |
| }; | |
| const updated = removeDeletedEnvVarFromState(vars, "WHATSAPP_DEBUG"); | |
| expect(updated).not.toHaveProperty("WHATSAPP_DEBUG"); | |
| expect(updated?.OPENAI_API_KEY).toBe(vars.OPENAI_API_KEY); | |
| }); | |
| it("keeps a catalog key available while marking it unset", () => { | |
| const vars = { OPENAI_API_KEY: envVar() }; | |
| const updated = removeDeletedEnvVarFromState(vars, "OPENAI_API_KEY"); | |
| expect(updated?.OPENAI_API_KEY).toEqual({ | |
| ...vars.OPENAI_API_KEY, | |
| is_set: false, | |
| redacted_value: null, | |
| }); | |
| }); | |
| }); | |