diff --git a/apps/server/src/routes/slack/handler.test.ts b/apps/server/src/routes/slack/handler.test.ts index 4aba624fb..8b405dea8 100644 --- a/apps/server/src/routes/slack/handler.test.ts +++ b/apps/server/src/routes/slack/handler.test.ts @@ -239,6 +239,24 @@ describe("handleSlackEvent", () => { expect(slackTestState.calls.length).toBe(0); }); + test("stays quiet when added to a channel in an unknown workspace", async () => { + await settleBackgroundTasks(); + slackTestState.calls = []; + await signAndPost(app, { + type: "event_callback", + team_id: "T_UNKNOWN", + event_id: `evt_join_unknown_${Date.now()}`, + event: { + type: "member_joined_channel", + user: "UBOT", + inviter: "U1", + channel: "C_NEW", + }, + }); + await settleBackgroundTasks(); + expect(slackTestState.calls.length).toBe(0); + }); + test("ignores app_home_opened for the messages tab", async () => { // Earlier tests' events may still be posting; only this one's calls count. await settleBackgroundTasks(); diff --git a/apps/server/src/routes/slack/interactions.test.ts b/apps/server/src/routes/slack/interactions.test.ts index 21328a8fc..5261d6c9c 100644 --- a/apps/server/src/routes/slack/interactions.test.ts +++ b/apps/server/src/routes/slack/interactions.test.ts @@ -1564,6 +1564,37 @@ describe("publish status update button", () => { ); }); + test("picking another status page redraws the form without an incident", async () => { + await signAndPost(app, { + type: "block_actions", + team: { id: "T_KNOWN" }, + user: { id: "U_OWNER" }, + view: { + id: "V_WELCOME", + private_metadata: JSON.stringify({ channelId: "C_NEW" }), + }, + actions: [ + { action_id: "incident_card_page", selected_option: { value: "1" } }, + ], + }); + const update = slackTestState.calls.find( + (c) => c.method === "views.update", + ); + expect(update?.args.view_id).toBe("V_WELCOME"); + const view = update?.args.view as { + callback_id?: string; + private_metadata?: string; + blocks: unknown[]; + }; + expect(view.callback_id).toBe("incident_card_status_page"); + expect(JSON.parse(view.private_metadata ?? "{}")).toEqual({ + channelId: "C_NEW", + }); + expect(JSON.stringify(view.blocks)).not.toContain( + "linked to this incident", + ); + }); + test("publishing creates an unlinked report and posts it in the channel", async () => { const title = `Welcome ${crypto.randomUUID()}`; const res = await signAndPost(app, { @@ -1589,8 +1620,8 @@ describe("publish status update button", () => { .from(statusReport) .where(eq(statusReport.title, title)) .get(); - expect(report?.pageId).toBe(1); if (report) created.push(report.id); + expect(report?.pageId).toBe(1); const linked = await db .select() .from(incident)