@desplega.ai/slack-mock 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  Store2,
5
5
  SlackMock2,
6
6
  frames2
7
- } from "./index-y82vvfa1.js";
7
+ } from "./index-86bw4z6k.js";
8
8
  import {
9
9
  findChrome2,
10
10
  screenshot2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desplega.ai/slack-mock",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Mock Slack server (Web API + Socket Mode) for end-to-end testing Slack bots",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/web-api.ts CHANGED
@@ -65,10 +65,23 @@ function botFields(ctx: ApiContext): Partial<SlackMessage> {
65
65
  };
66
66
  }
67
67
 
68
+ /**
69
+ * `markdown_text` is Slack's markdown input (`**bold**`, lists, code fences).
70
+ * Slack rejects it next to `text` or `blocks` and renders it server-side; the
71
+ * mock keeps the markdown as the message `text`.
72
+ */
73
+ function markdownText(args: Args): string | undefined {
74
+ const markdown = str(args, "markdown_text");
75
+ if (markdown === undefined) return undefined;
76
+ if (str(args, "text") || (Array.isArray(args.blocks) && args.blocks.length))
77
+ throw new SlackApiError("markdown_text_conflict");
78
+ return markdown;
79
+ }
80
+
68
81
  function messageContent(
69
82
  args: Args,
70
83
  ): Pick<SlackMessage, "text" | "blocks" | "attachments" | "metadata"> {
71
- const text = str(args, "text") ?? "";
84
+ const text = markdownText(args) ?? str(args, "text") ?? "";
72
85
  const blocks = Array.isArray(args.blocks) ? (args.blocks as unknown[]) : undefined;
73
86
  const attachments = Array.isArray(args.attachments) ? (args.attachments as unknown[]) : undefined;
74
87
  if (!text && !blocks?.length && !attachments?.length) throw new SlackApiError("no_text");
@@ -191,7 +204,9 @@ export const handlers: Record<string, Handler> = {
191
204
  if (existing.user !== ctx.actor.userId && !ctx.actor.isBot)
192
205
  throw new SlackApiError("cant_update_message");
193
206
  const patch: Partial<SlackMessage> = {};
194
- if (args.text !== undefined) patch.text = str(args, "text") ?? "";
207
+ const markdown = markdownText(args);
208
+ if (markdown !== undefined) patch.text = markdown;
209
+ else if (args.text !== undefined) patch.text = str(args, "text") ?? "";
195
210
  if (args.blocks !== undefined)
196
211
  patch.blocks = Array.isArray(args.blocks) ? (args.blocks as unknown[]) : undefined;
197
212
  if (args.attachments !== undefined)