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
| 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 | */ |
| 12 | import { announceToast } from "../dist/toaster.js"; |
| 13 | |
| 14 | const settle = () => new Promise(resolve => setTimeout(resolve, 250)); |
| 15 | |
| 16 | announceToast({ message: "smoke: saved", type: "success", duration: 60000 }); |
| 17 | announceToast({ message: "smoke: failed", type: "error", duration: 60000 }); |
| 18 | await settle(); |
| 19 | |
| 20 | const host = document.querySelector("pebble-toaster"); |
| 21 | const region = host?.querySelector('[part="toaster"]'); |
| 22 | const cards = [...(host?.querySelectorAll('[part="toast"]') ?? [])]; |
| 23 | const kinds = cards.map(card => card.getAttribute("data-kind")); |
| 24 | const roles = cards.map(card => card.getAttribute("role")); |
| 25 | const messages = cards.map(card => card.querySelector('[part="message"]')?.textContent); |
| 26 | |
| 27 | const 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 | }; |
| 40 | document.getElementById("smoke")!.textContent = `SMOKE:${JSON.stringify(verdict)}`; |