fix: make missing actions config optional

This commit is contained in:
Federico Jaramillo Martinez
2026-05-21 11:20:24 +02:00
parent 698a89948b
commit 73fe658195
5 changed files with 62 additions and 11 deletions
@@ -34,14 +34,24 @@ describe("workspace actions client", () => {
});
});
it("treats a missing optional actions config as unconfigured", async () => {
const fetcher: FetchLike = () => Promise.resolve(new Response(JSON.stringify({ error: "Path does not exist" }), { status: 400 }));
await expect(loadWorkspaceActionsConfig(workspace, { fetch: fetcher })).resolves.toEqual({
kind: "missing",
message: "No workspace actions configured here.",
hint: `${ACTIONS_CONFIG_PATH} is optional. Create it in this workspace if you want custom actions.`,
});
});
it("returns a visible unavailable state instead of throwing on request failures", async () => {
const fetcher: FetchLike = () => Promise.resolve(new Response(JSON.stringify({ error: "nope" }), { status: 400 }));
await expect(loadWorkspaceActionsConfig(workspace, { fetch: fetcher })).resolves.toMatchObject({
kind: "unavailable",
message: `No valid ${ACTIONS_CONFIG_PATH} found.`,
hint: `Add or fix ${ACTIONS_CONFIG_PATH}, then click Refresh.`,
detail: `Unable to read ${ACTIONS_CONFIG_PATH}: HTTP 400`,
message: "Could not load workspace actions.",
hint: `Fix ${ACTIONS_CONFIG_PATH}, then click Refresh.`,
detail: `Unable to read ${ACTIONS_CONFIG_PATH}: HTTP 400: nope`,
});
});