Labels: good first issue, area:webui, area:testing
Difficulty: S (~1–3 hours)
Context
apps/webui/src/ui/notification-settings.ts persists the cockpit's notification
preferences to localStorage and is deliberately defensive: SSR, a missing
localStorage, and corrupt stored values must all degrade to the all-off default.
That coercion logic currently has no test coverage at all (no test file references the
module), so a refactor could silently break the safe-degradation behavior.
What to do
- Read
apps/webui/src/ui/notification-settings.ts (70 lines). Public surface:
defaultNotificationSettings(), readNotificationSettings(),
persistNotificationSettings(); internal coerceCategories().
- Create
apps/webui/test/notification-settings.test.ts. The webui test suite runs in
a plain node environment (apps/webui/vitest.config.ts:16), so stub
window.localStorage with a small in-memory object — copy the pattern from
apps/webui/test/policy-cache.test.ts:28-51 (MemStorage + globalThis.window stub).
- Cover at least:
- no
window (SSR path) → defaults, no throw
- empty storage → defaults
- round-trip:
persistNotificationSettings(s) then readNotificationSettings() → s
- corrupt JSON / non-object JSON (
"42", "[]") → defaults
enabled present but not strictly true (1, "yes") → false
categories with unknown extra keys → dropped; non-true values → false
getItem / setItem throwing (private-mode simulation) → no throw, safe fallback
Acceptance criteria
- New test file passes:
pnpm --filter @actradeck/webui test
- All bullets above are asserted (not just the happy path).
- No production code changes needed. If you find an actual bug while testing, report it
in the issue thread instead of folding a behavior change into the test PR.
- Full gate green:
pnpm type-check && pnpm lint && pnpm format && pnpm test
Labels:
good first issue,area:webui,area:testingDifficulty: S (~1–3 hours)
Context
apps/webui/src/ui/notification-settings.tspersists the cockpit's notificationpreferences to
localStorageand is deliberately defensive: SSR, a missinglocalStorage, and corrupt stored values must all degrade to the all-off default.That coercion logic currently has no test coverage at all (no test file references the
module), so a refactor could silently break the safe-degradation behavior.
What to do
apps/webui/src/ui/notification-settings.ts(70 lines). Public surface:defaultNotificationSettings(),readNotificationSettings(),persistNotificationSettings(); internalcoerceCategories().apps/webui/test/notification-settings.test.ts. The webui test suite runs ina plain
nodeenvironment (apps/webui/vitest.config.ts:16), so stubwindow.localStoragewith a small in-memory object — copy the pattern fromapps/webui/test/policy-cache.test.ts:28-51(MemStorage+globalThis.windowstub).window(SSR path) → defaults, no throwpersistNotificationSettings(s)thenreadNotificationSettings()→s"42","[]") → defaultsenabledpresent but not strictlytrue(1,"yes") →falsecategorieswith unknown extra keys → dropped; non-truevalues →falsegetItem/setItemthrowing (private-mode simulation) → no throw, safe fallbackAcceptance criteria
pnpm --filter @actradeck/webui testin the issue thread instead of folding a behavior change into the test PR.
pnpm type-check && pnpm lint && pnpm format && pnpm test