@jskit-ai/shell-web 0.2.10 → 0.2.12
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.
- package/CHANGELOG.md +10 -0
- package/fixtures/adaptive-shell/src/App.vue +7 -0
- package/fixtures/adaptive-shell/src/OwnBarLayout.vue +24 -0
- package/fixtures/adaptive-shell/src/RecordListPage.vue +22 -0
- package/fixtures/adaptive-shell/src/RecordPage.vue +30 -0
- package/fixtures/adaptive-shell/src/ScreenPage.vue +7 -3
- package/fixtures/adaptive-shell/src/SettingsPage.vue +24 -0
- package/fixtures/adaptive-shell/src/StudioPage.vue +26 -0
- package/fixtures/adaptive-shell/src/main.js +64 -55
- package/fixtures/adaptive-shell/src/records.js +13 -0
- package/fixtures/adaptive-shell/src/theme/index.js +3 -0
- package/locales/en.json +1 -0
- package/package.json +22 -5
- package/patterns/application-shell/PATTERN.md +3 -1
- package/patterns/application-shell/example/expected-existing/src/pages/home/index.vue +5 -18
- package/patterns/application-shell/example/expected-existing/src/views/NotFound.vue +14 -0
- package/patterns/application-shell/example/src/pages/home/index.vue +21 -57
- package/patterns/application-shell/example/src/pages/home/settings/general/index.vue +24 -19
- package/patterns/application-shell/example/src/pages/home/settings.vue +27 -84
- package/patterns/application-shell/example/src/views/NotFound.vue +15 -0
- package/patterns/page-and-placement/example/src/components/SyncStatusElement.vue +2 -2
- package/patterns/page-and-placement/example/src/pages/home/reports/activity.vue +1 -1
- package/patterns/page-and-placement/example/src/pages/home/reports/overview.vue +1 -1
- package/patterns/page-and-placement/example/src/pages/home/reports.vue +6 -3
- package/patterns/page-and-placement/example/src/placement.js +1 -1
- package/src/client/components/ShellErrorHost.vue +13 -15
- package/src/client/components/ShellLayout.vue +340 -187
- package/src/client/components/ShellListDetail.vue +77 -0
- package/src/client/components/ShellMenuLinkItem.vue +10 -24
- package/src/client/components/ShellNavigationItem.vue +175 -0
- package/src/client/components/ShellNavigationScope.vue +18 -0
- package/src/client/components/ShellOutlet.vue +1 -1
- package/src/client/components/ShellOutletMenuWidget.vue +2 -2
- package/src/client/components/ShellPageAction.vue +91 -0
- package/src/client/components/ShellPageActions.vue +32 -0
- package/src/client/components/ShellPageActionsTarget.vue +24 -0
- package/src/client/components/ShellPageTitle.vue +49 -0
- package/src/client/components/ShellSurfaceAwareMenuLinkItem.vue +10 -24
- package/src/client/components/ShellTabLinkItem.vue +77 -3
- package/src/client/components/ShellUpButton.vue +29 -0
- package/src/client/composables/useShellAppBar.js +27 -0
- package/src/client/composables/useShellDrawer.js +28 -18
- package/src/client/composables/useShellPageTitle.js +15 -0
- package/src/client/composables/useShellRouteTransition.js +1 -1
- package/src/client/composables/useShellWindowSizeClass.js +21 -0
- package/src/client/error/presentation.js +3 -5
- package/src/client/index.js +11 -0
- package/src/client/lib/menuIcons.js +21 -65
- package/src/client/navigation/documentNavigation.js +38 -0
- package/src/client/navigation/shellNavigationRuntime.js +480 -0
- package/src/client/navigation/useShellNavigation.js +94 -0
- package/src/client/providers/ShellWebClientProvider.js +11 -0
- package/src/client/support/drawerPresentation.js +9 -4
- package/src/client/support/drawerWidth.js +18 -1
- package/src/client/support/navigationPresentation.js +40 -0
- package/src/client/support/shellLayoutClass.js +6 -25
- package/src/client/support/windowSizeClass.js +29 -0
- package/src/test/adaptiveShellSmoke.js +43 -16
- package/src/test/shellNavigation.js +32 -0
- package/test/adaptiveShell.browser.test.js +251 -111
- package/test/clientUpdate.test.js +6 -1
- package/test/drawerPresentation.test.js +7 -7
- package/test/errorPresentation.test.js +4 -5
- package/test/materialBaselines.browser.test.js +96 -0
- package/test/menuIcons.test.js +14 -22
- package/test/outletMenuWidgetContract.test.js +2 -3
- package/test/playwrightContract.test.js +3 -1
- package/test/provider.test.js +9 -1
- package/test/settingsPlacementContract.test.js +49 -28
- package/test/shellGestureSupport.test.js +21 -9
- package/test/translation.test.js +2 -2
- package/test/useShellDrawer.test.js +20 -5
- package/test/useShellRouteTransition.test.js +3 -3
- package/patterns/application-shell/example/src/pages/home/settings/index.vue +0 -7
- package/src/client/components/ShellNavigationTooltip.vue +0 -39
|
@@ -9,10 +9,12 @@ import {
|
|
|
9
9
|
startViteFixture,
|
|
10
10
|
stopProcess
|
|
11
11
|
} from "../../../tooling/testUtils/browserFixture.mjs";
|
|
12
|
+
import { materialSymbols } from "@jskit-ai/material-web/client/symbols";
|
|
12
13
|
import {
|
|
13
14
|
DEFAULT_VIEWPORTS,
|
|
14
15
|
runAdaptiveShellSmokeCase
|
|
15
16
|
} from "../src/test/adaptiveShellSmoke.js";
|
|
17
|
+
import { pressShellBack, shellBackButton, shellPageTitle } from "../src/test/shellNavigation.js";
|
|
16
18
|
|
|
17
19
|
const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
|
|
18
20
|
const FIXTURE_ROOT = path.resolve(TEST_DIRECTORY, "../fixtures/adaptive-shell");
|
|
@@ -48,81 +50,66 @@ function contrastRatio(foreground, background) {
|
|
|
48
50
|
return (lighter + 0.05) / (darker + 0.05);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const colors = await tooltip.evaluate((element) => {
|
|
62
|
-
const style = window.getComputedStyle(element);
|
|
63
|
-
return {
|
|
64
|
-
background: style.backgroundColor,
|
|
65
|
-
color: style.color,
|
|
66
|
-
opacity: Number(style.opacity)
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
const background = parseRgb(colors.background);
|
|
70
|
-
const foreground = parseRgb(colors.color);
|
|
71
|
-
assert.equal(colors.opacity, 1);
|
|
72
|
-
assert.equal(background.alpha, 1);
|
|
73
|
-
assert.ok(
|
|
74
|
-
contrastRatio(foreground, background) >= 4.5,
|
|
75
|
-
`${linkName} tooltip contrast was ${contrastRatio(foreground, background).toFixed(2)}:1.`
|
|
76
|
-
);
|
|
77
|
-
await page.keyboard.press("Escape");
|
|
53
|
+
// The computed colour of a theme role, read from a probe painted with it.
|
|
54
|
+
async function readRoleColor(page, role) {
|
|
55
|
+
return page.evaluate((name) => {
|
|
56
|
+
const probe = document.createElement("div");
|
|
57
|
+
probe.style.background = `rgb(var(--v-theme-${name}))`;
|
|
58
|
+
document.querySelector(".v-application").append(probe);
|
|
59
|
+
const color = window.getComputedStyle(probe).backgroundColor;
|
|
60
|
+
probe.remove();
|
|
61
|
+
return color;
|
|
62
|
+
}, role);
|
|
78
63
|
}
|
|
79
64
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const countVisibleTooltips = () => Array.from(
|
|
84
|
-
document.querySelectorAll(".shell-navigation-tooltip")
|
|
85
|
-
).filter((element) => {
|
|
86
|
-
const style = window.getComputedStyle(element);
|
|
87
|
-
const rect = element.getBoundingClientRect();
|
|
88
|
-
return (
|
|
89
|
-
style.display !== "none" &&
|
|
90
|
-
style.visibility !== "hidden" &&
|
|
91
|
-
Number(style.opacity) > 0 &&
|
|
92
|
-
rect.width > 0 &&
|
|
93
|
-
rect.height > 0
|
|
94
|
-
);
|
|
95
|
-
}).length;
|
|
96
|
-
|
|
97
|
-
const samples = [];
|
|
98
|
-
let activeLink = null;
|
|
99
|
-
for (const link of links) {
|
|
100
|
-
activeLink?.dispatchEvent(new MouseEvent("mouseleave"));
|
|
101
|
-
link.dispatchEvent(new MouseEvent("mouseenter"));
|
|
102
|
-
activeLink = link;
|
|
103
|
-
await pause(24);
|
|
104
|
-
samples.push(countVisibleTooltips());
|
|
105
|
-
}
|
|
106
|
-
activeLink?.dispatchEvent(new MouseEvent("mouseleave"));
|
|
107
|
-
await pause(100);
|
|
65
|
+
function symbolPath(alias) {
|
|
66
|
+
return materialSymbols[alias].slice("svg:".length);
|
|
67
|
+
}
|
|
108
68
|
|
|
69
|
+
// Material 3 chrome: a 64dp surface app bar and a surface drawer without dividers, the active destination on a
|
|
70
|
+
// secondary-container pill with its icon filled, and inactive labels readable on the drawer.
|
|
71
|
+
async function assertMaterialChrome(page, activeLabel, activeIcon) {
|
|
72
|
+
const drawer = page.getByTestId("jskit-shell-drawer");
|
|
73
|
+
await expect(drawer).toHaveAttribute("data-presentation", "drawer");
|
|
74
|
+
const surface = await readRoleColor(page, "surface");
|
|
75
|
+
const secondaryContainer = await readRoleColor(page, "secondary-container");
|
|
76
|
+
const chrome = await page.evaluate((label) => {
|
|
77
|
+
const style = (element) => window.getComputedStyle(element);
|
|
78
|
+
const appBar = document.querySelector("[data-testid='jskit-shell-app-bar']");
|
|
79
|
+
const drawerElement = document.querySelector("[data-testid='jskit-shell-drawer']");
|
|
80
|
+
const items = Array.from(drawerElement.querySelectorAll("a.shell-menu-link-item"));
|
|
81
|
+
const active = items.find((item) => item.textContent.trim() === label);
|
|
82
|
+
const inactive = items.find((item) => item !== active);
|
|
109
83
|
return {
|
|
110
|
-
|
|
111
|
-
|
|
84
|
+
appBarHeight: appBar.getBoundingClientRect().height,
|
|
85
|
+
appBarBackground: style(appBar).backgroundColor,
|
|
86
|
+
appBarBorders: [style(appBar).borderBottomWidth, style(appBar).borderTopWidth],
|
|
87
|
+
drawerBackground: style(drawerElement).backgroundColor,
|
|
88
|
+
drawerBorder: style(drawerElement).borderRightWidth,
|
|
89
|
+
activeBackground: style(active).backgroundColor,
|
|
90
|
+
activeHeight: active.getBoundingClientRect().height,
|
|
91
|
+
activeRadius: Number.parseFloat(style(active).borderTopLeftRadius),
|
|
92
|
+
activeIconPath: active.querySelector(".v-icon svg path")?.getAttribute("d") || "",
|
|
93
|
+
inactiveColor: style(inactive.querySelector(".v-list-item-title")).color
|
|
112
94
|
};
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
assert.equal(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
);
|
|
120
|
-
assert.equal(
|
|
95
|
+
}, activeLabel);
|
|
96
|
+
assert.equal(chrome.appBarHeight, 64);
|
|
97
|
+
assert.equal(chrome.appBarBackground, surface);
|
|
98
|
+
assert.deepEqual(chrome.appBarBorders, ["0px", "0px"]);
|
|
99
|
+
assert.equal(chrome.drawerBackground, surface);
|
|
100
|
+
assert.equal(chrome.drawerBorder, "0px");
|
|
101
|
+
assert.equal(chrome.activeBackground, secondaryContainer);
|
|
102
|
+
assert.equal(chrome.activeHeight, 56);
|
|
103
|
+
assert.ok(chrome.activeRadius >= 28, `The active destination's corner radius was ${chrome.activeRadius}px.`);
|
|
104
|
+
assert.equal(chrome.activeIconPath, symbolPath(activeIcon));
|
|
105
|
+
const ratio = contrastRatio(parseRgb(chrome.inactiveColor), parseRgb(chrome.drawerBackground));
|
|
106
|
+
assert.ok(ratio >= 4.5, `Inactive navigation labels had ${ratio.toFixed(2)}:1 contrast.`);
|
|
121
107
|
}
|
|
122
108
|
|
|
123
109
|
async function assertDrawerFit(page) {
|
|
124
110
|
const drawer = page.getByTestId("jskit-shell-drawer");
|
|
125
111
|
await expect(drawer).toHaveAttribute("data-presentation", "drawer");
|
|
112
|
+
await expect(drawer).toHaveAttribute("data-drawer-width-mode", "content");
|
|
126
113
|
assert.equal(
|
|
127
114
|
await drawer.locator(".v-list-subheader").count(),
|
|
128
115
|
0,
|
|
@@ -193,10 +180,11 @@ async function assertRailKeyboardAndSelection(page) {
|
|
|
193
180
|
}).toBeLessThanOrEqual(1);
|
|
194
181
|
|
|
195
182
|
const activeLink = page.getByRole("link", { name: "Bookings", exact: true });
|
|
196
|
-
const activeBackground = await activeLink.locator(".
|
|
183
|
+
const activeBackground = await activeLink.locator(".shell-menu-link-item__indicator").evaluate(
|
|
197
184
|
(element) => window.getComputedStyle(element).backgroundColor
|
|
198
185
|
);
|
|
199
|
-
assert.
|
|
186
|
+
assert.equal(activeBackground, await readRoleColor(page, "secondary-container"));
|
|
187
|
+
await expect(activeLink.locator(".shell-menu-link-item__rail-label")).toHaveText("Bookings");
|
|
200
188
|
|
|
201
189
|
const contacts = page.getByRole("link", { name: "Contacts", exact: true });
|
|
202
190
|
await contacts.focus();
|
|
@@ -231,49 +219,45 @@ test("shell-web adaptive navigation passes package-owned browser contracts", {
|
|
|
231
219
|
const page = await context.newPage();
|
|
232
220
|
await runAdaptiveShellSmokeCase({ page, expect, viewport });
|
|
233
221
|
if (viewport.name !== "compact") {
|
|
234
|
-
await expect(page).toHaveURL(/\/home\/settings
|
|
222
|
+
await expect(page).toHaveURL(/\/home\/settings$/u);
|
|
235
223
|
}
|
|
236
224
|
await page.close();
|
|
237
225
|
}
|
|
238
226
|
|
|
239
|
-
for (const pathAndTheme of [
|
|
240
|
-
"/home?theme=light",
|
|
241
|
-
"/home?theme=dark",
|
|
242
|
-
"/w/acme/admin/bookings?theme=light",
|
|
243
|
-
"/w/acme/admin/bookings?theme=dark"
|
|
227
|
+
for (const [pathAndTheme, activeLabel, activeIcon] of [
|
|
228
|
+
["/home?theme=light", "Home", "homeFilled"],
|
|
229
|
+
["/home?theme=dark", "Home", "homeFilled"],
|
|
230
|
+
["/w/acme/admin/bookings?theme=light", "Bookings", "adminPanelSettingsFilled"],
|
|
231
|
+
["/w/acme/admin/bookings?theme=dark", "Bookings", "adminPanelSettingsFilled"]
|
|
244
232
|
]) {
|
|
245
233
|
const page = await context.newPage();
|
|
246
234
|
await page.setViewportSize({ width: 1280, height: 900 });
|
|
247
235
|
await page.goto(pathAndTheme);
|
|
248
236
|
await expect(page.getByTestId("jskit-shell-drawer")).toBeVisible();
|
|
249
|
-
await
|
|
250
|
-
await assertRapidTooltipTraversal(page);
|
|
251
|
-
await assertTooltipContrast(page, "Bookings", "focus");
|
|
252
|
-
await assertTooltipContrast(page, "Help and support", "hover");
|
|
237
|
+
await assertMaterialChrome(page, activeLabel, activeIcon);
|
|
253
238
|
await page.close();
|
|
254
239
|
}
|
|
255
240
|
|
|
256
|
-
const
|
|
257
|
-
await
|
|
258
|
-
await
|
|
259
|
-
await expect(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
);
|
|
263
|
-
await
|
|
264
|
-
await mediumTooltipPage.close();
|
|
241
|
+
const mediumPage = await context.newPage();
|
|
242
|
+
await mediumPage.setViewportSize({ width: 768, height: 1024 });
|
|
243
|
+
await mediumPage.goto("/w/acme/admin/bookings?theme=light");
|
|
244
|
+
await expect(mediumPage.getByTestId("jskit-shell-drawer")).toHaveAttribute("data-layout", "medium");
|
|
245
|
+
const railLabels = mediumPage.getByTestId("jskit-shell-rail").locator(".shell-menu-link-item__rail-label");
|
|
246
|
+
await expect(railLabels.first()).toBeVisible();
|
|
247
|
+
assert.ok(await railLabels.count() >= 5, "The navigation rail labels each destination.");
|
|
248
|
+
await mediumPage.close();
|
|
265
249
|
|
|
266
250
|
const railPage = await context.newPage();
|
|
267
251
|
await railPage.setViewportSize({ width: 1280, height: 900 });
|
|
268
252
|
await railPage.goto("/w/acme/admin/bookings?theme=light");
|
|
269
|
-
await
|
|
253
|
+
await expect(railPage.getByTestId("jskit-shell-drawer")).toHaveAttribute("data-drawer-width", "360");
|
|
270
254
|
await assertRailKeyboardAndSelection(railPage);
|
|
271
255
|
await railPage.close();
|
|
272
256
|
|
|
273
257
|
const configuredPage = await context.newPage();
|
|
274
258
|
await configuredPage.setViewportSize({ width: 1280, height: 900 });
|
|
275
259
|
await configuredPage.goto(
|
|
276
|
-
"/w/acme/admin/bookings?theme=light&railWidth=64&navigationItemSpacing=8"
|
|
260
|
+
"/w/acme/admin/bookings?theme=light&railWidth=64&navigationItemSpacing=8&drawerWidth=content"
|
|
277
261
|
);
|
|
278
262
|
const configuredDrawer = configuredPage.getByTestId("jskit-shell-drawer");
|
|
279
263
|
await expect(configuredDrawer).toHaveAttribute("data-navigation-item-spacing", "8");
|
|
@@ -440,7 +424,7 @@ test("shell-web error banners never cover content and keep a readable close butt
|
|
|
440
424
|
}
|
|
441
425
|
});
|
|
442
426
|
|
|
443
|
-
test("shell-web
|
|
427
|
+
test("shell-web's app bar fills with surface-container once the page scrolls under it", {
|
|
444
428
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
445
429
|
timeout: 90_000
|
|
446
430
|
}, async () => {
|
|
@@ -448,31 +432,187 @@ test("shell-web chrome borders and surfaces follow app-supplied tokens", {
|
|
|
448
432
|
let browser;
|
|
449
433
|
try {
|
|
450
434
|
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
451
|
-
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width:
|
|
452
|
-
await page.goto("/home?theme=light");
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
assert.deepEqual(defaults.appBar.slice(0, 4), ["0px", "0px", "1px", "0px"]);
|
|
465
|
-
assert.deepEqual(defaults.drawer.slice(0, 4), ["0px", "1px", "0px", "0px"]);
|
|
466
|
-
|
|
467
|
-
await page.addStyleTag({
|
|
468
|
-
content: ":root { --shell-chrome-border-width: 0; --shell-app-bar-background: rgb(1, 2, 3); --shell-navigation-background: rgb(4, 5, 6); }"
|
|
469
|
-
});
|
|
470
|
-
const restyled = await read();
|
|
471
|
-
assert.deepEqual(restyled.appBar, ["0px", "0px", "0px", "0px", "rgb(1, 2, 3)"]);
|
|
472
|
-
assert.deepEqual(restyled.drawer, ["0px", "0px", "0px", "0px", "rgb(4, 5, 6)"]);
|
|
435
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 } });
|
|
436
|
+
await page.goto("/home/contacts?theme=light");
|
|
437
|
+
const appBar = page.getByTestId("jskit-shell-app-bar");
|
|
438
|
+
const background = () => appBar.evaluate((element) => window.getComputedStyle(element).backgroundColor);
|
|
439
|
+
await expect.poll(background).toBe(await readRoleColor(page, "surface"));
|
|
440
|
+
const bar = page.getByTestId("jskit-shell-bottom-nav");
|
|
441
|
+
assert.equal(
|
|
442
|
+
await bar.evaluate((element) => window.getComputedStyle(element).backgroundColor),
|
|
443
|
+
await readRoleColor(page, "surface-container")
|
|
444
|
+
);
|
|
445
|
+
assert.equal(Math.round((await bar.boundingBox()).height), 80);
|
|
446
|
+
await page.evaluate(() => window.scrollTo(0, 400));
|
|
447
|
+
await expect.poll(background).toBe(await readRoleColor(page, "surface-container"));
|
|
473
448
|
await page.close();
|
|
474
449
|
} finally {
|
|
475
450
|
await browser?.close();
|
|
476
451
|
await stopProcess(vite);
|
|
477
452
|
}
|
|
478
453
|
});
|
|
454
|
+
|
|
455
|
+
test("shell-web's bar pieces give a layout that draws its own top app bar the shell's Up, title and actions", {
|
|
456
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
457
|
+
timeout: 120_000
|
|
458
|
+
}, async () => {
|
|
459
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
460
|
+
let browser;
|
|
461
|
+
try {
|
|
462
|
+
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
463
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
464
|
+
const page = await browser.newPage({
|
|
465
|
+
baseURL: vite.baseURL,
|
|
466
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
467
|
+
});
|
|
468
|
+
const at = `${viewport.width}px`;
|
|
469
|
+
const ownBar = page.getByTestId("fixture-own-bar");
|
|
470
|
+
|
|
471
|
+
// A top-level page: the title is the page's one h1, in the app's own bar, with no arrow.
|
|
472
|
+
await page.goto("/home/studio");
|
|
473
|
+
await expect(ownBar.getByRole("heading", { level: 1, name: "Studio" }), at).toBeVisible();
|
|
474
|
+
await expect(page.getByRole("heading", { level: 1 }), at).toHaveCount(1);
|
|
475
|
+
await expect(shellBackButton(page), at).toHaveCount(0);
|
|
476
|
+
|
|
477
|
+
// An inner page: Up, its title and its actions, in the app's own bar; Up returns along the trail.
|
|
478
|
+
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
479
|
+
await expect(page).toHaveURL(/\/home\/studio\/ada$/u);
|
|
480
|
+
await expect(ownBar.getByTestId("jskit-shell-page-title"), at).toHaveText("Ada Lovelace");
|
|
481
|
+
await expect(ownBar.getByTestId("jskit-shell-back"), at).toHaveAccessibleName("Back");
|
|
482
|
+
await expect(ownBar.getByRole("button", { name: "Run" }), at).toBeVisible();
|
|
483
|
+
await pressShellBack(page);
|
|
484
|
+
await expect(page).toHaveURL(/\/home\/studio$/u);
|
|
485
|
+
await expect(shellBackButton(page), at).toHaveCount(0);
|
|
486
|
+
|
|
487
|
+
// A pasted link goes Up to the declared parent.
|
|
488
|
+
await page.goto("/home/studio/ada");
|
|
489
|
+
await pressShellBack(page);
|
|
490
|
+
await expect(page).toHaveURL(/\/home\/studio$/u);
|
|
491
|
+
await page.close();
|
|
492
|
+
}
|
|
493
|
+
} finally {
|
|
494
|
+
await browser?.close();
|
|
495
|
+
await stopProcess(vite);
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
async function openMainDestination(page, label) {
|
|
500
|
+
await page.getByRole("link", { name: label, exact: true }).filter({ visible: true }).first().click();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
test("shell-web Up follows the tab's trail, falls back to the parent and returns to where the person was", {
|
|
504
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
505
|
+
timeout: 180_000
|
|
506
|
+
}, async () => {
|
|
507
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
508
|
+
let browser;
|
|
509
|
+
try {
|
|
510
|
+
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
511
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
512
|
+
const context = await browser.newContext({
|
|
513
|
+
baseURL: vite.baseURL,
|
|
514
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
515
|
+
});
|
|
516
|
+
const page = await context.newPage();
|
|
517
|
+
const at = `${viewport.width}px`;
|
|
518
|
+
|
|
519
|
+
// Main-menu pages have no arrow.
|
|
520
|
+
for (const path of ["/home", "/home/contacts", "/home/suppliers", "/home/bookings", "/home/settings"]) {
|
|
521
|
+
await page.goto(path);
|
|
522
|
+
await expect(shellPageTitle(page)).toBeVisible();
|
|
523
|
+
await expect(shellBackButton(page), `${at} ${path}`).toHaveCount(0);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// contact -> supplier -> Up = contact -> Up = the Contacts list.
|
|
527
|
+
await page.goto("/home/contacts");
|
|
528
|
+
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
529
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
530
|
+
await expect(shellPageTitle(page)).toHaveText("Ada Lovelace");
|
|
531
|
+
await expect(shellBackButton(page)).toHaveAccessibleName("Back");
|
|
532
|
+
await page.getByRole("link", { name: "Supplier", exact: true }).click();
|
|
533
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
534
|
+
// A refresh keeps the trail.
|
|
535
|
+
await page.reload();
|
|
536
|
+
await expect(shellPageTitle(page)).toHaveText("Acme Supplies");
|
|
537
|
+
await pressShellBack(page);
|
|
538
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
539
|
+
// The browser's Back and Forward move the trail with them.
|
|
540
|
+
await page.goBack();
|
|
541
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
542
|
+
await page.goForward();
|
|
543
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
544
|
+
await pressShellBack(page);
|
|
545
|
+
await expect(page).toHaveURL(/\/home\/contacts$/u);
|
|
546
|
+
await expect(shellBackButton(page)).toHaveCount(0);
|
|
547
|
+
|
|
548
|
+
// The trail is a stack of visits: contact -> supplier -> the same contact -> Up = supplier.
|
|
549
|
+
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
550
|
+
await page.getByRole("link", { name: "Supplier", exact: true }).click();
|
|
551
|
+
await page.getByRole("link", { name: "Contact", exact: true }).click();
|
|
552
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
553
|
+
await pressShellBack(page);
|
|
554
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
555
|
+
|
|
556
|
+
// A main destination starts a fresh trail.
|
|
557
|
+
await openMainDestination(page, "Suppliers");
|
|
558
|
+
await expect(page).toHaveURL(/\/home\/suppliers$/u);
|
|
559
|
+
await page.getByRole("link", { name: "Acme Supplies", exact: true }).click();
|
|
560
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
561
|
+
await pressShellBack(page);
|
|
562
|
+
await expect(page).toHaveURL(/\/home\/suppliers$/u);
|
|
563
|
+
|
|
564
|
+
// Up to a page that is no longer available goes to the current page's parent instead.
|
|
565
|
+
await page.goto("/home/contacts/ada");
|
|
566
|
+
await page.getByRole("link", { name: "Supplier", exact: true }).click();
|
|
567
|
+
await page.evaluate(() => {
|
|
568
|
+
window.__fixtureBlockedRecords = ["ada"];
|
|
569
|
+
});
|
|
570
|
+
await pressShellBack(page);
|
|
571
|
+
await expect(page).toHaveURL(/\/home\/suppliers$/u);
|
|
572
|
+
await page.evaluate(() => {
|
|
573
|
+
window.__fixtureBlockedRecords = [];
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
// Up returns to the list where it was scrolled, with focus on the record it opened.
|
|
577
|
+
await page.goto("/home/contacts");
|
|
578
|
+
const deepLink = page.getByRole("link", { name: "Contact 35", exact: true });
|
|
579
|
+
await deepLink.scrollIntoViewIfNeeded();
|
|
580
|
+
const scrollBefore = await page.evaluate(() => window.scrollY);
|
|
581
|
+
assert.ok(scrollBefore > 200, `${at}: the contacts list did not scroll.`);
|
|
582
|
+
await deepLink.click();
|
|
583
|
+
await expect(page).toHaveURL(/\/home\/contacts\/contact-35$/u);
|
|
584
|
+
await pressShellBack(page);
|
|
585
|
+
await expect(page).toHaveURL(/\/home\/contacts$/u);
|
|
586
|
+
await expect.poll(() => page.evaluate(() => window.scrollY)).toBeGreaterThan(scrollBefore - 3);
|
|
587
|
+
assert.ok(Math.abs(await page.evaluate(() => window.scrollY) - scrollBefore) <= 2, `${at}: scroll was not restored.`);
|
|
588
|
+
await expect(page.getByRole("link", { name: "Contact 35", exact: true })).toBeFocused();
|
|
589
|
+
|
|
590
|
+
// A pasted supplier link goes Up to the Suppliers list.
|
|
591
|
+
const pasted = await context.newPage();
|
|
592
|
+
await pasted.goto("/home/suppliers/acme");
|
|
593
|
+
await pressShellBack(pasted);
|
|
594
|
+
await expect(pasted).toHaveURL(/\/home\/suppliers$/u);
|
|
595
|
+
await expect(shellPageTitle(pasted)).toHaveText("Suppliers");
|
|
596
|
+
await pasted.close();
|
|
597
|
+
|
|
598
|
+
// List-detail: beside the visible list, General has no arrow; alone, it has one back to the list.
|
|
599
|
+
await page.goto("/home/settings");
|
|
600
|
+
await page.getByRole("link", { name: "General", exact: true }).click();
|
|
601
|
+
await expect(page).toHaveURL(/\/home\/settings\/general$/u);
|
|
602
|
+
if (viewport.name === "expanded") {
|
|
603
|
+
await expect(shellBackButton(page)).toHaveCount(0);
|
|
604
|
+
await expect(page.getByRole("link", { name: "General", exact: true })).toBeVisible();
|
|
605
|
+
} else {
|
|
606
|
+
await pressShellBack(page);
|
|
607
|
+
await expect(page).toHaveURL(/\/home\/settings$/u);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// No page carries a worded back control.
|
|
611
|
+
await expect(page.getByText(/Back to /u)).toHaveCount(0);
|
|
612
|
+
await context.close();
|
|
613
|
+
}
|
|
614
|
+
} finally {
|
|
615
|
+
await browser?.close();
|
|
616
|
+
await stopProcess(vite);
|
|
617
|
+
}
|
|
618
|
+
});
|
|
@@ -104,7 +104,12 @@ async function startClient(t, { inputs = {}, providers = [], probe = { shell: "c
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
|
-
"client.router": {
|
|
107
|
+
"client.router": {
|
|
108
|
+
currentRoute: { value: { path: "/" } },
|
|
109
|
+
onError: () => () => {},
|
|
110
|
+
beforeEach: () => () => {},
|
|
111
|
+
afterEach: () => () => {}
|
|
112
|
+
},
|
|
108
113
|
"client.surface": createSurfaceRuntime({
|
|
109
114
|
allMode: "all",
|
|
110
115
|
surfaces: { app: { id: "app", pagesRoot: "app", enabled: true } },
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
test("wide closed navigation defaults to a visible Material navigation rail", () => {
|
|
10
10
|
assert.deepEqual(
|
|
11
|
-
resolveShellDrawerPresentation({
|
|
11
|
+
resolveShellDrawerPresentation({ modal: false, open: false }),
|
|
12
12
|
{
|
|
13
13
|
visible: true,
|
|
14
14
|
rail: true,
|
|
@@ -18,9 +18,9 @@ test("wide closed navigation defaults to a visible Material navigation rail", ()
|
|
|
18
18
|
);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
test("
|
|
21
|
+
test("closed modal navigation dismisses instead of retaining a rail", () => {
|
|
22
22
|
assert.deepEqual(
|
|
23
|
-
resolveShellDrawerPresentation({
|
|
23
|
+
resolveShellDrawerPresentation({ modal: true, open: false }),
|
|
24
24
|
{
|
|
25
25
|
visible: false,
|
|
26
26
|
rail: false,
|
|
@@ -34,7 +34,7 @@ test("desktopDrawerClosedMode hidden preserves an explicitly hidden wide drawer"
|
|
|
34
34
|
assert.equal(normalizeDesktopDrawerClosedMode("hidden"), "hidden");
|
|
35
35
|
assert.deepEqual(
|
|
36
36
|
resolveShellDrawerPresentation({
|
|
37
|
-
|
|
37
|
+
modal: false,
|
|
38
38
|
open: false,
|
|
39
39
|
desktopClosedMode: "hidden"
|
|
40
40
|
}),
|
|
@@ -49,7 +49,7 @@ test("desktopDrawerClosedMode hidden preserves an explicitly hidden wide drawer"
|
|
|
49
49
|
|
|
50
50
|
test("open navigation renders as a full drawer and labels its toggle responsively", () => {
|
|
51
51
|
assert.deepEqual(
|
|
52
|
-
resolveShellDrawerPresentation({
|
|
52
|
+
resolveShellDrawerPresentation({ modal: false, open: true }),
|
|
53
53
|
{
|
|
54
54
|
visible: true,
|
|
55
55
|
rail: false,
|
|
@@ -58,11 +58,11 @@ test("open navigation renders as a full drawer and labels its toggle responsivel
|
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
assert.equal(
|
|
61
|
-
resolveShellDrawerToggleLabel({
|
|
61
|
+
resolveShellDrawerToggleLabel({ modal: false, open: true }),
|
|
62
62
|
"Collapse navigation drawer"
|
|
63
63
|
);
|
|
64
64
|
assert.equal(
|
|
65
|
-
resolveShellDrawerToggleLabel({
|
|
65
|
+
resolveShellDrawerToggleLabel({ modal: true, open: false }),
|
|
66
66
|
"Open navigation menu"
|
|
67
67
|
);
|
|
68
68
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
|
-
import { mdiAlertOutline, mdiCheckCircleOutline, mdiInformationOutline } from "@mdi/js";
|
|
4
3
|
import {
|
|
5
4
|
actionsFor,
|
|
6
5
|
resolveBannerPlacement,
|
|
@@ -16,10 +15,10 @@ test("each severity has its color and icon, and anything else reads as an error"
|
|
|
16
15
|
assert.equal(resolveSeverityColor("critical"), "error");
|
|
17
16
|
assert.equal(resolveSeverityColor(""), "error");
|
|
18
17
|
|
|
19
|
-
assert.equal(resolveSeverityIcon("info"),
|
|
20
|
-
assert.equal(resolveSeverityIcon("success"),
|
|
21
|
-
assert.equal(resolveSeverityIcon("warning"),
|
|
22
|
-
assert.equal(resolveSeverityIcon("error"),
|
|
18
|
+
assert.equal(resolveSeverityIcon("info"), "$info");
|
|
19
|
+
assert.equal(resolveSeverityIcon("success"), "$success");
|
|
20
|
+
assert.equal(resolveSeverityIcon("warning"), "$warning");
|
|
21
|
+
assert.equal(resolveSeverityIcon("error"), "$warning");
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
test("a snackbar times out unless it persists or shows nothing", () => {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { chromium, expect } from "@playwright/test";
|
|
6
|
+
import {
|
|
7
|
+
createChromiumLaunchOptions,
|
|
8
|
+
startViteFixture,
|
|
9
|
+
stopProcess
|
|
10
|
+
} from "../../../tooling/testUtils/browserFixture.mjs";
|
|
11
|
+
import { expectMaterialBaseline } from "../../../tooling/testUtils/visualBaseline.mjs";
|
|
12
|
+
import { DEFAULT_VIEWPORTS } from "../src/test/adaptiveShellSmoke.js";
|
|
13
|
+
|
|
14
|
+
const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const FIXTURE_ROOT = path.resolve(TEST_DIRECTORY, "../fixtures/adaptive-shell");
|
|
16
|
+
// Kept in the repository, outside the published package.
|
|
17
|
+
const BASELINE_DIRECTORY = path.resolve(TEST_DIRECTORY, "../../../tooling/material-baselines/shell-web");
|
|
18
|
+
const RUN_BROWSER_TEST = process.env.JSKIT_MATERIAL_BASELINES === "1";
|
|
19
|
+
|
|
20
|
+
// What Material 3 fixes in the shell: the app bar and its page title and Up arrow, the navigation bar, rail and
|
|
21
|
+
// drawer with their active indicators, the page's margins and a list-detail page's panes.
|
|
22
|
+
const SHELL_PROBES = Object.freeze([
|
|
23
|
+
{ name: "application", selector: ".v-application" },
|
|
24
|
+
{ name: "appBar", selector: ".v-app-bar", width: true },
|
|
25
|
+
{ name: "pageTitle", selector: "[data-testid=jskit-shell-page-title]" },
|
|
26
|
+
{ name: "upButton", selector: "[data-testid=jskit-shell-back]", width: true },
|
|
27
|
+
{ name: "menuButton", selector: "[data-testid=jskit-shell-nav-toggle]", width: true },
|
|
28
|
+
{ name: "navigationBar", selector: "[data-testid=jskit-shell-bottom-nav]", width: true },
|
|
29
|
+
{ name: "navigationBarIndicator", selector: ".tab-link-item--active .tab-link-item__indicator", width: true },
|
|
30
|
+
{ name: "navigationBarLabel", selector: ".tab-link-item__label" },
|
|
31
|
+
{ name: "rail", selector: "[data-testid=jskit-shell-rail]", width: true },
|
|
32
|
+
{ name: "railIndicator", selector: "[data-testid=jskit-shell-rail] .v-list-item--active .shell-menu-link-item__indicator", width: true },
|
|
33
|
+
{ name: "railLabel", selector: "[data-testid=jskit-shell-rail] .shell-menu-link-item__rail-label" },
|
|
34
|
+
{ name: "drawer", selector: "[data-testid=jskit-shell-drawer].v-navigation-drawer--active", width: true },
|
|
35
|
+
{ name: "drawerActiveItem", selector: "[data-testid=jskit-shell-drawer] .shell-menu-link-item.v-list-item--active" },
|
|
36
|
+
{ name: "drawerItem", selector: "[data-testid=jskit-shell-drawer] .shell-menu-link-item:not(.v-list-item--active)" },
|
|
37
|
+
{ name: "scrim", selector: ".v-navigation-drawer__scrim" },
|
|
38
|
+
{ name: "content", selector: ".shell-layout__content" },
|
|
39
|
+
{ name: "listItem", selector: ".v-main .v-list-item" },
|
|
40
|
+
{ name: "listPane", selector: "[data-testid=jskit-shell-list-detail] .shell-list-detail__list", width: true }
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const SCREENS = Object.freeze([
|
|
44
|
+
{ name: "home", path: "/home" },
|
|
45
|
+
{ name: "list", path: "/home/contacts" },
|
|
46
|
+
{ name: "record", path: "/home/contacts/ada" },
|
|
47
|
+
{ name: "list-detail", path: "/home/settings/general" },
|
|
48
|
+
{ name: "drawer-open", path: "/home", openDrawer: true }
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
test("shell-web keeps its Material 3 baselines in light and dark at every window size", {
|
|
52
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_MATERIAL_BASELINES=1 to check the Material 3 baselines",
|
|
53
|
+
timeout: 300_000
|
|
54
|
+
}, async () => {
|
|
55
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
56
|
+
let browser = null;
|
|
57
|
+
try {
|
|
58
|
+
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
59
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
60
|
+
for (const theme of ["light", "dark"]) {
|
|
61
|
+
const context = await browser.newContext({
|
|
62
|
+
baseURL: vite.baseURL,
|
|
63
|
+
colorScheme: theme,
|
|
64
|
+
locale: "en-US",
|
|
65
|
+
reducedMotion: "reduce",
|
|
66
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
const page = await context.newPage();
|
|
70
|
+
for (const screen of SCREENS) {
|
|
71
|
+
// The expanded window already shows its drawer.
|
|
72
|
+
if (screen.openDrawer && viewport.name === "expanded") {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
await page.goto(`${screen.path}?theme=${theme}`);
|
|
76
|
+
await expect(page.getByTestId("jskit-shell-page-title")).toBeVisible();
|
|
77
|
+
if (screen.openDrawer) {
|
|
78
|
+
await page.getByTestId("jskit-shell-nav-toggle").click();
|
|
79
|
+
await expect(page.locator("[data-testid=jskit-shell-drawer].v-navigation-drawer--active")).toBeVisible();
|
|
80
|
+
}
|
|
81
|
+
await expectMaterialBaseline(page, {
|
|
82
|
+
directory: BASELINE_DIRECTORY,
|
|
83
|
+
name: `shell-${screen.name}-${viewport.width}-${theme}`,
|
|
84
|
+
probes: SHELL_PROBES
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
} finally {
|
|
88
|
+
await context.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} finally {
|
|
93
|
+
await browser?.close();
|
|
94
|
+
await stopProcess(vite);
|
|
95
|
+
}
|
|
96
|
+
});
|