@jskit-ai/shell-web 0.2.13 → 0.2.15
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 +18 -0
- package/fixtures/adaptive-shell/src/ActionsFormPage.vue +22 -0
- package/fixtures/adaptive-shell/src/ActionsPage.vue +74 -0
- package/fixtures/adaptive-shell/src/App.vue +1 -0
- package/fixtures/adaptive-shell/src/ButtonStatesPage.vue +63 -0
- package/fixtures/adaptive-shell/src/ButtonsPage.vue +33 -3
- package/fixtures/adaptive-shell/src/ComponentsPage.vue +178 -0
- package/fixtures/adaptive-shell/src/FeedbackPage.vue +59 -0
- package/fixtures/adaptive-shell/src/ReportsPage.vue +29 -0
- package/fixtures/adaptive-shell/src/StatusButton.vue +17 -0
- package/fixtures/adaptive-shell/src/TitleClaim.vue +17 -0
- package/fixtures/adaptive-shell/src/main.js +131 -5
- package/fixtures/production-build/index.html +15 -0
- package/fixtures/production-build/package.json +5 -0
- package/fixtures/production-build/src/App.vue +27 -0
- package/fixtures/production-build/src/componentChunk.css +5 -0
- package/fixtures/production-build/src/main.js +10 -0
- package/fixtures/production-build/vite.config.mjs +12 -0
- package/locales/en.json +1 -0
- package/package.json +9 -5
- package/patterns/application-shell/PATTERN.md +11 -6
- package/patterns/application-shell/example/src/components/menus/SectionTabLinkItem.vue +42 -0
- package/patterns/application-shell/example/src/pages/home.vue +1 -1
- package/patterns/application-shell/example/src/views/NotFound.vue +1 -1
- package/patterns/page-and-placement/PATTERN.md +6 -0
- package/patterns/page-and-placement/example/src/pages/home/reports.vue +9 -4
- package/patterns/page-and-placement/example/src/placementTopology.js +5 -3
- package/src/client/components/ShellErrorHost.vue +20 -1
- package/src/client/components/ShellLayout.vue +42 -27
- package/src/client/components/ShellNavigationItem.vue +8 -3
- package/src/client/components/ShellNavigationScope.vue +1 -1
- package/src/client/components/ShellOutlet.vue +12 -1
- package/src/client/components/ShellPageAction.vue +107 -28
- package/src/client/components/ShellPageActionsTarget.vue +81 -2
- package/src/client/components/ShellPrimaryAction.vue +69 -0
- package/src/client/components/ShellSectionTabLinkItem.vue +104 -0
- package/src/client/components/ShellTabLinkItem.vue +18 -3
- package/src/client/components/ShellUpButton.vue +13 -8
- package/src/client/composables/useShellAppBar.js +10 -1
- package/src/client/composables/useShellPageClose.js +18 -0
- package/src/client/index.js +3 -0
- package/src/client/navigation/shellNavigationRuntime.js +59 -12
- package/src/client/navigation/usePaths.js +13 -0
- package/src/client/navigation/useShellNavigation.js +2 -0
- package/src/client/providers/ShellWebClientProvider.js +25 -9
- package/src/client/support/drawerPresentation.js +23 -6
- package/src/client/support/navigationPresentation.js +1 -1
- package/src/client/support/pageActions.js +126 -0
- package/src/test/adaptiveShellSmoke.js +31 -16
- package/test/adaptiveShell.browser.test.js +1019 -334
- package/test/drawerPresentation.test.js +20 -2
- package/test/linkResolver.test.js +4 -0
- package/test/materialBaselines.browser.test.js +142 -27
- package/test/packageRouteParent.test.js +41 -0
- package/test/pageActions.test.js +84 -0
- package/test/productionBuild.browser.test.js +98 -0
- package/test/settingsPlacementContract.test.js +11 -4
- package/test/shellNavigationRuntime.test.js +272 -0
|
@@ -20,6 +20,17 @@ const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
|
|
|
20
20
|
const FIXTURE_ROOT = path.resolve(TEST_DIRECTORY, "../fixtures/adaptive-shell");
|
|
21
21
|
const RUN_BROWSER_TEST = process.env.JSKIT_SHELL_WEB_BROWSER_INTEGRATION === "1";
|
|
22
22
|
|
|
23
|
+
// Starts the fixture's Vite server and a browser for one test and stops them in its after hooks, which run when the
|
|
24
|
+
// test fails or times out too: a `finally` in the test body never runs after a timeout, so the server and browser
|
|
25
|
+
// would keep the test file's process alive.
|
|
26
|
+
async function startFixture(t) {
|
|
27
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
28
|
+
t.after(() => stopProcess(vite));
|
|
29
|
+
const browser = await chromium.launch(createChromiumLaunchOptions());
|
|
30
|
+
t.after(() => browser.close());
|
|
31
|
+
return { vite, browser };
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
function parseRgb(color) {
|
|
24
35
|
const channels = String(color || "").match(/[\d.]+/gu)?.map(Number) || [];
|
|
25
36
|
return {
|
|
@@ -204,12 +215,9 @@ test("shell-web adaptive navigation passes package-owned browser contracts", {
|
|
|
204
215
|
? false
|
|
205
216
|
: "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1 to run shell-web browser integration",
|
|
206
217
|
timeout: 180_000
|
|
207
|
-
}, async () => {
|
|
208
|
-
const vite = await
|
|
209
|
-
let browser = null;
|
|
210
|
-
|
|
218
|
+
}, async (t) => {
|
|
219
|
+
const { vite, browser } = await startFixture(t);
|
|
211
220
|
try {
|
|
212
|
-
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
213
221
|
const context = await browser.newContext({
|
|
214
222
|
baseURL: vite.baseURL,
|
|
215
223
|
locale: "en-US"
|
|
@@ -245,6 +253,18 @@ test("shell-web adaptive navigation passes package-owned browser contracts", {
|
|
|
245
253
|
const railLabels = mediumPage.getByTestId("jskit-shell-rail").locator(".shell-menu-link-item__rail-label");
|
|
246
254
|
await expect(railLabels.first()).toBeVisible();
|
|
247
255
|
assert.ok(await railLabels.count() >= 5, "The navigation rail labels each destination.");
|
|
256
|
+
// A label wider than the rail wraps to a second line instead of ending in an ellipsis.
|
|
257
|
+
const wrapped = await railLabels.nth(1).evaluate((element) => {
|
|
258
|
+
element.textContent = "Race Engineer";
|
|
259
|
+
const box = element.getBoundingClientRect();
|
|
260
|
+
const rail = element.closest("[data-testid=jskit-shell-rail]").getBoundingClientRect();
|
|
261
|
+
return {
|
|
262
|
+
lines: Math.round(box.height / Number.parseFloat(window.getComputedStyle(element).lineHeight)),
|
|
263
|
+
clipped: element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight,
|
|
264
|
+
inside: box.left >= rail.left && box.right <= rail.right
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
assert.deepEqual(wrapped, { lines: 2, clipped: false, inside: true });
|
|
248
268
|
await mediumPage.close();
|
|
249
269
|
|
|
250
270
|
const railPage = await context.newPage();
|
|
@@ -280,69 +300,74 @@ test("shell-web adaptive navigation passes package-owned browser contracts", {
|
|
|
280
300
|
`${error.message}\n\nAdaptive shell fixture output:\n${fixtureOutput}`,
|
|
281
301
|
{ cause: error }
|
|
282
302
|
);
|
|
283
|
-
} finally {
|
|
284
|
-
await browser?.close();
|
|
285
|
-
await stopProcess(vite);
|
|
286
303
|
}
|
|
287
304
|
});
|
|
288
305
|
|
|
306
|
+
test("the shared smoke case passes a phone shell whose destinations are all in the navigation bar", {
|
|
307
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
308
|
+
timeout: 90_000
|
|
309
|
+
}, async (t) => {
|
|
310
|
+
const { vite, browser } = await startFixture(t);
|
|
311
|
+
const page = await browser.newPage({ baseURL: vite.baseURL });
|
|
312
|
+
// The standard topology: admin's main navigation goes to shell-layout:primary-bottom-nav on a phone and it has no
|
|
313
|
+
// other destinations, so the shell draws no drawer or menu control there.
|
|
314
|
+
const compact = DEFAULT_VIEWPORTS.find(({ name }) => name === "compact");
|
|
315
|
+
await runAdaptiveShellSmokeCase({ page, expect, smokePath: "/w/acme/admin/bookings", viewport: compact });
|
|
316
|
+
await expect(page.getByTestId("jskit-shell-drawer")).toHaveCount(0);
|
|
317
|
+
await expect(page.getByTestId("jskit-shell-nav-toggle")).toHaveCount(0);
|
|
318
|
+
await page.close();
|
|
319
|
+
});
|
|
320
|
+
|
|
289
321
|
test("shell-web preserves the active form across responsive changes", {
|
|
290
322
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
291
323
|
timeout: 90_000
|
|
292
|
-
}, async () => {
|
|
293
|
-
const vite = await
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
await expect(page.getByRole("status")).toHaveText("Please review this answer.");
|
|
322
|
-
await expect(answer).toBeFocused();
|
|
323
|
-
assert.equal(await originalInput.evaluate((element) => element === document.activeElement), true);
|
|
324
|
-
await expect(page.locator(".shell-route-transition__pane")).toHaveCount(1);
|
|
325
|
-
await expect(page.getByRole("heading", { level: 1 })).toHaveCount(1);
|
|
326
|
-
}
|
|
327
|
-
// Real compact navigation still replaces the pane and runs its animation.
|
|
328
|
-
await page.getByRole("link", { name: "Contacts", exact: true }).click();
|
|
329
|
-
await expect(page).toHaveURL(/\/contacts$/u);
|
|
324
|
+
}, async (t) => {
|
|
325
|
+
const { vite, browser } = await startFixture(t);
|
|
326
|
+
for (const startingWidth of [1280, 390]) {
|
|
327
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: startingWidth, height: 900 } });
|
|
328
|
+
await page.goto("/w/acme/admin/contacts");
|
|
329
|
+
await page.getByRole("link", { name: "Bookings", exact: true }).click();
|
|
330
|
+
await expect(page).toHaveURL(/\/bookings$/u);
|
|
331
|
+
await expect(page.locator(".shell-route-transition__pane")).toHaveCount(1);
|
|
332
|
+
const answer = page.getByRole("textbox", { name: "Unsaved answer" });
|
|
333
|
+
await answer.fill("Keep this unsaved answer");
|
|
334
|
+
await page.getByText("More details", { exact: true }).click();
|
|
335
|
+
await page.getByRole("button", { name: "Validate answer" }).click();
|
|
336
|
+
await answer.focus();
|
|
337
|
+
const originalInput = await answer.elementHandle();
|
|
338
|
+
for (const viewport of [
|
|
339
|
+
{ width: 390, height: 844 },
|
|
340
|
+
{ width: 1024, height: 1024 },
|
|
341
|
+
{ width: 1280, height: 900 },
|
|
342
|
+
{ width: 1280, height: 420 },
|
|
343
|
+
{ width: 390, height: 420 },
|
|
344
|
+
{ width: 390, height: 844 }
|
|
345
|
+
]) {
|
|
346
|
+
await page.setViewportSize(viewport);
|
|
347
|
+
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
|
348
|
+
await expect(answer).toHaveValue("Keep this unsaved answer");
|
|
349
|
+
await expect(page.locator("details")).toHaveAttribute("open", "");
|
|
350
|
+
await expect(page.getByRole("status")).toHaveText("Please review this answer.");
|
|
351
|
+
await expect(answer).toBeFocused();
|
|
352
|
+
assert.equal(await originalInput.evaluate((element) => element === document.activeElement), true);
|
|
330
353
|
await expect(page.locator(".shell-route-transition__pane")).toHaveCount(1);
|
|
331
|
-
await expect(
|
|
332
|
-
assert.equal(await originalInput.evaluate((element) => element.isConnected), false);
|
|
333
|
-
// Desktop same-surface navigation continues to reuse the routed component.
|
|
334
|
-
await page.setViewportSize({ width: 1280, height: 900 });
|
|
335
|
-
await page.getByRole("link", { name: "Bookings", exact: true }).click();
|
|
336
|
-
await expect(page).toHaveURL(/\/bookings$/u);
|
|
337
|
-
await answer.fill("Desktop state");
|
|
338
|
-
await page.getByRole("link", { name: "Contacts", exact: true }).click();
|
|
339
|
-
await expect(page).toHaveURL(/\/contacts$/u);
|
|
340
|
-
await expect(answer).toHaveValue("Desktop state");
|
|
341
|
-
await page.close();
|
|
354
|
+
await expect(page.getByRole("heading", { level: 1 })).toHaveCount(1);
|
|
342
355
|
}
|
|
343
|
-
|
|
344
|
-
await
|
|
345
|
-
await
|
|
356
|
+
// Real compact navigation still replaces the pane and runs its animation.
|
|
357
|
+
await page.getByRole("link", { name: "Contacts", exact: true }).click();
|
|
358
|
+
await expect(page).toHaveURL(/\/contacts$/u);
|
|
359
|
+
await expect(page.locator(".shell-route-transition__pane")).toHaveCount(1);
|
|
360
|
+
await expect(answer).toHaveValue("");
|
|
361
|
+
assert.equal(await originalInput.evaluate((element) => element.isConnected), false);
|
|
362
|
+
// Desktop same-surface navigation continues to reuse the routed component.
|
|
363
|
+
await page.setViewportSize({ width: 1280, height: 900 });
|
|
364
|
+
await page.getByRole("link", { name: "Bookings", exact: true }).click();
|
|
365
|
+
await expect(page).toHaveURL(/\/bookings$/u);
|
|
366
|
+
await answer.fill("Desktop state");
|
|
367
|
+
await page.getByRole("link", { name: "Contacts", exact: true }).click();
|
|
368
|
+
await expect(page).toHaveURL(/\/contacts$/u);
|
|
369
|
+
await expect(answer).toHaveValue("Desktop state");
|
|
370
|
+
await page.close();
|
|
346
371
|
}
|
|
347
372
|
});
|
|
348
373
|
|
|
@@ -383,40 +408,643 @@ async function reportBannerAndMeasure(page) {
|
|
|
383
408
|
test("shell-web error banners never cover content and keep a readable close button", {
|
|
384
409
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
385
410
|
timeout: 120_000
|
|
411
|
+
}, async (t) => {
|
|
412
|
+
const { vite, browser } = await startFixture(t);
|
|
413
|
+
for (const viewport of [{ width: 1440, height: 900 }, { width: 390, height: 844 }]) {
|
|
414
|
+
for (const theme of ["light", "dark"]) {
|
|
415
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport });
|
|
416
|
+
await page.goto(`/sign-in?theme=${theme}`);
|
|
417
|
+
await expect(page.getByRole("heading", { level: 1, name: "Sign in" })).toBeVisible();
|
|
418
|
+
await expect(page.getByTestId("jskit-shell-app-bar")).toHaveCount(0);
|
|
419
|
+
const bare = await reportBannerAndMeasure(page);
|
|
420
|
+
for (const item of bare.content) {
|
|
421
|
+
assert.equal(
|
|
422
|
+
overlaps(bare.banner, item.rect),
|
|
423
|
+
false,
|
|
424
|
+
`${viewport.width}px ${theme}: the banner covers "${item.name}" on a surface without an app bar.`
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
const background = parseRgb(bare.background);
|
|
428
|
+
for (const color of [bare.closeColor, bare.closeColorWithThemedDefault]) {
|
|
429
|
+
const ratio = contrastRatio(parseRgb(color), background);
|
|
430
|
+
assert.ok(ratio >= 3, `${viewport.width}px ${theme}: banner close contrast was ${ratio.toFixed(2)}:1.`);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
await page.goto(`/home?theme=${theme}`);
|
|
434
|
+
await expect(page.getByTestId("jskit-shell-app-bar")).toBeVisible();
|
|
435
|
+
const shell = await reportBannerAndMeasure(page);
|
|
436
|
+
assert.ok(
|
|
437
|
+
shell.banner.top >= shell.appBar.bottom - 1,
|
|
438
|
+
`${viewport.width}px ${theme}: the banner overlaps the top app bar.`
|
|
439
|
+
);
|
|
440
|
+
await page.close();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
// Material 3 keeps a snackbar clear of the FAB and the actions it reports on, so a person who saves can press Save
|
|
446
|
+
// again at once (a bottom-end snackbar over Save made each second press wait out its 5 seconds). On a phone the form's
|
|
447
|
+
// Save is the app bar's primary action; wider, the form's own Save at the content's bottom end counts too.
|
|
448
|
+
test("a snackbar never covers the FAB, the navigation bar or a form's Save, so Save can be pressed again at once", {
|
|
449
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
450
|
+
timeout: 120_000
|
|
451
|
+
}, async (t) => {
|
|
452
|
+
const { vite, browser } = await startFixture(t);
|
|
453
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
454
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: viewport.width, height: viewport.height } });
|
|
455
|
+
try {
|
|
456
|
+
await page.goto("/home/feedback");
|
|
457
|
+
await expect(page.getByTestId("fixture-feedback")).toBeVisible();
|
|
458
|
+
const targets = {
|
|
459
|
+
bar: page.getByTestId("jskit-shell-app-bar").getByRole("button", { name: "Save", exact: true }),
|
|
460
|
+
form: page.getByTestId("fixture-form-save"),
|
|
461
|
+
fab: page.getByRole("button", { name: "New", exact: true })
|
|
462
|
+
};
|
|
463
|
+
const names = viewport.name === "compact" ? ["bar", "fab"] : ["bar", "form", "fab"];
|
|
464
|
+
const presses = page.getByTestId("fixture-presses");
|
|
465
|
+
const box = (locator) => locator.evaluate((element) => {
|
|
466
|
+
const rect = element.getBoundingClientRect();
|
|
467
|
+
return { top: rect.top, bottom: rect.bottom, left: rect.left, right: rect.right };
|
|
468
|
+
});
|
|
469
|
+
const counts = { bar: 0, form: 0, fab: 0 };
|
|
470
|
+
for (const name of names) {
|
|
471
|
+
await targets[name].click({ timeout: 2_000 });
|
|
472
|
+
const snackbar = page.locator(".shell-error-host__snackbar .v-snackbar__wrapper");
|
|
473
|
+
await expect(snackbar).toBeVisible();
|
|
474
|
+
// The snackbar's own transitions, which end: an endless animation elsewhere (a progress bar) never would.
|
|
475
|
+
await snackbar.evaluate((element) => Promise.all(element.closest(".v-snackbar").getAnimations({ subtree: true })
|
|
476
|
+
.filter((animation) => Number.isFinite(animation.effect?.getComputedTiming().endTime ?? Infinity))
|
|
477
|
+
.map((animation) => animation.finished.catch(() => null))));
|
|
478
|
+
const shown = await box(snackbar);
|
|
479
|
+
for (const other of names) {
|
|
480
|
+
assert.equal(overlaps(shown, await box(targets[other])), false,
|
|
481
|
+
`${viewport.width}px: the snackbar from ${name} covers ${other}: ${JSON.stringify(shown)}`);
|
|
482
|
+
}
|
|
483
|
+
const bottomNavigation = page.getByTestId("jskit-shell-bottom-nav");
|
|
484
|
+
if (await bottomNavigation.isVisible()) {
|
|
485
|
+
assert.ok(shown.bottom <= (await box(bottomNavigation)).top, `${viewport.width}px: the snackbar sits above the navigation bar`);
|
|
486
|
+
}
|
|
487
|
+
// Pressed again at once, while the snackbar shows: nothing may be in the way.
|
|
488
|
+
await targets[name].click({ timeout: 1_000 });
|
|
489
|
+
await expect(snackbar).toBeVisible();
|
|
490
|
+
counts[name] += 2;
|
|
491
|
+
await expect(presses).toHaveText(`${counts.bar} ${counts.form} ${counts.fab}`);
|
|
492
|
+
// Each press reported once: the second report waits its turn and shows when the first is dismissed.
|
|
493
|
+
const current = page.locator(".shell-error-host__snackbar .v-snackbar__wrapper:not(.v-snackbar-transition-leave-active)");
|
|
494
|
+
for (let report = 0; report < 2; report += 1) {
|
|
495
|
+
await current.getByRole("button", { name: "Dismiss", exact: true }).click();
|
|
496
|
+
}
|
|
497
|
+
await expect(snackbar).toBeHidden();
|
|
498
|
+
}
|
|
499
|
+
} finally {
|
|
500
|
+
await page.close();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
test("shell-web's app bar fills with surface-container once the page scrolls under it", {
|
|
506
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
507
|
+
timeout: 90_000
|
|
508
|
+
}, async (t) => {
|
|
509
|
+
const { vite, browser } = await startFixture(t);
|
|
510
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 } });
|
|
511
|
+
await page.goto("/home/contacts?theme=light");
|
|
512
|
+
const appBar = page.getByTestId("jskit-shell-app-bar");
|
|
513
|
+
const background = () => appBar.evaluate((element) => window.getComputedStyle(element).backgroundColor);
|
|
514
|
+
await expect.poll(background).toBe(await readRoleColor(page, "surface"));
|
|
515
|
+
const bar = page.getByTestId("jskit-shell-bottom-nav");
|
|
516
|
+
assert.equal(
|
|
517
|
+
await bar.evaluate((element) => window.getComputedStyle(element).backgroundColor),
|
|
518
|
+
await readRoleColor(page, "surface-container")
|
|
519
|
+
);
|
|
520
|
+
assert.equal(Math.round((await bar.boundingBox()).height), 80);
|
|
521
|
+
await page.evaluate(() => window.scrollTo(0, 400));
|
|
522
|
+
await expect.poll(background).toBe(await readRoleColor(page, "surface-container"));
|
|
523
|
+
await page.close();
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
test("shell-web's bar pieces give a layout that draws its own top app bar the shell's Up, title and actions", {
|
|
527
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
528
|
+
timeout: 120_000
|
|
529
|
+
}, async (t) => {
|
|
530
|
+
const { vite, browser } = await startFixture(t);
|
|
531
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
532
|
+
const page = await browser.newPage({
|
|
533
|
+
baseURL: vite.baseURL,
|
|
534
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
535
|
+
});
|
|
536
|
+
const at = `${viewport.width}px`;
|
|
537
|
+
const ownBar = page.getByTestId("fixture-own-bar");
|
|
538
|
+
|
|
539
|
+
// A top-level page: the title is the page's one h1, in the app's own bar, with no arrow.
|
|
540
|
+
await page.goto("/home/studio");
|
|
541
|
+
await expect(ownBar.getByRole("heading", { level: 1, name: "Studio" }), at).toBeVisible();
|
|
542
|
+
await expect(page.getByRole("heading", { level: 1 }), at).toHaveCount(1);
|
|
543
|
+
await expect(shellBackButton(page), at).toHaveCount(0);
|
|
544
|
+
// A title that is also a switcher: the menu activator is inside the h1, which keeps its id and focus target.
|
|
545
|
+
const title = ownBar.getByRole("heading", { level: 1 });
|
|
546
|
+
await expect(title, at).toHaveAttribute("id", "jskit-shell-page-title");
|
|
547
|
+
await expect(title, at).toHaveAttribute("tabindex", "-1");
|
|
548
|
+
await title.getByRole("button", { name: "Studio" }).click();
|
|
549
|
+
await expect(page.getByText("Other studio", { exact: true }), at).toBeVisible();
|
|
550
|
+
await page.keyboard.press("Escape");
|
|
551
|
+
await expect(page.getByText("Other studio", { exact: true }), at).toBeHidden();
|
|
552
|
+
|
|
553
|
+
// An inner page: Up, its title and its actions, in the app's own bar; Up returns along the trail.
|
|
554
|
+
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
555
|
+
await expect(page).toHaveURL(/\/home\/studio\/ada$/u);
|
|
556
|
+
await expect(ownBar.getByTestId("jskit-shell-page-title"), at).toHaveText("Ada Lovelace");
|
|
557
|
+
await expect(ownBar.getByTestId("jskit-shell-back"), at).toHaveAccessibleName("Back");
|
|
558
|
+
await expect(ownBar.getByRole("button", { name: "Run" }), at).toBeVisible();
|
|
559
|
+
await pressShellBack(page);
|
|
560
|
+
await expect(page).toHaveURL(/\/home\/studio$/u);
|
|
561
|
+
await expect(shellBackButton(page), at).toHaveCount(0);
|
|
562
|
+
|
|
563
|
+
// A pasted link goes Up to the declared parent.
|
|
564
|
+
await page.goto("/home/studio/ada");
|
|
565
|
+
await pressShellBack(page);
|
|
566
|
+
await expect(page).toHaveURL(/\/home\/studio$/u);
|
|
567
|
+
await page.close();
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
test("a surface with no navigation, or Home alone, draws no navigation bar, rail, drawer or menu control", {
|
|
572
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
573
|
+
timeout: 120_000
|
|
574
|
+
}, async (t) => {
|
|
575
|
+
const { vite, browser } = await startFixture(t);
|
|
576
|
+
const navigation = { compact: "jskit-shell-bottom-nav", medium: "jskit-shell-rail", expanded: "jskit-shell-drawer" };
|
|
577
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
578
|
+
const page = await browser.newPage({
|
|
579
|
+
baseURL: vite.baseURL,
|
|
580
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
581
|
+
});
|
|
582
|
+
const at = `${viewport.width}px`;
|
|
583
|
+
await page.goto("/account");
|
|
584
|
+
await expect(shellPageTitle(page), at).toHaveText("Account");
|
|
585
|
+
for (const id of ["jskit-shell-bottom-nav", "jskit-shell-rail", "jskit-shell-drawer", "jskit-shell-nav-toggle"]) {
|
|
586
|
+
await expect(page.getByTestId(id), `${at} ${id}`).toHaveCount(0);
|
|
587
|
+
}
|
|
588
|
+
assert.equal(Math.round((await page.locator("main").boundingBox()).x), 0, `${at}: the page starts at the window's edge`);
|
|
589
|
+
// Its title and Up stay in the app bar; Up returns to the declared parent on another surface, which has navigation.
|
|
590
|
+
await pressShellBack(page);
|
|
591
|
+
await expect(page).toHaveURL(/\/home$/u);
|
|
592
|
+
await expect(page.getByTestId(navigation[viewport.name]), at).toBeVisible();
|
|
593
|
+
|
|
594
|
+
// Home alone is nowhere to go: Material 3 navigation needs two destinations.
|
|
595
|
+
await page.goto("/solo");
|
|
596
|
+
await expect(shellPageTitle(page), at).toHaveText("Solo");
|
|
597
|
+
for (const id of ["jskit-shell-bottom-nav", "jskit-shell-rail", "jskit-shell-drawer", "jskit-shell-nav-toggle"]) {
|
|
598
|
+
await expect(page.getByTestId(id), `${at} solo ${id}`).toHaveCount(0);
|
|
599
|
+
}
|
|
600
|
+
assert.equal(Math.round((await page.locator("main").boundingBox()).x), 0, `${at}: the solo page starts at the window's edge`);
|
|
601
|
+
|
|
602
|
+
if (viewport.name === "expanded") {
|
|
603
|
+
// The standard drawer's header holds its menu control alone; the control's tooltip is its label.
|
|
604
|
+
await page.goto("/home");
|
|
605
|
+
const header = page.getByTestId("jskit-shell-drawer").locator(".shell-layout__drawer-header");
|
|
606
|
+
await expect(header).toBeVisible();
|
|
607
|
+
assert.equal((await header.innerText()).trim(), "", `${at}: no text beside the menu control`);
|
|
608
|
+
const toggle = page.getByTestId("jskit-shell-nav-toggle");
|
|
609
|
+
await expect(toggle).toHaveAccessibleName("Collapse navigation drawer");
|
|
610
|
+
await toggle.hover();
|
|
611
|
+
await expect(page.getByRole("tooltip", { name: "Collapse navigation drawer" })).toBeVisible();
|
|
612
|
+
await page.mouse.move(0, 0);
|
|
613
|
+
}
|
|
614
|
+
await page.close();
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// page.section-nav is a page's own tabs: Material 3 primary tabs (48dp, title-small, the active label primary over a
|
|
619
|
+
// 3dp indicator under its content), never navigation bar destinations, which belong to the navigation bar alone. The
|
|
620
|
+
// bar's item placed in a page draws the same tabs.
|
|
621
|
+
test("a page's section tabs are Material 3 primary tabs at every width, and the navigation bar keeps its destinations", {
|
|
622
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
623
|
+
timeout: 120_000
|
|
624
|
+
}, async (t) => {
|
|
625
|
+
const { vite, browser } = await startFixture(t);
|
|
626
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
627
|
+
const page = await browser.newPage({
|
|
628
|
+
baseURL: vite.baseURL,
|
|
629
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
630
|
+
});
|
|
631
|
+
const at = `${viewport.width}px`;
|
|
632
|
+
await page.goto("/home/reports/overview");
|
|
633
|
+
await expect(shellPageTitle(page), at).toHaveText("Reports");
|
|
634
|
+
const rows = await page.evaluate(() => {
|
|
635
|
+
const role = (name) => {
|
|
636
|
+
const probe = document.body.appendChild(document.createElement("span"));
|
|
637
|
+
probe.style.color = `rgb(var(--v-theme-${name}))`;
|
|
638
|
+
const color = getComputedStyle(probe).color;
|
|
639
|
+
probe.remove();
|
|
640
|
+
return color;
|
|
641
|
+
};
|
|
642
|
+
const read = (testId) => [...document.querySelectorAll(`[data-testid=${testId}] .v-btn`)].map((tab) => {
|
|
643
|
+
const label = tab.querySelector(".section-tab-link-item__label");
|
|
644
|
+
const indicator = tab.querySelector(".section-tab-link-item__indicator");
|
|
645
|
+
const style = getComputedStyle(tab);
|
|
646
|
+
const labelStyle = label ? getComputedStyle(label) : null;
|
|
647
|
+
const indicatorStyle = indicator ? getComputedStyle(indicator) : null;
|
|
648
|
+
return {
|
|
649
|
+
name: tab.textContent.trim(),
|
|
650
|
+
sectionTab: tab.classList.contains("section-tab-link-item"),
|
|
651
|
+
barItem: tab.classList.contains("tab-link-item"),
|
|
652
|
+
current: tab.getAttribute("aria-current") === "page",
|
|
653
|
+
height: Math.round(tab.getBoundingClientRect().height),
|
|
654
|
+
type: labelStyle ? [labelStyle.fontSize, labelStyle.fontWeight] : null,
|
|
655
|
+
clipped: label ? label.scrollWidth > label.clientWidth + 1 : null,
|
|
656
|
+
primaryLabel: style.color === role("primary"),
|
|
657
|
+
indicator: indicatorStyle ? [indicatorStyle.opacity, indicatorStyle.height, indicatorStyle.borderTopLeftRadius] : null,
|
|
658
|
+
indicatorUnderLabel: indicator && label ? Math.abs(indicator.getBoundingClientRect().width - label.getBoundingClientRect().width) <= 1 : null
|
|
659
|
+
};
|
|
660
|
+
});
|
|
661
|
+
return { sections: read("fixture-section-tabs"), views: read("fixture-bar-items-in-page") };
|
|
662
|
+
});
|
|
663
|
+
for (const [row, tabs] of Object.entries(rows)) {
|
|
664
|
+
assert.ok(tabs.length >= 2, `${at} ${row}: its tabs render`);
|
|
665
|
+
for (const tab of tabs) {
|
|
666
|
+
const active = tab.name === "Overview";
|
|
667
|
+
assert.deepEqual(tab, {
|
|
668
|
+
name: tab.name,
|
|
669
|
+
sectionTab: true,
|
|
670
|
+
barItem: false,
|
|
671
|
+
current: active,
|
|
672
|
+
height: 48,
|
|
673
|
+
type: ["14px", "500"],
|
|
674
|
+
clipped: false,
|
|
675
|
+
primaryLabel: active,
|
|
676
|
+
indicator: [active ? "1" : "0", "3px", "3px"],
|
|
677
|
+
indicatorUnderLabel: true
|
|
678
|
+
}, `${at} ${row} ${tab.name}`);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
// A tab moves to its section and becomes the active one.
|
|
682
|
+
await page.getByTestId("fixture-section-tabs").getByRole("link", { name: "Activity" }).click();
|
|
683
|
+
await expect(page).toHaveURL(/\/home\/reports\/activity$/u);
|
|
684
|
+
await expect(page.getByTestId("fixture-report-section")).toHaveText("activity");
|
|
685
|
+
await expect(page.getByTestId("fixture-section-tabs").getByRole("link", { name: "Activity" })).toHaveAttribute("aria-current", "page");
|
|
686
|
+
if (viewport.name === "compact") {
|
|
687
|
+
// The navigation bar's destinations keep their 64x32 indicators.
|
|
688
|
+
const indicator = page.getByTestId("jskit-shell-bottom-nav").locator(".tab-link-item__indicator").first();
|
|
689
|
+
const box = await indicator.boundingBox();
|
|
690
|
+
assert.deepEqual([Math.round(box.width), Math.round(box.height)], [64, 32], `${at}: a navigation bar destination`);
|
|
691
|
+
}
|
|
692
|
+
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
|
693
|
+
assert.ok(overflow <= 1, `${at}: the page never scrolls sideways; the tab row does`);
|
|
694
|
+
await page.close();
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
test("every button keeps its size, gets a 48dp touch target and ends a long label in an ellipsis; FABs and cards keep theirs", {
|
|
699
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
700
|
+
timeout: 90_000
|
|
701
|
+
}, async (t) => {
|
|
702
|
+
const { vite, browser } = await startFixture(t);
|
|
703
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 900 } });
|
|
704
|
+
await page.goto("/home/buttons");
|
|
705
|
+
// Vuetify's heights for x-small, small and large, JSKIT's 40dp default; an icon button is 12dp more, JSKIT's 40dp.
|
|
706
|
+
const heights = {
|
|
707
|
+
"x-small": [20, 32],
|
|
708
|
+
small: [28, 40],
|
|
709
|
+
default: [40, 40],
|
|
710
|
+
large: [44, 56]
|
|
711
|
+
};
|
|
712
|
+
for (const [size, [textHeight, iconHeight]] of Object.entries(heights)) {
|
|
713
|
+
for (const [id, height] of [[`fixture-button-${size}`, textHeight], [`fixture-icon-button-${size}`, iconHeight]]) {
|
|
714
|
+
const button = page.getByTestId(id);
|
|
715
|
+
const box = await button.boundingBox();
|
|
716
|
+
assert.equal(Math.round(box.height), height, `${id} keeps its visual height`);
|
|
717
|
+
const target = await button.evaluate((element) => {
|
|
718
|
+
const style = window.getComputedStyle(element, "::before");
|
|
719
|
+
return { width: Number.parseFloat(style.width), height: Number.parseFloat(style.height) };
|
|
720
|
+
});
|
|
721
|
+
assert.equal(Math.round(target.height), Math.max(48, height), `${id} touch target height`);
|
|
722
|
+
assert.ok(target.width >= 48, `${id} touch target width ${target.width}`);
|
|
723
|
+
if (height < 48) {
|
|
724
|
+
// A tap just above the visual, inside the touch target, reaches the button.
|
|
725
|
+
const point = [box.x + box.width / 2, box.y - (48 - height) / 2 + 1];
|
|
726
|
+
const hit = await page.evaluate(([x, y]) => document.elementFromPoint(x, y)?.closest(".v-btn")?.dataset.testid, point);
|
|
727
|
+
assert.equal(hit, id, `${id} answers inside its touch target`);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
const long = page.getByTestId("fixture-long-label");
|
|
732
|
+
const label = await long.evaluate((element) => {
|
|
733
|
+
const content = element.querySelector(".v-btn__content");
|
|
734
|
+
const style = window.getComputedStyle(content);
|
|
735
|
+
return {
|
|
736
|
+
buttonWidth: element.getBoundingClientRect().width,
|
|
737
|
+
buttonRight: element.getBoundingClientRect().right,
|
|
738
|
+
contentRight: content.getBoundingClientRect().right,
|
|
739
|
+
clipped: content.scrollWidth > content.clientWidth,
|
|
740
|
+
textOverflow: style.textOverflow,
|
|
741
|
+
height: element.getBoundingClientRect().height
|
|
742
|
+
};
|
|
743
|
+
});
|
|
744
|
+
assert.ok(label.buttonWidth <= 160.5, `the long button stays in its 160px (${label.buttonWidth})`);
|
|
745
|
+
assert.ok(label.contentRight <= label.buttonRight + 0.5, "the label stays inside its button");
|
|
746
|
+
assert.equal(label.clipped, true);
|
|
747
|
+
assert.equal(label.textOverflow, "ellipsis");
|
|
748
|
+
assert.equal(Math.round(label.height), 40, "the label stays on one line");
|
|
749
|
+
// A touch target reaching past a scroll container's corner adds no scrollbar.
|
|
750
|
+
const corner = await page.getByTestId("fixture-button-corner").evaluate((element) => ({
|
|
751
|
+
extraWidth: element.scrollWidth - element.clientWidth,
|
|
752
|
+
extraHeight: element.scrollHeight - element.clientHeight
|
|
753
|
+
}));
|
|
754
|
+
assert.deepEqual(corner, { extraWidth: 0, extraHeight: 0 });
|
|
755
|
+
// FABs keep Material 3's sizes, not the common button's 40dp.
|
|
756
|
+
for (const [id, width, height] of [
|
|
757
|
+
["fixture-fab", 56, 56],
|
|
758
|
+
["fixture-fab-small", 40, 40],
|
|
759
|
+
["fixture-fab-large", 96, 96],
|
|
760
|
+
["fixture-fab-extended", null, 56]
|
|
761
|
+
]) {
|
|
762
|
+
const box = await page.getByTestId(id).locator(".v-btn").boundingBox();
|
|
763
|
+
assert.equal(Math.round(box.height), height, `${id} height`);
|
|
764
|
+
if (width) assert.equal(Math.round(box.width), width, `${id} width`);
|
|
765
|
+
}
|
|
766
|
+
// An elevated card has its level-1 shadow; flat and tonal cards have none.
|
|
767
|
+
const shadows = {};
|
|
768
|
+
for (const variant of ["elevated", "flat", "tonal"]) {
|
|
769
|
+
shadows[variant] = await page.getByTestId(`fixture-card-${variant}`).evaluate((element) => window.getComputedStyle(element).boxShadow);
|
|
770
|
+
}
|
|
771
|
+
// A shadow of zero offsets, blur and spread (Vuetify's level 0) draws nothing.
|
|
772
|
+
const drawsShadow = (shadow) => shadow !== "none" &&
|
|
773
|
+
shadow.replace(/rgba?\([^)]*\)/gu, "").split(/[\s,]+/u).some((length) => Number.parseFloat(length) > 0);
|
|
774
|
+
assert.equal(drawsShadow(shadows.elevated), true, shadows.elevated);
|
|
775
|
+
assert.deepEqual([drawsShadow(shadows.flat), drawsShadow(shadows.tonal)], [false, false], JSON.stringify(shadows));
|
|
776
|
+
await page.close();
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
async function openMainDestination(page, label) {
|
|
780
|
+
await page.getByRole("link", { name: label, exact: true }).filter({ visible: true }).first().click();
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
test("adjacent icon buttons are at least 32dp and each answers a press on its own box, by mouse and by touch", {
|
|
784
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
785
|
+
timeout: 120_000
|
|
386
786
|
}, async () => {
|
|
387
787
|
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
388
788
|
let browser;
|
|
389
789
|
try {
|
|
390
790
|
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
391
|
-
for (const
|
|
392
|
-
for (const
|
|
393
|
-
const
|
|
394
|
-
await
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
`${
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
791
|
+
for (const width of [390, 1280]) {
|
|
792
|
+
for (const touch of [false, true]) {
|
|
793
|
+
const how = `${width}px ${touch ? "touch" : "mouse"}`;
|
|
794
|
+
const context = await browser.newContext({ baseURL: vite.baseURL, viewport: { width, height: 900 }, hasTouch: touch });
|
|
795
|
+
try {
|
|
796
|
+
const page = await context.newPage();
|
|
797
|
+
await page.goto("/home/buttons");
|
|
798
|
+
for (const name of ["history", "edit", "more", "info", "archive"]) {
|
|
799
|
+
const button = page.getByTestId(`fixture-adjacent-${name}`);
|
|
800
|
+
await button.scrollIntoViewIfNeeded();
|
|
801
|
+
const box = await button.boundingBox();
|
|
802
|
+
assert.ok(Math.round(box.width) >= 32 && Math.round(box.height) >= 32, `${how} ${name} is ${box.width}x${box.height}`);
|
|
803
|
+
// Its centre and the points just inside its sides are its own, not under its neighbour's touch target.
|
|
804
|
+
const y = box.y + box.height / 2;
|
|
805
|
+
for (const x of [box.x + 1, box.x + box.width / 2, box.x + box.width - 1]) {
|
|
806
|
+
const hit = await page.evaluate(([px, py]) => document.elementFromPoint(px, py)?.closest(".v-btn")?.dataset.testid, [x, y]);
|
|
807
|
+
assert.equal(hit, `fixture-adjacent-${name}`, `${how} ${name} at x=${Math.round(x - box.x)}`);
|
|
808
|
+
}
|
|
809
|
+
const centre = [box.x + box.width / 2, y];
|
|
810
|
+
await (touch ? page.touchscreen.tap(...centre) : page.mouse.click(...centre));
|
|
811
|
+
await expect(page.getByTestId("fixture-adjacent-pressed"), how).toHaveText(name);
|
|
812
|
+
}
|
|
813
|
+
} finally {
|
|
814
|
+
await context.close();
|
|
409
815
|
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
} finally {
|
|
819
|
+
await browser?.close();
|
|
820
|
+
await stopProcess(vite);
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
test("shell-web Up follows the tab's trail, falls back to the parent and returns to where the person was", {
|
|
825
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
826
|
+
timeout: 180_000
|
|
827
|
+
}, async (t) => {
|
|
828
|
+
const { vite, browser } = await startFixture(t);
|
|
829
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
830
|
+
const context = await browser.newContext({
|
|
831
|
+
baseURL: vite.baseURL,
|
|
832
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
833
|
+
});
|
|
834
|
+
const page = await context.newPage();
|
|
835
|
+
const at = `${viewport.width}px`;
|
|
836
|
+
|
|
837
|
+
// Main-menu pages have no arrow.
|
|
838
|
+
for (const path of ["/home", "/home/contacts", "/home/suppliers", "/home/bookings", "/home/settings"]) {
|
|
839
|
+
await page.goto(path);
|
|
840
|
+
await expect(shellPageTitle(page)).toBeVisible();
|
|
841
|
+
await expect(shellBackButton(page), `${at} ${path}`).toHaveCount(0);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// contact -> supplier -> Up = contact -> Up = the Contacts list.
|
|
845
|
+
await page.goto("/home/contacts");
|
|
846
|
+
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
847
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
848
|
+
await expect(shellPageTitle(page)).toHaveText("Ada Lovelace");
|
|
849
|
+
await expect(shellBackButton(page)).toHaveAccessibleName("Back");
|
|
850
|
+
await page.getByRole("link", { name: "Supplier", exact: true }).click();
|
|
851
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
852
|
+
// A refresh keeps the trail.
|
|
853
|
+
await page.reload();
|
|
854
|
+
await expect(shellPageTitle(page)).toHaveText("Acme Supplies");
|
|
855
|
+
await pressShellBack(page);
|
|
856
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
857
|
+
// The browser's Back and Forward move the trail with them.
|
|
858
|
+
await page.goBack();
|
|
859
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
860
|
+
await page.goForward();
|
|
861
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
862
|
+
await pressShellBack(page);
|
|
863
|
+
await expect(page).toHaveURL(/\/home\/contacts$/u);
|
|
864
|
+
await expect(shellBackButton(page)).toHaveCount(0);
|
|
865
|
+
|
|
866
|
+
// The trail is a stack of visits: contact -> supplier -> the same contact -> Up = supplier.
|
|
867
|
+
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
868
|
+
await page.getByRole("link", { name: "Supplier", exact: true }).click();
|
|
869
|
+
await page.getByRole("link", { name: "Contact", exact: true }).click();
|
|
870
|
+
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
871
|
+
await pressShellBack(page);
|
|
872
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
873
|
+
|
|
874
|
+
// A main destination starts a fresh trail.
|
|
875
|
+
await openMainDestination(page, "Suppliers");
|
|
876
|
+
await expect(page).toHaveURL(/\/home\/suppliers$/u);
|
|
877
|
+
await page.getByRole("link", { name: "Acme Supplies", exact: true }).click();
|
|
878
|
+
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
879
|
+
await pressShellBack(page);
|
|
880
|
+
await expect(page).toHaveURL(/\/home\/suppliers$/u);
|
|
410
881
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
882
|
+
// Up to a page that is no longer available goes to the current page's parent instead.
|
|
883
|
+
await page.goto("/home/contacts/ada");
|
|
884
|
+
await page.getByRole("link", { name: "Supplier", exact: true }).click();
|
|
885
|
+
await page.evaluate(() => {
|
|
886
|
+
window.__fixtureBlockedRecords = ["ada"];
|
|
887
|
+
});
|
|
888
|
+
await pressShellBack(page);
|
|
889
|
+
await expect(page).toHaveURL(/\/home\/suppliers$/u);
|
|
890
|
+
await page.evaluate(() => {
|
|
891
|
+
window.__fixtureBlockedRecords = [];
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
// Up returns to the list where it was scrolled, with focus on the record it opened.
|
|
895
|
+
await page.goto("/home/contacts");
|
|
896
|
+
const deepLink = page.getByRole("link", { name: "Contact 35", exact: true });
|
|
897
|
+
await deepLink.scrollIntoViewIfNeeded();
|
|
898
|
+
const scrollBefore = await page.evaluate(() => window.scrollY);
|
|
899
|
+
assert.ok(scrollBefore > 200, `${at}: the contacts list did not scroll.`);
|
|
900
|
+
await deepLink.click();
|
|
901
|
+
await expect(page).toHaveURL(/\/home\/contacts\/contact-35$/u);
|
|
902
|
+
await pressShellBack(page);
|
|
903
|
+
await expect(page).toHaveURL(/\/home\/contacts$/u);
|
|
904
|
+
await expect.poll(() => page.evaluate(() => window.scrollY)).toBeGreaterThan(scrollBefore - 3);
|
|
905
|
+
assert.ok(Math.abs(await page.evaluate(() => window.scrollY) - scrollBefore) <= 2, `${at}: scroll was not restored.`);
|
|
906
|
+
await expect(page.getByRole("link", { name: "Contact 35", exact: true })).toBeFocused();
|
|
907
|
+
|
|
908
|
+
// A pasted supplier link goes Up to the Suppliers list.
|
|
909
|
+
const pasted = await context.newPage();
|
|
910
|
+
await pasted.goto("/home/suppliers/acme");
|
|
911
|
+
await pressShellBack(pasted);
|
|
912
|
+
await expect(pasted).toHaveURL(/\/home\/suppliers$/u);
|
|
913
|
+
await expect(shellPageTitle(pasted)).toHaveText("Suppliers");
|
|
914
|
+
// A pasted edit link goes Up to its record: the parent "/contacts/:id" takes the id from the route.
|
|
915
|
+
await pasted.goto("/home/contacts/ada/edit");
|
|
916
|
+
await expect(shellPageTitle(pasted)).toHaveText("Edit contact");
|
|
917
|
+
await pressShellBack(pasted);
|
|
918
|
+
await expect(pasted).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
919
|
+
await pasted.close();
|
|
920
|
+
|
|
921
|
+
// List-detail: beside the visible list, General has no arrow; alone, it has one back to the list.
|
|
922
|
+
await page.goto("/home/settings");
|
|
923
|
+
await page.getByRole("link", { name: "General", exact: true }).click();
|
|
924
|
+
await expect(page).toHaveURL(/\/home\/settings\/general$/u);
|
|
925
|
+
if (viewport.name === "expanded") {
|
|
926
|
+
await expect(shellBackButton(page)).toHaveCount(0);
|
|
927
|
+
await expect(page.getByRole("link", { name: "General", exact: true })).toBeVisible();
|
|
928
|
+
} else {
|
|
929
|
+
await pressShellBack(page);
|
|
930
|
+
await expect(page).toHaveURL(/\/home\/settings$/u);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// No page carries a worded back control.
|
|
934
|
+
await expect(page.getByText(/Back to /u)).toHaveCount(0);
|
|
935
|
+
await context.close();
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
// What an element in the bar is: its tag, whether it is the action's own button and the attributes it carries.
|
|
940
|
+
async function describeElement(locator) {
|
|
941
|
+
return locator.evaluate((element) => ({
|
|
942
|
+
tag: element.tagName.toLowerCase(),
|
|
943
|
+
button: element.classList.contains("v-btn") || element.classList.contains("v-list-item"),
|
|
944
|
+
href: element.getAttribute("href"),
|
|
945
|
+
target: element.getAttribute("target"),
|
|
946
|
+
download: element.getAttribute("download"),
|
|
947
|
+
color: window.getComputedStyle(element).color
|
|
948
|
+
}));
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
test("page actions carry their attributes in every form, collapse into the overflow menu and keep the primary action adaptive", {
|
|
952
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
953
|
+
timeout: 150_000
|
|
954
|
+
}, async () => {
|
|
955
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
956
|
+
let browser;
|
|
957
|
+
try {
|
|
958
|
+
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
959
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
960
|
+
const page = await browser.newPage({
|
|
961
|
+
baseURL: vite.baseURL,
|
|
962
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
963
|
+
});
|
|
964
|
+
const at = `${viewport.width}px`;
|
|
965
|
+
const compact = viewport.name === "compact";
|
|
966
|
+
await page.goto("/home/actions");
|
|
967
|
+
const bar = page.getByTestId("jskit-shell-app-bar");
|
|
968
|
+
const error = await readRoleColor(page, "error");
|
|
969
|
+
const overflow = bar.getByTestId("jskit-shell-page-actions-overflow");
|
|
970
|
+
|
|
971
|
+
// Compact: the bar keeps its one trailing place for the primary action or the avatar, so every action is in the
|
|
972
|
+
// overflow menu; wider: every action but the overflow one is in the bar.
|
|
973
|
+
const inBar = compact
|
|
974
|
+
? []
|
|
975
|
+
: ["fixture-action-edit", "fixture-action-export", "fixture-action-site", "fixture-action-delete"];
|
|
976
|
+
const inMenu = compact
|
|
977
|
+
? [
|
|
978
|
+
"fixture-action-edit",
|
|
979
|
+
"fixture-action-export",
|
|
980
|
+
"fixture-action-site",
|
|
981
|
+
"fixture-action-delete",
|
|
982
|
+
"fixture-action-duplicate"
|
|
983
|
+
]
|
|
984
|
+
: ["fixture-action-duplicate"];
|
|
985
|
+
for (const id of inBar) {
|
|
986
|
+
const element = await describeElement(bar.getByTestId(id));
|
|
987
|
+
assert.equal(element.button, true, `${at} ${id}: the attribute is on the action's own button`);
|
|
988
|
+
}
|
|
989
|
+
await expect(overflow, at).toHaveAccessibleName("More actions");
|
|
990
|
+
await expect(bar.locator("[data-testid=fixture-action-duplicate]"), at).toHaveCount(0);
|
|
991
|
+
|
|
992
|
+
// The bar's own forms keep a download, a new tab and the error colour.
|
|
993
|
+
if (!compact) {
|
|
994
|
+
const exportAction = await describeElement(bar.getByTestId("fixture-action-export"));
|
|
995
|
+
assert.deepEqual(
|
|
996
|
+
[exportAction.tag, exportAction.href, exportAction.download],
|
|
997
|
+
["a", "/records.csv", "records.csv"],
|
|
998
|
+
at
|
|
417
999
|
);
|
|
418
|
-
await
|
|
1000
|
+
const site = await describeElement(bar.getByTestId("fixture-action-site"));
|
|
1001
|
+
assert.deepEqual([site.tag, site.href, site.target], ["a", "https://example.com/", "_blank"], at);
|
|
1002
|
+
assert.equal((await describeElement(bar.getByTestId("fixture-action-delete"))).color, error, `${at} Delete is error`);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
// The menu holds the rest in bar order, with their attributes, and runs their handlers.
|
|
1006
|
+
await overflow.click();
|
|
1007
|
+
const menu = page.getByRole("menu");
|
|
1008
|
+
await expect(menu, at).toBeVisible();
|
|
1009
|
+
assert.deepEqual(
|
|
1010
|
+
await menu.getByRole("menuitem").evaluateAll((items) => items.map((item) => item.dataset.testid)),
|
|
1011
|
+
inMenu,
|
|
1012
|
+
at
|
|
1013
|
+
);
|
|
1014
|
+
if (compact) {
|
|
1015
|
+
const exportItem = await describeElement(menu.getByTestId("fixture-action-export"));
|
|
1016
|
+
assert.deepEqual([exportItem.tag, exportItem.href, exportItem.download], ["a", "/records.csv", "records.csv"], at);
|
|
1017
|
+
const site = await describeElement(menu.getByTestId("fixture-action-site"));
|
|
1018
|
+
assert.deepEqual([site.tag, site.href, site.target], ["a", "https://example.com/", "_blank"], at);
|
|
1019
|
+
assert.equal((await describeElement(menu.getByTestId("fixture-action-delete"))).color, error, `${at} Delete is error`);
|
|
1020
|
+
}
|
|
1021
|
+
await menu.getByRole("menuitem", { name: "Duplicate" }).click();
|
|
1022
|
+
await expect(page.getByTestId("fixture-action-log"), at).toHaveText("duplicate");
|
|
1023
|
+
await expect(menu, at).toBeHidden();
|
|
1024
|
+
if (compact) {
|
|
1025
|
+
await overflow.click();
|
|
1026
|
+
await expect(page.getByRole("menu"), at).toBeVisible();
|
|
1027
|
+
await page.getByRole("menu").getByRole("menuitem", { name: "Delete" }).click();
|
|
1028
|
+
await expect(page.getByTestId("fixture-action-log"), at).toHaveText("duplicate,delete");
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// The primary action: an extended FAB on compact and medium windows, the bar's filled button on wider ones; its
|
|
1032
|
+
// click handler opens a dialog.
|
|
1033
|
+
const primary = page.getByTestId("fixture-primary");
|
|
1034
|
+
if (viewport.name === "expanded") {
|
|
1035
|
+
await expect(bar.getByTestId("fixture-primary"), at).toHaveText("New record");
|
|
1036
|
+
assert.equal((await describeElement(primary)).button, true, at);
|
|
1037
|
+
await expect(page.locator(".v-fab"), at).toHaveCount(0);
|
|
1038
|
+
} else {
|
|
1039
|
+
await expect(primary, at).toHaveClass(/v-fab--extended/u);
|
|
1040
|
+
await expect(primary.getByRole("button", { name: "New record" }), at).toBeVisible();
|
|
1041
|
+
await expect(bar.getByText("New record"), at).toHaveCount(0);
|
|
419
1042
|
}
|
|
1043
|
+
await (viewport.name === "expanded" ? primary : primary.locator(".v-btn")).click();
|
|
1044
|
+
await expect(page.getByTestId("fixture-new-dialog"), at).toBeVisible();
|
|
1045
|
+
await page.getByRole("button", { name: "Cancel" }).click();
|
|
1046
|
+
await expect(page.getByTestId("fixture-new-dialog"), at).toBeHidden();
|
|
1047
|
+
await page.close();
|
|
420
1048
|
}
|
|
421
1049
|
} finally {
|
|
422
1050
|
await browser?.close();
|
|
@@ -424,7 +1052,7 @@ test("shell-web error banners never cover content and keep a readable close butt
|
|
|
424
1052
|
}
|
|
425
1053
|
});
|
|
426
1054
|
|
|
427
|
-
test("
|
|
1055
|
+
test("a nested component's title gives the page's own title back, and Save returns to the list with its query", {
|
|
428
1056
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
429
1057
|
timeout: 90_000
|
|
430
1058
|
}, async () => {
|
|
@@ -432,19 +1060,33 @@ test("shell-web's app bar fills with surface-container once the page scrolls und
|
|
|
432
1060
|
let browser;
|
|
433
1061
|
try {
|
|
434
1062
|
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
435
|
-
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width:
|
|
436
|
-
await page.goto("/home/
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
await expect
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
await page.
|
|
447
|
-
await expect
|
|
1063
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 900 } });
|
|
1064
|
+
await page.goto("/home/actions?view=table");
|
|
1065
|
+
await expect(shellPageTitle(page)).toHaveText("Page actions");
|
|
1066
|
+
await page.getByTestId("fixture-toggle-panel").click();
|
|
1067
|
+
await expect(shellPageTitle(page)).toHaveText("Panel title");
|
|
1068
|
+
await page.getByTestId("fixture-toggle-panel").click();
|
|
1069
|
+
await expect(page.getByTestId("fixture-title-claim")).toHaveCount(0);
|
|
1070
|
+
await expect(shellPageTitle(page)).toHaveText("Page actions");
|
|
1071
|
+
|
|
1072
|
+
// Save finishes to the list it was opened from, which comes back with its query; so does the close, the form's
|
|
1073
|
+
// Cancel, which takes the Up arrow's place instead of sitting beside it.
|
|
1074
|
+
await page.getByRole("link", { name: "New entry", exact: true }).click();
|
|
1075
|
+
await expect(page).toHaveURL(/\/home\/actions\/new$/u);
|
|
1076
|
+
await shellPageActionButton(page, "Save").click();
|
|
1077
|
+
await expect(page).toHaveURL(/\/home\/actions\?view=table$/u);
|
|
1078
|
+
await page.getByRole("link", { name: "New entry", exact: true }).click();
|
|
1079
|
+
const close = page.getByTestId("jskit-shell-back");
|
|
1080
|
+
await expect(close).toHaveAttribute("data-action", "close");
|
|
1081
|
+
await expect(close).toHaveAccessibleName("Cancel");
|
|
1082
|
+
// The close and Save, with no Cancel beside them.
|
|
1083
|
+
await expect(page.getByTestId("jskit-shell-app-bar").getByRole("button")).toHaveCount(2);
|
|
1084
|
+
await close.click();
|
|
1085
|
+
await expect(page).toHaveURL(/\/home\/actions\?view=table$/u);
|
|
1086
|
+
await expect(page.getByTestId("jskit-shell-back")).toHaveCount(0);
|
|
1087
|
+
// The close replaced the form's entry, so Back doesn't reopen it.
|
|
1088
|
+
await page.goBack();
|
|
1089
|
+
await expect(page).toHaveURL(/\/home\/actions\?view=table$/u);
|
|
448
1090
|
await page.close();
|
|
449
1091
|
} finally {
|
|
450
1092
|
await browser?.close();
|
|
@@ -452,83 +1094,111 @@ test("shell-web's app bar fills with surface-container once the page scrolls und
|
|
|
452
1094
|
}
|
|
453
1095
|
});
|
|
454
1096
|
|
|
455
|
-
test("
|
|
1097
|
+
test("on a phone, the bar keeps one trailing item and moves the page actions and its other items into one menu", {
|
|
456
1098
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
457
|
-
timeout:
|
|
1099
|
+
timeout: 90_000
|
|
458
1100
|
}, async () => {
|
|
459
1101
|
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
460
1102
|
let browser;
|
|
461
1103
|
try {
|
|
462
1104
|
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
1105
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 } });
|
|
1106
|
+
// Tools, status and the account avatar: the list keeps the avatar, nearest the corner, and the overflow menu holds
|
|
1107
|
+
// every page action, then the tools and the status.
|
|
1108
|
+
await page.goto("/home/actions?topRight=3");
|
|
1109
|
+
const bar = page.getByTestId("jskit-shell-app-bar");
|
|
1110
|
+
const overflow = bar.getByTestId("jskit-shell-page-actions-overflow");
|
|
1111
|
+
const barItems = () =>
|
|
1112
|
+
bar.locator(".shell-layout__top-right [data-testid=fixture-status]").evaluateAll((items) =>
|
|
1113
|
+
items.map((item) => item.getAttribute("aria-label"))
|
|
1114
|
+
);
|
|
1115
|
+
assert.deepEqual(await barItems(), ["Account"]);
|
|
1116
|
+
await expect(bar.locator(".shell-page-action")).toHaveCount(0);
|
|
1117
|
+
await overflow.click();
|
|
1118
|
+
await expect(page.getByRole("menu")).toBeVisible();
|
|
1119
|
+
await expect(page.getByRole("menuitem")).toHaveText(["Edit", "Export", "Open site", "Delete", "Duplicate"]);
|
|
1120
|
+
const items = page.getByTestId("jskit-shell-page-actions-overflow-items");
|
|
1121
|
+
await expect(items.getByTestId("fixture-status")).toHaveCount(2);
|
|
1122
|
+
await expect(items.getByRole("button", { name: "Tools", exact: true })).toBeVisible();
|
|
1123
|
+
await expect(items.getByRole("button", { name: "Status", exact: true })).toBeVisible();
|
|
1124
|
+
await page.keyboard.press("Escape");
|
|
1125
|
+
await expect(page.getByRole("menu")).toBeHidden();
|
|
1126
|
+
const room = () =>
|
|
1127
|
+
page.evaluate(() => {
|
|
1128
|
+
const title = document.querySelector("[data-testid=jskit-shell-page-title]");
|
|
1129
|
+
const trailing = Array.from(document.querySelectorAll("[data-testid=jskit-shell-app-bar] .v-btn")).at(-1);
|
|
1130
|
+
return {
|
|
1131
|
+
title: Math.round(title.getBoundingClientRect().width),
|
|
1132
|
+
clipped: title.scrollWidth > title.clientWidth + 1,
|
|
1133
|
+
right: Math.round(trailing.getBoundingClientRect().right)
|
|
1134
|
+
};
|
|
467
1135
|
});
|
|
468
|
-
|
|
469
|
-
|
|
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
|
-
// A title that is also a switcher: the menu activator is inside the h1, which keeps its id and focus target.
|
|
477
|
-
const title = ownBar.getByRole("heading", { level: 1 });
|
|
478
|
-
await expect(title, at).toHaveAttribute("id", "jskit-shell-page-title");
|
|
479
|
-
await expect(title, at).toHaveAttribute("tabindex", "-1");
|
|
480
|
-
await title.getByRole("button", { name: "Studio" }).click();
|
|
481
|
-
await expect(page.getByText("Other studio", { exact: true }), at).toBeVisible();
|
|
482
|
-
await page.keyboard.press("Escape");
|
|
483
|
-
await expect(page.getByText("Other studio", { exact: true }), at).toBeHidden();
|
|
484
|
-
|
|
485
|
-
// An inner page: Up, its title and its actions, in the app's own bar; Up returns along the trail.
|
|
486
|
-
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
487
|
-
await expect(page).toHaveURL(/\/home\/studio\/ada$/u);
|
|
488
|
-
await expect(ownBar.getByTestId("jskit-shell-page-title"), at).toHaveText("Ada Lovelace");
|
|
489
|
-
await expect(ownBar.getByTestId("jskit-shell-back"), at).toHaveAccessibleName("Back");
|
|
490
|
-
await expect(ownBar.getByRole("button", { name: "Run" }), at).toBeVisible();
|
|
491
|
-
await pressShellBack(page);
|
|
492
|
-
await expect(page).toHaveURL(/\/home\/studio$/u);
|
|
493
|
-
await expect(shellBackButton(page), at).toHaveCount(0);
|
|
1136
|
+
const list = await room();
|
|
1137
|
+
assert.ok(list.title >= 96 && !list.clipped, `the list's title keeps its room (${list.title}px)`);
|
|
1138
|
+
assert.ok(list.right <= 390, `the avatar is in the window (${list.right}px)`);
|
|
494
1139
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
1140
|
+
// A form's Save is its one trailing item, so the avatar joins the tools and the status in the menu.
|
|
1141
|
+
await page.getByRole("link", { name: "New entry", exact: true }).click();
|
|
1142
|
+
await expect(bar.getByRole("button", { name: "Save", exact: true })).toBeVisible();
|
|
1143
|
+
await expect(page.getByTestId("jskit-shell-back")).toHaveAttribute("data-action", "close");
|
|
1144
|
+
assert.deepEqual(await barItems(), []);
|
|
1145
|
+
await overflow.click();
|
|
1146
|
+
await expect(items.getByTestId("fixture-status")).toHaveCount(3);
|
|
1147
|
+
await expect(page.getByRole("menuitem")).toHaveCount(0);
|
|
1148
|
+
await expect(items.getByRole("button", { name: "Account", exact: true })).toBeVisible();
|
|
1149
|
+
await page.keyboard.press("Escape");
|
|
1150
|
+
await expect(items).toBeHidden();
|
|
1151
|
+
const form = await room();
|
|
1152
|
+
assert.ok(form.title >= 96 && !form.clipped, `the form's title keeps its room (${form.title}px)`);
|
|
1153
|
+
assert.ok(form.right <= 390, `Save is in the window (${form.right}px)`);
|
|
1154
|
+
|
|
1155
|
+
// Wider windows keep every item in the bar.
|
|
1156
|
+
await page.setViewportSize({ width: 1280, height: 900 });
|
|
1157
|
+
await expect(bar.getByTestId("fixture-status")).toHaveCount(3);
|
|
1158
|
+
await page.close();
|
|
501
1159
|
} finally {
|
|
502
1160
|
await browser?.close();
|
|
503
1161
|
await stopProcess(vite);
|
|
504
1162
|
}
|
|
505
1163
|
});
|
|
506
1164
|
|
|
507
|
-
|
|
1165
|
+
function shellPageActionButton(page, name) {
|
|
1166
|
+
return page.getByTestId("jskit-shell-app-bar").getByRole("button", { name, exact: true });
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
test("a segmented button and a button group in a filter row's narrow column keep 12dp segments and whole labels", {
|
|
508
1170
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
509
|
-
timeout:
|
|
1171
|
+
timeout: 60_000
|
|
510
1172
|
}, async () => {
|
|
511
1173
|
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
512
1174
|
let browser;
|
|
513
1175
|
try {
|
|
514
1176
|
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
1177
|
+
for (const viewport of [{ width: 1440, height: 900 }, { width: 390, height: 844 }]) {
|
|
1178
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport });
|
|
1179
|
+
await page.goto("/home/components");
|
|
1180
|
+
for (const testId of ["fixture-segmented-two", "fixture-button-group"]) {
|
|
1181
|
+
const at = `${testId} at ${viewport.width}px`;
|
|
1182
|
+
const group = await page.getByTestId(testId).evaluate((element) => ({
|
|
1183
|
+
scrolls: element.scrollWidth > element.clientWidth + 1,
|
|
1184
|
+
widths: `group ${element.clientWidth}/${element.scrollWidth}px in a ${element.parentElement.clientWidth}px row: ${window.getComputedStyle(element.parentElement).gridTemplateColumns}`,
|
|
1185
|
+
segments: Array.from(element.querySelectorAll(":scope > .v-btn")).map((segment) => {
|
|
1186
|
+
const style = window.getComputedStyle(segment);
|
|
1187
|
+
const content = segment.querySelector(".v-btn__content");
|
|
1188
|
+
return {
|
|
1189
|
+
padding: [style.paddingInlineStart, style.paddingInlineEnd],
|
|
1190
|
+
cut: content.scrollWidth > content.clientWidth,
|
|
1191
|
+
room: segment.getBoundingClientRect().width - content.scrollWidth
|
|
1192
|
+
};
|
|
1193
|
+
})
|
|
1194
|
+
}));
|
|
1195
|
+
assert.equal(group.scrolls, false, `${at}: no segment scrolls inside the group (${group.widths})`);
|
|
1196
|
+
for (const segment of group.segments) {
|
|
1197
|
+
assert.deepEqual(segment.padding, ["12px", "12px"], `${at}: Material 3's 12dp segment sides`);
|
|
1198
|
+
assert.equal(segment.cut, false, `${at}: the whole label shows`);
|
|
1199
|
+
assert.ok(segment.room >= 23, `${at}: the label keeps its 12dp each side (${segment.room}px)`);
|
|
1200
|
+
}
|
|
526
1201
|
}
|
|
527
|
-
assert.equal(Math.round((await page.locator("main").boundingBox()).x), 0, `${at}: the page starts at the window's edge`);
|
|
528
|
-
// Its title and Up stay in the app bar; Up returns to the declared parent on another surface, which has navigation.
|
|
529
|
-
await pressShellBack(page);
|
|
530
|
-
await expect(page).toHaveURL(/\/home$/u);
|
|
531
|
-
await expect(page.getByTestId(navigation[viewport.name]), at).toBeVisible();
|
|
532
1202
|
await page.close();
|
|
533
1203
|
}
|
|
534
1204
|
} finally {
|
|
@@ -537,87 +1207,29 @@ test("a surface with no navigation draws no navigation bar, rail, drawer or menu
|
|
|
537
1207
|
}
|
|
538
1208
|
});
|
|
539
1209
|
|
|
540
|
-
|
|
1210
|
+
// A dialog is, with a menu, one of Vuetify's root defaults providers: under any VDialog default, an expansion panel
|
|
1211
|
+
// around the dialog re-rendering rebuilds the dialog's defaults, its virtual-scroll list, given its items anew, loses
|
|
1212
|
+
// their heights, and scrollToIndex gives up (material-web's README, Upstream workarounds). JSKIT sets no VDialog
|
|
1213
|
+
// defaults; this fails with `VDialog: { VCard: {} }` in them.
|
|
1214
|
+
test("a virtual-scroll list in a dialog reaches its last item after the page around it re-renders", {
|
|
541
1215
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
542
|
-
timeout:
|
|
1216
|
+
timeout: 60_000
|
|
543
1217
|
}, async () => {
|
|
544
1218
|
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
545
1219
|
let browser;
|
|
546
1220
|
try {
|
|
547
1221
|
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
548
1222
|
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 900 } });
|
|
549
|
-
await page.goto("/home/
|
|
550
|
-
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
for (const [id, height] of [[`fixture-button-${size}`, textHeight], [`fixture-icon-button-${size}`, iconHeight]]) {
|
|
559
|
-
const button = page.getByTestId(id);
|
|
560
|
-
const box = await button.boundingBox();
|
|
561
|
-
assert.equal(Math.round(box.height), height, `${id} keeps its visual height`);
|
|
562
|
-
const target = await button.evaluate((element) => {
|
|
563
|
-
const style = window.getComputedStyle(element, "::before");
|
|
564
|
-
return { width: Number.parseFloat(style.width), height: Number.parseFloat(style.height) };
|
|
565
|
-
});
|
|
566
|
-
assert.equal(Math.round(target.height), Math.max(48, height), `${id} touch target height`);
|
|
567
|
-
assert.ok(target.width >= 48, `${id} touch target width ${target.width}`);
|
|
568
|
-
if (height < 48) {
|
|
569
|
-
// A tap just above the visual, inside the touch target, reaches the button.
|
|
570
|
-
const point = [box.x + box.width / 2, box.y - (48 - height) / 2 + 1];
|
|
571
|
-
const hit = await page.evaluate(([x, y]) => document.elementFromPoint(x, y)?.closest(".v-btn")?.dataset.testid, point);
|
|
572
|
-
assert.equal(hit, id, `${id} answers inside its touch target`);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
const long = page.getByTestId("fixture-long-label");
|
|
577
|
-
const label = await long.evaluate((element) => {
|
|
578
|
-
const content = element.querySelector(".v-btn__content");
|
|
579
|
-
const style = window.getComputedStyle(content);
|
|
580
|
-
return {
|
|
581
|
-
buttonWidth: element.getBoundingClientRect().width,
|
|
582
|
-
buttonRight: element.getBoundingClientRect().right,
|
|
583
|
-
contentRight: content.getBoundingClientRect().right,
|
|
584
|
-
clipped: content.scrollWidth > content.clientWidth,
|
|
585
|
-
textOverflow: style.textOverflow,
|
|
586
|
-
height: element.getBoundingClientRect().height
|
|
587
|
-
};
|
|
588
|
-
});
|
|
589
|
-
assert.ok(label.buttonWidth <= 160.5, `the long button stays in its 160px (${label.buttonWidth})`);
|
|
590
|
-
assert.ok(label.contentRight <= label.buttonRight + 0.5, "the label stays inside its button");
|
|
591
|
-
assert.equal(label.clipped, true);
|
|
592
|
-
assert.equal(label.textOverflow, "ellipsis");
|
|
593
|
-
assert.equal(Math.round(label.height), 40, "the label stays on one line");
|
|
594
|
-
// A touch target reaching past a scroll container's corner adds no scrollbar.
|
|
595
|
-
const corner = await page.getByTestId("fixture-button-corner").evaluate((element) => ({
|
|
596
|
-
extraWidth: element.scrollWidth - element.clientWidth,
|
|
597
|
-
extraHeight: element.scrollHeight - element.clientHeight
|
|
598
|
-
}));
|
|
599
|
-
assert.deepEqual(corner, { extraWidth: 0, extraHeight: 0 });
|
|
600
|
-
// FABs keep Material 3's sizes, not the common button's 40dp.
|
|
601
|
-
for (const [id, width, height] of [
|
|
602
|
-
["fixture-fab", 56, 56],
|
|
603
|
-
["fixture-fab-small", 40, 40],
|
|
604
|
-
["fixture-fab-large", 96, 96],
|
|
605
|
-
["fixture-fab-extended", null, 56]
|
|
606
|
-
]) {
|
|
607
|
-
const box = await page.getByTestId(id).locator(".v-btn").boundingBox();
|
|
608
|
-
assert.equal(Math.round(box.height), height, `${id} height`);
|
|
609
|
-
if (width) assert.equal(Math.round(box.width), width, `${id} width`);
|
|
610
|
-
}
|
|
611
|
-
// An elevated card has its level-1 shadow; flat and tonal cards have none.
|
|
612
|
-
const shadows = {};
|
|
613
|
-
for (const variant of ["elevated", "flat", "tonal"]) {
|
|
614
|
-
shadows[variant] = await page.getByTestId(`fixture-card-${variant}`).evaluate((element) => window.getComputedStyle(element).boxShadow);
|
|
1223
|
+
await page.goto("/home/components");
|
|
1224
|
+
await page.getByRole("button", { name: "Open bookings" }).click();
|
|
1225
|
+
const list = page.getByTestId("fixture-bookings-scroll");
|
|
1226
|
+
await expect(list.getByText("Booking 1", { exact: true })).toBeVisible();
|
|
1227
|
+
for (const renders of ["1", "2"]) {
|
|
1228
|
+
await list.evaluate((element) => { element.scrollTop = 0; });
|
|
1229
|
+
await page.getByRole("button", { name: /^Last booking/u }).click();
|
|
1230
|
+
await expect(page.getByTestId("fixture-page-renders")).toHaveText(renders);
|
|
1231
|
+
await expect(list.getByText("Booking 40", { exact: true }), `jump ${renders}`).toBeVisible();
|
|
615
1232
|
}
|
|
616
|
-
// A shadow of zero offsets, blur and spread (Vuetify's level 0) draws nothing.
|
|
617
|
-
const drawsShadow = (shadow) => shadow !== "none" &&
|
|
618
|
-
shadow.replace(/rgba?\([^)]*\)/gu, "").split(/[\s,]+/u).some((length) => Number.parseFloat(length) > 0);
|
|
619
|
-
assert.equal(drawsShadow(shadows.elevated), true, shadows.elevated);
|
|
620
|
-
assert.deepEqual([drawsShadow(shadows.flat), drawsShadow(shadows.tonal)], [false, false], JSON.stringify(shadows));
|
|
621
1233
|
await page.close();
|
|
622
1234
|
} finally {
|
|
623
1235
|
await browser?.close();
|
|
@@ -625,126 +1237,199 @@ test("every button keeps its size, gets a 48dp touch target and ends a long labe
|
|
|
625
1237
|
}
|
|
626
1238
|
});
|
|
627
1239
|
|
|
628
|
-
|
|
629
|
-
await page.getByRole("link", { name: label, exact: true }).filter({ visible: true }).first().click();
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
test("shell-web Up follows the tab's trail, falls back to the parent and returns to where the person was", {
|
|
1240
|
+
test("segmented buttons, filter chips, fixed tabs, menus and dialog actions take Material 3's shapes and colours", {
|
|
633
1241
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
634
|
-
timeout:
|
|
1242
|
+
timeout: 90_000
|
|
635
1243
|
}, async () => {
|
|
636
1244
|
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
637
1245
|
let browser;
|
|
638
1246
|
try {
|
|
639
1247
|
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
1248
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 } });
|
|
1249
|
+
await page.goto("/home/components");
|
|
1250
|
+
const roles = {};
|
|
1251
|
+
for (const role of ["outline", "secondary-container", "on-secondary-container", "surface-container"]) {
|
|
1252
|
+
roles[role] = await readRoleColor(page, role);
|
|
1253
|
+
}
|
|
1254
|
+
const transparent = "rgba(0, 0, 0, 0)";
|
|
1255
|
+
|
|
1256
|
+
// The segmented button: a 40dp pill in the outline role, equal segments with 48dp touch targets, the selected one
|
|
1257
|
+
// in secondary-container leading with a check, which replaces a segment's own icon.
|
|
1258
|
+
const segmented = page.getByTestId("fixture-segmented");
|
|
1259
|
+
const group = await segmented.evaluate((element) => {
|
|
1260
|
+
const style = window.getComputedStyle(element);
|
|
1261
|
+
const segments = Array.from(element.querySelectorAll(":scope > .v-btn")).map((segment) => {
|
|
1262
|
+
const segmentStyle = window.getComputedStyle(segment);
|
|
1263
|
+
const check = window.getComputedStyle(segment.querySelector(".v-btn__content"), "::before");
|
|
1264
|
+
return {
|
|
1265
|
+
width: segment.getBoundingClientRect().width,
|
|
1266
|
+
height: segment.getBoundingClientRect().height,
|
|
1267
|
+
background: segmentStyle.backgroundColor,
|
|
1268
|
+
color: segmentStyle.color,
|
|
1269
|
+
check: check.content !== "none" && check.maskImage.includes("svg"),
|
|
1270
|
+
target: Number.parseFloat(window.getComputedStyle(segment, "::before").height)
|
|
1271
|
+
};
|
|
644
1272
|
});
|
|
645
|
-
|
|
646
|
-
|
|
1273
|
+
return {
|
|
1274
|
+
height: element.getBoundingClientRect().height,
|
|
1275
|
+
radius: Number.parseFloat(style.borderTopLeftRadius),
|
|
1276
|
+
border: [style.borderTopWidth, style.borderTopColor],
|
|
1277
|
+
segments
|
|
1278
|
+
};
|
|
1279
|
+
});
|
|
1280
|
+
assert.equal(Math.round(group.height), 40);
|
|
1281
|
+
assert.ok(group.radius >= 20, `the segmented button is a pill (${group.radius}px)`);
|
|
1282
|
+
assert.deepEqual(group.border, ["1px", roles.outline]);
|
|
1283
|
+
const widths = group.segments.map((segment) => segment.width);
|
|
1284
|
+
assert.ok(Math.max(...widths) - Math.min(...widths) <= 1, `equal segments: ${widths.join(", ")}`);
|
|
1285
|
+
// The pill's 1dp outline is inside its 40dp.
|
|
1286
|
+
assert.deepEqual(group.segments.map((segment) => Math.round(segment.height)), [38, 38, 38]);
|
|
1287
|
+
assert.deepEqual(group.segments.map((segment) => segment.target), [48, 48, 48]);
|
|
1288
|
+
assert.deepEqual(group.segments[0], { ...group.segments[0], background: roles["secondary-container"], color: roles["on-secondary-container"], check: true });
|
|
1289
|
+
assert.deepEqual([group.segments[1].background, group.segments[1].check], [transparent, false]);
|
|
1290
|
+
await segmented.getByRole("button", { name: "Month" }).click();
|
|
1291
|
+
// The selected container fades in.
|
|
1292
|
+
await expect.poll(() => segmented.getByRole("button", { name: "Month" }).evaluate((element) =>
|
|
1293
|
+
window.getComputedStyle(element).backgroundColor)).toBe(roles["secondary-container"]);
|
|
1294
|
+
const month = await segmented.getByRole("button", { name: "Month" }).evaluate((element) => ({
|
|
1295
|
+
background: window.getComputedStyle(element).backgroundColor,
|
|
1296
|
+
iconMask: window.getComputedStyle(element.querySelector(".v-btn__prepend .v-icon")).maskImage,
|
|
1297
|
+
glyph: window.getComputedStyle(element.querySelector(".v-btn__prepend svg")).visibility,
|
|
1298
|
+
contentCheck: window.getComputedStyle(element.querySelector(".v-btn__content"), "::before").content
|
|
1299
|
+
}));
|
|
1300
|
+
assert.equal(month.background, roles["secondary-container"]);
|
|
1301
|
+
assert.match(month.iconMask, /svg/u);
|
|
1302
|
+
assert.equal(month.glyph, "hidden");
|
|
1303
|
+
assert.equal(month.contentCheck, "none");
|
|
647
1304
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
1305
|
+
// Filter chips: 32dp, 8dp corners, an outline-role border unselected, secondary-container with a check selected,
|
|
1306
|
+
// and a 48dp touch target; in a chip group and toggled with aria-pressed alike.
|
|
1307
|
+
const chip = (id) => page.getByTestId(id).evaluate((element) => {
|
|
1308
|
+
const style = window.getComputedStyle(element);
|
|
1309
|
+
const check = window.getComputedStyle(element, "::before");
|
|
1310
|
+
return {
|
|
1311
|
+
height: Math.round(element.getBoundingClientRect().height),
|
|
1312
|
+
radius: style.borderTopLeftRadius,
|
|
1313
|
+
background: style.backgroundColor,
|
|
1314
|
+
border: [style.borderTopWidth, style.borderTopColor],
|
|
1315
|
+
check: Boolean(element.querySelector(".v-chip__filter .v-icon")?.checkVisibility()) ||
|
|
1316
|
+
(check.content !== "none" && check.maskImage.includes("svg")),
|
|
1317
|
+
target: Math.round(Number.parseFloat(window.getComputedStyle(element, "::after").height))
|
|
1318
|
+
};
|
|
1319
|
+
});
|
|
1320
|
+
const selected = { height: 32, radius: "8px", background: roles["secondary-container"], check: true, target: 48 };
|
|
1321
|
+
const unselected = { height: 32, radius: "8px", background: transparent, border: ["1px", roles.outline], check: false, target: 48 };
|
|
1322
|
+
const open = await chip("fixture-chip-open");
|
|
1323
|
+
assert.deepEqual({ ...open, border: undefined }, { ...selected, border: undefined });
|
|
1324
|
+
assert.deepEqual(await chip("fixture-chip-closed"), unselected);
|
|
1325
|
+
const starred = await chip("fixture-pressed-chip");
|
|
1326
|
+
assert.deepEqual({ ...starred, border: undefined }, { ...selected, border: undefined });
|
|
1327
|
+
await page.getByTestId("fixture-pressed-chip").click();
|
|
1328
|
+
await expect(page.getByTestId("fixture-pressed-chip")).toHaveAttribute("aria-pressed", "false");
|
|
1329
|
+
assert.deepEqual(await chip("fixture-pressed-chip"), unselected);
|
|
1330
|
+
const assist = await page.getByTestId("fixture-outlined-chip").evaluate((element) => window.getComputedStyle(element).borderTopColor);
|
|
1331
|
+
assert.equal(assist, roles.outline);
|
|
654
1332
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
await expect(page).toHaveURL(/\/home\/suppliers\/acme$/u);
|
|
671
|
-
await page.goForward();
|
|
672
|
-
await expect(page).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
673
|
-
await pressShellBack(page);
|
|
674
|
-
await expect(page).toHaveURL(/\/home\/contacts$/u);
|
|
675
|
-
await expect(shellBackButton(page)).toHaveCount(0);
|
|
1333
|
+
// Five fixed tabs share a phone's width without a 90dp minimum; tabs whose labels can't fit scroll, uncut.
|
|
1334
|
+
const tabs = (id) => page.getByTestId(id).evaluate((element) => {
|
|
1335
|
+
const container = element.querySelector(".v-slide-group__container");
|
|
1336
|
+
return {
|
|
1337
|
+
overflowing: container.scrollWidth > container.clientWidth + 1,
|
|
1338
|
+
widths: Array.from(element.querySelectorAll(".v-tab")).map((tab) => tab.getBoundingClientRect().width),
|
|
1339
|
+
cut: Array.from(element.querySelectorAll(".v-tab .v-btn__content")).some((label) => label.scrollWidth > label.clientWidth + 1)
|
|
1340
|
+
};
|
|
1341
|
+
});
|
|
1342
|
+
const grow = await tabs("fixture-grow-tabs");
|
|
1343
|
+
assert.equal(grow.overflowing, false, JSON.stringify(grow));
|
|
1344
|
+
assert.ok(Math.max(...grow.widths) - Math.min(...grow.widths) <= 1, `equal tabs: ${grow.widths.join(", ")}`);
|
|
1345
|
+
assert.ok(Math.min(...grow.widths) < 90, `tabs narrower than Vuetify's 90px minimum: ${grow.widths.join(", ")}`);
|
|
1346
|
+
const long = await tabs("fixture-long-tabs");
|
|
1347
|
+
assert.deepEqual([long.overflowing, long.cut], [true, false], JSON.stringify(long));
|
|
676
1348
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
1349
|
+
// A menu's own list is surface-container at level 2; a list in a rich menu panel is a plain list.
|
|
1350
|
+
const list = (id) => page.getByTestId(id).evaluate((element) => {
|
|
1351
|
+
const style = window.getComputedStyle(element);
|
|
1352
|
+
return { background: style.backgroundColor, shadow: style.boxShadow !== "none" && /[1-9]px/u.test(style.boxShadow) };
|
|
1353
|
+
});
|
|
1354
|
+
await page.getByRole("button", { name: "Plain menu" }).click();
|
|
1355
|
+
assert.deepEqual(await list("fixture-menu-list"), { background: roles["surface-container"], shadow: true });
|
|
1356
|
+
await page.keyboard.press("Escape");
|
|
1357
|
+
await page.getByRole("button", { name: "Rich menu" }).click();
|
|
1358
|
+
assert.deepEqual(await list("fixture-panel-list"), { background: transparent, shadow: false });
|
|
1359
|
+
await page.keyboard.press("Escape");
|
|
684
1360
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
1361
|
+
// A disabled filled button is one pill: its state layer, shown at rest, takes the button's corners instead of
|
|
1362
|
+
// reaching out square past them.
|
|
1363
|
+
const disabled = await page.getByTestId("fixture-disabled-button").evaluate((element) => ({
|
|
1364
|
+
radius: window.getComputedStyle(element).borderTopLeftRadius,
|
|
1365
|
+
layers: Array.from(element.querySelectorAll(":scope > .v-btn__overlay, :scope > .v-btn__underlay"))
|
|
1366
|
+
.map((layer) => window.getComputedStyle(layer).borderTopLeftRadius)
|
|
1367
|
+
}));
|
|
1368
|
+
assert.ok(Number.parseFloat(disabled.radius) >= 20, `the disabled button is a pill (${disabled.radius})`);
|
|
1369
|
+
assert.deepEqual(disabled.layers, disabled.layers.map(() => disabled.radius));
|
|
1370
|
+
assert.ok(disabled.layers.length > 0);
|
|
1371
|
+
// Its container is on-surface at 12% and its label at 38%, over the primary its colour gives it.
|
|
1372
|
+
const onSurface = (await readRoleColor(page, "on-surface")).replace(/^rgb\((.*)\)$/u, "$1");
|
|
1373
|
+
assert.deepEqual(
|
|
1374
|
+
await page.getByTestId("fixture-disabled-button").evaluate((element) => [
|
|
1375
|
+
window.getComputedStyle(element).backgroundColor,
|
|
1376
|
+
window.getComputedStyle(element).color
|
|
1377
|
+
]),
|
|
1378
|
+
[`rgba(${onSurface}, 0.12)`, `rgba(${onSurface}, 0.38)`]
|
|
1379
|
+
);
|
|
692
1380
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
await page.getByRole("link", { name: "Supplier", exact: true }).click();
|
|
696
|
-
await page.evaluate(() => {
|
|
697
|
-
window.__fixtureBlockedRecords = ["ada"];
|
|
698
|
-
});
|
|
699
|
-
await pressShellBack(page);
|
|
700
|
-
await expect(page).toHaveURL(/\/home\/suppliers$/u);
|
|
701
|
-
await page.evaluate(() => {
|
|
702
|
-
window.__fixtureBlockedRecords = [];
|
|
703
|
-
});
|
|
1381
|
+
// A button to the page above this one isn't active (selected) here.
|
|
1382
|
+
await expect(page.getByTestId("fixture-home-button")).not.toHaveClass(/v-btn--active/u);
|
|
704
1383
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
const
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
await expect.poll(() => page.evaluate(() => window.scrollY)).toBeGreaterThan(scrollBefore - 3);
|
|
716
|
-
assert.ok(Math.abs(await page.evaluate(() => window.scrollY) - scrollBefore) <= 2, `${at}: scroll was not restored.`);
|
|
717
|
-
await expect(page.getByRole("link", { name: "Contact 35", exact: true })).toBeFocused();
|
|
718
|
-
|
|
719
|
-
// A pasted supplier link goes Up to the Suppliers list.
|
|
720
|
-
const pasted = await context.newPage();
|
|
721
|
-
await pasted.goto("/home/suppliers/acme");
|
|
722
|
-
await pressShellBack(pasted);
|
|
723
|
-
await expect(pasted).toHaveURL(/\/home\/suppliers$/u);
|
|
724
|
-
await expect(shellPageTitle(pasted)).toHaveText("Suppliers");
|
|
725
|
-
// A pasted edit link goes Up to its record: the parent "/contacts/:id" takes the id from the route.
|
|
726
|
-
await pasted.goto("/home/contacts/ada/edit");
|
|
727
|
-
await expect(shellPageTitle(pasted)).toHaveText("Edit contact");
|
|
728
|
-
await pressShellBack(pasted);
|
|
729
|
-
await expect(pasted).toHaveURL(/\/home\/contacts\/ada$/u);
|
|
730
|
-
await pasted.close();
|
|
731
|
-
|
|
732
|
-
// List-detail: beside the visible list, General has no arrow; alone, it has one back to the list.
|
|
733
|
-
await page.goto("/home/settings");
|
|
734
|
-
await page.getByRole("link", { name: "General", exact: true }).click();
|
|
735
|
-
await expect(page).toHaveURL(/\/home\/settings\/general$/u);
|
|
736
|
-
if (viewport.name === "expanded") {
|
|
737
|
-
await expect(shellBackButton(page)).toHaveCount(0);
|
|
738
|
-
await expect(page.getByRole("link", { name: "General", exact: true })).toBeVisible();
|
|
739
|
-
} else {
|
|
740
|
-
await pressShellBack(page);
|
|
741
|
-
await expect(page).toHaveURL(/\/home\/settings$/u);
|
|
742
|
-
}
|
|
1384
|
+
// A pagination's current page is a light activated layer inside its shape, so its number shows.
|
|
1385
|
+
const current = await page.getByTestId("fixture-pagination").locator(".v-pagination__item--is-active .v-btn").evaluate((element) => {
|
|
1386
|
+
const overlay = window.getComputedStyle(element.querySelector(":scope > .v-btn__overlay"));
|
|
1387
|
+
return {
|
|
1388
|
+
opacity: Number.parseFloat(overlay.opacity),
|
|
1389
|
+
radius: overlay.borderTopLeftRadius === window.getComputedStyle(element).borderTopLeftRadius
|
|
1390
|
+
};
|
|
1391
|
+
});
|
|
1392
|
+
assert.ok(current.opacity > 0 && current.opacity <= 0.2, `the current page's layer (${current.opacity})`);
|
|
1393
|
+
assert.equal(current.radius, true);
|
|
743
1394
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
1395
|
+
// A shown placeholder is on-surface-variant at full strength; a labelled field hides it until active.
|
|
1396
|
+
const placeholder = (id) => page.getByTestId(id).locator("input").evaluate((element) => {
|
|
1397
|
+
const style = window.getComputedStyle(element, "::placeholder");
|
|
1398
|
+
return [style.color, style.opacity];
|
|
1399
|
+
});
|
|
1400
|
+
assert.deepEqual(await placeholder("fixture-placeholder"), [await readRoleColor(page, "on-surface-variant"), "1"]);
|
|
1401
|
+
assert.equal((await placeholder("fixture-labelled"))[1], "0");
|
|
1402
|
+
|
|
1403
|
+
// Cards and expansion panels rest flat; a dialog keeps its level 3.
|
|
1404
|
+
const drawsShadow = (shadow) => shadow !== "none" &&
|
|
1405
|
+
shadow.replace(/rgba?\([^)]*\)/gu, "").split(/[\s,]+/u).some((length) => Number.parseFloat(length) > 0);
|
|
1406
|
+
const shadowOf = (locator) => locator.evaluate((element) => window.getComputedStyle(element).boxShadow);
|
|
1407
|
+
const card = await shadowOf(page.getByTestId("fixture-card"));
|
|
1408
|
+
assert.equal(drawsShadow(card), false, card);
|
|
1409
|
+
const panels = await page.getByTestId("fixture-expansion-panels").evaluate((element) =>
|
|
1410
|
+
Array.from(element.querySelectorAll(".v-expansion-panel, .v-expansion-panel__shadow"))
|
|
1411
|
+
.map((part) => window.getComputedStyle(part).display === "none" ? "none" : window.getComputedStyle(part).boxShadow));
|
|
1412
|
+
assert.deepEqual(panels.map(drawsShadow), panels.map(() => false), JSON.stringify(panels));
|
|
1413
|
+
|
|
1414
|
+
// Dialog actions sit 24dp from the dialog's sides and bottom, 8dp apart, once the dialog has scaled in.
|
|
1415
|
+
await page.getByRole("button", { name: "Open dialog" }).click();
|
|
1416
|
+
const dialog = page.getByTestId("fixture-dialog");
|
|
1417
|
+
await expect(dialog).toBeVisible();
|
|
1418
|
+
const dialogActions = () => dialog.locator(".v-card-actions").evaluate((element) => {
|
|
1419
|
+
const style = window.getComputedStyle(element);
|
|
1420
|
+
const card = element.closest(".v-card").getBoundingClientRect();
|
|
1421
|
+
const buttons = Array.from(element.querySelectorAll(".v-btn")).map((button) => button.getBoundingClientRect());
|
|
1422
|
+
return {
|
|
1423
|
+
padding: [style.paddingTop, style.paddingRight, style.paddingBottom, style.paddingLeft],
|
|
1424
|
+
gap: Math.round(buttons[1].left - buttons[0].right),
|
|
1425
|
+
right: Math.round(card.right - buttons[1].right),
|
|
1426
|
+
bottom: Math.round(card.bottom - buttons[1].bottom)
|
|
1427
|
+
};
|
|
1428
|
+
});
|
|
1429
|
+
await expect.poll(dialogActions).toEqual({ padding: ["0px", "24px", "24px", "24px"], gap: 8, right: 24, bottom: 24 });
|
|
1430
|
+
const dialogShadow = await shadowOf(dialog);
|
|
1431
|
+
assert.equal(drawsShadow(dialogShadow), true, dialogShadow);
|
|
1432
|
+
await page.close();
|
|
748
1433
|
} finally {
|
|
749
1434
|
await browser?.close();
|
|
750
1435
|
await stopProcess(vite);
|