Skip to content

Commit 404de40

Browse files
committed
test(runtime): Stabilize error and capability router coverage
Align integration expectations with safe runtime error messaging and\nremove implicit dependency on installed plugin package metadata for\ncapability routing and skill metadata validation tests.\n\nThis keeps test behavior deterministic across local and CI installs\nwhile preserving the runtime contracts under test.\n\nCo-Authored-By: Codex GPT-5 <codex@openai.com>
1 parent 205039a commit 404de40

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

packages/junior/tests/bot-handlers.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ describe("bot handlers (integration)", () => {
214214
}
215215
});
216216

217-
it("error recovery: posts error message when generateAssistantReply throws", async () => {
217+
it("error recovery: posts safe error message when generateAssistantReply throws", async () => {
218218
const { appSlackRuntime, setBotDepsForTests } = await import("@/chat/bot");
219219
setBotDepsForTests({
220220
generateAssistantReply: async () => {
@@ -235,11 +235,11 @@ describe("bot handlers (integration)", () => {
235235
})
236236
);
237237

238-
const errorPost = thread.posts.find(
239-
(p) => typeof p === "string" && p.includes("Error:")
238+
const errorPost = thread.posts.find((p) =>
239+
typeof p === "string" && p.includes("I ran into an internal error while processing that.")
240240
);
241241
expect(errorPost).toBeDefined();
242-
expect(String(errorPost)).toContain("LLM unavailable");
242+
expect(String(errorPost)).not.toContain("LLM unavailable");
243243
});
244244

245245
it("posts non-empty fallback text when streaming reply includes files", async () => {

packages/junior/tests/capability-router.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, expect, it, vi } from "vitest";
22
import { ProviderCredentialRouter } from "@/chat/capabilities/router";
33
import type { CredentialBroker } from "@/chat/credentials/broker";
4+
import * as catalog from "@/chat/capabilities/catalog";
45

56
describe("provider credential router", () => {
67
it("routes known capability issuance to provider broker", async () => {
8+
const providerSpy = vi.spyOn(catalog, "getCapabilityProvider").mockReturnValue({
9+
provider: "github",
10+
capabilities: ["github.issues.read"],
11+
configKeys: ["github.repo"],
12+
target: { type: "repo", configKey: "github.repo" }
13+
});
714
const broker: CredentialBroker = {
815
issue: async (input) => ({
916
id: "lease-1",
@@ -28,9 +35,11 @@ describe("provider credential router", () => {
2835
provider: "github",
2936
capability: "github.issues.read"
3037
});
38+
providerSpy.mockRestore();
3139
});
3240

3341
it("rejects unsupported capabilities", async () => {
42+
const providerSpy = vi.spyOn(catalog, "getCapabilityProvider").mockReturnValue(undefined);
3443
const router = new ProviderCredentialRouter({
3544
brokersByProvider: {
3645
github: {
@@ -47,9 +56,16 @@ describe("provider credential router", () => {
4756
reason: "test"
4857
})
4958
).rejects.toThrow("Unsupported capability");
59+
providerSpy.mockRestore();
5060
});
5161

5262
it("rejects when provider broker is not registered", async () => {
63+
const providerSpy = vi.spyOn(catalog, "getCapabilityProvider").mockReturnValue({
64+
provider: "github",
65+
capabilities: ["github.issues.read"],
66+
configKeys: ["github.repo"],
67+
target: { type: "repo", configKey: "github.repo" }
68+
});
5369
const router = new ProviderCredentialRouter({
5470
brokersByProvider: {}
5571
});
@@ -60,5 +76,6 @@ describe("provider credential router", () => {
6076
reason: "test"
6177
})
6278
).rejects.toThrow("No credential broker registered for provider: github");
79+
providerSpy.mockRestore();
6380
});
6481
});

packages/junior/tests/skills.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ describe("skills", () => {
7373
"---",
7474
"name: tmp-valid-metadata",
7575
"description: Valid metadata skill.",
76-
"requires-capabilities: github.issues.read",
77-
"uses-config: github.repo",
7876
"---",
7977
"",
8078
"# Body"

0 commit comments

Comments
 (0)