Open History to see the last commit
1import { describe, expect, it } from "vitest";
2
3import { shouldApplyTerminalEvent } from "./service";
4
5describe("shouldApplyTerminalEvent", () => {
6 it("applies terminal events for draft-only threads", () => {
7 expect(
8 shouldApplyTerminalEvent({
9 serverThreadArchivedAt: undefined,
10 hasDraftThread: true,
11 }),
12 ).toBe(true);
13 });
14
15 it("drops terminal events for unknown threads", () => {
16 expect(
17 shouldApplyTerminalEvent({
18 serverThreadArchivedAt: undefined,
19 hasDraftThread: false,
20 }),
21 ).toBe(false);
22 });
23
24 it("drops terminal events for archived server threads even if a draft exists", () => {
25 expect(
26 shouldApplyTerminalEvent({
27 serverThreadArchivedAt: "2026-04-09T00:00:00.000Z",
28 hasDraftThread: true,
29 }),
30 ).toBe(false);
31 });
32
33 it("applies terminal events for active server threads", () => {
34 expect(
35 shouldApplyTerminalEvent({
36 serverThreadArchivedAt: null,
37 hasDraftThread: false,
38 }),
39 ).toBe(true);
40 });
41});