FSHSP-93 test(kit): add first unit tests on pure logic and wire vitest into CI - #30
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Première passe de FSHSP-93 : logique pure (pas de rendu Angular), pour valider toute la chaîne
vitestavant de s'attaquer aux tests de composants.mask-engine,option-resolver,format-label, et les helpers de date deui-datepicker.date-utils.ts(même précédent quemask-engine.tsdansforms/) — nécessaire : unexportdirect dansui-datepicker.tsfuit dans le.d.tspublic via leexport *depublic-api.ts. Vérifié après coup : seulUiDatepickerreste exporté.tsconfig.spec.jsonet la cibletestd'angular.json: le glob par défaut ne scanne queprojects/ui-kit/src(vide), jamais lesrc/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).@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 joba11ydanspr-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
TestBeddu repo.BaseControlValueAccessora 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 queui-checkbox/ui-input) sert de cobaye : 12 tests couvrant le mirroring d'unNgControlreactive-forms (dirty/touched/invalid/errors/disabled, le contratshowError) et le cas standalone (aucunNgControldu tout).Au passage :
eslint.config.jsétend l'exceptiondemo-*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.