Files
openclaw/extensions/slack/src/monitor/provider.auth-errors.test.ts
Subash Natarajan 01dcaba78d fix(slack): remove socket reconnect attempt cap so gateway stays connected indefinitely (#73162)
Merged via squash.

Prepared head SHA: ac51979a7f
Co-authored-by: suboss87 <11032439+suboss87@users.noreply.github.com>
Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
Reviewed-by: @steipete
2026-06-18 08:18:30 +02:00

69 lines
2.4 KiB
TypeScript

// Slack tests cover provider.auth errors plugin behavior.
import { describe, it, expect } from "vitest";
import { isNonRecoverableSlackAuthError } from "./reconnect-policy.js";
describe("isNonRecoverableSlackAuthError", () => {
it.each([
"An API error occurred: account_inactive",
"An API error occurred: invalid_auth",
"An API error occurred: token_revoked",
"An API error occurred: token_expired",
"An API error occurred: not_authed",
"An API error occurred: org_login_required",
"An API error occurred: team_access_not_granted",
"An API error occurred: user_removed_from_team",
"An API error occurred: team_disabled",
"An API error occurred: missing_scope",
"An API error occurred: cannot_find_service",
"An API error occurred: invalid_token",
])("returns true for non-recoverable error: %s", (msg) => {
expect(isNonRecoverableSlackAuthError(new Error(msg))).toBe(true);
});
it("returns true when error is a plain string", () => {
expect(isNonRecoverableSlackAuthError("account_inactive")).toBe(true);
});
it("matches case-insensitively", () => {
expect(isNonRecoverableSlackAuthError(new Error("ACCOUNT_INACTIVE"))).toBe(true);
expect(isNonRecoverableSlackAuthError(new Error("Invalid_Auth"))).toBe(true);
});
it.each([
"Connection timed out",
"ECONNRESET",
"Network request failed",
"socket hang up",
"ETIMEDOUT",
"rate_limited",
])("returns false for recoverable/transient error: %s", (msg) => {
expect(isNonRecoverableSlackAuthError(new Error(msg))).toBe(false);
});
it.each([
{
code: "slack_webapi_request_error",
original: new Error("ECONNRESET"),
},
{
code: "slack_webapi_http_error",
statusCode: 503,
statusMessage: "Service Unavailable",
},
])("returns false for recoverable Slack Web API errors", (error) => {
expect(isNonRecoverableSlackAuthError(error)).toBe(false);
});
it("returns false for non-error values", () => {
expect(isNonRecoverableSlackAuthError(null)).toBe(false);
expect(isNonRecoverableSlackAuthError(undefined)).toBe(false);
expect(isNonRecoverableSlackAuthError(42)).toBe(false);
expect(isNonRecoverableSlackAuthError({})).toBe(false);
});
it("returns false for empty string", () => {
expect(isNonRecoverableSlackAuthError("")).toBe(false);
expect(isNonRecoverableSlackAuthError(new Error(""))).toBe(false);
});
});