fix: verify ClickClack workspace ids during setup

This commit is contained in:
Shakker
2026-07-15 06:57:58 +01:00
committed by Shakker
parent 2c7705e363
commit 618c01af69
2 changed files with 8 additions and 6 deletions

View File

@@ -212,9 +212,8 @@ describe("ClickClack setup wizard", () => {
});
it("keeps setup saved when workspace resolution fails", async () => {
mocks.resolveWorkspaceId.mockRejectedValue(
new Error("ClickClack workspace not found: missing"),
);
mocks.resolveWorkspaceId.mockResolvedValue("wsp_missing");
mocks.workspaces.mockResolvedValue([]);
const note = vi.fn(async () => undefined);
await expect(
@@ -224,7 +223,7 @@ describe("ClickClack setup wizard", () => {
channels: {
clickclack: {
...configuredAccount.channels.clickclack,
workspace: "missing",
workspace: "wsp_missing",
},
},
},
@@ -232,7 +231,7 @@ describe("ClickClack setup wizard", () => {
}),
).resolves.toBeUndefined();
expect(note).toHaveBeenCalledWith(
'Workspace "missing" was not found. Check the id, slug, or name, list available workspaces, and rerun setup.',
'Workspace "wsp_missing" was not found. Check the id, slug, or name, list available workspaces, and rerun setup.',
"ClickClack connection check",
);
});

View File

@@ -162,10 +162,13 @@ export const clickClackSetupWizard: ChannelSetupWizard = {
const workspaceId = await resolveWorkspaceId(client, account.workspace);
const workspaces = await client.workspaces();
const workspace = workspaces.find((candidate) => candidate.id === workspaceId);
if (!workspace) {
throw new Error(`ClickClack workspace not found: ${account.workspace}`);
}
await prompter.note(
t("wizard.clickclack.connected", {
handle: me.handle,
workspace: workspace?.name ?? workspaceId,
workspace: workspace.name,
}),
t("wizard.clickclack.connectionTitle"),
);