Bots get list_hooks, pause_hook and delete_hook, which act directly since they only take away. A new hook, or a new name, brief or filter, or switching a paused one back on, goes through propose_hook: it stores a hook_proposals row and puts a [hook-proposal:ID] card in the reply, which the user it was proposed to confirms or rejects. The card is read from what Confirm saves, with the bot's reason labelled as its own; confirming checks everything again and saves through the Hooks modal's helpers. A new hook's URL is shown on the card once, to the user only, never in the outcome the bot is told. What calls a hook, its computers and its signing are never proposed. Only chat replies propose, and a hook call's own run gets no hook tools, so a caller's payload can't reach them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import botRef from "./bot-ref";
|
|
import workspaceRef from "./workspace-ref";
|
|
import computerRef from "./computer-ref";
|
|
import linkComputerRefs from "./link-computer-refs";
|
|
import hookProposalRef from "./hook-proposal-ref";
|
|
import proposalRef from "./proposal-ref";
|
|
import takeOverRef from "./take-over-ref";
|
|
|
|
describe("linkComputerRefs", () => {
|
|
test("links every computer a message names", () => {
|
|
expect(
|
|
linkComputerRefs({
|
|
text: `Your GitHub session is on ${computerRef({ id: 3 })}, not ${computerRef({ id: 12 })}.`,
|
|
}),
|
|
).toBe("Your GitHub session is on [computer 3](#computer-3), not [computer 12](#computer-12).");
|
|
});
|
|
|
|
test("leaves look-alikes and existing links alone", () => {
|
|
const text = "See [computer:x], [link](url) and [computer:4](https://example.com)";
|
|
|
|
expect(linkComputerRefs({ text })).toBe(text);
|
|
});
|
|
|
|
test("links proposals", () => {
|
|
expect(linkComputerRefs({ text: `Review it: ${proposalRef({ id: 7 })}` })).toBe(
|
|
"Review it: [proposal 7](#proposal-7)",
|
|
);
|
|
});
|
|
|
|
test("links hook proposals apart from extension proposals", () => {
|
|
expect(
|
|
linkComputerRefs({ text: `${hookProposalRef({ id: 4 })} and ${proposalRef({ id: 4 })}` }),
|
|
).toBe("[hook proposal 4](#hook-proposal-4) and [proposal 4](#proposal-4)");
|
|
});
|
|
|
|
test("links take-over requests", () => {
|
|
expect(
|
|
linkComputerRefs({
|
|
text: `Please log in to Gmail. ${takeOverRef({ id: 3, mode: "browser" })}`,
|
|
}),
|
|
).toBe("Please log in to Gmail. [take over](#take-over-3-browser)");
|
|
});
|
|
|
|
test("links every bot a message names", () => {
|
|
expect(
|
|
linkComputerRefs({
|
|
text: `${botRef({ id: 4 })} is on it. See [bot:x] and [bot:5](https://example.com).`,
|
|
}),
|
|
).toBe("[bot 4](#bot-4) is on it. See [bot:x] and [bot:5](https://example.com).");
|
|
});
|
|
|
|
test("links every workspace a message names", () => {
|
|
expect(
|
|
linkComputerRefs({
|
|
text: `Added to ${workspaceRef({ id: 2 })}. Not [workspace:x] or [workspace:3](https://example.com).`,
|
|
}),
|
|
).toBe("Added to [workspace 2](#workspace-2). Not [workspace:x] or [workspace:3](https://example.com).");
|
|
});
|
|
});
|