




















@@ -8,6 +8,7 @@ vi.mock("./slash-commands.runtime.js", () => {
88const reportExternalCommand = { key: "reportexternal", nativeName: "reportexternal" };
99const reportLongCommand = { key: "reportlong", nativeName: "reportlong" };
1010const reportLongButtonCommand = { key: "reportlongbutton", nativeName: "reportlongbutton" };
11+const reportHugeButtonCommand = { key: "reporthugebutton", nativeName: "reporthugebutton" };
1112const unsafeConfirmCommand = { key: "unsafeconfirm", nativeName: "unsafeconfirm" };
1213const longConfirmCommand = { key: "longconfirm", nativeName: "longconfirm" };
1314const statusAliasCommand = { key: "status", nativeName: "status" };
@@ -76,6 +77,9 @@ vi.mock("./slash-commands.runtime.js", () => {
7677if (normalized === "reportlongbutton") {
7778return reportLongButtonCommand;
7879}
80+if (normalized === "reporthugebutton") {
81+return reportHugeButtonCommand;
82+}
7983if (normalized === "unsafeconfirm") {
8084return unsafeConfirmCommand;
8185}
@@ -124,6 +128,12 @@ vi.mock("./slash-commands.runtime.js", () => {
124128acceptsArgs: true,
125129args: [],
126130},
131+{
132+name: "reporthugebutton",
133+description: "ReportHugeButton",
134+acceptsArgs: true,
135+args: [],
136+},
127137{
128138name: "unsafeconfirm",
129139description: "UnsafeConfirm",
@@ -168,6 +178,15 @@ vi.mock("./slash-commands.runtime.js", () => {
168178},
169179]);
170180}
181+if (params.command?.key === "reporthugebutton") {
182+return resolvePeriodMenu(
183+params,
184+Array.from({ length: 250 }, (_v, i) => ({
185+value: `${String(i + 1)}-${"x".repeat(170)}`,
186+label: `Long button label ${i + 1}`,
187+})),
188+);
189+}
171190if (params.command?.key === "reportcompact") {
172191return resolvePeriodMenu(params, baseReportPeriodChoices);
173192}
@@ -446,6 +465,7 @@ describe("Slack native command argument menus", () => {
446465let reportExternalHandler: (args: unknown) => Promise<void>;
447466let reportLongHandler: (args: unknown) => Promise<void>;
448467let reportLongButtonHandler: (args: unknown) => Promise<void>;
468+let reportHugeButtonHandler: (args: unknown) => Promise<void>;
449469let unsafeConfirmHandler: (args: unknown) => Promise<void>;
450470let longConfirmHandler: (args: unknown) => Promise<void>;
451471let agentStatusHandler: (args: unknown) => Promise<void>;
@@ -465,6 +485,11 @@ describe("Slack native command argument menus", () => {
465485"/reportlongbutton",
466486"/reportlongbutton",
467487);
488+reportHugeButtonHandler = requireHandler(
489+harness.commands,
490+"/reporthugebutton",
491+"/reporthugebutton",
492+);
468493unsafeConfirmHandler = requireHandler(harness.commands, "/unsafeconfirm", "/unsafeconfirm");
469494longConfirmHandler = requireHandler(harness.commands, "/longconfirm", "/longconfirm");
470495agentStatusHandler = requireHandler(harness.commands, "/agentstatus", "/agentstatus");
@@ -601,6 +626,18 @@ describe("Slack native command argument menus", () => {
601626expect(firstElement?.confirm).toBeTruthy();
602627});
603628629+it("caps large button fallback menus to Slack's block limit", async () => {
630+const { respond } = await runCommandHandler(reportHugeButtonHandler);
631+expect(respond).toHaveBeenCalledTimes(1);
632+const payload = respond.mock.calls[0]?.[0] as {
633+blocks?: Array<{ type: string; elements?: unknown[] }>;
634+};
635+const actionBlocks = (payload.blocks ?? []).filter((block) => block.type === "actions");
636+expect(payload.blocks).toHaveLength(50);
637+expect(actionBlocks).toHaveLength(47);
638+expect(actionBlocks.at(-1)?.elements).toHaveLength(5);
639+});
640+604641it("shows an overflow menu when choices fit compact range", async () => {
605642const element = await getFirstActionElementFromCommand(reportCompactHandler);
606643expect(element?.type).toBe("overflow");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。