Open History to see the last commit
1import { EnvironmentId } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import { resolveRenameCommit, shouldShowOpenInPicker } from "./ChatHeader";
5
6describe("shouldShowOpenInPicker", () => {
7 const primaryEnvironmentId = EnvironmentId.make("environment-primary");
8
9 it("shows the picker for projects in the primary environment", () => {
10 expect(
11 shouldShowOpenInPicker({
12 activeProjectName: "codething-mvp",
13 activeThreadEnvironmentId: primaryEnvironmentId,
14 primaryEnvironmentId,
15 }),
16 ).toBe(true);
17 });
18
19 it("hides the picker when hosted static mode has no primary environment", () => {
20 expect(
21 shouldShowOpenInPicker({
22 activeProjectName: "codething-mvp",
23 activeThreadEnvironmentId: EnvironmentId.make("environment-remote"),
24 primaryEnvironmentId: null,
25 }),
26 ).toBe(false);
27 });
28
29 it("hides the picker for remote environments", () => {
30 expect(
31 shouldShowOpenInPicker({
32 activeProjectName: "codething-mvp",
33 activeThreadEnvironmentId: EnvironmentId.make("environment-remote"),
34 primaryEnvironmentId,
35 }),
36 ).toBe(false);
37 });
38
39 it("hides the picker when there is no active project", () => {
40 expect(
41 shouldShowOpenInPicker({
42 activeProjectName: undefined,
43 activeThreadEnvironmentId: primaryEnvironmentId,
44 primaryEnvironmentId,
45 }),
46 ).toBe(false);
47 });
48});
49
50describe("resolveRenameCommit", () => {
51 it("commits a trimmed changed title", () => {
52 expect(resolveRenameCommit({ title: " New title ", originalTitle: "Old" })).toEqual({
53 action: "commit",
54 title: "New title",
55 });
56 });
57
58 it("rejects empty and whitespace-only titles", () => {
59 expect(resolveRenameCommit({ title: " ", originalTitle: "Old" })).toEqual({
60 action: "reject-empty",
61 });
62 });
63
64 it("no-ops when the trimmed title is unchanged", () => {
65 expect(resolveRenameCommit({ title: " Old ", originalTitle: "Old" })).toEqual({
66 action: "noop",
67 });
68 });
69});