[Bug] Frontend CI: profile.component.spec.ts fails with NG0201 (No provider found for Keycloak) #302

Closed
opened 2026-07-01 14:22:58 +00:00 by spikerj · 1 comment
Owner

Summary

The frontend test pipeline is red. All 54 tests in projects/spikersoft/src/app/_components/profile/profile.component.spec.ts fail with:

ɵNotFound: NG0201: No provider found for `Keycloak`. Source: Standalone[_ProfileComponent].

Every other spec passes (1769 passed / 7 skipped before the fix), so this single file is what breaks nx test spikersoft.

Root cause

ProfileComponent gained a Keycloak dependency:

// profile.component.ts
import Keycloak from "keycloak-js";
...
private readonly keycloak = inject(Keycloak);

used in the child-account removal path (keycloak.logout() when the backend reports the user no longer exists). The component's spec TestBed.configureTestingModule({ providers: [...] }) was never updated to provide Keycloak, so DI throws at createComponent. This matches the pattern every other component/service spec already follows ({ provide: Keycloak, useValue: mock }).

Fix

Provide a minimal Keycloak stub ({ authenticated: true, logout: vi.fn() }) in the profile spec's providers, mirroring the existing convention (e.g. contact.component.spec.ts, menu-bar.component.spec.ts).

Acceptance criteria

  • nx test spikersoft is green (all profile specs pass).
  • No production code change required — test-only fix.

Severity

High (CI-blocking) but low-risk (test-only).

## Summary The frontend test pipeline is red. All **54 tests** in `projects/spikersoft/src/app/_components/profile/profile.component.spec.ts` fail with: ``` ɵNotFound: NG0201: No provider found for `Keycloak`. Source: Standalone[_ProfileComponent]. ``` Every other spec passes (1769 passed / 7 skipped before the fix), so this single file is what breaks `nx test spikersoft`. ## Root cause `ProfileComponent` gained a `Keycloak` dependency: ```ts // profile.component.ts import Keycloak from "keycloak-js"; ... private readonly keycloak = inject(Keycloak); ``` used in the child-account removal path (`keycloak.logout()` when the backend reports the user no longer exists). The component's spec `TestBed.configureTestingModule({ providers: [...] })` was never updated to provide `Keycloak`, so DI throws at `createComponent`. This matches the pattern every other component/service spec already follows (`{ provide: Keycloak, useValue: mock }`). ## Fix Provide a minimal `Keycloak` stub (`{ authenticated: true, logout: vi.fn() }`) in the profile spec's providers, mirroring the existing convention (e.g. `contact.component.spec.ts`, `menu-bar.component.spec.ts`). ## Acceptance criteria - [ ] `nx test spikersoft` is green (all profile specs pass). - [ ] No production code change required — test-only fix. ## Severity High (CI-blocking) but low-risk (test-only).
Author
Owner

Resolved in spikersoft-angular PR #87 (merged to master). Added a minimal Keycloak stub to profile.component.spec.ts's TestBed providers, matching the repo-wide convention. nx test spikersoft is green again: 1823 passed / 7 skipped (was 54 failed). Closing.

Resolved in spikersoft-angular PR #87 (merged to `master`). Added a minimal `Keycloak` stub to `profile.component.spec.ts`'s `TestBed` providers, matching the repo-wide convention. `nx test spikersoft` is green again: 1823 passed / 7 skipped (was 54 failed). Closing.
Sign in to join this conversation.