Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveComposerControlsOwnership } from "./composerControlsOwnership";
4
5const base = {
6 matchesDefault: true,
7 hasTraits: true,
8 planModeUiEnabled: false,
9 collapsed: false,
10 measuredHiddenBlockCount: 0,
11};
12
13describe("resolveComposerControlsOwnership", () => {
14 it("hides the chip at the default and lets the effort menu answer composer.mode", () => {
15 const result = resolveComposerControlsOwnership(base);
16 expect(result).toMatchObject({
17 accessDisplay: "hidden",
18 showModeBlock: false,
19 hiddenBlockIds: [],
20 effortOwnsModeShortcut: true,
21 });
22 });
23
24 it("shows a labelled chip that owns composer.mode when the mode differs", () => {
25 const result = resolveComposerControlsOwnership({ ...base, matchesDefault: false });
26 expect(result).toMatchObject({
27 accessDisplay: "label",
28 showModeBlock: true,
29 effortOwnsModeShortcut: false,
30 });
31 });
32
33 it("never leaves an empty overflow menu: the effort chip overflows with the chip", () => {
34 const result = resolveComposerControlsOwnership({
35 ...base,
36 matchesDefault: false,
37 measuredHiddenBlockCount: 1,
38 });
39 expect(result.hiddenBlockIds).toEqual(["traits", "mode"]);
40 expect(result.overflowShowsPermissions).toBe(true);
41 // One composer.mode target: the overflow menu, not the overflowed effort chip.
42 expect(result.effortOwnsModeShortcut).toBe(false);
43 });
44
45 it("keeps the Plan toggle block at the default and overflows it before the effort chip", () => {
46 const result = resolveComposerControlsOwnership({
47 ...base,
48 planModeUiEnabled: true,
49 measuredHiddenBlockCount: 1,
50 });
51 expect(result.showModeBlock).toBe(true);
52 expect(result.hiddenBlockIds).toEqual(["mode"]);
53 expect(result.overflowShowsPermissions).toBe(false);
54 expect(result.effortOwnsModeShortcut).toBe(true);
55 });
56
57 it("overflows only the chip when the Plan toggle gives the overflow menu content", () => {
58 const result = resolveComposerControlsOwnership({
59 ...base,
60 matchesDefault: false,
61 planModeUiEnabled: true,
62 measuredHiddenBlockCount: 1,
63 });
64 expect(result.hiddenBlockIds).toEqual(["mode"]);
65 // Permissions stay in the visible effort menu, which now answers composer.mode.
66 expect(result.overflowShowsPermissions).toBe(false);
67 expect(result.effortOwnsModeShortcut).toBe(true);
68 });
69
70 it("keeps a permissions icon for models without traits, even at the default", () => {
71 const result = resolveComposerControlsOwnership({ ...base, hasTraits: false });
72 expect(result.accessDisplay).toBe("icon");
73 const overflowed = resolveComposerControlsOwnership({
74 ...base,
75 hasTraits: false,
76 measuredHiddenBlockCount: 1,
77 });
78 expect(overflowed.hiddenBlockIds).toEqual(["mode"]);
79 expect(overflowed.overflowShowsPermissions).toBe(true);
80 });
81
82 it("shows the non-default chip as an icon in the compacted row", () => {
83 const result = resolveComposerControlsOwnership({
84 ...base,
85 matchesDefault: false,
86 collapsed: true,
87 });
88 expect(result.accessDisplay).toBe("icon");
89 });
90});