Files
openclaw/extensions/slack/src/monitor/provider.auth-errors.test.ts
scoootscooob 8746362f5e refactor(slack): move Slack channel code to extensions/slack/src/ (#45621)
Move all Slack channel implementation files from src/slack/ to
extensions/slack/src/ and replace originals with shim re-exports.
This follows the extension migration pattern for channel plugins.

- Copy all .ts files to extensions/slack/src/ (preserving directory
  structure: monitor/, http/, monitor/events/, monitor/message-handler/)
- Transform import paths: external src/ imports use relative paths
  back to src/, internal slack imports stay relative within extension
- Replace all src/slack/ files with shim re-exports pointing to
  the extension copies
- Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." so
  the DTS build can follow shim chains into extensions/
- Update write-plugin-sdk-entry-dts.ts re-export path accordingly
- Preserve extensions/slack/index.ts, package.json, openclaw.plugin.json,
  src/channel.ts, src/runtime.ts, src/channel.test.ts (untouched)
2026-03-14 02:47:04 -07:00

52 lines
1.9 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { isNonRecoverableSlackAuthError } from "./provider.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: 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("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);
});
});