Skip to content

test(ui-ng): cover shell, switchers and navigation - #859

Merged
BryanFRD merged 6 commits into
mainfrom
test/coverage-shell
Nov 28, 2026
Merged

BryanFRD merged 6 commits into
mainfrom
test/coverage-shell

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

Summary

Public changelog

  • Changelog entry added (or N/A: internal-only change)

N/A: tests only.

Test plan

  • pnpm --filter @ferrlabs/ui-ng test:coverage passes (2019 tests)
  • pnpm lint passes, spec tsconfig typechecks

@BryanFRD
BryanFRD enabled auto-merge (squash) November 28, 2026 15:20
ferrfleet-interne[bot]
ferrfleet-interne Bot previously approved these changes Nov 28, 2026

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: setInput relies on private Angular internals. It reads the input's ɵSIGNAL node and calls applyValueToInputSignal, 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 with componentRef.setInput) needs a DOM test environment, and this package runs vitest with environment: '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.include is src/**/*.ts and only *.spec.ts is excluded, so the new src/lib/testing/*.ts helpers count as library code in the coverage report. Suggested fix: add 'src/lib/testing/**' to coverage.exclude.

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 existing testing/component-harness.ts. main already ships createComponent (environment injector with INJECTOR_SCOPE root and provideZonelessChangeDetection, ElementRef host stub), setInputs and flushEffects. This PR adds createHarness/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 by site-path.spec for injectSitePath()), access to the injector for destroy(), and setting inputs through the real input node via ɵSIGNAL instead of replacing the field.
    • Fix: fold those capabilities into component-harness.ts instead of adding a new file, for example export a createInjectionHarness(providers) (or let createComponent accept a factory) that returns the injector, and add a setInput variant 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.

Suggestions

  • packages/ui-ng/src/lib/app-rail/app-rail.component.spec.ts:1: redundant @angular/compiler imports. injector-harness.ts already imports it, and app-switcher.component.spec.ts works 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 vitest setupFiles entry).

Formal verification did not run for this pull request.

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/flushEffects replace inputs with plain signals, while createHarness/setInput drive the real input node. New specs use only the second, so the two will drift. Move existing specs to createHarness/setInput and drop the old API, or have createComponent delegate to createHarness. Can be a follow-up.
  • suggestion, packages/ui-ng/src/lib/testing/component-harness.ts:86: setInput reads input[ɵ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 as providers as never, which disables type checking. The same pattern is in project-switcher.component.spec.ts. Type it as Provider[] from @angular/core and drop the cast.

Formal verification was not run for this pull request.

@BryanFRD
BryanFRD merged commit 68c9357 into main Nov 28, 2026
18 checks passed
@BryanFRD
BryanFRD deleted the test/coverage-shell branch November 28, 2026 16:26
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