@jskit-ai/shell-web 0.1.148 → 0.1.150

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.
@@ -1,7 +1,7 @@
1
1
  const DEFAULT_SMOKE_PATH = String(process.env.JSKIT_PLAYWRIGHT_SMOKE_PATH || "/home");
2
2
  const DEFAULT_VIEWPORTS = Object.freeze([
3
3
  Object.freeze({ name: "compact", width: 390, height: 844 }),
4
- Object.freeze({ name: "medium", width: 768, height: 1024 }),
4
+ Object.freeze({ name: "medium", width: 1024, height: 1024 }),
5
5
  Object.freeze({ name: "expanded", width: 1280, height: 900 })
6
6
  ]);
7
7
 
@@ -68,6 +68,152 @@ async function isElementVisibleInViewport(page, testId) {
68
68
  });
69
69
  }
70
70
 
71
+ async function expectElementVisibility(page, expect, testId, visible) {
72
+ await expect.poll(
73
+ () => isElementVisibleInViewport(page, testId),
74
+ { message: `${testId} did not reach its expected visibility.` }
75
+ ).toBe(visible);
76
+ }
77
+
78
+ async function readShellLayoutClass(drawer) {
79
+ const layoutClass = String(await drawer.getAttribute("data-layout") || "");
80
+ if (!["compact", "medium", "expanded"].includes(layoutClass)) {
81
+ throw new Error(`Shell drawer exposed an invalid data-layout value: ${layoutClass || "(empty)"}.`);
82
+ }
83
+ return layoutClass;
84
+ }
85
+
86
+ async function readConfiguredWidth(drawer, attribute) {
87
+ const width = Number(await drawer.getAttribute(attribute));
88
+ if (!Number.isFinite(width) || width <= 0) {
89
+ throw new Error(`Shell drawer exposed an invalid ${attribute} value.`);
90
+ }
91
+ return width;
92
+ }
93
+
94
+ async function expectDrawerWidth(drawer, expect, expectedWidth) {
95
+ await expect.poll(async () => {
96
+ const box = await drawer.boundingBox();
97
+ return box ? Math.abs(box.width - expectedWidth) : Number.POSITIVE_INFINITY;
98
+ }, {
99
+ message: `Shell drawer did not settle at ${expectedWidth}px.`
100
+ }).toBeLessThanOrEqual(1);
101
+ }
102
+
103
+ async function expectContentAwareDrawerFit(drawer, expect) {
104
+ if (await drawer.getAttribute("data-drawer-width-mode") !== "content") {
105
+ return;
106
+ }
107
+
108
+ const fit = await drawer.evaluate((element) => {
109
+ const drawerRect = element.getBoundingClientRect();
110
+ const drawerStyle = window.getComputedStyle(element);
111
+ const rightToLeft = drawerStyle.direction === "rtl";
112
+ const endBorderWidth = Number.parseFloat(
113
+ rightToLeft ? drawerStyle.borderLeftWidth : drawerStyle.borderRightWidth
114
+ ) || 0;
115
+ const innerEnd = rightToLeft
116
+ ? drawerRect.left + endBorderWidth
117
+ : drawerRect.right - endBorderWidth;
118
+ const labels = Array.from(element.querySelectorAll(".v-list-item-title"))
119
+ .filter((label) => {
120
+ const style = window.getComputedStyle(label);
121
+ return style.display !== "none" && style.visibility !== "hidden";
122
+ })
123
+ .map((label) => {
124
+ const range = document.createRange();
125
+ range.selectNodeContents(label);
126
+ const textRect = range.getBoundingClientRect();
127
+ range.detach?.();
128
+ return {
129
+ clipped: (
130
+ label.scrollWidth > label.clientWidth ||
131
+ label.scrollHeight > label.clientHeight ||
132
+ (rightToLeft
133
+ ? textRect.left < innerEnd - 1
134
+ : textRect.right > innerEnd + 1)
135
+ ),
136
+ logicalEnd: rightToLeft ? textRect.left : textRect.right,
137
+ width: textRect.width
138
+ };
139
+ })
140
+ .filter((label) => label.width > 0);
141
+
142
+ if (labels.length === 0) {
143
+ return null;
144
+ }
145
+ const furthestLabel = labels.reduce((furthest, label) => {
146
+ if (!furthest) {
147
+ return label;
148
+ }
149
+ return rightToLeft
150
+ ? label.logicalEnd < furthest.logicalEnd ? label : furthest
151
+ : label.logicalEnd > furthest.logicalEnd ? label : furthest;
152
+ }, null);
153
+ return {
154
+ clipped: labels.some((label) => label.clipped),
155
+ endGap: rightToLeft
156
+ ? furthestLabel.logicalEnd - innerEnd
157
+ : innerEnd - furthestLabel.logicalEnd
158
+ };
159
+ });
160
+
161
+ expect(fit).not.toBeNull();
162
+ expect(fit.clipped).toBe(false);
163
+ expect(fit.endGap).toBeGreaterThanOrEqual(9);
164
+ expect(fit.endGap).toBeLessThanOrEqual(11);
165
+ }
166
+
167
+ async function expectCentredRailNavigation(page, drawer, expect) {
168
+ const links = drawer.locator("a.shell-menu-link-item[href]");
169
+ await expect(links.first()).toBeVisible();
170
+ const firstLink = links.first();
171
+ const firstIcon = firstLink.locator(".v-icon").first();
172
+ const geometry = await Promise.all([drawer.boundingBox(), firstLink.boundingBox(), firstIcon.boundingBox()]);
173
+ const [drawerBox, linkBox, iconBox] = geometry;
174
+
175
+ expect(drawerBox).not.toBeNull();
176
+ expect(linkBox).not.toBeNull();
177
+ expect(iconBox).not.toBeNull();
178
+ expect(linkBox.width).toBeGreaterThanOrEqual(48);
179
+ expect(linkBox.height).toBeGreaterThanOrEqual(48);
180
+ expect(Math.abs(
181
+ iconBox.x + iconBox.width / 2 - (drawerBox.x + drawerBox.width / 2)
182
+ )).toBeLessThanOrEqual(1);
183
+
184
+ const currentUrl = new URL(page.url());
185
+ const linkCount = await links.count();
186
+ let navigationLink = null;
187
+ let targetUrl = null;
188
+ for (let index = 0; index < linkCount; index += 1) {
189
+ const candidate = links.nth(index);
190
+ const href = await candidate.getAttribute("href");
191
+ if (!href) {
192
+ continue;
193
+ }
194
+ const resolved = new URL(href, currentUrl);
195
+ if (resolved.pathname !== currentUrl.pathname || resolved.search !== currentUrl.search) {
196
+ navigationLink = candidate;
197
+ targetUrl = resolved;
198
+ break;
199
+ }
200
+ }
201
+
202
+ expect(navigationLink).not.toBeNull();
203
+ await navigationLink.locator(".v-icon").first().click();
204
+ await expect.poll(() => {
205
+ const actual = new URL(page.url());
206
+ return `${actual.pathname}${actual.search}`;
207
+ }).toBe(`${targetUrl.pathname}${targetUrl.search}`);
208
+ }
209
+
210
+ async function openCompactDrawer(page, expect) {
211
+ const drawer = page.getByTestId("jskit-shell-drawer");
212
+ await page.getByTestId("jskit-shell-nav-toggle").click();
213
+ await expect(drawer).toHaveAttribute("data-presentation", "modal");
214
+ await expectElementVisibility(page, expect, "jskit-shell-drawer", true);
215
+ }
216
+
71
217
  async function runAdaptiveShellSmokeCase({
72
218
  page,
73
219
  expect,
@@ -83,8 +229,11 @@ async function runAdaptiveShellSmokeCase({
83
229
  await expect(page.locator("body")).toBeVisible();
84
230
  await expectGeneratedScreenContract(page, expect);
85
231
  await expectNoHorizontalOverflow(page, expect);
232
+ const drawer = page.getByTestId("jskit-shell-drawer");
233
+ const toggle = page.getByTestId("jskit-shell-nav-toggle");
234
+ const layoutClass = await readShellLayoutClass(drawer);
86
235
 
87
- if (viewport.name === "compact") {
236
+ if (layoutClass === "compact") {
88
237
  let bootstrapRequests = 0;
89
238
  await page.route("**/api/bootstrap**", async (route) => {
90
239
  bootstrapRequests += 1;
@@ -93,7 +242,20 @@ async function runAdaptiveShellSmokeCase({
93
242
  const bootstrapRequestsBeforePull = bootstrapRequests;
94
243
 
95
244
  await expect(page.getByTestId("jskit-shell-bottom-nav")).toBeVisible();
96
- expect(await isElementVisibleInViewport(page, "jskit-shell-drawer")).toBe(false);
245
+ await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
246
+
247
+ await openCompactDrawer(page, expect);
248
+ await toggle.click();
249
+ await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
250
+
251
+ await openCompactDrawer(page, expect);
252
+ await page.locator(".v-navigation-drawer__scrim").click();
253
+ await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
254
+
255
+ await openCompactDrawer(page, expect);
256
+ await page.keyboard.press("Escape");
257
+ await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
258
+ await expect(toggle).toBeFocused();
97
259
 
98
260
  const navButtonHeights = await page.getByTestId("jskit-shell-bottom-nav").locator(".v-btn").evaluateAll((buttons) =>
99
261
  buttons.map((button) => button.getBoundingClientRect().height)
@@ -106,7 +268,21 @@ async function runAdaptiveShellSmokeCase({
106
268
  await pullToRefresh(page, expect);
107
269
  await expect.poll(() => bootstrapRequests).toBeGreaterThan(bootstrapRequestsBeforePull);
108
270
  } else {
109
- await expect(page.getByTestId("jskit-shell-drawer")).toBeVisible();
271
+ await expect(drawer).toBeVisible();
272
+ if (await drawer.getAttribute("data-presentation") === "rail") {
273
+ await toggle.click();
274
+ }
275
+ await expect(drawer).toHaveAttribute("data-presentation", "drawer");
276
+ await expectDrawerWidth(drawer, expect, await readConfiguredWidth(drawer, "data-drawer-width"));
277
+ await expectContentAwareDrawerFit(drawer, expect);
278
+ await page.keyboard.press("Escape");
279
+ await expect(drawer).toHaveAttribute("data-presentation", "drawer");
280
+
281
+ await toggle.click();
282
+ await expect(drawer).toHaveAttribute("data-presentation", "rail");
283
+ await expectDrawerWidth(drawer, expect, await readConfiguredWidth(drawer, "data-rail-width"));
284
+ await expectCentredRailNavigation(page, drawer, expect);
285
+ await expectNoHorizontalOverflow(page, expect);
110
286
  }
111
287
  }
112
288
 
@@ -6,6 +6,7 @@ export default {
6
6
  name: "ShellLayout",
7
7
  inheritAttrs: false,
8
8
  setup(_, { attrs, slots }) {
9
+ // Keep drawerWidth, railWidth, and future shell props package-owned.
9
10
  return () => h(PackageShellLayout, attrs, slots);
10
11
  }
11
12
  };
@@ -19,7 +19,7 @@ const drawerDefaultOpenModel = computed({
19
19
  <div>
20
20
  <h2 class="text-h6 mb-2">Navigation</h2>
21
21
  <p class="text-body-2 text-medium-emphasis mb-0">
22
- Choose the default behavior for wider screens. Phone layouts keep primary navigation in the bottom bar.
22
+ On wider screens, collapsed navigation remains available as a rail. Phone layouts close the drawer and keep primary navigation in the bottom bar.
23
23
  </p>
24
24
  </div>
25
25
 
@@ -28,7 +28,7 @@ const drawerDefaultOpenModel = computed({
28
28
  color="primary"
29
29
  inset
30
30
  hide-details="auto"
31
- label="Open drawer by default on wider screens"
31
+ label="Start with expanded navigation on wider screens"
32
32
  />
33
33
  </section>
34
34
  </template>
@@ -0,0 +1,290 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawn } from "node:child_process";
3
+ import net from "node:net";
4
+ import path from "node:path";
5
+ import process from "node:process";
6
+ import test from "node:test";
7
+ import { fileURLToPath } from "node:url";
8
+ import { chromium, expect } from "@playwright/test";
9
+ import {
10
+ DEFAULT_VIEWPORTS,
11
+ runAdaptiveShellSmokeCase
12
+ } from "../src/test/adaptiveShellSmoke.js";
13
+
14
+ const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
15
+ const REPOSITORY_ROOT = path.resolve(TEST_DIRECTORY, "../../..");
16
+ const FIXTURE_ROOT = path.resolve(TEST_DIRECTORY, "../fixtures/adaptive-shell");
17
+ const VITE_CLI = path.join(REPOSITORY_ROOT, "node_modules", "vite", "bin", "vite.js");
18
+ const RUN_BROWSER_TEST = process.env.JSKIT_SHELL_WEB_BROWSER_INTEGRATION === "1";
19
+
20
+ function startVite(port) {
21
+ const child = spawn(process.execPath, [
22
+ VITE_CLI,
23
+ "--config",
24
+ path.join(FIXTURE_ROOT, "vite.config.mjs"),
25
+ "--port",
26
+ String(port),
27
+ "--clearScreen",
28
+ "false"
29
+ ], {
30
+ cwd: FIXTURE_ROOT,
31
+ stdio: ["ignore", "pipe", "pipe"],
32
+ env: {
33
+ ...process.env,
34
+ NO_COLOR: "1",
35
+ FORCE_COLOR: "0"
36
+ }
37
+ });
38
+ let output = "";
39
+ child.stdout.on("data", collectOutput);
40
+ child.stderr.on("data", collectOutput);
41
+
42
+ function collectOutput(chunk) {
43
+ output += chunk.toString("utf8");
44
+ }
45
+
46
+ async function waitUntilReady() {
47
+ await new Promise((resolve, reject) => {
48
+ const startedAt = Date.now();
49
+ const timer = setInterval(checkReadiness, 50);
50
+
51
+ function checkReadiness() {
52
+ if (new RegExp(`http://127\\.0\\.0\\.1:${port}/`, "u").test(output)) {
53
+ clearInterval(timer);
54
+ resolve();
55
+ return;
56
+ }
57
+ if (child.exitCode !== null) {
58
+ clearInterval(timer);
59
+ reject(new Error(`Vite exited before becoming ready.\n${output}`));
60
+ return;
61
+ }
62
+ if (Date.now() - startedAt >= 30_000) {
63
+ clearInterval(timer);
64
+ reject(new Error(`Timed out waiting for Vite.\n${output}`));
65
+ }
66
+ }
67
+ });
68
+ }
69
+
70
+ return Object.freeze({ child, waitUntilReady });
71
+ }
72
+
73
+ async function stopVite(runtime) {
74
+ const child = runtime?.child;
75
+ if (!child || child.exitCode !== null || child.signalCode !== null) {
76
+ return;
77
+ }
78
+ await new Promise((resolve) => {
79
+ const forceTimer = setTimeout(forceStop, 5_000);
80
+ child.once("exit", finishStop);
81
+ child.kill("SIGTERM");
82
+
83
+ function forceStop() {
84
+ child.kill("SIGKILL");
85
+ }
86
+
87
+ function finishStop() {
88
+ clearTimeout(forceTimer);
89
+ resolve();
90
+ }
91
+ });
92
+ }
93
+
94
+ async function reservePort() {
95
+ const server = net.createServer();
96
+ await new Promise((resolve, reject) => {
97
+ server.once("error", reject);
98
+ server.listen(0, "127.0.0.1", resolve);
99
+ });
100
+ const address = server.address();
101
+ assert.ok(address && typeof address === "object");
102
+ await new Promise((resolve, reject) => {
103
+ server.close((error) => error ? reject(error) : resolve());
104
+ });
105
+ return address.port;
106
+ }
107
+
108
+ function parseRgb(color) {
109
+ const channels = String(color || "").match(/[\d.]+/gu)?.map(Number) || [];
110
+ return {
111
+ red: channels[0] || 0,
112
+ green: channels[1] || 0,
113
+ blue: channels[2] || 0,
114
+ alpha: channels.length > 3 ? channels[3] : 1
115
+ };
116
+ }
117
+
118
+ function relativeLuminance(color) {
119
+ const channels = [color.red, color.green, color.blue].map(normalizeChannel);
120
+ return channels[0] * 0.2126 + channels[1] * 0.7152 + channels[2] * 0.0722;
121
+ }
122
+
123
+ function normalizeChannel(channel) {
124
+ const normalized = channel / 255;
125
+ return normalized <= 0.03928
126
+ ? normalized / 12.92
127
+ : ((normalized + 0.055) / 1.055) ** 2.4;
128
+ }
129
+
130
+ function contrastRatio(foreground, background) {
131
+ const foregroundLuminance = relativeLuminance(foreground);
132
+ const backgroundLuminance = relativeLuminance(background);
133
+ const lighter = Math.max(foregroundLuminance, backgroundLuminance);
134
+ const darker = Math.min(foregroundLuminance, backgroundLuminance);
135
+ return (lighter + 0.05) / (darker + 0.05);
136
+ }
137
+
138
+ async function assertTooltipContrast(page, linkName, interaction) {
139
+ const link = page.getByRole("link", { name: linkName, exact: true });
140
+ if (interaction === "focus") {
141
+ await link.focus();
142
+ } else {
143
+ await link.hover();
144
+ }
145
+ const tooltip = page.locator(".shell-navigation-tooltip").filter({ hasText: linkName }).last();
146
+ await expect(tooltip).toBeVisible();
147
+ const colors = await tooltip.evaluate((element) => {
148
+ const style = window.getComputedStyle(element);
149
+ return {
150
+ background: style.backgroundColor,
151
+ color: style.color,
152
+ opacity: Number(style.opacity)
153
+ };
154
+ });
155
+ const background = parseRgb(colors.background);
156
+ const foreground = parseRgb(colors.color);
157
+ assert.equal(colors.opacity, 1);
158
+ assert.equal(background.alpha, 1);
159
+ assert.ok(
160
+ contrastRatio(foreground, background) >= 4.5,
161
+ `${linkName} tooltip contrast was ${contrastRatio(foreground, background).toFixed(2)}:1.`
162
+ );
163
+ await page.keyboard.press("Escape");
164
+ }
165
+
166
+ async function assertDrawerFit(page) {
167
+ const drawer = page.getByTestId("jskit-shell-drawer");
168
+ await expect(drawer).toHaveAttribute("data-presentation", "drawer");
169
+ await expect.poll(async () => {
170
+ const configured = Number(await drawer.getAttribute("data-drawer-width"));
171
+ const box = await drawer.boundingBox();
172
+ return box ? Math.abs(box.width - configured) : Number.POSITIVE_INFINITY;
173
+ }).toBeLessThanOrEqual(1);
174
+ const result = await drawer.evaluate((element) => {
175
+ const drawerRect = element.getBoundingClientRect();
176
+ const border = Number.parseFloat(window.getComputedStyle(element).borderRightWidth) || 0;
177
+ const innerEnd = drawerRect.right - border;
178
+ const labels = Array.from(element.querySelectorAll(".v-list-item-title")).map((label) => {
179
+ const range = document.createRange();
180
+ range.selectNodeContents(label);
181
+ const rect = range.getBoundingClientRect();
182
+ range.detach?.();
183
+ return {
184
+ clientHeight: label.clientHeight,
185
+ clientWidth: label.clientWidth,
186
+ rect,
187
+ scrollHeight: label.scrollHeight,
188
+ scrollWidth: label.scrollWidth
189
+ };
190
+ });
191
+ const furthestEnd = Math.max(...labels.map((label) => label.rect.right));
192
+ return {
193
+ clipped: labels.some((label) => (
194
+ label.scrollWidth > label.clientWidth ||
195
+ label.scrollHeight > label.clientHeight
196
+ )),
197
+ endGap: innerEnd - furthestEnd,
198
+ overflow: document.documentElement.scrollWidth - document.documentElement.clientWidth
199
+ };
200
+ });
201
+ assert.equal(result.clipped, false, "A drawer label was clipped or ellipsized.");
202
+ assert.ok(result.endGap >= 9 && result.endGap <= 11, `Drawer label end gap was ${result.endGap}px.`);
203
+ assert.ok(result.overflow <= 1, `Page overflowed horizontally by ${result.overflow}px.`);
204
+ }
205
+
206
+ async function assertRailKeyboardAndSelection(page) {
207
+ const drawer = page.getByTestId("jskit-shell-drawer");
208
+ await page.getByTestId("jskit-shell-nav-toggle").click();
209
+ await expect(drawer).toHaveAttribute("data-presentation", "rail");
210
+ const configuredRailWidth = Number(await drawer.getAttribute("data-rail-width"));
211
+ await expect.poll(async () => {
212
+ const box = await drawer.boundingBox();
213
+ return box ? Math.abs(box.width - configuredRailWidth) : Number.POSITIVE_INFINITY;
214
+ }).toBeLessThanOrEqual(1);
215
+
216
+ const activeLink = page.getByRole("link", { name: "Bookings", exact: true });
217
+ const activeBackground = await activeLink.locator(".v-list-item__overlay").evaluate(
218
+ (element) => window.getComputedStyle(element).backgroundColor
219
+ );
220
+ assert.notEqual(activeBackground, "rgba(0, 0, 0, 0)");
221
+
222
+ const contacts = page.getByRole("link", { name: "Contacts", exact: true });
223
+ await contacts.focus();
224
+ await contacts.press("Enter");
225
+ await expect(page).toHaveURL(/\/contacts(?:\?|$)/u);
226
+
227
+ const assistant = page.getByRole("link", { name: "Assistant", exact: true });
228
+ await assistant.focus();
229
+ const scrollBeforeSpace = await page.evaluate(() => window.scrollY);
230
+ await assistant.press("Space");
231
+ await expect(page).toHaveURL(/\/assistant(?:\?|$)/u);
232
+ assert.equal(await page.evaluate(() => window.scrollY), scrollBeforeSpace);
233
+ }
234
+
235
+ test("shell-web adaptive navigation passes package-owned browser contracts", {
236
+ skip: RUN_BROWSER_TEST
237
+ ? false
238
+ : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1 to run shell-web browser integration",
239
+ timeout: 180_000
240
+ }, async () => {
241
+ const port = await reservePort();
242
+ const vite = startVite(port);
243
+ let browser = null;
244
+
245
+ try {
246
+ await vite.waitUntilReady();
247
+ const executablePath = String(process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH || "").trim();
248
+ browser = await chromium.launch({
249
+ headless: true,
250
+ ...(executablePath ? { executablePath } : {})
251
+ });
252
+ const context = await browser.newContext({
253
+ baseURL: `http://127.0.0.1:${port}`,
254
+ locale: "en-US"
255
+ });
256
+
257
+ for (const viewport of DEFAULT_VIEWPORTS) {
258
+ const page = await context.newPage();
259
+ await runAdaptiveShellSmokeCase({ page, expect, viewport });
260
+ await page.close();
261
+ }
262
+
263
+ for (const pathAndTheme of [
264
+ "/home?theme=light",
265
+ "/home?theme=dark",
266
+ "/w/acme/admin/bookings?theme=light",
267
+ "/w/acme/admin/bookings?theme=dark"
268
+ ]) {
269
+ const page = await context.newPage();
270
+ await page.setViewportSize({ width: 1280, height: 900 });
271
+ await page.goto(pathAndTheme);
272
+ await expect(page.getByTestId("jskit-shell-drawer")).toBeVisible();
273
+ await assertDrawerFit(page);
274
+ await assertTooltipContrast(page, "Bookings", "focus");
275
+ await assertTooltipContrast(page, "Help and support", "hover");
276
+ await page.close();
277
+ }
278
+
279
+ const railPage = await context.newPage();
280
+ await railPage.setViewportSize({ width: 1280, height: 900 });
281
+ await railPage.goto("/w/acme/admin/bookings?theme=light");
282
+ await assertDrawerFit(railPage);
283
+ await assertRailKeyboardAndSelection(railPage);
284
+ await railPage.close();
285
+ await context.close();
286
+ } finally {
287
+ await browser?.close();
288
+ await stopVite(vite);
289
+ }
290
+ });
@@ -0,0 +1,68 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import {
4
+ normalizeDesktopDrawerClosedMode,
5
+ resolveShellDrawerPresentation,
6
+ resolveShellDrawerToggleLabel
7
+ } from "../src/client/support/drawerPresentation.js";
8
+
9
+ test("wide closed navigation defaults to a visible Material navigation rail", () => {
10
+ assert.deepEqual(
11
+ resolveShellDrawerPresentation({ compact: false, open: false }),
12
+ {
13
+ visible: true,
14
+ rail: true,
15
+ kind: "rail",
16
+ closedMode: "rail"
17
+ }
18
+ );
19
+ });
20
+
21
+ test("compact closed navigation dismisses instead of retaining a rail", () => {
22
+ assert.deepEqual(
23
+ resolveShellDrawerPresentation({ compact: true, open: false }),
24
+ {
25
+ visible: false,
26
+ rail: false,
27
+ kind: "modal",
28
+ closedMode: "rail"
29
+ }
30
+ );
31
+ });
32
+
33
+ test("desktopDrawerClosedMode hidden preserves an explicitly hidden wide drawer", () => {
34
+ assert.equal(normalizeDesktopDrawerClosedMode("hidden"), "hidden");
35
+ assert.deepEqual(
36
+ resolveShellDrawerPresentation({
37
+ compact: false,
38
+ open: false,
39
+ desktopClosedMode: "hidden"
40
+ }),
41
+ {
42
+ visible: false,
43
+ rail: false,
44
+ kind: "hidden",
45
+ closedMode: "hidden"
46
+ }
47
+ );
48
+ });
49
+
50
+ test("open navigation renders as a full drawer and labels its toggle responsively", () => {
51
+ assert.deepEqual(
52
+ resolveShellDrawerPresentation({ compact: false, open: true }),
53
+ {
54
+ visible: true,
55
+ rail: false,
56
+ kind: "drawer",
57
+ closedMode: "rail"
58
+ }
59
+ );
60
+ assert.equal(
61
+ resolveShellDrawerToggleLabel({ compact: false, open: true }),
62
+ "Collapse navigation drawer"
63
+ );
64
+ assert.equal(
65
+ resolveShellDrawerToggleLabel({ compact: true, open: false }),
66
+ "Open navigation menu"
67
+ );
68
+ });
@@ -0,0 +1,48 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import {
4
+ DEFAULT_SHELL_DRAWER_WIDTH,
5
+ DEFAULT_SHELL_RAIL_WIDTH,
6
+ normalizeShellDrawerWidth,
7
+ normalizeShellRailWidth,
8
+ resolveContentAwareDrawerWidth
9
+ } from "../src/client/support/drawerWidth.js";
10
+
11
+ test("content-aware drawer width includes the rendered label start, width, and 10px end gap", () => {
12
+ assert.equal(
13
+ resolveContentAwareDrawerWidth([
14
+ { logicalStart: 72, textWidth: 40 },
15
+ { logicalStart: 72, textWidth: 78 }
16
+ ]),
17
+ 160
18
+ );
19
+ assert.equal(
20
+ resolveContentAwareDrawerWidth([
21
+ { logicalStart: 72, textWidth: 99.015625 }
22
+ ]),
23
+ 182
24
+ );
25
+ });
26
+
27
+ test("drawer and rail widths have stable defaults and bounded overrides", () => {
28
+ assert.equal(normalizeShellDrawerWidth(null), DEFAULT_SHELL_DRAWER_WIDTH);
29
+ assert.equal(normalizeShellDrawerWidth(180), 180);
30
+ assert.equal(normalizeShellDrawerWidth(1000), 360);
31
+ assert.equal(normalizeShellRailWidth(null), DEFAULT_SHELL_RAIL_WIDTH);
32
+ assert.equal(normalizeShellRailWidth(96), 96);
33
+ assert.equal(normalizeShellRailWidth(20), 48);
34
+ });
35
+
36
+ test("content-aware width ignores invalid measurements and uses a bounded fallback", () => {
37
+ assert.equal(
38
+ resolveContentAwareDrawerWidth([
39
+ { logicalStart: -1, textWidth: 20 },
40
+ { logicalStart: 40, textWidth: Number.NaN }
41
+ ]),
42
+ DEFAULT_SHELL_DRAWER_WIDTH
43
+ );
44
+ assert.equal(
45
+ resolveContentAwareDrawerWidth([{ logicalStart: 72, textWidth: 900 }]),
46
+ 360
47
+ );
48
+ });
@@ -151,10 +151,18 @@ test("shell-web generic link items support the expected shared route and icon be
151
151
 
152
152
  assert.match(shellMenuSource, /exact:\s*\{/);
153
153
  assert.match(shellMenuSource, /:exact="props\.exact"/);
154
+ assert.match(shellMenuSource, /:aria-label="props\.label"/);
155
+ assert.match(shellMenuSource, /ShellNavigationTooltip/);
156
+ assert.match(shellMenuSource, /@keydown\.space="activateShellNavigationLinkOnSpace"/);
157
+ assert.doesNotMatch(shellMenuSource, /v-tooltip="props\.label"/);
154
158
  assert.match(shellMenuSource, /class="shell-menu-link-item"/);
155
159
  assert.match(shellMenuSource, /min-height:\s*48px/);
156
160
  assert.match(shellSurfaceAwareSource, /exact:\s*\{/);
157
161
  assert.match(shellSurfaceAwareSource, /:exact="props\.exact"/);
162
+ assert.match(shellSurfaceAwareSource, /:aria-label="props\.label"/);
163
+ assert.match(shellSurfaceAwareSource, /ShellNavigationTooltip/);
164
+ assert.match(shellSurfaceAwareSource, /@keydown\.space="activateShellNavigationLinkOnSpace"/);
165
+ assert.doesNotMatch(shellSurfaceAwareSource, /v-tooltip="props\.label"/);
158
166
  assert.match(shellSurfaceAwareSource, /class="shell-menu-link-item"/);
159
167
  assert.match(shellSurfaceAwareSource, /min-height:\s*48px/);
160
168
  assert.match(shellTabSource, /icon:\s*\{/);
@@ -163,6 +171,18 @@ test("shell-web generic link items support the expected shared route and icon be
163
171
  assert.match(shellTabSource, /stacked/);
164
172
  assert.match(shellTabSource, /min-height:\s*48px/);
165
173
  assert.match(shellTabSource, /<v-icon v-if="resolvedIcon" :icon="resolvedIcon" \/>/);
174
+
175
+ const tooltipSource = await readFile(
176
+ path.join(PACKAGE_DIR, "src", "client", "components", "ShellNavigationTooltip.vue"),
177
+ "utf8"
178
+ );
179
+ assert.match(tooltipSource, /:theme="theme\.name\.value"/);
180
+ assert.match(tooltipSource, /location="end"/);
181
+ assert.match(tooltipSource, /:open-on-focus="true"/);
182
+ assert.match(tooltipSource, /:open-on-hover="true"/);
183
+ assert.match(tooltipSource, /--v-theme-inverse-surface, var\(--v-theme-on-surface\)/);
184
+ assert.match(tooltipSource, /--v-theme-inverse-on-surface, var\(--v-theme-surface\)/);
185
+ assert.match(tooltipSource, /opacity:\s*1\s*!important/);
166
186
  });
167
187
 
168
188
  test("shell-web binds the local link-item wrapper tokens into MainClientProvider", () => {