Skip to content

FSHSP-93 test(kit): add first unit tests on pure logic and wire vitest into CI - #30

Merged
LBU4SH merged 4 commits into
mainfrom
chore/fshsp-93-unit-tests-pure-utils
Aug 13, 2026
Merged

FSHSP-93 test(kit): add first unit tests on pure logic and wire vitest into CI#30
LBU4SH merged 4 commits into
mainfrom
chore/fshsp-93-unit-tests-pure-utils

Conversation

@LBU4SH

@LBU4SH LBU4SH commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Première passe de FSHSP-93 : logique pure (pas de rendu Angular), pour valider toute la chaîne vitest avant de s'attaquer aux tests de composants.

  • 68 tests sur 4 modules : mask-engine, option-resolver, format-label, et les helpers de date de ui-datepicker.
  • Les helpers de date sont extraits dans date-utils.ts (même précédent que mask-engine.ts dans forms/) — nécessaire : un export direct dans ui-datepicker.ts fuit dans le .d.ts public via le export * de public-api.ts. Vérifié après coup : seul UiDatepicker reste exporté.
  • Bug de découverte des tests corrigé dans tsconfig.spec.json et la cible test d'angular.json : le glob par défaut ne scanne que projects/ui-kit/src (vide), jamais le src/ propre à chaque entry point (forms/src, ui-datepicker/src…) où vivent réellement les specs. Sans ce fix, ng test ui-kit échoue avec "No tests found" malgré des specs bien présents.
  • npm run test (nouveau script) branché en CI (pr-checks.yml).
  • Nettoyage : @types/jasmine, résidu mort de l'ère Karma, retiré.

A11y en CI (2e commit)

@storybook/addon-a11y était déjà configuré mais ne tournait que dans le panneau navigateur. Ajout d'un job a11y dans pr-checks.yml (@storybook/test-runner + axe-playwright@storybook/addon-vitest, le chemin plus récent, nécessite un Storybook sur Vite, pas webpack comme ici).

Premier run complet : 122 violations sur 21/54 composants (color-contrast, aria-allowed-attr, aria-valid-attr-value, nested-interactive…) — de la vraie dette, pas des faux positifs. Rendre le check bloquant tout de suite aurait cassé la CI de toute PR touchant l'un de ces composants, y compris sans rapport avec l'a11y. Job gardé informationnel (continue-on-error: true) le temps de corriger — suivi dans FSHSP-106.

BaseControlValueAccessor (3e commit)

Premier test TestBed du repo. BaseControlValueAccessor a besoin d'un vrai contexte d'injection Angular (inject(Injector), afterNextRender) — pas testable comme de la logique pure. Un composant CVA minimal (DemoCva, même pattern que ui-checkbox/ui-input) sert de cobaye : 12 tests couvrant le mirroring d'un NgControl reactive-forms (dirty/touched/invalid/errors/disabled, le contrat showError) et le cas standalone (aucun NgControl du tout).

Au passage : eslint.config.js étend l'exception demo-* sur le sélecteur de composant (jusqu'ici limitée à *.stories.ts) aux *.spec.ts — même raisonnement, un composant de test ne part jamais dans le package publié non plus.

Hors scope, pour un prochain ticket : play functions Storybook ; specs sur les composants régressés en QA (ui-tooltip/ui-input-mask/ui-input-otp).

Pas d'entrée CHANGELOG : tests, outillage CI et refactor interne, invisibles pour un consommateur du package.

LBU4SH added 4 commits August 13, 2026 11:12
…t into CI

Covers mask-engine, option-resolver, format-label, and the date helpers
extracted from ui-datepicker into their own date-utils.ts module (no
public API change — public-api.ts still only re-exports the component).

Fixes the test discovery glob in both tsconfig.spec.json and angular.json's
test target: it only ever scanned projects/ui-kit/src, never the sibling
src/ of each entry point (forms/, ui-datepicker/...), where every spec
actually lives.

Also drops @types/jasmine, a dead Karma-era devDependency.

BaseControlValueAccessor is left for a follow-up: it needs an Angular
injection context (TestBed), out of scope for this pure-logic pass.
…playwright

The addon was already configured but only ever ran in the browser panel,
never automatically. @storybook/addon-vitest (the newer, simpler path)
needs a Vite-powered Storybook framework — this repo runs @storybook/angular
on webpack, so @storybook/test-runner + axe-playwright is the supported
route here.

New 'a11y' job in pr-checks.yml, reusing the 'storybook' job's build via
artifact upload/download rather than rebuilding it.

First full run: 122 violations across 21/54 components (color-contrast,
aria-allowed-attr, aria-valid-attr-value, nested-interactive...) — real
pre-existing debt, not false positives. Turning this into a blocking check
today would break every PR touching one of those components, including
unrelated ones. Kept informational (continue-on-error) until FSHSP-106
(tracking the fix) clears the backlog.
First TestBed-based spec in the repo: mirrors a reactive-forms NgControl
(dirty/touched/invalid/errors/disabled, the showError contract) and the
standalone-usage fallback (no NgControl at all), via a minimal demo CVA
component — same pattern real field components (ui-checkbox, ui-input...)
follow.

eslint.config.js: extends the demo-* component-selector override (till now
scoped to *.stories.ts) to *.spec.ts too — same rationale, a spec's demo
component never reaches the packaged output either.
…ests-pure-utils

# Conflicts:
#	package-lock.json
#	package.json
@LBU4SH
LBU4SH merged commit 92e0b14 into main Aug 13, 2026
2 of 3 checks passed
@LBU4SH
LBU4SH deleted the chore/fshsp-93-unit-tests-pure-utils branch August 13, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant