@sentropic/design-system-svelte 0.34.70 → 0.34.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AppShell.panelCollapse.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppShell.panelCollapse.test.d.ts","sourceRoot":"","sources":["../src/lib/AppShell.panelCollapse.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,129 @@
1
+ import { fireEvent, render } from "@testing-library/svelte";
2
+ import { createRawSnippet } from "svelte";
3
+ import { describe, expect, it } from "vitest";
4
+ import AppShell from "./AppShell.svelte";
5
+ const snippet = (html) => createRawSnippet(() => ({ render: () => `<div>${html}</div>` }));
6
+ const panelProps = {
7
+ primaryRail: snippet("rail-content"),
8
+ navigationPanel: snippet("nav-content"),
9
+ main: snippet("main-content"),
10
+ contextPanel: snippet("context-content"),
11
+ utilityPanel: snippet("utility-content"),
12
+ };
13
+ describe("AppShell — panelCollapse default (stack)", () => {
14
+ it("renders no disclosure buttons and no panel-region wrappers when panelCollapse is omitted", () => {
15
+ const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
16
+ expect(container.querySelectorAll(".st-appShell__panelDisclosure").length).toBe(0);
17
+ expect(container.querySelectorAll(".st-appShell__panelRegion").length).toBe(0);
18
+ });
19
+ it("renders no disclosure buttons when panelCollapse is explicitly 'stack'", () => {
20
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "stack", ...panelProps } });
21
+ expect(container.querySelectorAll(".st-appShell__panelDisclosure").length).toBe(0);
22
+ });
23
+ it("still renders every panel's content directly inside its aside (unchanged desktop/stack markup)", () => {
24
+ const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
25
+ expect(container.querySelector(".st-appShell__primaryRail")?.textContent).toContain("rail-content");
26
+ expect(container.querySelector(".st-appShell__navigationPanel")?.textContent).toContain("nav-content");
27
+ expect(container.querySelector(".st-appShell__main")?.textContent).toContain("main-content");
28
+ expect(container.querySelector(".st-appShell__contextPanel")?.textContent).toContain("context-content");
29
+ expect(container.querySelector(".st-appShell__utilityPanel")?.textContent).toContain("utility-content");
30
+ });
31
+ it('sets data-panel-collapse="stack" on the root by default', () => {
32
+ const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
33
+ expect(container.querySelector(".st-appShell")?.getAttribute("data-panel-collapse")).toBe("stack");
34
+ });
35
+ });
36
+ describe("AppShell — panelCollapse='accordion'", () => {
37
+ it("renders a disclosure button for each present panel, all initially collapsed", () => {
38
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
39
+ const buttons = container.querySelectorAll(".st-appShell__panelDisclosure");
40
+ expect(buttons.length).toBe(4);
41
+ buttons.forEach((btn) => {
42
+ expect(btn.getAttribute("aria-expanded")).toBe("false");
43
+ });
44
+ });
45
+ it("wires aria-controls on each trigger to the id of its region, and the region is labelled by the trigger", () => {
46
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
47
+ const buttons = Array.from(container.querySelectorAll(".st-appShell__panelDisclosure"));
48
+ expect(buttons.length).toBeGreaterThan(0);
49
+ for (const button of buttons) {
50
+ const controlsId = button.getAttribute("aria-controls");
51
+ expect(controlsId).toBeTruthy();
52
+ const region = container.querySelector(`#${controlsId}`);
53
+ expect(region).toBeTruthy();
54
+ expect(region?.getAttribute("role")).toBe("region");
55
+ expect(region?.getAttribute("aria-labelledby")).toBe(button.id);
56
+ }
57
+ });
58
+ it("toggles aria-expanded on click and reflects the collapsed state on the region", async () => {
59
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
60
+ const trigger = container.querySelector("#st-appShell-navigationPanel-trigger");
61
+ const region = container.querySelector("#st-appShell-navigationPanel-region");
62
+ expect(trigger.getAttribute("aria-expanded")).toBe("false");
63
+ expect(region.classList.contains("st-appShell__panelRegion--collapsed")).toBe(true);
64
+ await fireEvent.click(trigger);
65
+ expect(trigger.getAttribute("aria-expanded")).toBe("true");
66
+ expect(region.classList.contains("st-appShell__panelRegion--collapsed")).toBe(false);
67
+ await fireEvent.click(trigger);
68
+ expect(trigger.getAttribute("aria-expanded")).toBe("false");
69
+ expect(region.classList.contains("st-appShell__panelRegion--collapsed")).toBe(true);
70
+ });
71
+ it("toggles via the keyboard (Enter/Space activate a native button)", async () => {
72
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
73
+ const trigger = container.querySelector("#st-appShell-contextPanel-trigger");
74
+ expect(trigger.getAttribute("aria-expanded")).toBe("false");
75
+ trigger.focus();
76
+ expect(document.activeElement).toBe(trigger);
77
+ // Native <button> activates on Enter/Space via its click event; assert the
78
+ // handler is reachable through a synthesized click (jsdom does not
79
+ // synthesize the keydown->click default action for us).
80
+ await fireEvent.click(trigger);
81
+ expect(trigger.getAttribute("aria-expanded")).toBe("true");
82
+ });
83
+ it("renders no disclosure for a panel that is not provided", () => {
84
+ const { container } = render(AppShell, {
85
+ props: { variant: "workspace", panelCollapse: "accordion", navigationPanel: snippet("nav-only"), main: panelProps.main },
86
+ });
87
+ const buttons = container.querySelectorAll(".st-appShell__panelDisclosure");
88
+ expect(buttons.length).toBe(1);
89
+ expect(container.querySelector(".st-appShell__primaryRail")).toBeNull();
90
+ expect(container.querySelector(".st-appShell__contextPanel")).toBeNull();
91
+ expect(container.querySelector(".st-appShell__utilityPanel")).toBeNull();
92
+ });
93
+ it("keeps the panel content mounted in the DOM even while collapsed (no destroy/remount)", () => {
94
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
95
+ // Collapsed by default, yet content is present — collapse is a CSS
96
+ // concern (sizing/hiding the region), never a conditional {#if}.
97
+ expect(container.querySelector("#st-appShell-utilityPanel-region")?.textContent).toContain("utility-content");
98
+ });
99
+ it("desktop markup still contains the panel content (accordion mode never removes it)", () => {
100
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
101
+ // jsdom does not evaluate @media queries for layout, but the component
102
+ // must not conditionally destroy content based on breakpoint — assert
103
+ // every panel's content is present regardless.
104
+ expect(container.querySelector(".st-appShell__primaryRail")?.textContent).toContain("rail-content");
105
+ expect(container.querySelector(".st-appShell__navigationPanel")?.textContent).toContain("nav-content");
106
+ expect(container.querySelector(".st-appShell__contextPanel")?.textContent).toContain("context-content");
107
+ expect(container.querySelector(".st-appShell__utilityPanel")?.textContent).toContain("utility-content");
108
+ });
109
+ it("uses custom *Label props as the disclosure text, falling back to the existing aria-label props", async () => {
110
+ const { container } = render(AppShell, {
111
+ props: {
112
+ variant: "workspace",
113
+ panelCollapse: "accordion",
114
+ ...panelProps,
115
+ primaryRailLabel: "Rail perso",
116
+ contextLabel: "Contexte",
117
+ utilityPanelLabel: "Outils",
118
+ },
119
+ });
120
+ expect(container.querySelector("#st-appShell-primaryRail-trigger")?.textContent).toContain("Rail perso");
121
+ // contextPanelLabel not set -> falls back to contextLabel.
122
+ expect(container.querySelector("#st-appShell-contextPanel-trigger")?.textContent).toContain("Contexte");
123
+ expect(container.querySelector("#st-appShell-utilityPanel-trigger")?.textContent).toContain("Outils");
124
+ });
125
+ it('sets data-panel-collapse="accordion" on the root', () => {
126
+ const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
127
+ expect(container.querySelector(".st-appShell")?.getAttribute("data-panel-collapse")).toBe("accordion");
128
+ });
129
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AppShell.panelResize.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppShell.panelResize.test.d.ts","sourceRoot":"","sources":["../src/lib/AppShell.panelResize.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,338 @@
1
+ import { fireEvent, render } from "@testing-library/svelte";
2
+ import { createRawSnippet } from "svelte";
3
+ import { describe, expect, it, vi } from "vitest";
4
+ import AppShell from "./AppShell.svelte";
5
+ const snippet = (html) => createRawSnippet(() => ({ render: () => `<div>${html}</div>` }));
6
+ const panelProps = {
7
+ primaryRail: snippet("rail-content"),
8
+ navigationPanel: snippet("nav-content"),
9
+ main: snippet("main-content"),
10
+ contextPanel: snippet("context-content"),
11
+ utilityPanel: snippet("utility-content"),
12
+ };
13
+ describe("AppShell — panelResize default (false)", () => {
14
+ it("renders no resize handles", () => {
15
+ const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
16
+ expect(container.querySelectorAll(".st-appShell__resizeHandle").length).toBe(0);
17
+ });
18
+ it("does not set an inline style on the shell root (byte-identical to today)", () => {
19
+ const { container } = render(AppShell, {
20
+ props: { variant: "workspace", ...panelProps, defaultPanelWidths: { navigationPanel: 400 } },
21
+ });
22
+ const root = container.querySelector(".st-appShell");
23
+ // No `style` attribute at all — panelResize=false never touches width vars,
24
+ // even if defaultPanelWidths is (pointlessly) supplied.
25
+ expect(root.getAttribute("style")).toBeFalsy();
26
+ });
27
+ });
28
+ describe("AppShell — panelResize=true", () => {
29
+ it("renders exactly one resize handle per RESIZABLE present panel (navigation/context/utility)", () => {
30
+ const { container } = render(AppShell, { props: { variant: "workspace", panelResize: true, ...panelProps } });
31
+ const handles = container.querySelectorAll(".st-appShell__resizeHandle");
32
+ expect(handles.length).toBe(3);
33
+ handles.forEach((handle) => {
34
+ expect(handle.getAttribute("role")).toBe("separator");
35
+ expect(handle.getAttribute("aria-orientation")).toBe("vertical");
36
+ expect(handle.getAttribute("tabindex")).toBe("0");
37
+ });
38
+ });
39
+ it("renders NO handle on primaryRail, even with panelResize=true and the primaryRail slot present", () => {
40
+ const { container } = render(AppShell, { props: { variant: "workspace", panelResize: true, ...panelProps } });
41
+ // `primaryRail` is a fixed-width icon rail (à la VS Code's activity bar),
42
+ // not a resizable panel — it is not part of `AppShellPanelKey` and must
43
+ // never receive a handle, regardless of panelResize/panelWidths.
44
+ expect(container.querySelector(".st-appShell__primaryRail .st-appShell__resizeHandle")).toBeNull();
45
+ expect(container.querySelector(".st-appShell__primaryRail")).not.toBeNull(); // the rail itself still renders
46
+ });
47
+ it("labels each handle 'Resize {panel label}', falling back to the existing aria-label props", () => {
48
+ const { container } = render(AppShell, {
49
+ props: { variant: "workspace", panelResize: true, ...panelProps },
50
+ });
51
+ expect(container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle')?.getAttribute("aria-label")).toBe("Resize Workspace navigation");
52
+ expect(container.querySelector('.st-appShell__contextPanel .st-appShell__resizeHandle')?.getAttribute("aria-label")).toBe("Resize Context panel");
53
+ expect(container.querySelector('.st-appShell__utilityPanel .st-appShell__resizeHandle')?.getAttribute("aria-label")).toBe("Resize Utility panel");
54
+ });
55
+ it("defaults aria-valuemin/aria-valuemax to 180/640 and reports a clamped aria-valuenow", () => {
56
+ const { container } = render(AppShell, { props: { variant: "workspace", panelResize: true, ...panelProps } });
57
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
58
+ expect(handle.getAttribute("aria-valuemin")).toBe("180");
59
+ expect(handle.getAttribute("aria-valuemax")).toBe("640");
60
+ // No explicit/default width supplied — nominal 320px default is inside [180,640].
61
+ expect(handle.getAttribute("aria-valuenow")).toBe("320");
62
+ });
63
+ it("honors custom panelMinWidth/panelMaxWidth on every handle", () => {
64
+ const { container } = render(AppShell, {
65
+ props: { variant: "workspace", panelResize: true, ...panelProps, panelMinWidth: 200, panelMaxWidth: 300 },
66
+ });
67
+ const handles = container.querySelectorAll(".st-appShell__resizeHandle");
68
+ expect(handles.length).toBe(3);
69
+ handles.forEach((handle) => {
70
+ expect(handle.getAttribute("aria-valuemin")).toBe("200");
71
+ expect(handle.getAttribute("aria-valuemax")).toBe("300");
72
+ });
73
+ });
74
+ it("renders no handle for a panel that is not provided", () => {
75
+ const { container } = render(AppShell, {
76
+ props: { variant: "workspace", panelResize: true, navigationPanel: panelProps.navigationPanel, main: panelProps.main },
77
+ });
78
+ expect(container.querySelectorAll(".st-appShell__resizeHandle").length).toBe(1);
79
+ });
80
+ it("renders NO handle for utilityPanel when utilitySide='bottom', but keeps handles for the other resizable panels", () => {
81
+ const { container } = render(AppShell, {
82
+ props: { variant: "workspace", panelResize: true, utilitySide: "bottom", ...panelProps },
83
+ });
84
+ expect(container.querySelector(".st-appShell__utilityPanel .st-appShell__resizeHandle")).toBeNull();
85
+ expect(container.querySelector(".st-appShell__navigationPanel .st-appShell__resizeHandle")).not.toBeNull();
86
+ expect(container.querySelector(".st-appShell__contextPanel .st-appShell__resizeHandle")).not.toBeNull();
87
+ });
88
+ it("applies the width CSS custom properties to the shell root, one per explicitly-widthed panel", () => {
89
+ const { container } = render(AppShell, {
90
+ props: {
91
+ variant: "workspace",
92
+ panelResize: true,
93
+ ...panelProps,
94
+ defaultPanelWidths: { navigationPanel: 300, contextPanel: 260, utilityPanel: 420 },
95
+ },
96
+ });
97
+ const root = container.querySelector(".st-appShell");
98
+ expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("300px");
99
+ expect(root.style.getPropertyValue("--st-appShell-context-width")).toBe("260px");
100
+ expect(root.style.getPropertyValue("--st-appShell-utility-width")).toBe("420px");
101
+ // primaryRail is not resizable — no rail-width var is ever emitted, regardless of panelResize.
102
+ expect(root.style.getPropertyValue("--st-appShell-rail-width")).toBe("");
103
+ });
104
+ it("does not set a width var for a panel with no explicit/default/controlled width (defers to the token default)", () => {
105
+ const { container } = render(AppShell, {
106
+ props: { variant: "workspace", panelResize: true, ...panelProps, defaultPanelWidths: { navigationPanel: 300 } },
107
+ });
108
+ const root = container.querySelector(".st-appShell");
109
+ expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("300px");
110
+ expect(root.style.getPropertyValue("--st-appShell-context-width")).toBe("");
111
+ expect(root.style.getPropertyValue("--st-appShell-utility-width")).toBe("");
112
+ });
113
+ });
114
+ describe("AppShell — panelResize keyboard interaction (uncontrolled)", () => {
115
+ it("ArrowRight grows a left-edge panel (navigationPanel) by 16px and fires onPanelResize", async () => {
116
+ const onPanelResize = vi.fn();
117
+ const { container } = render(AppShell, {
118
+ props: {
119
+ variant: "workspace",
120
+ panelResize: true,
121
+ ...panelProps,
122
+ defaultPanelWidths: { navigationPanel: 300 },
123
+ onPanelResize,
124
+ },
125
+ });
126
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
127
+ await fireEvent.keyDown(handle, { key: "ArrowRight" });
128
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 316);
129
+ expect(handle.getAttribute("aria-valuenow")).toBe("316");
130
+ });
131
+ it("ArrowLeft shrinks a left-edge panel (navigationPanel) by 16px", async () => {
132
+ const onPanelResize = vi.fn();
133
+ const { container } = render(AppShell, {
134
+ props: {
135
+ variant: "workspace",
136
+ panelResize: true,
137
+ ...panelProps,
138
+ defaultPanelWidths: { navigationPanel: 300 },
139
+ onPanelResize,
140
+ },
141
+ });
142
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
143
+ await fireEvent.keyDown(handle, { key: "ArrowLeft" });
144
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 284);
145
+ });
146
+ it("ArrowRight SHRINKS a right-edge panel (contextPanel) — moving the splitter right moves toward main", async () => {
147
+ const onPanelResize = vi.fn();
148
+ const { container } = render(AppShell, {
149
+ props: {
150
+ variant: "workspace",
151
+ panelResize: true,
152
+ ...panelProps,
153
+ defaultPanelWidths: { contextPanel: 300 },
154
+ onPanelResize,
155
+ },
156
+ });
157
+ const handle = container.querySelector('.st-appShell__contextPanel .st-appShell__resizeHandle');
158
+ await fireEvent.keyDown(handle, { key: "ArrowRight" });
159
+ expect(onPanelResize).toHaveBeenCalledWith("contextPanel", 284);
160
+ await fireEvent.keyDown(handle, { key: "ArrowLeft" });
161
+ expect(onPanelResize).toHaveBeenLastCalledWith("contextPanel", 300);
162
+ });
163
+ it("utilityPanel (default utilitySide='right') resizes like a right-edge panel", async () => {
164
+ const onPanelResize = vi.fn();
165
+ const { container } = render(AppShell, {
166
+ props: {
167
+ variant: "workspace",
168
+ panelResize: true,
169
+ ...panelProps,
170
+ defaultPanelWidths: { utilityPanel: 300 },
171
+ onPanelResize,
172
+ },
173
+ });
174
+ const handle = container.querySelector('.st-appShell__utilityPanel .st-appShell__resizeHandle');
175
+ await fireEvent.keyDown(handle, { key: "ArrowRight" });
176
+ expect(onPanelResize).toHaveBeenCalledWith("utilityPanel", 284);
177
+ });
178
+ it("utilityPanel with utilitySide='left' resizes like a left-edge panel", async () => {
179
+ const onPanelResize = vi.fn();
180
+ const { container } = render(AppShell, {
181
+ props: {
182
+ variant: "workspace",
183
+ panelResize: true,
184
+ utilitySide: "left",
185
+ ...panelProps,
186
+ defaultPanelWidths: { utilityPanel: 300 },
187
+ onPanelResize,
188
+ },
189
+ });
190
+ const handle = container.querySelector('.st-appShell__utilityPanel .st-appShell__resizeHandle');
191
+ await fireEvent.keyDown(handle, { key: "ArrowRight" });
192
+ expect(onPanelResize).toHaveBeenCalledWith("utilityPanel", 316);
193
+ });
194
+ it("Home jumps to panelMinWidth and End jumps to panelMaxWidth, both firing onPanelResize", async () => {
195
+ const onPanelResize = vi.fn();
196
+ const { container } = render(AppShell, {
197
+ props: {
198
+ variant: "workspace",
199
+ panelResize: true,
200
+ ...panelProps,
201
+ defaultPanelWidths: { navigationPanel: 300 },
202
+ panelMinWidth: 150,
203
+ panelMaxWidth: 500,
204
+ onPanelResize,
205
+ },
206
+ });
207
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
208
+ await fireEvent.keyDown(handle, { key: "Home" });
209
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 150);
210
+ expect(handle.getAttribute("aria-valuenow")).toBe("150");
211
+ await fireEvent.keyDown(handle, { key: "End" });
212
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 500);
213
+ expect(handle.getAttribute("aria-valuenow")).toBe("500");
214
+ });
215
+ it("clamps at the upper bound: repeated ArrowRight never exceeds panelMaxWidth", async () => {
216
+ const onPanelResize = vi.fn();
217
+ const { container } = render(AppShell, {
218
+ props: {
219
+ variant: "workspace",
220
+ panelResize: true,
221
+ ...panelProps,
222
+ defaultPanelWidths: { navigationPanel: 495 },
223
+ panelMinWidth: 180,
224
+ panelMaxWidth: 500,
225
+ onPanelResize,
226
+ },
227
+ });
228
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
229
+ await fireEvent.keyDown(handle, { key: "ArrowRight" }); // 495 + 16 = 511 -> clamped to 500
230
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 500);
231
+ await fireEvent.keyDown(handle, { key: "ArrowRight" }); // stays clamped, still fires
232
+ expect(onPanelResize).toHaveBeenLastCalledWith("navigationPanel", 500);
233
+ expect(handle.getAttribute("aria-valuenow")).toBe("500");
234
+ });
235
+ it("clamps at the lower bound: repeated ArrowLeft never goes below panelMinWidth", async () => {
236
+ const onPanelResize = vi.fn();
237
+ const { container } = render(AppShell, {
238
+ props: {
239
+ variant: "workspace",
240
+ panelResize: true,
241
+ ...panelProps,
242
+ defaultPanelWidths: { navigationPanel: 190 },
243
+ panelMinWidth: 180,
244
+ onPanelResize,
245
+ },
246
+ });
247
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
248
+ await fireEvent.keyDown(handle, { key: "ArrowLeft" }); // 190 - 16 = 174 -> clamped to 180
249
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 180);
250
+ });
251
+ it("ignores keys other than ArrowLeft/ArrowRight/Home/End", async () => {
252
+ const onPanelResize = vi.fn();
253
+ const { container } = render(AppShell, {
254
+ props: { variant: "workspace", panelResize: true, ...panelProps, onPanelResize },
255
+ });
256
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
257
+ await fireEvent.keyDown(handle, { key: "Tab" });
258
+ await fireEvent.keyDown(handle, { key: "Enter" });
259
+ expect(onPanelResize).not.toHaveBeenCalled();
260
+ });
261
+ });
262
+ describe("AppShell — panelResize pointer drag (uncontrolled)", () => {
263
+ it("dragging a left-edge handle rightward grows the panel and fires onPanelResize on move", async () => {
264
+ const onPanelResize = vi.fn();
265
+ const { container } = render(AppShell, {
266
+ props: {
267
+ variant: "workspace",
268
+ panelResize: true,
269
+ ...panelProps,
270
+ defaultPanelWidths: { navigationPanel: 300 },
271
+ onPanelResize,
272
+ },
273
+ });
274
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
275
+ await fireEvent.pointerDown(handle, { clientX: 100, pointerId: 1 });
276
+ await fireEvent.pointerMove(handle, { clientX: 140, pointerId: 1 });
277
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 340);
278
+ await fireEvent.pointerUp(handle, { clientX: 140, pointerId: 1 });
279
+ // Further movement after pointerup is a no-op (drag ended).
280
+ onPanelResize.mockClear();
281
+ await fireEvent.pointerMove(handle, { clientX: 200, pointerId: 1 });
282
+ expect(onPanelResize).not.toHaveBeenCalled();
283
+ });
284
+ it("dragging a right-edge handle rightward shrinks the panel", async () => {
285
+ const onPanelResize = vi.fn();
286
+ const { container } = render(AppShell, {
287
+ props: {
288
+ variant: "workspace",
289
+ panelResize: true,
290
+ ...panelProps,
291
+ defaultPanelWidths: { contextPanel: 300 },
292
+ onPanelResize,
293
+ },
294
+ });
295
+ const handle = container.querySelector('.st-appShell__contextPanel .st-appShell__resizeHandle');
296
+ await fireEvent.pointerDown(handle, { clientX: 100, pointerId: 1 });
297
+ await fireEvent.pointerMove(handle, { clientX: 140, pointerId: 1 });
298
+ expect(onPanelResize).toHaveBeenCalledWith("contextPanel", 260);
299
+ });
300
+ });
301
+ describe("AppShell — panelResize controlled mode (panelWidths)", () => {
302
+ it("never mutates its own state: the rendered width stays exactly what panelWidths says, even after a commit-triggering interaction", async () => {
303
+ const onPanelResize = vi.fn();
304
+ const { container } = render(AppShell, {
305
+ props: {
306
+ variant: "workspace",
307
+ panelResize: true,
308
+ ...panelProps,
309
+ panelWidths: { navigationPanel: 250, contextPanel: 300, utilityPanel: 400 },
310
+ onPanelResize,
311
+ },
312
+ });
313
+ const root = container.querySelector(".st-appShell");
314
+ const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
315
+ expect(handle.getAttribute("aria-valuenow")).toBe("250");
316
+ expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("250px");
317
+ await fireEvent.keyDown(handle, { key: "ArrowRight" });
318
+ // onPanelResize told the consumer what the next width *should* be...
319
+ expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 266);
320
+ // ...but since the consumer (the test) never fed that back through the
321
+ // `panelWidths` prop, the component itself must not have changed anything.
322
+ expect(handle.getAttribute("aria-valuenow")).toBe("250");
323
+ expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("250px");
324
+ await fireEvent.pointerDown(handle, { clientX: 0, pointerId: 2 });
325
+ await fireEvent.pointerMove(handle, { clientX: 50, pointerId: 2 });
326
+ expect(onPanelResize).toHaveBeenLastCalledWith("navigationPanel", 300);
327
+ expect(handle.getAttribute("aria-valuenow")).toBe("250");
328
+ });
329
+ it("re-renders from a new panelWidths prop (the consumer driving the loop back)", async () => {
330
+ const { container, rerender } = render(AppShell, {
331
+ props: { variant: "workspace", panelResize: true, ...panelProps, panelWidths: { navigationPanel: 250 } },
332
+ });
333
+ const root = container.querySelector(".st-appShell");
334
+ expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("250px");
335
+ await rerender({ variant: "workspace", panelResize: true, ...panelProps, panelWidths: { navigationPanel: 400 } });
336
+ expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("400px");
337
+ });
338
+ });