5.0 KiB
5.0 KiB
Implementation Plan: Authenticated Shell LED Visibility Fix
1. Architectural Reconnaissance
- Codebase style & conventions: Node.js monorepo with an Angular 17 standalone-component SPA and NestJS backend. The authenticated shell uses OnPush components, signal inputs/outputs, inline Angular templates/styles, and theme CSS custom properties.
HomeComponentowns event-stream lifecycle and passesEventStatusStore.state()into the presentationalShellHeaderComponent. Quick tabs and change-password behavior are already implemented and are not implicated in this regression. - Data Layer: TypeORM-backed backend settings provide
eventStartUtcandeventEndUtc; no schema or persistence changes are required. The backend event-state calculation and authenticated SSE payload are already functioning: the shell receives the correctrunning,countdown,stopped, orunconfiguredstate and applies the matching class. - Test Framework & Structure: Root Jest 29 multi-project configuration with
ts-jest; frontend tests run in jsdom from the dedicatedtests/frontend/directory.npm testruns all backend and frontend tests, whilenpm run test:frontendruns the frontend project only. Existingtests/frontend/shell-led.spec.tsis a source-structure assertion and does not instantiate the component or verify the rendered style binding. - Required Tools & Dependencies: No new system tools, global CLIs, npm packages, persistent
/dataassets, orsetup.shchanges are required. Existing Angular, Jest, jsdom, and TypeScript dependencies are sufficient.
2. Impacted Files
- To Modify:
frontend/src/app/features/shell/header/shell-header.component.ts— remove the conflicting transparent base declaration and bind the state-specific background color directly on the LED element so the browser paints the themed color reliably.tests/frontend/shell-led.spec.ts— replace/extend brittle source-only assertions with a focused automated regression covering the style value produced for each event state and preserving the accessible state label.
- To Create: None.
3. Proposed Changes
- Database / Schema Migration: None. Event timestamps, settings storage, REST/SSE contracts, and backend state computation remain unchanged.
- Backend Logic & APIs: None.
/api/v1/events/statusalready emits the correct state, andEventStatusStorealready forwards it to the shell. - Frontend UI Integration:
- In
ShellHeaderComponent, define a typed state-to-theme-color mapping for allEventStatevalues:running→var(--color-success),countdown→var(--color-warning),stopped→var(--color-danger), andunconfigured→var(--color-secondary). - Replace the unused
ledClasscomputed value with a computed background-color value derived fromeventState(); keep the existing state class bindings because they are useful selectors and preserve the current DOM contract. - Bind the computed value directly to the LED span's
style.background-color. This gives the element an explicit non-transparent author value while continuing to resolve the active theme token at runtime, matching the reported proof that a direct targeted declaration makes the dot visible. - Remove
background-color: transparentfrom the component base.ledrule, and remove the redundant component state-color declarations if the inline binding becomes the single authoritative color source. Retain only the shape/layout styling (inline-block, 10×10 dimensions, circular radius, border, alignment). - Remove the global LED state rules from
frontend/src/styles.cssif they are no longer consumed, avoiding duplicate ownership and future cascade ambiguity; keep canonical theme token declarations untouched. - Preserve the existing
data-testid, four state classes, andaria-label="Event status: <state>", so status remains exposed textually rather than by color alone. - Do not modify
HomeComponent,QuickTabsComponent, change-password components, event store, routes, SSE transport, or backend services because repository tracing shows those layers already deliver the correct state and shell behavior.
- In
4. Test Strategy
- Target Unit Test File:
tests/frontend/shell-led.spec.ts. - Mocking Strategy: No backend, HTTP, SSE, timers, filesystem fixtures, browser automation, or persistent data. Exercise a small exported pure state-to-color helper (or equivalent component mapping) with table-driven assertions for the four states, and retain focused source/template assertions that the LED consumes that value through
[style.background-color], keeps each state class binding, and keeps the dynamicaria-label. This directly prevents a regression to a transparent base color while remaining fast and CLI-only undernpm test. - Verification Commands for the implementer: Run
npm run test:frontend,npm test, andnpm run buildfrom/repo. The root build compiles both Angular and NestJS; no separate lint or typecheck script is defined.