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

推荐订阅源

Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 司徒正美
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
月光博客
月光博客
量子位
大猫的无限游戏
大猫的无限游戏
Stack Overflow Blog
Stack Overflow Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
P
Proofpoint News Feed
B
Blog RSS Feed
美团技术团队
腾讯CDC
C
Check Point Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
J
Java Code Geeks
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享

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
feat(slack): publish App Home tab views · openclaw/opencl...
vincentkoc · 2026-05-01 · via Recent Commits to openclaw:main

@@ -0,0 +1,102 @@

1+

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

2+3+

let buildSlackHomeView: typeof import("./home.js").buildSlackHomeView;

4+

let registerSlackHomeEvents: typeof import("./home.js").registerSlackHomeEvents;

5+

let createSlackSystemEventTestHarness: typeof import("./system-event-test-harness.js").createSlackSystemEventTestHarness;

6+7+

type HomeHandler = (args: { event: Record<string, unknown>; body: unknown }) => Promise<void>;

8+9+

function createHomeContext(params?: {

10+

trackEvent?: () => void;

11+

shouldDropMismatchedSlackEvent?: (body: unknown) => boolean;

12+

}) {

13+

const harness = createSlackSystemEventTestHarness();

14+

const publish = vi.fn().mockResolvedValue({ ok: true });

15+

if (params?.shouldDropMismatchedSlackEvent) {

16+

harness.ctx.shouldDropMismatchedSlackEvent = params.shouldDropMismatchedSlackEvent;

17+

}

18+

harness.ctx.botToken = "xoxb-test";

19+

(harness.ctx.app as unknown as { client: { views: { publish: typeof publish } } }).client = {

20+

views: { publish },

21+

};

22+

registerSlackHomeEvents({ ctx: harness.ctx, trackEvent: params?.trackEvent });

23+

return {

24+

publish,

25+

getHomeHandler: () => harness.getHandler("app_home_opened") as HomeHandler | null,

26+

};

27+

}

28+29+

describe("registerSlackHomeEvents", () => {

30+

beforeAll(async () => {

31+

({ buildSlackHomeView, registerSlackHomeEvents } = await import("./home.js"));

32+

({ createSlackSystemEventTestHarness } = await import("./system-event-test-harness.js"));

33+

});

34+35+

beforeEach(() => {

36+

vi.clearAllMocks();

37+

});

38+39+

it("publishes the default Home tab view for app_home_opened", async () => {

40+

const trackEvent = vi.fn();

41+

const { publish, getHomeHandler } = createHomeContext({ trackEvent });

42+

const handler = getHomeHandler();

43+

expect(handler).toBeTruthy();

44+45+

await handler!({

46+

event: {

47+

type: "app_home_opened",

48+

user: "U123",

49+

channel: "D123",

50+

tab: "home",

51+

event_ts: "123.456",

52+

},

53+

body: { api_app_id: "A1" },

54+

});

55+56+

expect(trackEvent).toHaveBeenCalledTimes(1);

57+

expect(publish).toHaveBeenCalledTimes(1);

58+

expect(publish).toHaveBeenCalledWith({

59+

token: "xoxb-test",

60+

user_id: "U123",

61+

view: buildSlackHomeView(),

62+

});

63+

});

64+65+

it("does not publish when Slack reports the Messages tab", async () => {

66+

const trackEvent = vi.fn();

67+

const { publish, getHomeHandler } = createHomeContext({ trackEvent });

68+69+

await getHomeHandler()!({

70+

event: {

71+

type: "app_home_opened",

72+

user: "U123",

73+

channel: "D123",

74+

tab: "messages",

75+

},

76+

body: {},

77+

});

78+79+

expect(trackEvent).toHaveBeenCalledTimes(1);

80+

expect(publish).not.toHaveBeenCalled();

81+

});

82+83+

it("does not track or publish mismatched events", async () => {

84+

const trackEvent = vi.fn();

85+

const { publish, getHomeHandler } = createHomeContext({

86+

trackEvent,

87+

shouldDropMismatchedSlackEvent: () => true,

88+

});

89+90+

await getHomeHandler()!({

91+

event: {

92+

type: "app_home_opened",

93+

user: "U123",

94+

tab: "home",

95+

},

96+

body: { api_app_id: "A_OTHER" },

97+

});

98+99+

expect(trackEvent).not.toHaveBeenCalled();

100+

expect(publish).not.toHaveBeenCalled();

101+

});

102+

});