@jskit-ai/shell-web 0.2.44 → 0.2.45
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 +1 -0
- package/fixtures/app-environment-banner/vite.config.mjs +8 -2
- package/locales/en.json +3 -1
- package/package.json +3 -3
- package/src/client/appEnvironment/appEnvironmentBanner.js +18 -8
- package/test/appEnvironmentBanner.browser.test.js +18 -0
- package/test/appEnvironmentBanner.test.js +28 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- The environment banner of a staging page that real people use (its server has `STAGING_REACHES_REAL_PEOPLE=true`, so the page carries the kernel's `jskit-staging-reaches-real-people` tag) reads "Staging · real people", described as "Staging that real people use: email and text messages reach the people they are for, other messages are logged and payments use the sandbox.", in place of the test-copy wording; `installAppEnvironmentBanner` takes `reachesRealPeople`, read from the page when omitted. New message keys: `jskit.shell.appEnvironment.stagingRealPeople` and `stagingRealPeopleDescription`. Every other page's banner is unchanged.
|
|
5
6
|
- A navigation rail label never breaks inside a word. A label wider than the rail wraps between its words to a second line, as Material 3's rail labels do, and only a label that needs a third line ends its second in an ellipsis, as before; a single word wider than the rail now ends in an ellipsis too, where it was split across two lines ("Administrati" over "on").
|
|
6
7
|
- Closing a dialog no longer makes a closed modal navigation drawer or side sheet reachable. The page behind a dialog made every part `ShellLayout` marks `data-shell-page` live when the dialog closed, and when the layout mounted, the closed drawer and side sheet included, which Vuetify keeps `inert` while they are closed, so their off-screen destinations and content took keyboard focus and assistive technology read them. Now only the parts the dialog made inert are made live again; a part already inert stays so, and a drawer that closes behind the dialog (a window that narrows, a link in the dialog) is inert once the dialog closes.
|
|
7
8
|
- The page behind an open modal dialog is inert, as the WAI-ARIA dialog pattern has it and as the dialog's scrim already had it for the pointer: while a `v-dialog` or a `v-bottom-sheet` is open, `ShellLayout`'s app bar, rail, drawer, main (with the page's FAB and its other actions), navigation bar and side sheet carry `inert`, so they take no focus, assistive technology skips them and axe judges only the dialog, its target-size rule included. Before, the page stayed live in the accessibility tree under the scrim: axe's target-size rule judged a note's Edit button and a card link behind the scrim as targets, and an app had to narrow its axe checks to the topmost dialog. Vuetify's overlay layer, where it teleports dialogs, menus, tooltips and snackbars, is never inert, so a select or menu opened in the dialog works and a snackbar shown over it is announced; of two dialogs open at once, the lower is inert under the upper until that closes. The shell sees every dialog, an app's and JSKIT's own (`ShellErrorHost`'s, auth-web's `SecondFactorDialog`), by watching the document for Vuetify's open modal overlays (`.v-overlay--active[aria-modal="true"]`), with no dialog component of its own. The page is live again the moment its dialog closes or unmounts, before the dialog gives focus back, and focus then returns to the element that opened the dialog when it has nowhere else to be: Vuetify's own return to an activator runs while the page is still inert, and a dialog opened from `v-model`, with no activator, never had one. A dialog that closes by leaving its page leaves focus to the next page, and the page there is live. A dialog attached or contained inside the page (`attach`, `contained`) stays local to that part and leaves the page as it is. The parts the shell makes inert carry `data-shell-page`. An app that drew its own layout around `v-main` (with `useShellAppBar()`) does not get this.
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { fileURLToPath, URL } from "node:url";
|
|
2
2
|
import { defineConfig } from "vite";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
appEnvironment,
|
|
5
|
+
stagingReachesRealPeople,
|
|
6
|
+
withAppEnvironmentMeta
|
|
7
|
+
} from "@jskit-ai/kernel/shared/support/appEnvironment";
|
|
4
8
|
|
|
5
9
|
// The page names the server's APP_ENV as a JSKIT server or development server names it.
|
|
6
10
|
const appEnvironmentPage = {
|
|
7
11
|
name: "fixture-app-environment-page",
|
|
8
|
-
transformIndexHtml: (html) => withAppEnvironmentMeta(html, appEnvironment(process.env)
|
|
12
|
+
transformIndexHtml: (html) => withAppEnvironmentMeta(html, appEnvironment(process.env), {
|
|
13
|
+
reachesRealPeople: stagingReachesRealPeople(process.env)
|
|
14
|
+
})
|
|
9
15
|
};
|
|
10
16
|
|
|
11
17
|
export default defineConfig({
|
package/locales/en.json
CHANGED
|
@@ -52,7 +52,9 @@
|
|
|
52
52
|
"test": "Test",
|
|
53
53
|
"testDescription": "Test: emails and messages are logged, not sent; payments use the sandbox.",
|
|
54
54
|
"staging": "Staging",
|
|
55
|
-
"stagingDescription": "Staging: email and text messages reach only the staging test addresses, other messages are logged and payments use the sandbox."
|
|
55
|
+
"stagingDescription": "Staging: email and text messages reach only the staging test addresses, other messages are logged and payments use the sandbox.",
|
|
56
|
+
"stagingRealPeople": "Staging · real people",
|
|
57
|
+
"stagingRealPeopleDescription": "Staging that real people use: email and text messages reach the people they are for, other messages are logged and payments use the sandbox."
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/shell-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.45",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"./locales/en.json": "./locales/en.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@jskit-ai/architecture-inspector": "0.1.
|
|
50
|
+
"@jskit-ai/architecture-inspector": "0.1.28"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@jskit-ai/material-web": "0.1.9",
|
|
54
54
|
"@vue/compiler-sfc": "3.5.44"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@jskit-ai/kernel": "0.2.
|
|
57
|
+
"@jskit-ai/kernel": "0.2.29",
|
|
58
58
|
"pinia": "^4.0.3",
|
|
59
59
|
"vue": "^3.5.44",
|
|
60
60
|
"vue-router": "^5.3.1",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pageAppEnvironment } from "@jskit-ai/kernel/shared/support/appEnvironment";
|
|
1
|
+
import { pageAppEnvironment, pageStagingReachesRealPeople } from "@jskit-ai/kernel/shared/support/appEnvironment";
|
|
2
2
|
import { pageDocument } from "../browser.js";
|
|
3
3
|
import { useJskitText } from "../i18n.js";
|
|
4
4
|
|
|
@@ -7,8 +7,10 @@ const { t } = useJskitText();
|
|
|
7
7
|
const APP_ENVIRONMENT_BANNER_ID = "jskit-app-environment-banner";
|
|
8
8
|
// Every environment but production names itself on the page.
|
|
9
9
|
const BANNERED_ENVIRONMENTS = Object.freeze(["development", "test", "staging"]);
|
|
10
|
-
// Each bannered environment's label and description: `<prefix><environment>` and `<prefix><environment>Description
|
|
10
|
+
// Each bannered environment's label and description: `<prefix><environment>` and `<prefix><environment>Description`;
|
|
11
|
+
// a staging page that real people use reads `<prefix>stagingRealPeople` and its description instead.
|
|
11
12
|
const BANNER_TEXT_PREFIX = "jskit.shell.appEnvironment.";
|
|
13
|
+
const STAGING_REAL_PEOPLE_TEXT = "stagingRealPeople";
|
|
12
14
|
|
|
13
15
|
// A small tab hanging from the top edge, above everything, that never takes a click or a tap: it marks the page
|
|
14
16
|
// without covering a control the person needs. Amber with near-black text reads the same in light and dark themes.
|
|
@@ -34,16 +36,23 @@ function removeNothing() {}
|
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Shows the page's environment, "Development", "Test" or "Staging", from the page's APP_ENV meta tag, so everyone
|
|
37
|
-
* using a copy that is not production knows what it sends
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
* using a copy that is not production knows what it sends; a staging page that real people use shows
|
|
40
|
+
* "Staging · real people", saying its email and messages reach the people they are for. It needs no application
|
|
41
|
+
* code: the shell adds it to the page's body, outside the application's own layout. A production page, or a page
|
|
42
|
+
* that names no environment, gets none. Returns the function that removes it.
|
|
40
43
|
* @param {object} [options]
|
|
41
44
|
* @param {Document | null} [options.documentObject]
|
|
42
45
|
* @param {"development" | "test" | "staging" | "production" | ""} [options.environment] The page's environment; read
|
|
43
46
|
* from its meta tag when omitted.
|
|
47
|
+
* @param {boolean} [options.reachesRealPeople] Whether real people use this staging page; read from its meta tag
|
|
48
|
+
* when omitted.
|
|
44
49
|
* @returns {() => void}
|
|
45
50
|
*/
|
|
46
|
-
function installAppEnvironmentBanner({
|
|
51
|
+
function installAppEnvironmentBanner({
|
|
52
|
+
documentObject = pageDocument(),
|
|
53
|
+
environment = pageAppEnvironment(documentObject),
|
|
54
|
+
reachesRealPeople = pageStagingReachesRealPeople(documentObject)
|
|
55
|
+
} = {}) {
|
|
47
56
|
if (!BANNERED_ENVIRONMENTS.includes(environment) || !documentObject?.body ||
|
|
48
57
|
documentObject.getElementById(APP_ENVIRONMENT_BANNER_ID)) {
|
|
49
58
|
return removeNothing;
|
|
@@ -54,8 +63,9 @@ function installAppEnvironmentBanner({ documentObject = pageDocument(), environm
|
|
|
54
63
|
// A note read by its visible text, with the full sentence as its description. A label would make it a labelled
|
|
55
64
|
// element, which a browser test's field lookup such as `getByLabel("Email")` would also find.
|
|
56
65
|
banner.setAttribute("role", "note");
|
|
57
|
-
|
|
58
|
-
banner.
|
|
66
|
+
const text = environment === "staging" && reachesRealPeople === true ? STAGING_REAL_PEOPLE_TEXT : environment;
|
|
67
|
+
banner.setAttribute("aria-description", t(`${BANNER_TEXT_PREFIX}${text}Description`));
|
|
68
|
+
banner.textContent = t(`${BANNER_TEXT_PREFIX}${text}`);
|
|
59
69
|
// Through the style object, not a style attribute, so a strict content policy without inline styles allows it.
|
|
60
70
|
Object.assign(banner.style, APP_ENVIRONMENT_BANNER_STYLE);
|
|
61
71
|
documentObject.body.append(banner);
|
|
@@ -80,6 +80,24 @@ test("a development page shows the Development banner at every width, in light a
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
+
test("a staging page real people use shows Staging · real people, small at the narrowest width, taking no click", {
|
|
84
|
+
skip: !RUN_BROWSER_TEST
|
|
85
|
+
}, async (t) => {
|
|
86
|
+
const { vite, browser } = await startFixture(t, { APP_ENV: "staging", STAGING_REACHES_REAL_PEOPLE: "true" });
|
|
87
|
+
const page = await browser.newPage({ viewport: VIEWPORTS[0] });
|
|
88
|
+
await page.goto(vite.baseURL);
|
|
89
|
+
await page.waitForSelector("html[data-ready=true]");
|
|
90
|
+
const banner = page.getByTestId("jskit-app-environment-banner");
|
|
91
|
+
assert.equal(await banner.textContent(), "Staging · real people");
|
|
92
|
+
assert.equal(await banner.getAttribute("aria-description"), "Staging that real people use: email and text messages " +
|
|
93
|
+
"reach the people they are for, other messages are logged and payments use the sandbox.");
|
|
94
|
+
const box = await banner.boundingBox();
|
|
95
|
+
assert.ok(box.width < VIEWPORTS[0].width / 2, `small (${box.width})`);
|
|
96
|
+
assert.equal(await page.getByLabel("Email").count(), 1, "one Email match");
|
|
97
|
+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
|
98
|
+
assert.equal(await page.locator("#under-banner").textContent(), "Pressed 1 times");
|
|
99
|
+
});
|
|
100
|
+
|
|
83
101
|
test("a test page shows Test and a staging page Staging, at the narrowest width; a production page shows none", {
|
|
84
102
|
skip: !RUN_BROWSER_TEST
|
|
85
103
|
}, async (t) => {
|
|
@@ -2,8 +2,9 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { createAppEnvironmentBannerRuntime, installAppEnvironmentBanner } from "../src/client/appEnvironment/appEnvironmentBanner.js";
|
|
4
4
|
|
|
5
|
-
// The part of a document the banner uses: a body to append to, elements, and lookup by id.
|
|
6
|
-
|
|
5
|
+
// The part of a document the banner uses: a body to append to, elements, and lookup by id. Its meta tags answer
|
|
6
|
+
// `environment`, and the real-people tag `realPeople` when given.
|
|
7
|
+
function fakeDocument(environment, realPeople) {
|
|
7
8
|
const appended = [];
|
|
8
9
|
const documentObject = {
|
|
9
10
|
appended,
|
|
@@ -18,7 +19,10 @@ function fakeDocument(environment) {
|
|
|
18
19
|
return { tag, style: {}, attributes, setAttribute: (name, value) => { attributes[name] = value; } };
|
|
19
20
|
},
|
|
20
21
|
getElementById: (id) => appended.find((element) => element.id === id) || null,
|
|
21
|
-
querySelector: () =>
|
|
22
|
+
querySelector: (selector) => {
|
|
23
|
+
const content = selector.includes("jskit-staging-reaches-real-people") ? realPeople : environment;
|
|
24
|
+
return content === undefined ? null : { getAttribute: () => content };
|
|
25
|
+
}
|
|
22
26
|
};
|
|
23
27
|
return documentObject;
|
|
24
28
|
}
|
|
@@ -50,6 +54,27 @@ test("a development, test or staging page gets one banner naming its environment
|
|
|
50
54
|
}
|
|
51
55
|
});
|
|
52
56
|
|
|
57
|
+
test("a staging page real people use says so in its banner, and only a staging page can", () => {
|
|
58
|
+
const documentObject = fakeDocument("staging", "true");
|
|
59
|
+
installAppEnvironmentBanner({ documentObject });
|
|
60
|
+
const [banner] = documentObject.appended;
|
|
61
|
+
assert.equal(banner.textContent, "Staging · real people");
|
|
62
|
+
assert.equal(banner.attributes["aria-description"], "Staging that real people use: email and text messages reach the " +
|
|
63
|
+
"people they are for, other messages are logged and payments use the sandbox.");
|
|
64
|
+
assert.equal(banner.style.pointerEvents, "none");
|
|
65
|
+
for (const environment of ["development", "test"]) {
|
|
66
|
+
const other = fakeDocument(environment, "true");
|
|
67
|
+
installAppEnvironmentBanner({ documentObject: other });
|
|
68
|
+
assert.equal(other.appended[0].textContent, environment === "test" ? "Test" : "Development", environment);
|
|
69
|
+
}
|
|
70
|
+
const production = fakeDocument("production", "true");
|
|
71
|
+
installAppEnvironmentBanner({ documentObject: production });
|
|
72
|
+
assert.equal(production.appended.length, 0, "production never gets one");
|
|
73
|
+
const plain = fakeDocument("staging");
|
|
74
|
+
installAppEnvironmentBanner({ documentObject: plain });
|
|
75
|
+
assert.equal(plain.appended[0].textContent, "Staging", "without the tag, the test-copy wording");
|
|
76
|
+
});
|
|
77
|
+
|
|
53
78
|
test("a production page, a page that names no environment and no document get no banner", () => {
|
|
54
79
|
for (const environment of ["production", "", "live", undefined]) {
|
|
55
80
|
const documentObject = fakeDocument(environment);
|