惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
L
LangChain Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
IT之家
IT之家
A
About on SuperTechFans
H
Help Net Security

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: clear discord provider broad matchers · openclaw/op...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -102,6 +102,26 @@ function createConfigWithDiscordAccount(overrides: Record<string, unknown> = {})

102102

} as OpenClawConfig;

103103

}

104104105+

type MockCallReader = { mock: { calls: unknown[][] } };

106+107+

function mockMessages(mock: unknown): string[] {

108+

return (mock as MockCallReader).mock.calls.map((call) => String(call[0] ?? ""));

109+

}

110+111+

function expectMockLogContains(mock: unknown, expected: string): void {

112+

expect(mockMessages(mock).some((message) => message.includes(expected))).toBe(true);

113+

}

114+115+

function expectMockLogNotContains(mock: unknown, expected: string): void {

116+

expect(mockMessages(mock).every((message) => !message.includes(expected))).toBe(true);

117+

}

118+119+

function expectMessagesContainAll(messages: string[], expected: string[]): void {

120+

for (const entry of expected) {

121+

expect(messages.some((message) => message.includes(entry))).toBe(true);

122+

}

123+

}

124+105125

vi.mock("../voice/manager.runtime.js", () => {

106126

voiceRuntimeModuleLoadedMock();

107127

return {

@@ -163,6 +183,21 @@ describe("monitorDiscordProvider", () => {

163183

return reconcileParams.healthProbe;

164184

};

165185186+

const getMonitorLifecycleParams = (): {

187+

gatewayReadyTimeoutMs?: number;

188+

gatewayRuntimeReadyTimeoutMs?: number;

189+

} => {

190+

expect(monitorLifecycleMock).toHaveBeenCalledTimes(1);

191+

const firstCall = monitorLifecycleMock.mock.calls.at(0);

192+

const params = firstCall?.[0] as

193+

| { gatewayReadyTimeoutMs?: number; gatewayRuntimeReadyTimeoutMs?: number }

194+

| undefined;

195+

if (!params) {

196+

throw new Error("expected lifecycle monitor params");

197+

}

198+

return params;

199+

};

200+166201

beforeAll(async () => {

167202

vi.doMock("openclaw/plugin-sdk/plugin-runtime", async () => {

168203

const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/plugin-runtime")>(

@@ -330,8 +365,9 @@ describe("monitorDiscordProvider", () => {

330365

expect(

331366

emitter.emit("error", new Error("Max reconnect attempts (0) reached after code 1005")),

332367

).toBe(true);

333-

expect(runtime.error).toHaveBeenCalledWith(

334-

expect.stringContaining("suppressed late gateway reconnect-exhausted error after dispose"),

368+

expectMockLogContains(

369+

runtime.error,

370+

"suppressed late gateway reconnect-exhausted error after dispose",

335371

);

336372

});

337373

@@ -350,7 +386,7 @@ describe("monitorDiscordProvider", () => {

350386

expect(monitorLifecycleMock).not.toHaveBeenCalled();

351387

expect(createdBindingManagers).toHaveLength(1);

352388

expect(createdBindingManagers[0]?.stop).toHaveBeenCalledTimes(1);

353-

expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("identity offline"));

389+

expectMockLogContains(runtime.error, "identity offline");

354390

});

355391356392

it("fails closed before lifecycle when Discord bot identity has no usable id", async () => {

@@ -368,7 +404,7 @@ describe("monitorDiscordProvider", () => {

368404

expect(monitorLifecycleMock).not.toHaveBeenCalled();

369405

expect(createdBindingManagers).toHaveLength(1);

370406

expect(createdBindingManagers[0]?.stop).toHaveBeenCalledTimes(1);

371-

expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("no usable id"));

407+

expectMockLogContains(runtime.error, "no usable id");

372408

});

373409374410

it("does not double-stop thread bindings when lifecycle performs cleanup", async () => {

@@ -402,12 +438,9 @@ describe("monitorDiscordProvider", () => {

402438

runtime: baseRuntime(),

403439

});

404440405-

expect(monitorLifecycleMock).toHaveBeenCalledWith(

406-

expect.objectContaining({

407-

gatewayReadyTimeoutMs: 90_000,

408-

gatewayRuntimeReadyTimeoutMs: 120_000,

409-

}),

410-

);

441+

const lifecycleParams = getMonitorLifecycleParams();

442+

expect(lifecycleParams.gatewayReadyTimeoutMs).toBe(90_000);

443+

expect(lifecycleParams.gatewayRuntimeReadyTimeoutMs).toBe(120_000);

411444

});

412445413446

it("does not load the Discord voice runtime when voice is disabled", async () => {

@@ -852,9 +885,7 @@ describe("monitorDiscordProvider", () => {

852885853886

await vi.waitFor(() => expect(clientDeployCommandsMock).toHaveBeenCalledTimes(1));

854887

expect(monitorLifecycleMock).toHaveBeenCalledTimes(1);

855-

expect(runtime.error).not.toHaveBeenCalledWith(

856-

expect.stringContaining("failed to deploy native commands"),

857-

);

888+

expectMockLogNotContains(runtime.error, "failed to deploy native commands");

858889

expect(

859890

vi

860891

.mocked(runtime.log)

@@ -908,9 +939,7 @@ describe("monitorDiscordProvider", () => {

908939

expect(warningMessages[0]).toContain("retry after 0s");

909940

expect(warningMessages[0]).toContain("Message send/receive is unaffected.");

910941

expect(warningMessages[0]).not.toContain("body=");

911-

expect(runtime.error).not.toHaveBeenCalledWith(

912-

expect.stringContaining("native-slash-command-deploy-rest"),

913-

);

942+

expectMockLogNotContains(runtime.error, "native-slash-command-deploy-rest");

914943

});

915944916945

it("formats Discord deploy rate limits without raw response bodies", () => {

@@ -985,11 +1014,10 @@ describe("monitorDiscordProvider", () => {

98510149861015

await vi.waitFor(() => expect(clientDeployCommandsMock).toHaveBeenCalledTimes(1));

9871016

expect(clientDeployCommandsMock).toHaveBeenCalledWith({ mode: "reconcile" });

988-

expect(getConstructedClientOptions().requestOptions).toMatchObject({

989-

timeout: 15_000,

990-

runtimeProfile: "persistent",

991-

maxQueueSize: 1000,

992-

});

1017+

const requestOptions = getConstructedClientOptions().requestOptions;

1018+

expect(requestOptions?.timeout).toBe(15_000);

1019+

expect(requestOptions?.runtimeProfile).toBe("persistent");

1020+

expect(requestOptions?.maxQueueSize).toBe(1000);

9931021

expect(getConstructedClientOptions().eventQueue?.listenerTimeout).toBe(120_000);

9941022

});

9951023

@@ -1017,9 +1045,7 @@ describe("monitorDiscordProvider", () => {

10171045

expect(listNativeCommandSpecsForConfigMock).not.toHaveBeenCalled();

10181046

expect(getPluginCommandSpecsMock).not.toHaveBeenCalled();

10191047

expect(clientDeployCommandsMock).not.toHaveBeenCalled();

1020-

expect(runtime.log).not.toHaveBeenCalledWith(

1021-

expect.stringContaining("cleared native commands"),

1022-

);

1048+

expectMockLogNotContains(runtime.log, "cleared native commands");

10231049

});

1024105010251051

it("derives application id from token before probing Discord over REST", async () => {

@@ -1082,8 +1108,9 @@ describe("monitorDiscordProvider", () => {

10821108

setStatus,

10831109

});

108411101085-

expect(setStatus.mock.calls).toContainEqual([expect.objectContaining({ connected: true })]);

1086-

expect(setStatus.mock.calls).toContainEqual([expect.objectContaining({ connected: false })]);

1111+

const statuses = setStatus.mock.calls.map((call) => call[0] as { connected?: boolean });

1112+

expect(statuses.some((status) => status.connected === true)).toBe(true);

1113+

expect(statuses.some((status) => status.connected === false)).toBe(true);

10871114

});

1088111510891116

it("logs Discord startup phases and early gateway debug events", async () => {

@@ -1104,27 +1131,21 @@ describe("monitorDiscordProvider", () => {

11041131

runtime,

11051132

});

110611331107-

await vi.waitFor(() =>

1108-

expect(vi.mocked(runtime.log).mock.calls.map((call) => String(call[0]))).toEqual(

1109-

expect.arrayContaining([expect.stringContaining("deploy-commands:done")]),

1110-

),

1111-

);

1134+

await vi.waitFor(() => expectMockLogContains(runtime.log, "deploy-commands:done"));

1112113511131136

const messages = vi.mocked(runtime.log).mock.calls.map((call) => String(call[0]));

1114-

expect(messages).toEqual(

1115-

expect.arrayContaining([

1116-

expect.stringContaining("fetch-application-id:start"),

1117-

expect.stringContaining("fetch-application-id:done"),

1118-

expect.stringContaining("deploy-commands:schedule"),

1119-

expect.stringContaining("deploy-commands:scheduled"),

1120-

expect.stringContaining("deploy-commands:done"),

1121-

expect.stringContaining("fetch-bot-identity:start"),

1122-

expect.stringContaining("fetch-bot-identity:done"),

1123-

]),

1124-

);

1125-

expect(messages).toEqual(

1126-

expect.arrayContaining([expect.stringMatching(/gateway-debug.*Gateway websocket opened/)]),

1127-

);

1137+

expectMessagesContainAll(messages, [

1138+

"fetch-application-id:start",

1139+

"fetch-application-id:done",

1140+

"deploy-commands:schedule",

1141+

"deploy-commands:scheduled",

1142+

"deploy-commands:done",

1143+

"fetch-bot-identity:start",

1144+

"fetch-bot-identity:done",

1145+

]);

1146+

expect(

1147+

messages.some((message) => /gateway-debug.*Gateway websocket opened/.test(message)),

1148+

).toBe(true);

11281149

});

1129115011301151

it("keeps Discord startup chatter quiet by default", async () => {

@@ -1136,8 +1157,6 @@ describe("monitorDiscordProvider", () => {

11361157

});

1137115811381159

const messages = vi.mocked(runtime.log).mock.calls.map((call) => String(call[0]));

1139-

expect(messages).not.toEqual(

1140-

expect.arrayContaining([expect.stringContaining("discord startup [")]),

1141-

);

1160+

expect(messages.every((message) => !message.includes("discord startup ["))).toBe(true);

11421161

});

11431162

});