mirror of https://github.com/openclaw/openclaw.git
test: cover Slack probe auth mapping
This commit is contained in:
parent
63e41d1735
commit
ecc73fe47c
|
|
@ -33,6 +33,7 @@ Docs: https://docs.openclaw.ai
|
||||||
- macOS/onboarding: avoid self-restarting freshly bootstrapped launchd gateways and give new daemon installs longer to become healthy, so `openclaw onboard --install-daemon` no longer false-fails on slower Macs and fresh VM snapshots.
|
- macOS/onboarding: avoid self-restarting freshly bootstrapped launchd gateways and give new daemon installs longer to become healthy, so `openclaw onboard --install-daemon` no longer false-fails on slower Macs and fresh VM snapshots.
|
||||||
- Agents/compaction: preserve safeguard compaction summary language continuity via default and configurable custom instructions so persona drift is reduced after auto-compaction. (#10456) Thanks @keepitmello.
|
- Agents/compaction: preserve safeguard compaction summary language continuity via default and configurable custom instructions so persona drift is reduced after auto-compaction. (#10456) Thanks @keepitmello.
|
||||||
- Agents/tool warnings: distinguish gated core tools like `apply_patch` from plugin-only unknown entries in `tools.profile` warnings, so unavailable core tools now report current runtime/provider/model/config gating instead of suggesting a missing plugin.
|
- Agents/tool warnings: distinguish gated core tools like `apply_patch` from plugin-only unknown entries in `tools.profile` warnings, so unavailable core tools now report current runtime/provider/model/config gating instead of suggesting a missing plugin.
|
||||||
|
- Slack/probe: keep `auth.test()` bot and team metadata mapping stable while simplifying the probe result path. (#44775) Thanks @Cafexss.
|
||||||
|
|
||||||
## 2026.3.12
|
## 2026.3.12
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
|
const authTestMock = vi.hoisted(() => vi.fn());
|
||||||
|
const createSlackWebClientMock = vi.hoisted(() => vi.fn());
|
||||||
|
const withTimeoutMock = vi.hoisted(() => vi.fn());
|
||||||
|
|
||||||
|
vi.mock("./client.js", () => ({
|
||||||
|
createSlackWebClient: createSlackWebClientMock,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../utils/with-timeout.js", () => ({
|
||||||
|
withTimeout: withTimeoutMock,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const { probeSlack } = await import("./probe.js");
|
||||||
|
|
||||||
|
describe("probeSlack", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
authTestMock.mockReset();
|
||||||
|
createSlackWebClientMock.mockReset();
|
||||||
|
withTimeoutMock.mockReset();
|
||||||
|
|
||||||
|
createSlackWebClientMock.mockReturnValue({
|
||||||
|
auth: {
|
||||||
|
test: authTestMock,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
withTimeoutMock.mockImplementation(async (promise: Promise<unknown>) => await promise);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("maps Slack auth metadata on success", async () => {
|
||||||
|
vi.spyOn(Date, "now").mockReturnValueOnce(100).mockReturnValueOnce(145);
|
||||||
|
authTestMock.mockResolvedValue({
|
||||||
|
ok: true,
|
||||||
|
user_id: "U123",
|
||||||
|
user: "openclaw-bot",
|
||||||
|
team_id: "T123",
|
||||||
|
team: "OpenClaw",
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(probeSlack("xoxb-test", 2500)).resolves.toEqual({
|
||||||
|
ok: true,
|
||||||
|
status: 200,
|
||||||
|
elapsedMs: 45,
|
||||||
|
bot: { id: "U123", name: "openclaw-bot" },
|
||||||
|
team: { id: "T123", name: "OpenClaw" },
|
||||||
|
});
|
||||||
|
expect(createSlackWebClientMock).toHaveBeenCalledWith("xoxb-test");
|
||||||
|
expect(withTimeoutMock).toHaveBeenCalledWith(expect.any(Promise), 2500);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps optional auth metadata fields undefined when Slack omits them", async () => {
|
||||||
|
vi.spyOn(Date, "now").mockReturnValueOnce(200).mockReturnValueOnce(235);
|
||||||
|
authTestMock.mockResolvedValue({ ok: true });
|
||||||
|
|
||||||
|
const result = await probeSlack("xoxb-test");
|
||||||
|
|
||||||
|
expect(result.ok).toBe(true);
|
||||||
|
expect(result.status).toBe(200);
|
||||||
|
expect(result.elapsedMs).toBe(35);
|
||||||
|
expect(result.bot).toStrictEqual({ id: undefined, name: undefined });
|
||||||
|
expect(result.team).toStrictEqual({ id: undefined, name: undefined });
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue