





















@@ -41,6 +41,35 @@ describe("readSlackMessages", () => {
4141expect(result.messages.map((message) => message.ts)).toEqual(["171234.890", "171235.000"]);
4242});
434344+it("filters a specific thread reply by messageId", async () => {
45+const client = createClient();
46+client.conversations.replies.mockResolvedValueOnce({
47+messages: [{ ts: "171234.567" }, { ts: "171234.890", text: "reply" }],
48+has_more: true,
49+});
50+51+const result = await readSlackMessages("C1", {
52+ client,
53+threadId: "171234.567",
54+messageId: "171234.890",
55+limit: 20,
56+token: "xoxb-test",
57+});
58+59+expect(client.conversations.replies).toHaveBeenCalledWith({
60+channel: "C1",
61+ts: "171234.567",
62+limit: 1,
63+inclusive: true,
64+latest: "171234.890",
65+oldest: undefined,
66+});
67+expect(result).toEqual({
68+messages: [{ ts: "171234.890", text: "reply" }],
69+hasMore: false,
70+});
71+});
72+4473it("uses conversations.history when threadId is missing", async () => {
4574const client = createClient();
4675client.conversations.history.mockResolvedValueOnce({
@@ -63,4 +92,30 @@ describe("readSlackMessages", () => {
6392expect(client.conversations.replies).not.toHaveBeenCalled();
6493expect(result.messages.map((message) => message.ts)).toEqual(["1"]);
6594});
95+96+it("filters a specific channel message by messageId", async () => {
97+const client = createClient();
98+client.conversations.history.mockResolvedValueOnce({
99+messages: [{ ts: "171234.890", text: "exact" }, { ts: "171234.891" }],
100+has_more: true,
101+});
102+103+const result = await readSlackMessages("C1", {
104+ client,
105+messageId: "171234.890",
106+token: "xoxb-test",
107+});
108+109+expect(client.conversations.history).toHaveBeenCalledWith({
110+channel: "C1",
111+limit: 1,
112+inclusive: true,
113+latest: "171234.890",
114+oldest: undefined,
115+});
116+expect(result).toEqual({
117+messages: [{ ts: "171234.890", text: "exact" }],
118+hasMore: false,
119+});
120+});
66121});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。