



























@@ -857,17 +857,21 @@ describe("createMattermostInteractionHandler", () => {
857857post: fetchedPost,
858858});
859859expect(enqueueSystemEvent).toHaveBeenCalledWith(
860-expect.stringContaining('Mattermost button click: action="approve"'),
861-expect.objectContaining({ sessionKey: "session:thread:root-9" }),
862-);
863-expect(dispatchButtonClick).toHaveBeenCalledWith(
864-expect.objectContaining({
865-channelId: "chan-1",
866-userId: "user-1",
867-postId: "post-1",
868-post: fetchedPost,
869-}),
860+'Mattermost button click: action="approve" by alice in channel chan-1',
861+{
862+sessionKey: "session:thread:root-9",
863+contextKey: "mattermost:interaction:post-1:approve",
864+},
870865);
866+expect(dispatchButtonClick).toHaveBeenCalledWith({
867+channelId: "chan-1",
868+userId: "user-1",
869+userName: "alice",
870+actionId: "approve",
871+actionName: "Approve",
872+postId: "post-1",
873+post: fetchedPost,
874+});
871875});
872876873877it("lets a custom interaction handler short-circuit generic completion updates", async () => {
@@ -877,45 +881,45 @@ describe("createMattermostInteractionHandler", () => {
877881ephemeral_text: "Only the original requester can use this picker.",
878882});
879883const dispatchButtonClick = vi.fn();
884+const originalPost = createActionPost({
885+actionId: "mdlprov",
886+actionName: "Browse providers",
887+});
880888const handler = createMattermostInteractionHandler({
881889client: createMattermostClientMock(async (path: string, init?: { method?: string }) => {
882890requestLog.push({ path, method: init?.method });
883-return createActionPost({
884-actionId: "mdlprov",
885-actionName: "Browse providers",
886-});
891+return originalPost;
887892}),
888893botUserId: "bot",
889894accountId: "acct",
890895 handleInteraction,
891896 dispatchButtonClick,
892897});
893-894-const res = await runHandler(handler, {
895-body: createInteractionBody({
896- context,
897- token,
898-userId: "user-2",
899-userName: "alice",
900-}),
898+const body = createInteractionBody({
899+ context,
900+ token,
901+userId: "user-2",
902+userName: "alice",
901903});
902904905+const res = await runHandler(handler, { body });
906+903907expect(res.statusCode).toBe(200);
904908expect(res.body).toBe(
905909JSON.stringify({
906910ephemeral_text: "Only the original requester can use this picker.",
907911}),
908912);
909913expect(requestLog).toEqual([{ path: "/posts/post-1", method: undefined }]);
910-expect(handleInteraction).toHaveBeenCalledWith(
911-expect.objectContaining({
912- actionId: "mdlprov",
913- actionName: "Browse providers",
914- originalMessage: "Choose",
915- post: expect.objectContaining({ id: "post-1" }),
916- userName: "alice",
917-}),
918-);
914+expect(handleInteraction).toHaveBeenCalledWith({
915+payload: body,
916+userName: "alice",
917+actionId: "mdlprov",
918+actionName: "Browse providers",
919+originalMessage: "Choose",
920+context,
921+post: originalPost,
922+});
919923expect(dispatchButtonClick).not.toHaveBeenCalled();
920924});
921925});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。