tobogganSe connecter

library

Prebuilt pebble components: drop-in custom elements, no compiler needed

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Dernier runAucun
0Étoiles
0Forks
2Issues
40 lignes · 1779 octetsBrut · Historique
1/**
2 * The page half of the toaster smoke fixture (see toaster.html). Imports the
3 * shipped dist bundle — registration is the import's side effect, exactly as
4 * a consumer's `<script type="module">` gets it — announces a polite and an
5 * assertive toast, and writes a JSON verdict (`SMOKE:{...}`) into
6 * <pre id="smoke"> for the headless-Chromium driver (toaster-smoke.ts).
7 *
8 * Durations are the 60s ceiling so the cards outlive the driver's virtual
9 * time budget; what is asserted is that announcing RENDERS, not the timers
10 * (those are the happy-dom suite's job, on a subject-driven clock).
11 */
12import { announceToast } from "../dist/toaster.js";
13
14const settle = () => new Promise(resolve => setTimeout(resolve, 250));
15
16announceToast({ message: "smoke: saved", type: "success", duration: 60000 });
17announceToast({ message: "smoke: failed", type: "error", duration: 60000 });
18await settle();
19
20const host = document.querySelector("pebble-toaster");
21const region = host?.querySelector('[part="toaster"]');
22const cards = [...(host?.querySelectorAll('[part="toast"]') ?? [])];
23const kinds = cards.map(card => card.getAttribute("data-kind"));
24const roles = cards.map(card => card.getAttribute("role"));
25const messages = cards.map(card => card.querySelector('[part="message"]')?.textContent);
26
27const verdict = {
28 ok:
29 host !== null &&
30 region?.getAttribute("aria-live") === "polite" &&
31 kinds.join(",") === "success,error" &&
32 roles.join(",") === "status,alert" &&
33 messages.join("|") === "smoke: saved|smoke: failed",
34 registered: customElements.get("pebble-toaster") !== undefined,
35 ariaLive: region?.getAttribute("aria-live") ?? null,
36 kinds,
37 roles,
38 messages,
39};
40document.getElementById("smoke")!.textContent = `SMOKE:${JSON.stringify(verdict)}`;