Theme Tests and Fix Plan
"/home/yossef/notes/git/projects/maplibra/risks/Theme Tests and Fix Plan.md"
path: maplibra/risks/Theme Tests and Fix Plan.md
- **fileName**: Theme Tests and Fix Plan
- **Created on**: 2026-06-16 00:48:42
Theme Tests and Fix Plan
Migrated from: obs_vault
Parent: ./Theme Risk Index.md
This note consolidates the missing tests and the practical fix sequence for the theme risk set.
Current Coverage Summary
tests/theme-host-mode.test.js: covers Android host preferring Mapbox when token and local PMTiles are present.tests/basemap-style.test.js: covers network raster fallback shape.tests/navigation-icon-theme.test.js: covers icon theme metadata and tintability.tests/style-layer.test.js: covers fast wall line creation and replacement by prepared 3D walls.tests/visibility-manager.test.js: covers annotation marker floor behavior and disabling annotation layer visibility.
Missing High-Value Tests
ThemeController destroy removes click storage and media listeners.ThemeController repeated init destroy does not multiply toggles.resolveMapStyle uses offline style on appassets when remote basemap is not explicitly allowed.resolveMapStyle treats configured PMTiles URL as local PMTiles availability.getThemeByMode resolves mapStyle from current runtime overrides.static offline-style json matches dynamic dark campus offline style.applyThemeToMap does not hide building-shell.applyThemeToMap only changes allowlisted basemap layers.LayerManager reapplyThemeColors updates doors and labels.LayerManager reapplyThemeColors handles fast wall line layers without fill-extrusion warnings.visibility manager restores user-hidden layers after indoor visibility toggles.
Fix Sequence
- Fix listener references and teardown in ./Theme Controller Listener Cleanup.md.
- Add
applyThemeToMap()allowlist/exclusions for ./Broad Map Layer ID Matching.md. - Make host style resolution offline-first unless remote basemap is explicitly allowed in ./Host Mode Style Resolution.md.
- Collapse static/dynamic offline style drift in ./Offline Basemap Theme Drift.md.
- Make
LayerManager.reapplyThemeColors()type-aware and repaint doors in ./LayerManager Theme Reapply State.md. - Add regression tests before or alongside each fix.
Suggested Test Files
- Add
tests/theme-controller.test.jsforThemeControllerlifecycle. - Extend
tests/theme-host-mode.test.jsfor host decision matrix. - Extend
tests/basemap-style.test.jsfor offline style generation and static parity. - Add
tests/apply-theme-to-map.test.jsor extend existing theme tests for layer allowlisting. - Add
tests/layer-manager-theme.test.jsforLayerManager.reapplyThemeColors(). - Extend
tests/visibility-manager.test.jsfor shell and visibility snapshot behavior.
Implementation Principles
- Keep basemap theming and indoor-layer theming separate.
- Use explicit ownership or source allowlists instead of layer ID substring matching.
- Store event-listener references before adding them.
- Prefer generated styles or generated static JSON over manually maintained duplicates.
- Add tests for the exact bugs that were found, not just happy-path color assertions.