fix(slack): mrkdwn + thread edge cases (#464) (thanks @austinm911)

This commit is contained in:
Peter Steinberger
2026-01-09 22:09:02 +01:00
parent 8890fbcf38
commit 84046cbad8
8 changed files with 222 additions and 49 deletions

View File

@@ -56,23 +56,26 @@ describe("slack groupPolicy gating", () => {
describe("resolveSlackThreadTs", () => {
const threadTs = "1234567890.123456";
const messageTs = "9999999999.999999";
describe("replyToMode=off", () => {
it("returns baseThreadTs when in a thread", () => {
it("returns incomingThreadTs when in a thread", () => {
expect(
resolveSlackThreadTs({
replyToMode: "off",
baseThreadTs: threadTs,
incomingThreadTs: threadTs,
messageTs,
hasReplied: false,
}),
).toBe(threadTs);
});
it("returns baseThreadTs even after replies (stays in thread)", () => {
it("returns incomingThreadTs even after replies (stays in thread)", () => {
expect(
resolveSlackThreadTs({
replyToMode: "off",
baseThreadTs: threadTs,
incomingThreadTs: threadTs,
messageTs,
hasReplied: true,
}),
).toBe(threadTs);
@@ -82,7 +85,8 @@ describe("resolveSlackThreadTs", () => {
expect(
resolveSlackThreadTs({
replyToMode: "off",
baseThreadTs: undefined,
incomingThreadTs: undefined,
messageTs,
hasReplied: false,
}),
).toBeUndefined();
@@ -90,21 +94,34 @@ describe("resolveSlackThreadTs", () => {
});
describe("replyToMode=first", () => {
it("returns baseThreadTs for first reply", () => {
it("returns incomingThreadTs when in a thread (always stays threaded)", () => {
expect(
resolveSlackThreadTs({
replyToMode: "first",
baseThreadTs: threadTs,
incomingThreadTs: threadTs,
messageTs,
hasReplied: false,
}),
).toBe(threadTs);
});
it("returns undefined for subsequent replies (goes to main channel)", () => {
it("returns messageTs for first reply when not in a thread", () => {
expect(
resolveSlackThreadTs({
replyToMode: "first",
baseThreadTs: threadTs,
incomingThreadTs: undefined,
messageTs,
hasReplied: false,
}),
).toBe(messageTs);
});
it("returns undefined for subsequent replies when not in a thread (goes to main channel)", () => {
expect(
resolveSlackThreadTs({
replyToMode: "first",
incomingThreadTs: undefined,
messageTs,
hasReplied: true,
}),
).toBeUndefined();
@@ -112,24 +129,26 @@ describe("resolveSlackThreadTs", () => {
});
describe("replyToMode=all", () => {
it("returns baseThreadTs for first reply", () => {
it("returns incomingThreadTs when in a thread", () => {
expect(
resolveSlackThreadTs({
replyToMode: "all",
baseThreadTs: threadTs,
incomingThreadTs: threadTs,
messageTs,
hasReplied: false,
}),
).toBe(threadTs);
});
it("returns baseThreadTs for subsequent replies (all go to thread)", () => {
it("returns messageTs when not in a thread (starts thread)", () => {
expect(
resolveSlackThreadTs({
replyToMode: "all",
baseThreadTs: threadTs,
incomingThreadTs: undefined,
messageTs,
hasReplied: true,
}),
).toBe(threadTs);
).toBe(messageTs);
});
});
});