Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
21 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { beforeForgetting, cleanChannelId, forgotKey } from "./forget.ts";
5
6test("a notification of a message from before the clear is dropped; one after is told", () => {
7 const forgot = "2026-10-14T12:00:00.000Z";
8 assert.ok(beforeForgetting({ created_at: "2026-10-14T11:59:59.000Z" }, forgot));
9 assert.ok(beforeForgetting({ created_at: forgot }, forgot));
10 assert.ok(!beforeForgetting({ created_at: "2026-10-14T12:00:00.001Z" }, forgot));
11 // Without a time it counts as before; a conversation never cleared drops nothing.
12 assert.ok(beforeForgetting({ created_at: "soon" }, forgot));
13 assert.ok(!beforeForgetting({ created_at: "2026-10-14T11:00:00.000Z" }, null));
14});
15
16test("forgetting is kept per workspace and conversation, and takes only chat's ids", () => {
17 assert.equal(forgotKey("Acme", "chn_1"), "forgot:acme:chn_1");
18 assert.notEqual(forgotKey("acme", "chn_1"), forgotKey("other", "chn_1"));
19 assert.equal(cleanChannelId("chn_01jabc"), "chn_01jabc");
20 for (const bad of ["", "chn 1", "chn_1' OR 1=1", "x".repeat(65), 7, null]) assert.equal(cleanChannelId(bad), null, String(bad));
21});