koala73 / koala73/worldmonitor

Mobile map caps are covered only by source-text regex tests, not runtime behavior

Open
#4,546 1 comment 0 reactions 0 assignees View on GitHub
P3 performance
Dominant language
TypeScript
Stars
86.6k
Forks
13.1k
Avg merge
8h 4m
Merged PRs (30d)
825

Description

Follow-up from the adversarial review of #4541 (closes #4463).

## Summary
`tests/map-mobile-feature-caps.test.mjs` reads `Map.ts` as a string (`readFileSync`, line 9) and asserts only via `assert.match(mapSrc, /.../)` regexes and `indexOf` ordering checks. It never constructs a `MapComponent`, dispatches an event, or spies on `updateLabelVisibility`.

## Why it matters
These tests give false confidence — they cannot catch real regressions in the capping/arming logic, including:
- The Iran `slice(0,50)` ordering/severity dependency (left entirely untested).
- The zoom-button arming gap fixed in the #4541 follow-up (a behavioral bug invisible to source-text matching).
- Listener wiring / teardown regressions.
- A mobile↔desktop inversion of one of the ternaries at runtime (some inversions are caught only incidentally by a second assertion).

They are also brittle: assertions key off exact comment markers (`// Earthquakes (magnitude-based sizing)`, `// Economic Centers`, `// Iran events ...`, `// Hotspots`) and exact whitespace, so harmless refactors break them. (The #4541 follow-up already had to patch one `pointerdown` regex after adding an `AbortController` signal.)

## Suggested fix
Add at least one behavioral test that instantiates `MapComponent` with `isMobile: true` (jsdom or equivalent) and asserts:
- Earthquake/Iran render lists are actually capped at runtime (and uncapped on desktop).
- `updateLabelVisibility` is not called until a synthetic direct map `pointerdown`/`touchstart` (and now also after a zoom-control tap).
- Iran ordering: a high-severity event positioned after 50 newer low-tier events is still rendered (guards the fix proposed in the companion Iran-cap issue).

## Verification status
CONFIRMED — methodology critique verified against the actual test file.

_Severity: medium_

Contributor guide

Open the contributing guide

Research direction

Start with tests/map-mobile-feature-caps.test.mjs and Map.ts, replacing the source-text regex checks with runtime coverage for MapComponent in a jsdom or equivalent setup. Verify mobile and desktop cap behavior, pointerdown/touchstart and zoom-control arming, listener behavior, and Iran ordering, including a high-severity event after 50 newer low-tier events.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.