From 24935c3f276582a1acafb8b87945837e9a887bc7 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Thu, 12 Nov 2026 19:12:52 -0300 Subject: [PATCH] test: #27's refusals in the codes #29 gave the contract #27 and #29 merged from the same base, so main ran #27's tests against #29's contract: connect.test failed with no_key_held, which the fake spin no longer writes, and proxy.test still held key_not_enrolled to be a code the contract does not know. The refusal is key_not_enrolled now, shown with its Add Key; the unknown code is one no release writes yet. Co-Authored-By: Claude Opus 5.5 --- test/unit/connect.test.ts | 4 ++-- test/unit/proxy.test.ts | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/test/unit/connect.test.ts b/test/unit/connect.test.ts index 2624456..631a36f 100644 --- a/test/unit/connect.test.ts +++ b/test/unit/connect.test.ts @@ -104,10 +104,10 @@ describe("prepareConnection", () => { }) it("shows a refusal with its action, then closes the remote", async () => { - const { deps, seen } = setup({ FAKE_SPIN_ERROR: "no_key_held" }) + const { deps, seen } = setup({ FAKE_SPIN_ERROR: "key_not_enrolled" }) expect(await prepareConnection(deps, "ssh-remote", "ssh-remote+spin.my-ws")).toBe(false) expect(seen.errors).toHaveLength(1) - expect((seen.errors[0] as CliError).code).toBe("no_key_held") + expect((seen.errors[0] as CliError).code).toBe("key_not_enrolled") expect(seen.closed).toBe(1) }) diff --git a/test/unit/proxy.test.ts b/test/unit/proxy.test.ts index e9380bd..4b4fa21 100644 --- a/test/unit/proxy.test.ts +++ b/test/unit/proxy.test.ts @@ -117,15 +117,19 @@ describe("fileProxyStatus", () => { }) describe("proxyFailure", () => { - it("is the CLI's envelope for a code the contract knows", () => { - const error = { code: "no_capacity", action: "retry", message: "full" } - expect(proxyFailure(status("failed", { error }))).toEqual({ envelope: { error } }) + it.each([ + ["a refusal", "refused", KEY_NOT_ENROLLED], + ["a failure", "failed", { code: "no_capacity", action: "retry", message: "full" }], + ] as const)("is the CLI's envelope, with its action, for %s", (_what, phase, error) => { + expect(proxyFailure(status(phase, { error }))).toEqual({ envelope: { error } }) }) + // A release newer than the contract can write a code it does not know yet. it("is the message and its page for a code the contract does not know", () => { - expect(proxyFailure(status("refused", { error: KEY_NOT_ENROLLED }))).toEqual({ - message: `Spinbox could not connect to ${HOST}: ${KEY_NOT_ENROLLED.message}`, - url: KEY_NOT_ENROLLED.url, + const error = { ...KEY_NOT_ENROLLED, code: "key_revoked" } + expect(proxyFailure(status("refused", { error }))).toEqual({ + message: `Spinbox could not connect to ${HOST}: ${error.message}`, + url: error.url, }) })