@devopsplaybook.io/common-web 0.14.0 → 0.15.0-beta.26.9be6a6b

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 CHANGED
@@ -5,6 +5,41 @@ All notable changes to this project are documented here.
5
5
  This project follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6
6
  and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.15.0] - 2026-11-25
9
+
10
+ ### Added
11
+
12
+ - A real-browser theme-contrast harness (`npm run test:e2e`, Playwright +
13
+ Chromium, specs in `e2e/`) that renders `LoginWithCodeCard`,
14
+ `AuthorizeDeviceCard` and `LoginCodeInput` in six host modes — the Nuxt layer
15
+ in light and dark, a plain Vite host with Planner's partial dark and light
16
+ palettes, and token-less hosts in both schemes — then measures WCAG 2.2 AA
17
+ contrast for code text, muted labels, primary and secondary button labels, the
18
+ warning callout, error text and input text from real `getComputedStyle`
19
+ values. It also pins the measured colours to the host tokens, proves the
20
+ `partial-dark` code panel is a dark surface using host text (the reported
21
+ regression), and snapshots every scenario and host mode.
22
+ - `tests/theme-host/`: a plain Vite + Vue fixture (no Nuxt, no common-web layer,
23
+ no `tokens.css`) importing the components from the packed tarball with a
24
+ no-network `LoginCodeService` stub, plus the `partial-dark`, `partial-light`,
25
+ `tokenless-dark` and `tokenless-light` palette pages.
26
+ - `playground/pages/theme-harness.vue` (`/theme-harness`) with the same
27
+ scenarios inside the layer, used for the layer light/dark runs.
28
+ - A blocking `theme-contrast` job in `PR Check` (after `test-and-build`) that
29
+ installs Chromium, runs the harness and uploads the Playwright report on
30
+ failure; `publish-beta` now waits for it.
31
+ - README section "Testing the theming contract" and a CONTRIBUTING entry for the
32
+ new local check. Planner's light `--color-text-muted` (4.41:1 on white, 4.01:1
33
+ on the derived raised panel) is documented as the one exempt pair with a 3.9
34
+ floor; raising that token is a Planner change.
35
+
36
+ ### Changed
37
+
38
+ - `@playwright/test` is a devDependency and `vite` is an explicit devDependency
39
+ (it was already resolved through Nuxt) for the harness runner.
40
+ - Test and CI only: no component API, service, composable or shipped-style
41
+ change, so the published file set and consumer behaviour are unchanged.
42
+
8
43
  ## [0.14.0] - 2026-11-25
9
44
 
10
45
  ### Added
package/CONTRIBUTING.md CHANGED
@@ -10,9 +10,15 @@ npm run lint
10
10
  npm run typecheck
11
11
  npm test
12
12
  npm run build
13
+ npm run test:e2e
13
14
  npm audit --omit=dev --audit-level=high
14
15
  ```
15
16
 
17
+ `npm run test:e2e` is the real-browser theme-contrast harness (Playwright,
18
+ Chromium). Install the browser once with `npx playwright install chromium`; it
19
+ needs `npm run build` first because the layer host is served from
20
+ `playground/.output`. See "Testing the theming contract" in the README.
21
+
16
22
  The tests consume the generated npm tarball, not only the working tree.
17
23
  `npm run build` checks the publish file list and builds the Nuxt playground.
18
24
 
@@ -31,12 +37,17 @@ Three quality gates run with `npm test`:
31
37
  - **Accessibility**: `tests/accessibility.spec.ts` runs axe-core against every
32
38
  shipped component mounted in a real DOM tree and fails on violations. The
33
39
  `color-contrast` rule is disabled there because jsdom cannot compute rendered
34
- contrast; WCAG AA color pairs are already gated by `tests/contrast.spec.ts`
35
- against the packed tokens.
40
+ contrast.
36
41
  - **SSR**: `tests/ssr.spec.ts` renders the shipped components in a Node
37
42
  environment with `createSSRApp` and `renderToString`, so the SSR
38
43
  compatibility promised by the README is exercised on every test run.
39
44
 
45
+ A fourth gate, `npm run test:e2e` (the blocking `theme-contrast` job in
46
+ `PR Check`), renders the login-with-code components in Chromium across the layer
47
+ and non-layer host modes and measures WCAG 2.2 AA contrast for their text and
48
+ button colours. `tests/contrast.spec.ts` still gates the shipped token values
49
+ themselves.
50
+
40
51
  ## Scope and compatibility
41
52
 
42
53
  Keep the layer limited to UI and browser behavior that is shared by multiple
package/README.md CHANGED
@@ -471,6 +471,99 @@ radius, background, shadow or outer padding) and match the heading structure wit
471
471
  colour declarations, only documented host tokens, `--color-on-primary` shipped in
472
472
  every theme block, and the spacing bridge through `--lc-space`.
473
473
 
474
+ ## Testing the theming contract
475
+
476
+ `tests/accessibility.spec.ts` disables axe's `color-contrast` rule because jsdom
477
+ cannot resolve the CSS cascade or `var()`. The real-browser harness in `e2e/`
478
+ closes that gap: it renders the three login-with-code components in every
479
+ supported host mode, reads `getComputedStyle` in Chromium, and asserts WCAG 2.2
480
+ AA contrast (4.5:1) for the text/background pairs of the components.
481
+
482
+ ### What it covers
483
+
484
+ | Host mode | Page | Theme |
485
+ | --- | --- | --- |
486
+ | `partial-dark` | plain Vite host, Planner's dark palette only | `color-scheme: dark` |
487
+ | `partial-light` | plain Vite host, Planner's light palette only | `color-scheme: light` |
488
+ | `tokenless-dark` | plain Vite host, no `--color-*`/`--space-*` | `color-scheme: dark` |
489
+ | `tokenless-light` | plain Vite host, no `--color-*`/`--space-*` | `color-scheme: light` |
490
+ | `layer-light` | built playground layer, `/theme-harness` | `data-theme="light"` |
491
+ | `layer-dark` | built playground layer, `/theme-harness` | `data-theme="dark"` |
492
+
493
+ The partial palettes are Planner's exact tokens with the gaps Planner really has
494
+ (no `--color-surface-raised`, `--color-error`, `--color-on-warning` or
495
+ `--space-base`, and no common-web `tokens.css`); the token-less pages declare
496
+ only `color-scheme`, so the components fall back to their documented
497
+ `light-dark()` values. Both fixtures import the components from the packed
498
+ tarball, exactly like a consumer.
499
+
500
+ Scenarios (each a `[data-scenario]` section rendered by both hosts): the
501
+ `LoginWithCodeCard` waiting state, its `variant="plain"` embedding and its retry
502
+ state; the `AuthorizeDeviceCard` code-entry, preview and rate-limited error
503
+ states; and `LoginCodeInput` in its normal and error states. Per scenario the
504
+ harness checks code text, muted labels, primary and secondary button labels,
505
+ the warning callout, error text and input text against their actual backgrounds.
506
+ Structural assertions pin the measured colours to the host tokens, require the
507
+ `partial-dark` code panel to be a dark surface (relative luminance < 0.1) with
508
+ host text rather than light-theme `#171717`, require the dark primary label to be
509
+ the host `--color-on-primary` (not `#fff`), and prove `variant="plain"` paints no
510
+ card border, shadow, background or padding. Element screenshots
511
+ (`toHaveScreenshot`, 1 % diff budget) snapshot every scenario and host mode.
512
+
513
+ ### Running it locally
514
+
515
+ ```sh
516
+ npx playwright install chromium # once
517
+ npm run build # produces playground/.output for the layer host
518
+ npm run test:e2e
519
+ ```
520
+
521
+ `npm run test:e2e` packs the tarball (`npm pack`), extracts it to
522
+ `node_modules/.cache/common-web-e2e/package`, starts both host servers and
523
+ runs Playwright; the Vite fixture imports the packed sources. Pass Playwright
524
+ flags through, for example `npm run test:e2e -- --update-snapshots` or
525
+ `npm run test:e2e -- -g partial-dark`. The servers are the Vite fixture on port
526
+ 4310 and the built playground's Node server on port 4311; set
527
+ `THEME_FIXTURE_PORT` / `THEME_LAYER_PORT` if those ports are taken. The layer
528
+ host needs `npm run build` first.
529
+
530
+ CI runs the same command in the blocking `theme-contrast` job of `PR Check`
531
+ after `test-and-build`, and uploads the Playwright report and screenshot diffs
532
+ when it fails.
533
+
534
+ ### Required `color-scheme` and host palettes
535
+
536
+ Non-layer and token-less hosts must declare the CSS `color-scheme` so the
537
+ components' `light-dark()` fallbacks follow the theme:
538
+
539
+ ```css
540
+ :root {
541
+ color-scheme: light dark;
542
+ }
543
+ ```
544
+
545
+ To add a host palette, add a stylesheet under `tests/theme-host/palettes/`, an
546
+ HTML page that loads `harness.css` and that stylesheet, and a `HostMode` entry in
547
+ `e2e/palettes.ts` with the tokens the page exposes and the colours the components
548
+ should render. New scenarios are declared once in `e2e/scenarios.ts` and must be
549
+ rendered by both `tests/theme-host/App.vue` and
550
+ `playground/pages/theme-harness.vue`, each wrapped in
551
+ `<section data-scenario="…">`. Regenerate baselines after intentional visual
552
+ changes.
553
+
554
+ Screenshot baselines are Linux/Chromium with the DejaVu font set only (CI
555
+ installs `fonts-dejavu-core`). Do not commit macOS or Windows baselines;
556
+ regenerate them on Linux with `--update-snapshots`.
557
+
558
+ ### Known exemption: Planner's light muted token
559
+
560
+ Planner's light `--color-text-muted: #6b7a88` is 4.41:1 on `#ffffff` and
561
+ 4.01:1 on the derived raised panel, below AA 4.5. The component cannot exceed a
562
+ host token, so the harness still pins the muted label to that host token but
563
+ applies a documented 3.9 floor to the `partial-light` muted pairs only; all other
564
+ pairs keep the 4.5:1 minimum. Raising the token is a Planner change (for example
565
+ to `#5f6368`), after which the exemption can be removed.
566
+
474
567
  ## Authentication state and HTTP integration
475
568
 
476
569
  `AuthService.saveToken()` and `removeToken()` emit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devopsplaybook.io/common-web",
3
- "version": "0.14.0",
3
+ "version": "0.15.0-beta.26.9be6a6b",
4
4
  "description": "Shared Nuxt layer for DevOpsPlaybook web applications",
5
5
  "license": "ISC",
6
6
  "repository": {
@@ -39,17 +39,18 @@
39
39
  ],
40
40
  "scripts": {
41
41
  "dev": "nuxi dev playground",
42
- "lint": "oxlint components composables services stores tests scripts playground vitest.config.ts nuxt.config.ts",
42
+ "lint": "oxlint components composables services stores tests scripts playground e2e vitest.config.ts nuxt.config.ts playwright.config.ts",
43
43
  "typecheck": "nuxi typecheck",
44
44
  "pretest": "nuxi prepare",
45
45
  "test": "node scripts/test-packed.mjs",
46
+ "test:e2e": "node scripts/test-e2e.mjs",
46
47
  "prebuild": "nuxi prepare",
47
48
  "build": "node scripts/build-package.mjs"
48
49
  },
49
50
  "peerDependencies": {
50
51
  "nuxt": "^4.0.0",
51
- "vue": "^3.5.0",
52
- "pinia": "^2.0.0 || ^3.0.0 || ^4.0.0"
52
+ "pinia": "^2.0.0 || ^3.0.0 || ^4.0.0",
53
+ "vue": "^3.5.0"
53
54
  },
54
55
  "peerDependenciesMeta": {
55
56
  "pinia": {
@@ -62,6 +63,7 @@
62
63
  "mitt": "^3.0.1"
63
64
  },
64
65
  "devDependencies": {
66
+ "@playwright/test": "^1.65.1",
65
67
  "@types/node": "^26.6.6",
66
68
  "@vitejs/plugin-vue": "^6.0.11",
67
69
  "@vitest/coverage-v8": "^5.1.1",
@@ -73,6 +75,7 @@
73
75
  "pinia": "^4.1.0",
74
76
  "postcss": "^8.5.32",
75
77
  "typescript": "^6.0.3",
78
+ "vite": "^8.3.8",
76
79
  "vitest": "^5.1.1",
77
80
  "vue-tsc": "^3.3.14"
78
81
  },