test(frontend): harden admin-cameras app.js loading and fix README omitted-field note #268

Open
opened 2026-10-03 12:55:32 +00:00 by gabogg · 0 comments
Owner

P3 follow-up from PR #227 review pass 2.

Finding

  • Globals can leak. tests/frontend/test_admin_cameras.test.js:20-37 sets window, localStorage, document and t, then requires app.js before the try. If loading app.js throws, those globals leak into later tests. Open the try before the first global is set.
  • The guard is never exercised (Speculative Generality). The typeof localStorage guard at app.js:16-17 never runs in tests, because the only test that loads app.js stubs localStorage first. Drop the guard, or drop the stub and let the guard work.
  • The README contradicts itself. README.md:154 says previous_month_daily_average is "always present", but the field is omitted when it is null.

Acceptance Criteria

  • No global leaks when loading app.js fails.
  • The guard and the stub are consistent.
  • The README describes the field correctly.
P3 follow-up from PR #227 review pass 2. ### Finding - **Globals can leak.** `tests/frontend/test_admin_cameras.test.js:20-37` sets `window`, `localStorage`, `document` and `t`, then `require`s app.js *before* the `try`. If loading app.js throws, those globals leak into later tests. Open the `try` before the first global is set. - **The guard is never exercised** (Speculative Generality). The `typeof localStorage` guard at `app.js:16-17` never runs in tests, because the only test that loads app.js stubs `localStorage` first. Drop the guard, or drop the stub and let the guard work. - **The README contradicts itself.** `README.md:154` says `previous_month_daily_average` is "always present", but the field is omitted when it is null. ### Acceptance Criteria - No global leaks when loading app.js fails. - The guard and the stub are consistent. - The README describes the field correctly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gabogg/hikcentral#268
No description provided.