test: pin gateway close messages

This commit is contained in:
Shakker
2026-05-12 18:11:12 +01:00
parent 49029cbdcc
commit 1d31583e0d

View File

@@ -505,7 +505,7 @@ describe("connectGateway", () => {
});
expect(host.lastErrorCode).toBe(ConnectErrorDetailCodes.AUTH_TOKEN_MISMATCH);
expect(host.lastError).toContain("gateway token mismatch");
expect(host.lastError).toBe("gateway token mismatch");
});
it("maps TypeError fetch failures to actionable auth rate-limit guidance", () => {
@@ -525,7 +525,7 @@ describe("connectGateway", () => {
});
expect(host.lastErrorCode).toBe(ConnectErrorDetailCodes.AUTH_RATE_LIMITED);
expect(host.lastError).toContain("too many failed authentication attempts");
expect(host.lastError).toBe("too many failed authentication attempts");
});
it("maps generic fetch failures to actionable device identity guidance", () => {
@@ -545,7 +545,9 @@ describe("connectGateway", () => {
});
expect(host.lastErrorCode).toBe(ConnectErrorDetailCodes.CONTROL_UI_DEVICE_IDENTITY_REQUIRED);
expect(host.lastError).toContain("device identity required");
expect(host.lastError).toBe(
"device identity required (use HTTPS/localhost or allow insecure auth explicitly)",
);
});
it("maps generic fetch failures to actionable origin guidance", () => {
@@ -565,7 +567,9 @@ describe("connectGateway", () => {
});
expect(host.lastErrorCode).toBe(ConnectErrorDetailCodes.CONTROL_UI_ORIGIN_NOT_ALLOWED);
expect(host.lastError).toContain("origin not allowed");
expect(host.lastError).toBe(
"origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)",
);
});
it("preserves specific close errors even when auth detail codes are present", () => {
@@ -605,7 +609,9 @@ describe("connectGateway", () => {
},
});
expect(host.lastError).toContain("gateway token mismatch");
expect(host.lastError).toBe(
"unauthorized: gateway token mismatch (open the dashboard URL and paste the token in Control UI settings)",
);
expect(host.lastErrorCode).toBe("AUTH_TOKEN_MISMATCH");
});