






















@@ -41,6 +41,21 @@ function buildMissingScopeError(overrides?: {
4141return err;
4242}
434344+function readPostMessagePayload(
45+client: ReturnType<typeof createSlackSendTestClient>,
46+index: number,
47+): Record<string, unknown> {
48+const call = vi.mocked(client.chat.postMessage).mock.calls[index];
49+if (!call) {
50+throw new Error(`expected Slack postMessage call #${index + 1}`);
51+}
52+const [payload] = call;
53+if (!payload || typeof payload !== "object") {
54+throw new Error(`expected Slack postMessage payload #${index + 1}`);
55+}
56+return payload as Record<string, unknown>;
57+}
58+4459describe("sendMessageSlack customize-scope fallback", () => {
4560beforeEach(() => {
4661vi.mocked(logVerbose).mockClear();
@@ -60,8 +75,8 @@ describe("sendMessageSlack customize-scope fallback", () => {
6075});
61766277expect(client.chat.postMessage).toHaveBeenCalledTimes(2);
63-const [firstCall] = vi.mocked(client.chat.postMessage).mock.calls[0];
64-const [secondCall] = vi.mocked(client.chat.postMessage).mock.calls[1];
78+const firstCall = readPostMessagePayload(client, 0);
79+const secondCall = readPostMessagePayload(client, 1);
6580expect(firstCall).toEqual({
6681channel: "C123",
6782text: "hello",
@@ -94,7 +109,7 @@ describe("sendMessageSlack customize-scope fallback", () => {
94109});
9511096111expect(client.chat.postMessage).toHaveBeenCalledTimes(2);
97-const [secondCall] = vi.mocked(client.chat.postMessage).mock.calls[1];
112+const secondCall = readPostMessagePayload(client, 1);
98113expect(secondCall).not.toHaveProperty("icon_emoji");
99114expect(vi.mocked(logVerbose)).toHaveBeenCalledWith(
100115"slack send: missing chat:write.customize, retrying without custom identity",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。