Skip to content

Commit b41d766

Browse files
committed
test: pin skill update config writes
1 parent 6fb630a commit b41d766

1 file changed

Lines changed: 24 additions & 30 deletions

File tree

src/gateway/server-methods/skills.update.normalizes-api-key.test.ts

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ vi.mock("../../config/config.js", () => {
2323

2424
const { skillsHandlers } = await import("./skills.js");
2525

26+
function expectWrittenSkillEntry(skillKey: string, entry: unknown) {
27+
expect(writtenConfig).toBeDefined();
28+
const config = writtenConfig as {
29+
skills?: {
30+
entries?: Record<string, unknown>;
31+
};
32+
};
33+
expect(Object.keys(config).sort()).toEqual(["skills"]);
34+
expect(Object.keys(config.skills ?? {}).sort()).toEqual(["entries"]);
35+
expect(config.skills?.entries?.[skillKey]).toEqual(entry);
36+
}
37+
2638
describe("skills.update", () => {
2739
it("strips embedded CR/LF from apiKey", async () => {
2840
writtenConfig = null;
@@ -51,14 +63,8 @@ describe("skills.update", () => {
5163

5264
expect(ok).toBe(true);
5365
expect(error).toBeUndefined();
54-
expect(writtenConfig).toMatchObject({
55-
skills: {
56-
entries: {
57-
"brave-search": {
58-
apiKey: "abcdef",
59-
},
60-
},
61-
},
66+
expectWrittenSkillEntry("brave-search", {
67+
apiKey: "abcdef",
6268
});
6369
});
6470

@@ -90,17 +96,11 @@ describe("skills.update", () => {
9096
});
9197

9298
// Full values must be persisted to config
93-
expect(writtenConfig).toMatchObject({
94-
skills: {
95-
entries: {
96-
"demo-skill": {
97-
apiKey: "secret-api-key-123",
98-
env: {
99-
GEMINI_API_KEY: "secret-env-key-456",
100-
BRAVE_REGION: "us",
101-
},
102-
},
103-
},
99+
expectWrittenSkillEntry("demo-skill", {
100+
apiKey: "secret-api-key-123",
101+
env: {
102+
GEMINI_API_KEY: "secret-env-key-456",
103+
BRAVE_REGION: "us",
104104
},
105105
});
106106

@@ -145,17 +145,11 @@ describe("skills.update", () => {
145145
respond: () => {},
146146
});
147147

148-
expect(writtenConfig).toMatchObject({
149-
skills: {
150-
entries: {
151-
"demo-skill": {
152-
apiKey: "secret-api-key-123",
153-
env: {
154-
GEMINI_API_KEY: "secret-env-key-456",
155-
BRAVE_REGION: "eu",
156-
},
157-
},
158-
},
148+
expectWrittenSkillEntry("demo-skill", {
149+
apiKey: "secret-api-key-123",
150+
env: {
151+
GEMINI_API_KEY: "secret-env-key-456",
152+
BRAVE_REGION: "eu",
159153
},
160154
});
161155
});

0 commit comments

Comments
 (0)