@jskit-ai/shell-web 0.2.25 → 0.2.27
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 +2 -0
- package/fixtures/test-copy-banner/index.html +15 -0
- package/fixtures/test-copy-banner/src/main.js +13 -0
- package/fixtures/test-copy-banner/vite.config.mjs +17 -0
- package/locales/en.json +4 -0
- package/package.json +3 -3
- package/src/client/providers/ShellWebClientProvider.js +7 -1
- package/src/client/sideEffects/testCopyBanner.js +86 -0
- package/test/provider.test.js +2 -1
- package/test/testCopyBanner.browser.test.js +89 -0
- package/test/testCopyBanner.test.js +64 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- The "Test copy" banner has no accessible label any more: it is a note read by its visible "Test copy", with "Test copy: emails, messages and payments are simulated, not sent." as its `aria-description`. The label made it a labelled element, so an application's browser test looking up its Email field with Playwright's inexact `page.getByLabel("Email")` found the banner too and failed strict mode.
|
|
6
|
+
- A page whose server simulates side effects (`SIDE_EFFECTS` is not `live`) shows a small amber "Test copy" tab at the top centre, with no application code: the shell adds it at boot from the page's `jskit-side-effects` meta tag and removes it at shutdown. It never takes a click or a tap, reads the same in light and dark themes, and its accessible label says emails, messages and payments are simulated. A live page, or a page that names no setting (a mobile bundle), has none.
|
|
5
7
|
- Menu and tab links, and the navigation bar's swipe destinations, take the current surface's params from the URL when the route declares none, as on the not-found route that catches any path: on `/w/acme/no-such-page` a link to the workspace surface goes to `/w/acme/...`. They threw "Missing required surface route params" on every render instead, so a workspace surface's not-found page showed that error in an alert, drew its drawer without destinations and logged the error again each time the shell redrew. The route's own params still win, and a link to a surface whose params neither the route nor the URL holds still throws.
|
|
6
8
|
- `shell.bootstrap.refresh()` runs one bootstrap request at a time and keeps at most one more waiting: everyone who asks while one waits shares it, and it reads the route and the handlers' request only when it starts. Each call used to queue its own request, so a burst of N realtime events or auth state reads fetched and applied the whole bootstrap N times in a row; it now does so at most twice.
|
|
7
9
|
- The navigation bar's destinations (`ShellTabLinkItem`) are plain `v-btn`s with an icon and a label, drawn by `@jskit-ai/material-web`'s `material.css` as every `v-bottom-navigation` is: their icon is 24dp in the 64x32 indicator (it was 19dp), and `.tab-link-item__indicator` is gone (the indicator is the icon's own box, `.tab-link-item .v-icon`).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>JSKIT Test copy banner</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<button id="under-banner" type="button">Pressed 0 times</button>
|
|
10
|
+
<!-- An application's Email field, which an inexact getByLabel("Email") must find alone. -->
|
|
11
|
+
<label for="email">Email</label>
|
|
12
|
+
<input id="email" type="email">
|
|
13
|
+
<script type="module" src="/src/main.js"></script>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createTestCopyBannerRuntime } from "../../../src/client/sideEffects/testCopyBanner.js";
|
|
2
|
+
|
|
3
|
+
// A control stretched across the top of the page, where the banner hangs, counts the presses that reach it.
|
|
4
|
+
const button = document.getElementById("under-banner");
|
|
5
|
+
Object.assign(button.style, { position: "fixed", inset: "0 0 auto 0", height: "48px", width: "100%" });
|
|
6
|
+
let presses = 0;
|
|
7
|
+
button.addEventListener("click", () => {
|
|
8
|
+
presses += 1;
|
|
9
|
+
button.textContent = `Pressed ${presses} times`;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
createTestCopyBannerRuntime().install();
|
|
13
|
+
document.documentElement.dataset.ready = "true";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from "node:url";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import { resolveSideEffectsMode, withSideEffectsMeta } from "@jskit-ai/kernel/shared/support/sideEffects";
|
|
4
|
+
|
|
5
|
+
// The page names the server's SIDE_EFFECTS as a JSKIT server or development server names it.
|
|
6
|
+
const sideEffectsPage = {
|
|
7
|
+
name: "fixture-side-effects-page",
|
|
8
|
+
transformIndexHtml: (html) => withSideEffectsMeta(html, resolveSideEffectsMode(process.env))
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
root: fileURLToPath(new URL(".", import.meta.url)),
|
|
13
|
+
plugins: [sideEffectsPage],
|
|
14
|
+
server: {
|
|
15
|
+
host: "127.0.0.1"
|
|
16
|
+
}
|
|
17
|
+
});
|
package/locales/en.json
CHANGED
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
"reloadFailed": "The app cannot reload because the app server is not reachable. Restart the server, then click Reload.",
|
|
46
46
|
"thisAppUpdated": "This app was updated. Reload to get the latest version.",
|
|
47
47
|
"unreachable": "{label} could not reach the server or network. Check the connection and try again."
|
|
48
|
+
},
|
|
49
|
+
"sideEffects": {
|
|
50
|
+
"testCopy": "Test copy",
|
|
51
|
+
"testCopyDescription": "Test copy: emails, messages and payments are simulated, not sent."
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
}
|
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.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"./locales/en.json": "./locales/en.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@jskit-ai/architecture-inspector": "0.1.
|
|
49
|
+
"@jskit-ai/architecture-inspector": "0.1.18"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@jskit-ai/material-web": "0.1.5",
|
|
53
53
|
"@vue/compiler-sfc": "3.5.44"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@jskit-ai/kernel": "0.2.
|
|
56
|
+
"@jskit-ai/kernel": "0.2.20",
|
|
57
57
|
"pinia": "^4.0.3",
|
|
58
58
|
"vue": "^3.5.44",
|
|
59
59
|
"vue-router": "^5.3.1",
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "../asyncModuleRecovery/inject.js";
|
|
11
11
|
import { createShellAsyncModuleRecoveryRuntime } from "../asyncModuleRecovery/runtime.js";
|
|
12
12
|
import { createShellClientUpdateRuntime } from "../clientUpdate/runtime.js";
|
|
13
|
+
import { createTestCopyBannerRuntime } from "../sideEffects/testCopyBanner.js";
|
|
13
14
|
import {
|
|
14
15
|
SHELL_REQUEST_RECOVERY_RUNTIME_KEY
|
|
15
16
|
} from "../requestRecovery/inject.js";
|
|
@@ -336,6 +337,7 @@ const ShellWebClientProvider = defineProvider({
|
|
|
336
337
|
logger
|
|
337
338
|
});
|
|
338
339
|
const navigationRuntime = createShellNavigationRuntime({ router });
|
|
340
|
+
const testCopyBannerRuntime = createTestCopyBannerRuntime();
|
|
339
341
|
|
|
340
342
|
return {
|
|
341
343
|
shell: Object.freeze({
|
|
@@ -348,7 +350,8 @@ const ShellWebClientProvider = defineProvider({
|
|
|
348
350
|
navigation: navigationRuntime,
|
|
349
351
|
placement: placementRuntime,
|
|
350
352
|
refresh: refreshRuntime,
|
|
351
|
-
requestRecovery: requestRecoveryRuntime
|
|
353
|
+
requestRecovery: requestRecoveryRuntime,
|
|
354
|
+
testCopyBanner: testCopyBannerRuntime
|
|
352
355
|
})
|
|
353
356
|
};
|
|
354
357
|
},
|
|
@@ -367,6 +370,8 @@ const ShellWebClientProvider = defineProvider({
|
|
|
367
370
|
asyncModuleRecoveryRuntime.install();
|
|
368
371
|
// Before the router's first navigation, so the trail starts with the page the tab opened on.
|
|
369
372
|
navigationRuntime.install();
|
|
373
|
+
// A test copy says so from the first frame, whatever the application's layout.
|
|
374
|
+
outputs.shell.testCopyBanner.install();
|
|
370
375
|
|
|
371
376
|
const appModules = importAppModules();
|
|
372
377
|
const placementTopology = await loadAppPlacementTopology(logger, asyncModuleRecoveryRuntime, appModules.placementTopology);
|
|
@@ -408,6 +413,7 @@ const ShellWebClientProvider = defineProvider({
|
|
|
408
413
|
installRouterErrorBridge(router, errorRuntime, logger);
|
|
409
414
|
},
|
|
410
415
|
shutdown(_dependencies, { outputs }) {
|
|
416
|
+
outputs.shell.testCopyBanner.dispose();
|
|
411
417
|
outputs.shell.navigation.dispose();
|
|
412
418
|
outputs.shell.clientUpdate.dispose();
|
|
413
419
|
outputs.shell.requestRecovery.dispose();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SIDE_EFFECTS_SIMULATE,
|
|
3
|
+
pageSideEffectsMode
|
|
4
|
+
} from "@jskit-ai/kernel/shared/support/sideEffects";
|
|
5
|
+
import { pageDocument } from "../browser.js";
|
|
6
|
+
import { useJskitText } from "../i18n.js";
|
|
7
|
+
|
|
8
|
+
const { t } = useJskitText();
|
|
9
|
+
|
|
10
|
+
const TEST_COPY_BANNER_ID = "jskit-test-copy-banner";
|
|
11
|
+
|
|
12
|
+
// A small tab hanging from the top edge, above everything, that never takes a click or a tap: it marks the page
|
|
13
|
+
// without covering a control the person needs. Amber with near-black text reads the same in light and dark themes.
|
|
14
|
+
const TEST_COPY_BANNER_STYLE = Object.freeze({
|
|
15
|
+
position: "fixed",
|
|
16
|
+
top: "env(safe-area-inset-top, 0px)",
|
|
17
|
+
left: "50%",
|
|
18
|
+
transform: "translateX(-50%)",
|
|
19
|
+
zIndex: "2147483000",
|
|
20
|
+
pointerEvents: "none",
|
|
21
|
+
userSelect: "none",
|
|
22
|
+
padding: "2px 12px 3px",
|
|
23
|
+
borderRadius: "0 0 8px 8px",
|
|
24
|
+
background: "#ffb300",
|
|
25
|
+
color: "#1f1300",
|
|
26
|
+
font: "600 12px/16px system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif",
|
|
27
|
+
letterSpacing: "0.02em",
|
|
28
|
+
whiteSpace: "nowrap",
|
|
29
|
+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.3)"
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function removeNothing() {}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Shows the "Test copy" banner when the page says its server simulates side effects (SIDE_EFFECTS is not `live`),
|
|
36
|
+
* so everyone using a test copy knows no real email, message or payment goes out. It needs no application code: the
|
|
37
|
+
* shell adds it to the page's body, outside the application's own layout. A live page, or a page that names no
|
|
38
|
+
* setting, gets none. Returns the function that removes it.
|
|
39
|
+
* @param {object} [options]
|
|
40
|
+
* @param {Document | null} [options.documentObject]
|
|
41
|
+
* @param {"live" | "simulate" | ""} [options.mode] The page's setting; read from its meta tag when omitted.
|
|
42
|
+
* @returns {() => void}
|
|
43
|
+
*/
|
|
44
|
+
function installTestCopyBanner({ documentObject = pageDocument(), mode = pageSideEffectsMode(documentObject) } = {}) {
|
|
45
|
+
if (mode !== SIDE_EFFECTS_SIMULATE || !documentObject?.body || documentObject.getElementById(TEST_COPY_BANNER_ID)) {
|
|
46
|
+
return removeNothing;
|
|
47
|
+
}
|
|
48
|
+
const banner = documentObject.createElement("div");
|
|
49
|
+
banner.id = TEST_COPY_BANNER_ID;
|
|
50
|
+
banner.setAttribute("data-testid", TEST_COPY_BANNER_ID);
|
|
51
|
+
// A note read by its visible text, with the full sentence as its description. A label would make it a labelled
|
|
52
|
+
// element, which a browser test's field lookup such as `getByLabel("Email")` would also find.
|
|
53
|
+
banner.setAttribute("role", "note");
|
|
54
|
+
banner.setAttribute("aria-description", t("jskit.shell.sideEffects.testCopyDescription"));
|
|
55
|
+
banner.textContent = t("jskit.shell.sideEffects.testCopy");
|
|
56
|
+
// Through the style object, not a style attribute, so a strict content policy without inline styles allows it.
|
|
57
|
+
Object.assign(banner.style, TEST_COPY_BANNER_STYLE);
|
|
58
|
+
documentObject.body.append(banner);
|
|
59
|
+
return () => banner.remove();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The shell's banner runtime: `install()` shows the banner as the shell boots, `dispose()` removes it as it shuts
|
|
64
|
+
* down.
|
|
65
|
+
* @param {Parameters<typeof installTestCopyBanner>[0]} [options]
|
|
66
|
+
*/
|
|
67
|
+
function createTestCopyBannerRuntime(options) {
|
|
68
|
+
let remove = removeNothing;
|
|
69
|
+
|
|
70
|
+
function install() {
|
|
71
|
+
remove();
|
|
72
|
+
remove = installTestCopyBanner(options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function dispose() {
|
|
76
|
+
remove();
|
|
77
|
+
remove = removeNothing;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return Object.freeze({
|
|
81
|
+
install,
|
|
82
|
+
dispose
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { TEST_COPY_BANNER_ID, createTestCopyBannerRuntime, installTestCopyBanner };
|
package/test/provider.test.js
CHANGED
|
@@ -156,7 +156,8 @@ test("shell capability owns placement, navigation, bootstrap, refresh, errors, a
|
|
|
156
156
|
"navigation",
|
|
157
157
|
"placement",
|
|
158
158
|
"refresh",
|
|
159
|
-
"requestRecovery"
|
|
159
|
+
"requestRecovery",
|
|
160
|
+
"testCopyBanner"
|
|
160
161
|
]);
|
|
161
162
|
assert.deepEqual(fixture.shell.placement.getContext().surfaceAccess, {
|
|
162
163
|
app: { allowed: true }
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { chromium } from "@playwright/test";
|
|
7
|
+
import {
|
|
8
|
+
createChromiumLaunchOptions,
|
|
9
|
+
startViteFixture,
|
|
10
|
+
stopProcess
|
|
11
|
+
} from "../../../tooling/testUtils/browserFixture.mjs";
|
|
12
|
+
|
|
13
|
+
const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const FIXTURE_ROOT = path.resolve(TEST_DIRECTORY, "../fixtures/test-copy-banner");
|
|
15
|
+
const RUN_BROWSER_TEST = process.env.JSKIT_SHELL_WEB_BROWSER_INTEGRATION === "1";
|
|
16
|
+
const VIEWPORTS = Object.freeze([
|
|
17
|
+
{ name: "compact", width: 360, height: 740 },
|
|
18
|
+
{ name: "medium", width: 768, height: 1024 },
|
|
19
|
+
{ name: "expanded", width: 1280, height: 800 }
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
function channel(value) {
|
|
23
|
+
const normalized = value / 255;
|
|
24
|
+
return normalized <= 0.03928 ? normalized / 12.92 : ((normalized + 0.055) / 1.055) ** 2.4;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function luminance(color) {
|
|
28
|
+
const [red, green, blue] = String(color).match(/[\d.]+/gu).map(Number);
|
|
29
|
+
return channel(red) * 0.2126 + channel(green) * 0.7152 + channel(blue) * 0.0722;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function contrast(first, second) {
|
|
33
|
+
const [light, dark] = [luminance(first), luminance(second)].sort((left, right) => right - left);
|
|
34
|
+
return (light + 0.05) / (dark + 0.05);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The fixture's server and a browser for one test, stopped in its after hooks, which run on a failure or timeout too.
|
|
38
|
+
async function startFixture(t, env) {
|
|
39
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT, env });
|
|
40
|
+
t.after(() => stopProcess(vite));
|
|
41
|
+
const browser = await chromium.launch(createChromiumLaunchOptions());
|
|
42
|
+
t.after(() => browser.close());
|
|
43
|
+
return { vite, browser };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
test("a simulating page shows the Test copy banner at every width, in light and dark, without taking a click", {
|
|
47
|
+
skip: !RUN_BROWSER_TEST
|
|
48
|
+
}, async (t) => {
|
|
49
|
+
const { vite, browser } = await startFixture(t, { SIDE_EFFECTS: "" });
|
|
50
|
+
for (const colorScheme of ["light", "dark"]) {
|
|
51
|
+
for (const viewport of VIEWPORTS) {
|
|
52
|
+
const context = await browser.newContext({ viewport, colorScheme });
|
|
53
|
+
t.after(() => context.close());
|
|
54
|
+
const page = await context.newPage();
|
|
55
|
+
await page.goto(vite.baseURL);
|
|
56
|
+
await page.waitForSelector("html[data-ready=true]");
|
|
57
|
+
const label = `${colorScheme} ${viewport.name}`;
|
|
58
|
+
const banner = page.getByTestId("jskit-test-copy-banner");
|
|
59
|
+
assert.equal(await banner.textContent(), "Test copy", label);
|
|
60
|
+
assert.equal(await page.getByRole("note").textContent(), "Test copy", `${label}: a note`);
|
|
61
|
+
assert.equal(await banner.getAttribute("aria-description"), "Test copy: emails, messages and payments are simulated, not sent.", label);
|
|
62
|
+
// An application's inexact field lookup finds only its Email field, never the banner whose sentence says emails.
|
|
63
|
+
assert.equal(await page.getByLabel("Email").count(), 1, `${label}: one Email match`);
|
|
64
|
+
assert.equal(await page.getByLabel("Email").getAttribute("id"), "email", `${label}: the Email field`);
|
|
65
|
+
const box = await banner.boundingBox();
|
|
66
|
+
assert.equal(box.y, 0, `${label}: hangs from the top edge`);
|
|
67
|
+
assert.ok(Math.abs(box.x + box.width / 2 - viewport.width / 2) <= 1, `${label}: centred`);
|
|
68
|
+
assert.ok(box.width < viewport.width / 2 && box.height <= 24, `${label}: small (${box.width}x${box.height})`);
|
|
69
|
+
const style = await banner.evaluate((element) => {
|
|
70
|
+
const computed = getComputedStyle(element);
|
|
71
|
+
return { color: computed.color, background: computed.backgroundColor, pointerEvents: computed.pointerEvents };
|
|
72
|
+
});
|
|
73
|
+
assert.equal(style.pointerEvents, "none", label);
|
|
74
|
+
assert.ok(contrast(style.color, style.background) >= 4.5, `${label}: readable (${contrast(style.color, style.background)})`);
|
|
75
|
+
// A press on the banner reaches the control beneath it.
|
|
76
|
+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
|
77
|
+
assert.equal(await page.locator("#under-banner").textContent(), "Pressed 1 times", label);
|
|
78
|
+
await context.close();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("a live page has no banner", { skip: !RUN_BROWSER_TEST }, async (t) => {
|
|
84
|
+
const { vite, browser } = await startFixture(t, { SIDE_EFFECTS: "live" });
|
|
85
|
+
const page = await browser.newPage();
|
|
86
|
+
await page.goto(vite.baseURL);
|
|
87
|
+
await page.waitForSelector("html[data-ready=true]");
|
|
88
|
+
assert.equal(await page.getByTestId("jskit-test-copy-banner").count(), 0);
|
|
89
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createTestCopyBannerRuntime, installTestCopyBanner } from "../src/client/sideEffects/testCopyBanner.js";
|
|
4
|
+
|
|
5
|
+
// The part of a document the banner uses: a body to append to, elements, and lookup by id.
|
|
6
|
+
function fakeDocument(sideEffects) {
|
|
7
|
+
const appended = [];
|
|
8
|
+
const documentObject = {
|
|
9
|
+
appended,
|
|
10
|
+
body: {
|
|
11
|
+
append(element) {
|
|
12
|
+
appended.push(element);
|
|
13
|
+
element.remove = () => appended.splice(appended.indexOf(element), 1);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
createElement(tag) {
|
|
17
|
+
const attributes = {};
|
|
18
|
+
return { tag, style: {}, attributes, setAttribute: (name, value) => { attributes[name] = value; } };
|
|
19
|
+
},
|
|
20
|
+
getElementById: (id) => appended.find((element) => element.id === id) || null,
|
|
21
|
+
querySelector: () => (sideEffects === undefined ? null : { getAttribute: () => sideEffects })
|
|
22
|
+
};
|
|
23
|
+
return documentObject;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
test("a simulating page gets one Test copy banner that takes no clicks", () => {
|
|
27
|
+
const documentObject = fakeDocument("simulate");
|
|
28
|
+
const remove = installTestCopyBanner({ documentObject });
|
|
29
|
+
assert.equal(documentObject.appended.length, 1);
|
|
30
|
+
const [banner] = documentObject.appended;
|
|
31
|
+
assert.equal(banner.textContent, "Test copy");
|
|
32
|
+
assert.equal(banner.attributes.role, "note");
|
|
33
|
+
assert.equal(banner.attributes["aria-description"], "Test copy: emails, messages and payments are simulated, not sent.");
|
|
34
|
+
// No label, so a field lookup by label (Playwright's getByLabel reads aria-label and aria-labelledby) never finds it.
|
|
35
|
+
assert.equal("aria-label" in banner.attributes, false);
|
|
36
|
+
assert.equal("aria-labelledby" in banner.attributes, false);
|
|
37
|
+
assert.equal(banner.attributes["data-testid"], "jskit-test-copy-banner");
|
|
38
|
+
assert.equal(banner.style.pointerEvents, "none");
|
|
39
|
+
assert.equal(banner.style.position, "fixed");
|
|
40
|
+
installTestCopyBanner({ documentObject });
|
|
41
|
+
assert.equal(documentObject.appended.length, 1, "never two");
|
|
42
|
+
remove();
|
|
43
|
+
assert.equal(documentObject.appended.length, 0);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("a live page, a page that names no setting and no document get no banner", () => {
|
|
47
|
+
for (const sideEffects of ["live", undefined]) {
|
|
48
|
+
const documentObject = fakeDocument(sideEffects);
|
|
49
|
+
installTestCopyBanner({ documentObject });
|
|
50
|
+
assert.equal(documentObject.appended.length, 0, String(sideEffects));
|
|
51
|
+
}
|
|
52
|
+
assert.doesNotThrow(() => installTestCopyBanner({ documentObject: null })());
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("the shell's banner runtime shows the banner on install and removes it on dispose", () => {
|
|
56
|
+
const documentObject = fakeDocument("simulate");
|
|
57
|
+
const runtime = createTestCopyBannerRuntime({ documentObject });
|
|
58
|
+
runtime.install();
|
|
59
|
+
runtime.install();
|
|
60
|
+
assert.equal(documentObject.appended.length, 1);
|
|
61
|
+
runtime.dispose();
|
|
62
|
+
assert.equal(documentObject.appended.length, 0);
|
|
63
|
+
runtime.dispose();
|
|
64
|
+
});
|