mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:11:23 +00:00
fix: reduce Slack WebClient retries
This commit is contained in:
46
src/slack/client.test.ts
Normal file
46
src/slack/client.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("@slack/web-api", () => {
|
||||
const WebClient = vi.fn(function WebClientMock(
|
||||
this: Record<string, unknown>,
|
||||
token: string,
|
||||
options?: Record<string, unknown>,
|
||||
) {
|
||||
this.token = token;
|
||||
this.options = options;
|
||||
});
|
||||
return { WebClient };
|
||||
});
|
||||
|
||||
const slackWebApi = await import("@slack/web-api");
|
||||
const { createSlackWebClient, resolveSlackWebClientOptions, SLACK_DEFAULT_RETRY_OPTIONS } =
|
||||
await import("./client.js");
|
||||
|
||||
const WebClient = slackWebApi.WebClient as unknown as ReturnType<typeof vi.fn>;
|
||||
|
||||
describe("slack web client config", () => {
|
||||
it("applies the default retry config when none is provided", () => {
|
||||
const options = resolveSlackWebClientOptions();
|
||||
|
||||
expect(options.retryConfig).toEqual(SLACK_DEFAULT_RETRY_OPTIONS);
|
||||
});
|
||||
|
||||
it("respects explicit retry config overrides", () => {
|
||||
const customRetry = { retries: 0 };
|
||||
const options = resolveSlackWebClientOptions({ retryConfig: customRetry });
|
||||
|
||||
expect(options.retryConfig).toBe(customRetry);
|
||||
});
|
||||
|
||||
it("passes merged options into WebClient", () => {
|
||||
createSlackWebClient("xoxb-test", { timeout: 1234 });
|
||||
|
||||
expect(WebClient).toHaveBeenCalledWith(
|
||||
"xoxb-test",
|
||||
expect.objectContaining({
|
||||
timeout: 1234,
|
||||
retryConfig: SLACK_DEFAULT_RETRY_OPTIONS,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user