@jskit-ai/shell-web 0.2.9 → 0.2.11
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 +9 -0
- package/fixtures/adaptive-shell/src/App.vue +2 -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/main.js +60 -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 +17 -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 +388 -186
- 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/ShellSurfaceAwareMenuLinkItem.vue +10 -24
- package/src/client/components/ShellTabLinkItem.vue +77 -3
- 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 +7 -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 +207 -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 +33 -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
|
@@ -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
|
+
});
|
package/test/menuIcons.test.js
CHANGED
|
@@ -3,12 +3,6 @@ import path from "node:path";
|
|
|
3
3
|
import test from "node:test";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import {
|
|
7
|
-
mdiAccountKeyOutline,
|
|
8
|
-
mdiCogOutline,
|
|
9
|
-
mdiConsoleNetworkOutline,
|
|
10
|
-
mdiViewListOutline
|
|
11
|
-
} from "@mdi/js";
|
|
12
6
|
import {
|
|
13
7
|
resolveMenuLinkIcon,
|
|
14
8
|
resolveSurfaceSwitchIcon
|
|
@@ -17,26 +11,24 @@ import {
|
|
|
17
11
|
const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
|
|
18
12
|
const PACKAGE_DIR = path.resolve(TEST_DIRECTORY, "..");
|
|
19
13
|
|
|
20
|
-
test("
|
|
21
|
-
assert.equal(resolveMenuLinkIcon({ icon: "
|
|
22
|
-
assert.equal(resolveMenuLinkIcon({ icon: "
|
|
23
|
-
assert.equal(
|
|
24
|
-
resolveSurfaceSwitchIcon("home", "mdi-console-network-outline"),
|
|
25
|
-
mdiConsoleNetworkOutline
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("shell-web leaves unknown explicit mdi metadata icons unchanged", () => {
|
|
30
|
-
assert.equal(resolveMenuLinkIcon({ icon: "mdi-not-a-real-supported-icon" }), "mdi-not-a-real-supported-icon");
|
|
14
|
+
test("an explicit menu icon is used as given, an app alias or path alike", () => {
|
|
15
|
+
assert.equal(resolveMenuLinkIcon({ icon: "$receiptLong" }), "$receiptLong");
|
|
16
|
+
assert.equal(resolveMenuLinkIcon({ icon: "svg:M1 1h22v22H1z" }), "svg:M1 1h22v22H1z");
|
|
17
|
+
assert.equal(resolveSurfaceSwitchIcon("home", "$terminal"), "$terminal");
|
|
31
18
|
});
|
|
32
19
|
|
|
33
|
-
test("
|
|
34
|
-
assert.equal(resolveMenuLinkIcon({
|
|
20
|
+
test("menu links without an icon get a Material Symbols alias from their label or target", () => {
|
|
21
|
+
assert.equal(resolveMenuLinkIcon({ label: "Home", to: "/home" }), "$home");
|
|
22
|
+
assert.equal(resolveMenuLinkIcon({ label: "Settings", to: "/home/settings" }), "$settings");
|
|
23
|
+
assert.equal(resolveMenuLinkIcon({ label: "Sign in", to: "/auth/login" }), "$login");
|
|
24
|
+
assert.equal(resolveMenuLinkIcon({ label: "Members", to: "/w/acme/members" }), "$group");
|
|
25
|
+
assert.equal(resolveMenuLinkIcon({ label: "Go to admin" }), "$adminPanelSettings");
|
|
26
|
+
assert.equal(resolveSurfaceSwitchIcon("console"), "$terminal");
|
|
27
|
+
assert.equal(resolveSurfaceSwitchIcon("reports"), "$arrowCircleRight");
|
|
35
28
|
});
|
|
36
29
|
|
|
37
|
-
test("shell-web menu
|
|
30
|
+
test("shell-web menu icons are aliases, not Material Design Icons", async () => {
|
|
38
31
|
const source = await readFile(path.join(PACKAGE_DIR, "src", "client", "lib", "menuIcons.js"), "utf8");
|
|
39
32
|
|
|
40
|
-
assert.doesNotMatch(source,
|
|
41
|
-
assert.doesNotMatch(source, /mdiIcons\[/);
|
|
33
|
+
assert.doesNotMatch(source, /@mdi\/js|mdi-/u);
|
|
42
34
|
});
|
|
@@ -13,12 +13,11 @@ test("shell-web outlet menu widget exposes a configurable nested outlet", async
|
|
|
13
13
|
"utf8"
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
-
assert.match(source, /import \{ mdiCogOutline \} from "@mdi\/js";/);
|
|
17
16
|
assert.match(source, /:target="props\.target"/);
|
|
18
17
|
assert.doesNotMatch(source, /defaultLinkComponentToken/);
|
|
19
18
|
assert.doesNotMatch(source, /default-link-component-token/);
|
|
20
|
-
assert.match(source, /default:
|
|
21
|
-
assert.doesNotMatch(source,
|
|
19
|
+
assert.match(source, /default: "\$settings"/u);
|
|
20
|
+
assert.doesNotMatch(source, /@mdi\/js|mdi-[a-z0-9-]+/u);
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
test("shell-web exports the outlet menu widget from both client index and package exports", async () => {
|
|
@@ -58,7 +58,9 @@ test("adaptive shell smoke follows rendered layout state and waits for drawer tr
|
|
|
58
58
|
assert.match(source, /data-rail-width/u);
|
|
59
59
|
assert.match(source, /expect\.poll/u);
|
|
60
60
|
assert.match(source, /toBeFocused/u);
|
|
61
|
-
|
|
61
|
+
// The modal drawer opens over the app bar; the smoke closes it from the scrim beside it and with Escape.
|
|
62
|
+
assert.match(source, /toHaveAttribute\("aria-label", "Close navigation menu"\)/u);
|
|
63
|
+
assert.match(source, /page\.mouse\.click\(viewport\.width - 8/u);
|
|
62
64
|
assert.doesNotMatch(source, /v-navigation-drawer__scrim/u);
|
|
63
65
|
assert.match(source, /page\.keyboard\.press\("Escape"\)[\s\S]*data-presentation", "drawer"/u);
|
|
64
66
|
assert.match(source, /centers\.push\(box\.x \+ box\.width \/ 2\)/u);
|
package/test/provider.test.js
CHANGED
|
@@ -57,6 +57,13 @@ function createRouter() {
|
|
|
57
57
|
onError(handler) {
|
|
58
58
|
errorHandlers.push(handler);
|
|
59
59
|
return () => {};
|
|
60
|
+
},
|
|
61
|
+
// The shell's navigation trail hooks every navigation.
|
|
62
|
+
beforeEach() {
|
|
63
|
+
return () => {};
|
|
64
|
+
},
|
|
65
|
+
afterEach() {
|
|
66
|
+
return () => {};
|
|
60
67
|
}
|
|
61
68
|
};
|
|
62
69
|
}
|
|
@@ -129,7 +136,7 @@ async function startShell({
|
|
|
129
136
|
);
|
|
130
137
|
}
|
|
131
138
|
|
|
132
|
-
test("shell capability owns placement, bootstrap, refresh, errors, and recovery without a container", async () => {
|
|
139
|
+
test("shell capability owns placement, navigation, bootstrap, refresh, errors, and recovery without a container", async () => {
|
|
133
140
|
const fixture = await startShell({
|
|
134
141
|
bootstrapPayload: {
|
|
135
142
|
surfaceAccess: {
|
|
@@ -146,6 +153,7 @@ test("shell capability owns placement, bootstrap, refresh, errors, and recovery
|
|
|
146
153
|
"clientUpdate",
|
|
147
154
|
"error",
|
|
148
155
|
"errorPresentationStore",
|
|
156
|
+
"navigation",
|
|
149
157
|
"placement",
|
|
150
158
|
"refresh",
|
|
151
159
|
"requestRecovery"
|
|
@@ -62,8 +62,8 @@ test("shell-web application pattern exposes surface-derived settings outlets", a
|
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
assert.match(source, /target="home-settings:primary-menu"/);
|
|
65
|
-
assert.match(source,
|
|
66
|
-
assert.
|
|
65
|
+
assert.match(source, /<ShellListDetail :detail-open="detailOpen">/u);
|
|
66
|
+
assert.doesNotMatch(source, /<style|border|v-sheet/u);
|
|
67
67
|
assert.doesNotMatch(source, /generated-ui/u);
|
|
68
68
|
assert.doesNotMatch(source, /default-link-component-token/);
|
|
69
69
|
assert.match(source, /<RouterView \/>/);
|
|
@@ -78,14 +78,17 @@ test("shell-web shell layout registers navigation at the app layout level", asyn
|
|
|
78
78
|
assert.match(source, /ShellRouteTransition/);
|
|
79
79
|
assert.match(source, /<ShellRouteTransition>[\s\S]*<slot \/>[\s\S]*<\/ShellRouteTransition>/);
|
|
80
80
|
assert.match(source, /data-testid="jskit-shell-app-bar"/);
|
|
81
|
-
assert.match(source, /:
|
|
82
|
-
assert.match(source,
|
|
81
|
+
assert.match(source, /:height="64"/u);
|
|
82
|
+
assert.match(source, /:color="scrolled \? 'surface-container' : 'surface'"/u);
|
|
83
|
+
assert.match(source, /data-testid="jskit-shell-back"[\s\S]*:aria-label="t\('jskit\.shell\.actions\.back'\)"/u);
|
|
84
|
+
assert.match(source, /:id="PAGE_TITLE_ID"/u);
|
|
85
|
+
assert.match(source, /:id="SHELL_PAGE_ACTIONS_ID"/u);
|
|
83
86
|
assert.match(source, /shell-layout__surface-label/);
|
|
84
87
|
assert.doesNotMatch(source, /shell-layout__surface-chip/);
|
|
85
88
|
assert.doesNotMatch(source, /<v-chip[^>]*resolvedSurfaceLabel/);
|
|
86
|
-
assert.match(source, /shell-layout__top-right[\s\S]*max-width:\s*min\(45vw, 18rem\)/);
|
|
87
89
|
assert.match(source, /<v-bottom-navigation[\s\S]*target="shell-layout:primary-bottom-nav"/);
|
|
88
|
-
assert.match(source,
|
|
90
|
+
assert.match(source, /bg-color="surface-container"[\s\S]*:height="80"/u);
|
|
91
|
+
assert.doesNotMatch(source, /!important|border-(?:top|bottom|right|left)?-?width:\s*thin/u);
|
|
89
92
|
assert.match(source, /<v-bottom-sheet[\s\S]*target="shell-layout:supporting-bottom-sheet"/);
|
|
90
93
|
assert.match(source, /target="shell-layout:supporting-side-panel"/);
|
|
91
94
|
assert.match(source, /data-testid="jskit-shell-supporting-bottom-sheet"/);
|
|
@@ -129,7 +132,8 @@ test("shell-web shell layout registers navigation at the app layout level", asyn
|
|
|
129
132
|
assert.match(source, /:model-value="drawerPresentation\.visible"/);
|
|
130
133
|
assert.match(source, /data-testid="jskit-shell-nav-toggle"/);
|
|
131
134
|
assert.match(source, /data-testid="jskit-shell-bottom-nav"/);
|
|
132
|
-
assert.match(source, /padding:\s*
|
|
135
|
+
assert.match(source, /padding:\s*8px 24px calc\(24px \+ env\(safe-area-inset-bottom, 0px\)\)/u);
|
|
136
|
+
assert.match(source, /\.shell-layout__content--compact\s*\{\s*padding-inline:\s*16px;/u);
|
|
133
137
|
|
|
134
138
|
const template = await readFile(
|
|
135
139
|
path.join(PACKAGE_DIR, "patterns", "application-shell", "example", "src", "components", "ShellLayout.vue"),
|
|
@@ -142,21 +146,21 @@ test("shell-web shell layout registers navigation at the app layout level", asyn
|
|
|
142
146
|
assert.doesNotMatch(template, /ShellOutlet|ShellRouteTransition|useShellLayoutState|pointerdown|v-navigation-drawer|v-bottom-navigation/);
|
|
143
147
|
});
|
|
144
148
|
|
|
145
|
-
test("shell
|
|
149
|
+
test("shell-web application pattern renders its not-found view in the shell, whose app bar carries the title", async () => {
|
|
146
150
|
const source = await readFile(
|
|
147
|
-
path.join(PACKAGE_DIR, "
|
|
151
|
+
path.join(PACKAGE_DIR, "patterns", "application-shell", "example", "src", "views", "NotFound.vue"),
|
|
148
152
|
"utf8"
|
|
149
153
|
);
|
|
150
154
|
|
|
151
|
-
assert.match(source,
|
|
152
|
-
assert.doesNotMatch(source, /
|
|
155
|
+
assert.match(source, /<ShellLayout title="Not Found"/u);
|
|
156
|
+
assert.doesNotMatch(source, /<h1/u);
|
|
153
157
|
});
|
|
154
158
|
|
|
155
159
|
test("shell-web error host uses one explicit close affordance for banner errors", async () => {
|
|
156
160
|
const source = await readClientSources("components/ShellErrorHost.vue", "error/presentation.js");
|
|
157
161
|
|
|
158
162
|
assert.match(source, /function resolveSeverityIcon/);
|
|
159
|
-
assert.match(source, /
|
|
163
|
+
assert.match(source, /"\$warning"/u);
|
|
160
164
|
assert.match(source, /:icon="resolveSeverityIcon\(entry\.severity\)"/);
|
|
161
165
|
assert.match(source, /closable[\s\S]*@click:close="dismiss\(entry\)"/);
|
|
162
166
|
assert.doesNotMatch(source, /mdi-close/);
|
|
@@ -167,8 +171,9 @@ test("shell-web error host keeps snackbar color stable while closing", async ()
|
|
|
167
171
|
|
|
168
172
|
assert.match(source, /displayedSnackbarEntry/);
|
|
169
173
|
assert.match(source, /@after-leave="onSnackbarAfterLeave"/);
|
|
170
|
-
|
|
171
|
-
assert.doesNotMatch(source,
|
|
174
|
+
// Material 3 snackbars are always inverse-surface, whatever the message's severity.
|
|
175
|
+
assert.doesNotMatch(source, /<v-snackbar[^>]*:color=/u);
|
|
176
|
+
assert.doesNotMatch(source, /!important/u);
|
|
172
177
|
});
|
|
173
178
|
|
|
174
179
|
test("shell-web application pattern uses intent-driven default error presentation", async () => {
|
|
@@ -203,7 +208,9 @@ test("shell-web application pattern includes adaptive shell Playwright coverage"
|
|
|
203
208
|
assert.match(helperSource, /jskit-shell-drawer/);
|
|
204
209
|
assert.match(helperSource, /scrollWidth/);
|
|
205
210
|
assert.match(helperSource, /toBeGreaterThanOrEqual\(48\)/);
|
|
206
|
-
|
|
211
|
+
// The modal drawer opens over the app bar; the smoke closes it from the scrim beside it and with Escape.
|
|
212
|
+
assert.match(helperSource, /toHaveAttribute\("aria-label", "Close navigation menu"\)/);
|
|
213
|
+
assert.match(helperSource, /page\.mouse\.click\(viewport\.width - 8/);
|
|
207
214
|
assert.doesNotMatch(helperSource, /\.v-navigation-drawer__scrim|generated-ui-screen/u);
|
|
208
215
|
|
|
209
216
|
const packageJson = JSON.parse(await readFile(path.join(PACKAGE_DIR, "package.json"), "utf8"));
|
|
@@ -318,15 +325,13 @@ test("shell-web route transition key preserves no-motion surfaces and animated p
|
|
|
318
325
|
);
|
|
319
326
|
});
|
|
320
327
|
|
|
321
|
-
test("shell-web pattern settings
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
"utf8"
|
|
325
|
-
);
|
|
328
|
+
test("shell-web pattern settings page is a list-detail page whose landing shows the list, not a redirect", async () => {
|
|
329
|
+
const settingsRoot = path.join(PACKAGE_DIR, "patterns", "application-shell", "example", "src", "pages", "home");
|
|
330
|
+
const source = await readFile(path.join(settingsRoot, "settings.vue"), "utf8");
|
|
326
331
|
|
|
327
|
-
assert.match(source,
|
|
328
|
-
assert.match(source, /
|
|
329
|
-
assert.
|
|
332
|
+
assert.match(source, /<ShellListDetail :detail-open="detailOpen">/);
|
|
333
|
+
assert.match(source, /title: "Settings"/);
|
|
334
|
+
await assert.rejects(readFile(path.join(settingsRoot, "settings", "index.vue"), "utf8"), { code: "ENOENT" });
|
|
330
335
|
});
|
|
331
336
|
|
|
332
337
|
test("shell-web pattern settings page exposes an adaptive drawer preference", async () => {
|
|
@@ -347,14 +352,15 @@ test("shell-web pattern settings page exposes an adaptive drawer preference", as
|
|
|
347
352
|
);
|
|
348
353
|
|
|
349
354
|
assert.match(source, /useShellLayoutState/);
|
|
350
|
-
assert.match(source, /
|
|
355
|
+
assert.match(source, /parent: "\/settings"/);
|
|
356
|
+
assert.match(source, /<v-card>\s*<v-list lines="three">/);
|
|
351
357
|
assert.doesNotMatch(source, /generated-ui/u);
|
|
352
358
|
assert.match(source, /drawerDefaultOpen/);
|
|
353
359
|
assert.match(source, /setDrawerDefaultOpen/);
|
|
354
360
|
assert.match(source, /collapsed navigation remains available as a rail/);
|
|
355
361
|
assert.match(source, /Phone layouts close the drawer/);
|
|
356
362
|
assert.match(source, /Start with expanded navigation on wider screens/);
|
|
357
|
-
assert.
|
|
363
|
+
assert.doesNotMatch(source, /<style|min-height/u);
|
|
358
364
|
assert.doesNotMatch(source, /live in this browser only|tiny example|starter settings/);
|
|
359
365
|
});
|
|
360
366
|
|
|
@@ -579,13 +585,12 @@ test("shell-web pattern home page relies on adaptive navigation instead of dead
|
|
|
579
585
|
"utf8"
|
|
580
586
|
);
|
|
581
587
|
|
|
582
|
-
assert.
|
|
583
|
-
assert.match(source, /--home-surface-panel-padding/);
|
|
588
|
+
assert.doesNotMatch(source, /<style|--home-surface/u);
|
|
584
589
|
assert.doesNotMatch(source, /generated-ui/u);
|
|
585
590
|
assert.match(source, /Service health/);
|
|
586
591
|
assert.match(source, /<v-skeleton-loader/u);
|
|
587
592
|
assert.doesNotMatch(source, /loading\.\.\.|v-progress-circular/u);
|
|
588
|
-
assert.match(source,
|
|
593
|
+
assert.match(source, /:to="paths\.page\('\/settings'\)"/);
|
|
589
594
|
assert.doesNotMatch(source, /Use bottom navigation|Replace this content|Main public surface/);
|
|
590
595
|
assert.doesNotMatch(source, /\/console/);
|
|
591
596
|
assert.doesNotMatch(source, /\/auth\/signout/);
|
|
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { isPrimaryTouchPointer, isShellGestureIgnoredTarget } from "../src/client/support/gestureTargets.js";
|
|
4
4
|
import { resolveShellLayoutClass } from "../src/client/support/shellLayoutClass.js";
|
|
5
|
+
import { resolveWindowSizeClass } from "../src/client/support/windowSizeClass.js";
|
|
5
6
|
|
|
6
7
|
function createTarget(matchingSelectors = []) {
|
|
7
8
|
return {
|
|
@@ -12,15 +13,26 @@ function createTarget(matchingSelectors = []) {
|
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
test("shell layout class
|
|
16
|
-
assert.equal(resolveShellLayoutClass(
|
|
17
|
-
assert.equal(resolveShellLayoutClass(
|
|
18
|
-
assert.equal(resolveShellLayoutClass(
|
|
19
|
-
assert.equal(resolveShellLayoutClass(
|
|
20
|
-
assert.equal(resolveShellLayoutClass(
|
|
21
|
-
assert.equal(resolveShellLayoutClass(
|
|
22
|
-
assert.equal(resolveShellLayoutClass(
|
|
23
|
-
assert.equal(resolveShellLayoutClass(
|
|
16
|
+
test("shell layout class is the Material 3 window size class, with large placed like expanded", () => {
|
|
17
|
+
assert.equal(resolveShellLayoutClass(390), "compact");
|
|
18
|
+
assert.equal(resolveShellLayoutClass(599), "compact");
|
|
19
|
+
assert.equal(resolveShellLayoutClass(600), "medium");
|
|
20
|
+
assert.equal(resolveShellLayoutClass(768), "medium");
|
|
21
|
+
assert.equal(resolveShellLayoutClass(839), "medium");
|
|
22
|
+
assert.equal(resolveShellLayoutClass(840), "expanded");
|
|
23
|
+
assert.equal(resolveShellLayoutClass(1199), "expanded");
|
|
24
|
+
assert.equal(resolveShellLayoutClass(1280), "expanded");
|
|
25
|
+
assert.equal(resolveShellLayoutClass(1920), "expanded");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("window size classes follow the Material 3 breakpoints", () => {
|
|
29
|
+
assert.equal(resolveWindowSizeClass(0), "compact");
|
|
30
|
+
assert.equal(resolveWindowSizeClass(599), "compact");
|
|
31
|
+
assert.equal(resolveWindowSizeClass(600), "medium");
|
|
32
|
+
assert.equal(resolveWindowSizeClass(840), "expanded");
|
|
33
|
+
assert.equal(resolveWindowSizeClass(1199), "expanded");
|
|
34
|
+
assert.equal(resolveWindowSizeClass(1200), "large");
|
|
35
|
+
assert.equal(resolveWindowSizeClass(2400), "large");
|
|
24
36
|
});
|
|
25
37
|
|
|
26
38
|
test("shell gestures follow primary touch and pen pointers only", () => {
|
package/test/translation.test.js
CHANGED
|
@@ -52,7 +52,7 @@ test("shell texts stay English without an app vue-i18n instance", () => {
|
|
|
52
52
|
requestRecoveryMessage(null),
|
|
53
53
|
"The app could not reach the server or network. Check the connection and try again."
|
|
54
54
|
);
|
|
55
|
-
assert.equal(resolveShellDrawerToggleLabel({
|
|
55
|
+
assert.equal(resolveShellDrawerToggleLabel({ modal: true, open: false }), "Open navigation menu");
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
test("shell texts follow the app's active language", () => {
|
|
@@ -65,7 +65,7 @@ test("shell texts follow the app's active language", () => {
|
|
|
65
65
|
requestRecoveryMessage(null, { label: "jskit.shell.recovery.appDataLabel" }),
|
|
66
66
|
"[xx] [xx] App data could not reach the server or network. Check the connection and try again."
|
|
67
67
|
);
|
|
68
|
-
assert.equal(resolveShellDrawerToggleLabel({
|
|
68
|
+
assert.equal(resolveShellDrawerToggleLabel({ modal: false, open: true }), "[xx] Collapse navigation drawer");
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
|
|
@@ -65,6 +65,7 @@ function mountDrawer(t, { compact = false, props = {} } = {}) {
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
const isCompactLayout = ref(compact);
|
|
68
|
+
const viewportWidth = ref(compact ? 390 : 1280);
|
|
68
69
|
const drawerOpen = ref(true);
|
|
69
70
|
const focused = [];
|
|
70
71
|
const navigationToggle = ref({ $el: { focus: (options) => focused.push(options) } });
|
|
@@ -76,7 +77,8 @@ function mountDrawer(t, { compact = false, props = {} } = {}) {
|
|
|
76
77
|
navigationItemSpacing: 12,
|
|
77
78
|
...props
|
|
78
79
|
},
|
|
79
|
-
isCompactLayout,
|
|
80
|
+
modalLayout: isCompactLayout,
|
|
81
|
+
viewportWidth,
|
|
80
82
|
navigationToggle,
|
|
81
83
|
layoutState: {
|
|
82
84
|
drawerDefaultOpen: ref(true),
|
|
@@ -87,7 +89,7 @@ function mountDrawer(t, { compact = false, props = {} } = {}) {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}));
|
|
90
|
-
return { app, drawerOpen, focused, fontListeners, frames, isCompactLayout, observers, page, result };
|
|
92
|
+
return { app, drawerOpen, focused, fontListeners, frames, isCompactLayout, observers, page, result, viewportWidth };
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
async function runFrames(frames) {
|
|
@@ -161,8 +163,21 @@ test("Escape closes the compact drawer and returns focus to its toggle", async (
|
|
|
161
163
|
app.unmount();
|
|
162
164
|
});
|
|
163
165
|
|
|
164
|
-
test("the drawer's
|
|
165
|
-
const { app, frames,
|
|
166
|
+
test("the drawer is Material 3's 360dp wide and a modal one leaves 56dp of the page", async (t) => {
|
|
167
|
+
const { app, frames, isCompactLayout, result, viewportWidth } = mountDrawer(t);
|
|
168
|
+
assert.equal(result.fixedDrawerWidth.value, true);
|
|
169
|
+
assert.equal(result.resolvedDrawerWidth.value, 360);
|
|
170
|
+
await runFrames(frames);
|
|
171
|
+
assert.equal(result.resolvedDrawerWidth.value, 360);
|
|
172
|
+
|
|
173
|
+
isCompactLayout.value = true;
|
|
174
|
+
viewportWidth.value = 390;
|
|
175
|
+
assert.equal(result.resolvedDrawerWidth.value, 390 - 56);
|
|
176
|
+
app.unmount();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("a content drawer's width follows its measured labels", async (t) => {
|
|
180
|
+
const { app, frames, observers, result } = mountDrawer(t, { props: { drawerWidth: "content" } });
|
|
166
181
|
assert.equal(result.resolvedDrawerWidth.value, 248);
|
|
167
182
|
|
|
168
183
|
await runFrames(frames);
|
|
@@ -198,7 +213,7 @@ test("a closed wide drawer only ignores a request to open it", (t) => {
|
|
|
198
213
|
});
|
|
199
214
|
|
|
200
215
|
test("unmounting detaches every listener and pending measurement", async (t) => {
|
|
201
|
-
const { app, fontListeners, frames, observers, page } = mountDrawer(t);
|
|
216
|
+
const { app, fontListeners, frames, observers, page } = mountDrawer(t, { props: { drawerWidth: "content" } });
|
|
202
217
|
await nextTick();
|
|
203
218
|
await nextTick();
|
|
204
219
|
assert.equal(page.listeners.size, 2);
|
|
@@ -28,7 +28,7 @@ function createPlacementRuntime() {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function mountTransition(t, { path = "/home/contacts",
|
|
31
|
+
function mountTransition(t, { path = "/home/contacts", width = 390, props = {} } = {}) {
|
|
32
32
|
const page = installPage(t);
|
|
33
33
|
const route = reactive({ path, params: {} });
|
|
34
34
|
const pushes = [];
|
|
@@ -50,7 +50,7 @@ function mountTransition(t, { path = "/home/contacts", displayName = "xs", props
|
|
|
50
50
|
provide: [
|
|
51
51
|
[routerKey, router],
|
|
52
52
|
[routeLocationKey, route],
|
|
53
|
-
[Symbol.for("vuetify:display"), {
|
|
53
|
+
[Symbol.for("vuetify:display"), { width: ref(width), mobile: ref(false) }],
|
|
54
54
|
[SHELL_WEB_PLACEMENT_RUNTIME_KEY, createPlacementRuntime()]
|
|
55
55
|
]
|
|
56
56
|
}
|
|
@@ -93,7 +93,7 @@ test("a route change away from every destination has no motion", (t) => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
test("wide layouts keep the pane still and never start a swipe", (t) => {
|
|
96
|
-
const { app, page, pushes, result, route } = mountTransition(t, {
|
|
96
|
+
const { app, page, pushes, result, route } = mountTransition(t, { width: 1280 });
|
|
97
97
|
assert.equal(page.classes.has("shell-route-swipe-enabled"), false);
|
|
98
98
|
|
|
99
99
|
page.dispatch("pointerdown", { ...touch, clientX: 300, clientY: 100 });
|