Repository navigation
test(ui-ng): cover shell, switchers and navigation - #859
Conversation
There was a problem hiding this comment.
Approve. Test-only PR: node-environment specs for the shell, switchers and site chrome, built on a small injector harness. The assertions match the behaviour they cover, and nothing blocks the merge.
Code review: verdict approve, no blocking findings. Formal verification was not part of this review.
Findings
- minor
packages/ui-ng/src/lib/testing/component-harness.ts:41:setInputrelies on private Angular internals. It reads the input'sɵSIGNALnode and callsapplyValueToInputSignal, which is not public API and can change in any Angular minor release. A change would break every spec that uses it at once. The public route (TestBed withcomponentRef.setInput) needs a DOM test environment, and this package runs vitest withenvironment: 'node', so the shortcut is understandable. Suggested fix: keep it, and add a comment naming the Angular version it was checked against and why TestBed is not used. That way whoever upgrades Angular knows where a break will show up first. - suggestion
packages/ui-ng/vitest.config.mts:13:coverage.includeissrc/**/*.tsand only*.spec.tsis excluded, so the newsrc/lib/testing/*.tshelpers count as library code in the coverage report. Suggested fix: add'src/lib/testing/**'tocoverage.exclude.
There was a problem hiding this comment.
Changes requested: the specs are well targeted, but the PR adds a second test harness next to one that already exists on main.
Blocking
packages/ui-ng/src/lib/testing/injector-harness.ts:24: duplicates the existingtesting/component-harness.ts.mainalready shipscreateComponent(environment injector withINJECTOR_SCOPEroot andprovideZonelessChangeDetection,ElementRefhost stub),setInputsandflushEffects. This PR addscreateHarness/setInput/flush, which do the same job in a different shape, so future specs will pick one at random. The new one does add real capabilities: an arbitrary factory (needed bysite-path.specforinjectSitePath()), access to the injector fordestroy(), and setting inputs through the real input node viaɵSIGNALinstead of replacing the field.- Fix: fold those capabilities into
component-harness.tsinstead of adding a new file, for example export acreateInjectionHarness(providers)(or letcreateComponentaccept a factory) that returns the injector, and add asetInputvariant that usesɵSIGNAL. Then port these specs to it, or migrate the existing specs to the new API and delete the old file. One harness either way.
- Fix: fold those capabilities into
Suggestions
packages/ui-ng/src/lib/app-rail/app-rail.component.spec.ts:1: redundant@angular/compilerimports.injector-harness.tsalready imports it, andapp-switcher.component.spec.tsworks without its own import. The per-spec imports in the app-rail, brand-dropdown, menu, project-switcher, rail-toggle, site-path and site-footer specs are noise. Drop them and keep the import in the harness (or a vitestsetupFilesentry).
Formal verification did not run for this pull request.
There was a problem hiding this comment.
Approve. Test-only PR: unit specs for the shell, switchers, navigation and site chrome, plus two test helpers. The assertions match the component code the review checked (brand-dropdown, harness, fixture). The suite was not run, and CI's "Unit test coverage" job was skipped, so pass/fail is unverified.
No blocking findings.
Suggestions and minor
- suggestion,
packages/ui-ng/src/lib/testing/component-harness.ts:59: Two parallel harness APIs in one module.createComponent/setInputs/flushEffectsreplace inputs with plain signals, whilecreateHarness/setInputdrive the real input node. New specs use only the second, so the two will drift. Move existing specs tocreateHarness/setInputand drop the old API, or havecreateComponentdelegate tocreateHarness. Can be a follow-up. - suggestion,
packages/ui-ng/src/lib/testing/component-harness.ts:86:setInputreadsinput[ɵSIGNAL].applyValueToInputSignal, which is private Angular API and can change in any minor release, breaking every spec that uses it at once. Keep it confined to this helper, and add a comment naming the Angular version it was checked against. - minor,
packages/ui-ng/src/lib/app-switcher/app-switcher.component.spec.ts:109: Providers array typed{provide: unknown; useValue: unknown}[]and passed asproviders as never, which disables type checking. The same pattern is inproject-switcher.component.spec.ts. Type it asProvider[]from@angular/coreand drop the cast.
Formal verification was not run for this pull request.
Summary
src/lib/testingwith a small harness (zoneless environment injector, input setter) and a site chrome fixture, shared by the specs.Public changelog
N/A: tests only.
Test plan
pnpm --filter @ferrlabs/ui-ng test:coveragepasses (2019 tests)pnpm lintpasses, spec tsconfig typechecks