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

composerControlsOwnership.test.ts

76 lines2.5 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { resolveComposerControlsOwnership } from "./composerControlsOwnership";
4​
5const base = {
6 matchesDefault: true,
7 planModeUiEnabled: false,
8 collapsed: false,
9 measuredHiddenBlockCount: 0,
10};
11​
12describe("resolveComposerControlsOwnership", () => {
13 it("hides the chip at the default and lets the model picker answer composer.mode", () => {
14 const result = resolveComposerControlsOwnership(base);
15 expect(result).toMatchObject({
16 accessDisplay: "hidden",
17 showModeBlock: false,
18 hiddenBlockIds: [],
19 pickerOwnsModeShortcut: true,
20 });
21 });
22​
23 it("shows a labelled chip that owns composer.mode when the mode differs", () => {
24 const result = resolveComposerControlsOwnership({ ...base, matchesDefault: false });
25 expect(result).toMatchObject({
26 accessDisplay: "label",
27 showModeBlock: true,
28 pickerOwnsModeShortcut: false,
29 });
30 });
31​
32 it("gives an overflowed chip's Permissions to the overflow menu when it has no Plan toggle", () => {
33 const result = resolveComposerControlsOwnership({
34 ...base,
35 matchesDefault: false,
36 measuredHiddenBlockCount: 1,
37 });
38 expect(result.hiddenBlockIds).toEqual(["mode"]);
39 expect(result.overflowShowsPermissions).toBe(true);
40 expect(result.pickerOwnsModeShortcut).toBe(false);
41 });
42​
43 it("keeps the Plan toggle block at the default and leaves Permissions with the picker", () => {
44 const result = resolveComposerControlsOwnership({
45 ...base,
46 planModeUiEnabled: true,
47 measuredHiddenBlockCount: 1,
48 });
49 expect(result.showModeBlock).toBe(true);
50 expect(result.hiddenBlockIds).toEqual(["mode"]);
51 expect(result.overflowShowsPermissions).toBe(false);
52 expect(result.pickerOwnsModeShortcut).toBe(true);
53 });
54​
55 it("overflows only the chip when the Plan toggle gives the overflow menu content", () => {
56 const result = resolveComposerControlsOwnership({
57 ...base,
58 matchesDefault: false,
59 planModeUiEnabled: true,
60 measuredHiddenBlockCount: 1,
61 });
62 expect(result.hiddenBlockIds).toEqual(["mode"]);
63 // Permissions stay in the model picker, which now answers composer.mode.
64 expect(result.overflowShowsPermissions).toBe(false);
65 expect(result.pickerOwnsModeShortcut).toBe(true);
66 });
67​
68 it("shows the non-default chip as an icon in the compacted row", () => {
69 const result = resolveComposerControlsOwnership({
70 ...base,
71 matchesDefault: false,
72 collapsed: true,
73 });
74 expect(result.accessDisplay).toBe("icon");
75 });
76});