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

推荐订阅源

Martin Fowler
Martin Fowler
V
Visual Studio Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
B
Blog
I
InfoQ
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
H
Help Net Security
博客园 - Franky
宝玉的分享
宝玉的分享
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家

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(extensions): trim hot extension imports · openclaw/o...
steipete · 2026-04-23 · via Recent Commits to openclaw:main

@@ -1,23 +1,25 @@

1-

import { afterEach, describe, expect, it, vi } from "vitest";

1+

import { beforeEach, describe, expect, it, vi } from "vitest";

2+

import { getActiveWebListener, resolveWebAccountId } from "./active-listener.js";

2334

vi.mock("openclaw/plugin-sdk/config-runtime", () => ({

45

loadConfig: () => ({

56

channels: { whatsapp: { accounts: { work: { enabled: true } }, defaultAccount: "work" } },

67

}),

78

}));

8910+

const registryMocks = vi.hoisted(() => ({

11+

getRegisteredWhatsAppConnectionController: vi.fn(),

12+

}));

13+14+

vi.mock("./connection-controller-registry.js", () => ({

15+

getRegisteredWhatsAppConnectionController:

16+

registryMocks.getRegisteredWhatsAppConnectionController,

17+

}));

18+919

const WHATSAPP_ACTIVE_LISTENER_TEST_CFG = {

1020

channels: { whatsapp: { accounts: { work: { enabled: true } }, defaultAccount: "work" } },

1121

};

122213-

type ActiveListenerModule = typeof import("./active-listener.js");

14-15-

const activeListenerModuleUrl = new URL("./active-listener.ts", import.meta.url).href;

16-17-

async function importActiveListenerModule(cacheBust: string): Promise<ActiveListenerModule> {

18-

return (await import(`${activeListenerModuleUrl}?t=${cacheBust}`)) as ActiveListenerModule;

19-

}

20-2123

function makeListener() {

2224

return {

2325

sendMessage: vi.fn(async () => ({ messageId: "msg-1" })),

@@ -27,53 +29,43 @@ function makeListener() {

2729

};

2830

}

293130-

afterEach(() => {

31-

vi.doUnmock("./connection-controller-registry.js");

32+

beforeEach(() => {

33+

registryMocks.getRegisteredWhatsAppConnectionController.mockReset();

3234

});

33353436

describe("active WhatsApp listener view", () => {

35-

it("reads controller-backed state across duplicate module instances", async () => {

37+

it("reads controller-backed state", () => {

3638

const listener = makeListener();

37-

vi.doMock("./connection-controller-registry.js", () => ({

38-

getRegisteredWhatsAppConnectionController: (accountId: string) =>

39+

registryMocks.getRegisteredWhatsAppConnectionController.mockImplementation(

40+

(accountId: string) =>

3941

accountId === "work"

4042

? {

4143

getActiveListener: () => listener,

4244

}

4345

: null,

44-

}));

45-46-

const first = await importActiveListenerModule(`first-${Date.now()}`);

47-

const second = await importActiveListenerModule(`second-${Date.now()}`);

46+

);

484749-

expect(first.getActiveWebListener("work")).toBe(listener);

50-

expect(second.getActiveWebListener("work")).toBe(listener);

48+

expect(getActiveWebListener("work")).toBe(listener);

5149

});

525053-

it("resolves the configured default account when accountId is omitted", async () => {

51+

it("resolves the configured default account when accountId is omitted", () => {

5452

const listener = makeListener();

55-

vi.doMock("./connection-controller-registry.js", () => ({

56-

getRegisteredWhatsAppConnectionController: (accountId: string) =>

53+

registryMocks.getRegisteredWhatsAppConnectionController.mockImplementation(

54+

(accountId: string) =>

5755

accountId === "work"

5856

? {

5957

getActiveListener: () => listener,

6058

}

6159

: null,

62-

}));

60+

);

636164-

const mod = await importActiveListenerModule(`default-${Date.now()}`);

65-66-

expect(mod.resolveWebAccountId({ cfg: WHATSAPP_ACTIVE_LISTENER_TEST_CFG })).toBe("work");

67-

expect(mod.getActiveWebListener("work")).toBe(listener);

62+

expect(resolveWebAccountId({ cfg: WHATSAPP_ACTIVE_LISTENER_TEST_CFG })).toBe("work");

63+

expect(getActiveWebListener("work")).toBe(listener);

6864

});

696570-

it("returns null when the controller has no active listener for the account", async () => {

71-

vi.doMock("./connection-controller-registry.js", () => ({

72-

getRegisteredWhatsAppConnectionController: () => null,

73-

}));

74-75-

const mod = await importActiveListenerModule(`missing-${Date.now()}`);

66+

it("returns null when the controller has no active listener for the account", () => {

67+

registryMocks.getRegisteredWhatsAppConnectionController.mockReturnValue(null);

766877-

expect(mod.getActiveWebListener("work")).toBeNull();

69+

expect(getActiveWebListener("work")).toBeNull();

7870

});

7971

});