Files
openclaw/extensions/discord/src/status-issues.test.ts
Josh Avant ba31afb099 fix(discord): surface stalled transport health (#76327)
* fix(discord): surface stalled transport health

* fix(discord): surface stalled transport health

* fix(discord): surface stalled transport health

---------

Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
2026-05-02 22:33:19 -05:00

93 lines
2.4 KiB
TypeScript

import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";
import { describe, expect, it } from "vitest";
import { collectDiscordStatusIssues } from "./status-issues.js";
describe("collectDiscordStatusIssues", () => {
it("reports disabled message content intent and unresolved channel ids", () => {
const issues = collectDiscordStatusIssues([
{
accountId: "ops",
enabled: true,
configured: true,
application: {
intents: {
messageContent: "disabled",
},
},
audit: {
unresolvedChannels: 2,
},
} as ChannelAccountSnapshot,
]);
expect(issues).toEqual(
expect.arrayContaining([
expect.objectContaining({
channel: "discord",
accountId: "ops",
kind: "intent",
}),
expect.objectContaining({
channel: "discord",
accountId: "ops",
kind: "config",
}),
]),
);
});
it("reports channel permission failures with match metadata", () => {
const issues = collectDiscordStatusIssues([
{
accountId: "ops",
enabled: true,
configured: true,
audit: {
channels: [
{
channelId: "123",
ok: false,
missing: ["ViewChannel", "SendMessages"],
error: "403",
matchKey: "alerts",
matchSource: "guilds.ops.channels",
},
],
},
} as ChannelAccountSnapshot,
]);
expect(issues).toHaveLength(1);
expect(issues[0]).toMatchObject({
channel: "discord",
accountId: "ops",
kind: "permissions",
});
expect(issues[0]?.message).toContain("Channel 123 permission check failed");
expect(issues[0]?.message).toContain("alerts");
expect(issues[0]?.message).toContain("guilds.ops.channels");
});
it("reports degraded runtime transport state", () => {
const issues = collectDiscordStatusIssues([
{
accountId: "ops",
enabled: true,
configured: true,
running: true,
connected: true,
healthState: "stale-socket",
} as ChannelAccountSnapshot,
]);
expect(issues).toEqual([
expect.objectContaining({
channel: "discord",
accountId: "ops",
kind: "runtime",
message: expect.stringContaining("stale-socket"),
}),
]);
});
});