@jskit-ai/shell-web 0.2.11 → 0.2.13

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,9 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
- import { createApp } from "vue";
3
+ import { createApp, ref } from "vue";
4
4
  import { resolveShellLinkPath, useShellLinkResolver } from "../src/client/navigation/linkResolver.js";
5
+ import { usePaths } from "../src/client/navigation/usePaths.js";
6
+ import { SHELL_WEB_PLACEMENT_RUNTIME_KEY } from "../src/client/placement/inject.js";
5
7
 
6
8
  function createPlacementContext() {
7
9
  return {
@@ -132,3 +134,50 @@ test("useShellLinkResolver exposes only surface-relative resolve", () => {
132
134
  assert.deepEqual(Object.keys(resolver), ["resolve"]);
133
135
  assert.equal(resolver.resolve("/reports"), "/console/reports");
134
136
  });
137
+
138
+ test("resolveShellLinkPath fills the relative path's :name segments from params", () => {
139
+ const to = resolveShellLinkPath({
140
+ context: createPlacementContext(),
141
+ surface: "app",
142
+ params: { workspaceSlug: "acme", proposalId: "7 b" },
143
+ relativePath: "/program/proposal/:proposalId/edit"
144
+ });
145
+
146
+ assert.equal(to, "/w/acme/program/proposal/7%20b/edit");
147
+ });
148
+
149
+ test("resolveShellLinkPath throws for a relative path's missing param unless params are not strict", () => {
150
+ const link = { context: createPlacementContext(), surface: "console", relativePath: "/books/:bookId" };
151
+ assert.throws(() => resolveShellLinkPath(link), /Missing required route params for "\/books\/:bookId": bookId\./u);
152
+ assert.equal(resolveShellLinkPath({ ...link, strictParams: false }), "/console/books/:bookId");
153
+ });
154
+
155
+ test("resolveShellLinkPath leaves an external URL, a query and a hash alone", () => {
156
+ const context = createPlacementContext();
157
+ assert.equal(
158
+ resolveShellLinkPath({ context, surface: "console", relativePath: "https://example.com:8080/:x" }),
159
+ "https://example.com:8080/:x"
160
+ );
161
+ assert.equal(
162
+ resolveShellLinkPath({ context, surface: "console", relativePath: "/search?at=:time#:part", params: { time: "now" } }),
163
+ "/console/search?at=:time#:part"
164
+ );
165
+ });
166
+
167
+ test("usePaths().page() fills a declared parent's params from the current route", () => {
168
+ const context = createPlacementContext();
169
+ const app = createApp({ render: () => null });
170
+ app.provide(SHELL_WEB_PLACEMENT_RUNTIME_KEY, { getContext: () => context, subscribe: () => () => {} });
171
+ const paths = app.runWithContext(() => usePaths({
172
+ routeContext: {
173
+ route: { params: { bookId: "7" } },
174
+ placementContext: ref(context),
175
+ currentSurfaceId: ref("console")
176
+ }
177
+ }));
178
+
179
+ // What the Up arrow of a direct visit to /console/books/7/edit resolves its parent "/books/:bookId" to.
180
+ assert.equal(paths.page("/books/:bookId"), "/console/books/7");
181
+ assert.equal(paths.page("/books/:bookId", { params: { bookId: "8" } }), "/console/books/8");
182
+ assert.throws(() => paths.page("/authors/:authorId"), /Missing required route params/u);
183
+ });
@@ -70,7 +70,21 @@ test("shell-web application pattern exposes surface-derived settings outlets", a
70
70
  });
71
71
 
72
72
  test("shell-web shell layout registers navigation at the app layout level", async () => {
73
+ const layoutSource = await readClientSources("components/ShellLayout.vue");
73
74
  const source = await readClientSources("composables/useShellDrawer.js", "components/ShellLayout.vue");
75
+ const barPieces = await readClientSources(
76
+ "components/ShellUpButton.vue",
77
+ "components/ShellPageTitle.vue",
78
+ "components/ShellPageActionsTarget.vue",
79
+ "composables/useShellAppBar.js"
80
+ );
81
+
82
+ // ShellLayout's bar is made of the pieces a layout with its own top app bar uses: one owner, no copy.
83
+ assert.match(layoutSource, /useShellAppBar\(\);/u);
84
+ assert.match(layoutSource, /<ShellUpButton v-if="canGoUp" class="shell-layout__leading" \/>/u);
85
+ assert.match(layoutSource, /<ShellPageTitle :title="fallbackTitle" \/>/u);
86
+ assert.match(layoutSource, /<ShellPageActionsTarget \/>/u);
87
+ assert.doesNotMatch(layoutSource, /\$arrowBack|PAGE_TITLE_ID|SHELL_PAGE_ACTIONS_ID|attachShell/u);
74
88
 
75
89
  assert.doesNotMatch(source, /<v-layout\b/);
76
90
  assert.doesNotMatch(source, /overflow-hidden/);
@@ -80,9 +94,11 @@ test("shell-web shell layout registers navigation at the app layout level", asyn
80
94
  assert.match(source, /data-testid="jskit-shell-app-bar"/);
81
95
  assert.match(source, /:height="64"/u);
82
96
  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);
97
+ assert.match(barPieces, /data-testid="jskit-shell-back"[\s\S]*:aria-label="t\('jskit\.shell\.actions\.back'\)"/u);
98
+ assert.match(barPieces, /:id="PAGE_TITLE_ID"/u);
99
+ assert.match(barPieces, /:id="SHELL_PAGE_ACTIONS_ID"/u);
100
+ assert.match(barPieces, /provide\(SHELL_PAGE_ACTIONS_TARGET_KEY, `#\$\{SHELL_PAGE_ACTIONS_ID\}`\)/u);
101
+ assert.match(barPieces, /release = navigationRuntime\.attachShell\(\);/u);
86
102
  assert.match(source, /shell-layout__surface-label/);
87
103
  assert.doesNotMatch(source, /shell-layout__surface-chip/);
88
104
  assert.doesNotMatch(source, /<v-chip[^>]*resolvedSurfaceLabel/);