Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

queries.test.ts

62 lines1.6 KB

1import { describe, expect, it } from "@effect/vitest";
2import { EnvironmentId, ThreadId } from "@t3tools/contracts";
3​
4import { buildCheckpointDiffTargets, normalizeComposerPathSearchQuery } from "./queryTargets";
5​
6describe("appQueries", () => {
7 it("normalizes composer path search input", () => {
8 expect(normalizeComposerPathSearchQuery(" src/app ")).toBe("src/app");
9 expect(normalizeComposerPathSearchQuery(null)).toBe("");
10 });
11​
12 it("routes the first turn range through the full-thread diff query", () => {
13 const environmentId = EnvironmentId.make("environment-a");
14 const threadId = ThreadId.make("thread-a");
15​
16 expect(
17 buildCheckpointDiffTargets({
18 environmentId,
19 threadId,
20 fromTurnCount: 0,
21 toTurnCount: 4,
22 ignoreWhitespace: true,
23 }),
24 ).toEqual({
25 fullThread: {
26 environmentId,
27 input: {
28 threadId,
29 toTurnCount: 4,
30 ignoreWhitespace: true,
31 },
32 },
33 turn: null,
34 });
35 });
36​
37 it("routes later ranges through the incremental turn diff query", () => {
38 const environmentId = EnvironmentId.make("environment-a");
39 const threadId = ThreadId.make("thread-a");
40​
41 expect(
42 buildCheckpointDiffTargets({
43 environmentId,
44 threadId,
45 fromTurnCount: 3,
46 toTurnCount: 4,
47 ignoreWhitespace: false,
48 }),
49 ).toEqual({
50 fullThread: null,
51 turn: {
52 environmentId,
53 input: {
54 threadId,
55 fromTurnCount: 3,
56 toTurnCount: 4,
57 ignoreWhitespace: false,
58 },
59 },
60 });
61 });
62});