Frontend Unit Tests (card logic)¶
Pure-JS unit tests for the card's own computational logic β coordinate math, hit-testing, state accessors, validation engines, colour/theme resolution β run with Node's built-in test runner, no browser and no build.
- Run them all:
npm run test:units(node --test "src/**/*.test.mjs"). β Use the npm script, not a hand-typed glob. The quotes are load-bearing: they hand**to node, which expands it recursively. Unquoted in Bash,**matches ONE level and silently drops the top-level files (src/focus-restore.test.mjs,src/header-battery.test.mjs) β 1215 cases instead of 1222, with no warning that anything was skipped. - Run one file:
node --test src/state/rooms-logic.test.mjs. - 1418 cases across 155 files, currently all green. Node β₯ 21 (native glob).
(Re-measured 2026-11-14 from
npm run test:unitsand the glob it runs; the previous figure, 1047/103, had drifted well behind the tree.) (Thenode --testsummary line is the authority for these numbers β rerunnpm run test:unitsrather than trusting this doc's total.)
β THIS SUITE IS NOT WHAT CI's NODE JOB RUNS β it is one of its two commands. The other is
node --test scripts/*.test.mjs harness/lib/*.test.mjs, which carries the Chromium-driven intake sanitisers andcheck-screenshot-freshness. A green run here is not a greennode-tests.yml: in 2.5.3 a push went out on a greensrc/**and landed red on the freshness gate, which lives inscripts/. Run both before pushing.And remember the third track: a change that only re-words a string is still a visual change, so
card-visual.ymlgates it against committed baselines. See render-harness Β§ Visual baselines.
This is one of three separate frontend test tracks β see the three tracks.
How this set got big (2026-07-04, then the 2026-08 audit campaign)
It started as 13 files / 102 cases (mostly map/coordinate helpers). A
frontend-logic coverage audit then found that most of src/ is genuinely
plumbing (renderers, event-binding, hass-orchestration β correctly not
unit-tested), but a dense set of pure-derivation engines was untested:
the room access-graph, the reorder engine, start-block reasons, rule
validation, resolvedTheme, the learning summary/progress, map compose
geometry, floor-scope, and a few computations that had leaked inline into
renderers. Those were closed in three waves; the later floor-texture map view
then added the compositor + material-resolver engines (src/textures/),
taking the suite to 524 cases. The 2026-08 audit campaign added the next
tier: per-defect regression files across src/actions/ (service-failure
and refusal surfacing), src/bindings/ (confirm dialogs, rejected-import
surfacing), src/renderers/ (the review modal, job summary, live
charge/zone banners), the steps editors under src/state/, and the
i18n/font wiring β taking it to 904 cases across 91 files at the campaign's close.
The map¶
Grouped by src/ area. Each file's test names carry inline [XX-N] ids (the
same convention as the Python suite; the check_legend_drift.py legend gate is
Python-only, so these .mjs ids are not legend-checked).
src/state/ β panel state accessors, coordinate math, and derivation engines¶
The card's state lives in applyXState(proto) mixins. These tests build a stub
proto (Object.create over the mixin'd prototype) and assert the pure
derivations β no DOM, no hass.
| File | Cases | What it guards |
|---|---|---|
rooms-logic.test.mjs |
29 | The room access-graph validator (validateRoomAccessUpdate + DFS cycle / self-reference / duplicate-edge / missing-ref / single-inbound rules β issue codes) and the start-button readiness reason-code precedence (no_rooms_included > already_cleaning > returning_to_dock > vacuum_error); orphanedRooms. |
order-engine.test.mjs |
24 | The reorder engine β _sortOrderedItems (numeric order + id tiebreak; the Number(null)===0 sort-to-front footgun is pinned), move-to-position clamp+splice, swap-by-id, 1-based reindex, and the scope-preview wrappers. Drives room drag-and-drop β backend number entities. |
room-rules-logic.test.mjs |
28 | ruleEntityDescriptor (domain β category + allowed-operator set), roomRulesDraftIsValid (Save-enabled gate incl. the clean_passes 1|2 rule), scored entity search tiers, operator-group filtering. |
theme-resolve.test.mjs |
29 | resolvedTheme β the deterministic 4-layer merge (room-fill palette defaults + floor-texture material defaults seeded from FLOOR_TEXTURE_REGISTRY, incl. the map-rotate token; computed -eff layers excluded β active theme β working draft), plus filteredThemeTokens / filteredPresetIds (facet AND/OR + search filtering). [FT-2] and [FT-3] are now two DIFFERENT predicates and that is the point: the "Unsaved only" checkbox is draft-sourced ([FT-2]), the "Customised" chip is draft or theme ([FT-3]). [FT-3] used to assert the chip was draft-only, which is what shipped and what issue #83 reported β the reporter changed variables, SAVED them, and the filter went empty while every group header read 0 / N. [FT-3b] is the guard against the obvious wrong fix, source !== "default": the read sites use sources[key] \|\| "ha", so an untouched token resolves to "ha", passes that test, and the chip becomes indistinguishable from All. [FT-3c] is the one that had NO coverage at all before β themeGroupCounts was a second, separate expression of the same question, so a header could read (1 / N) above two rows the chip would show; it sums the per-group counts over every group the registry declares and asserts the total equals what the chip lists, and it asserts more than one customised token exists in the fixture first, because with exactly one the two predicates agree and it could not discriminate. The fixture also now seeds groupSearchQueryByName, without which themeGroupCounts throws and no test could reach the group headers. |
map-compose-and-viewport.test.mjs |
25 | composeToSegments (custom-segment draft β save payload: subtract-ordering, group/room_id resolution, rotated-rect β polygon trig), clampMapTransform (off-screen-recovery clamp), applyMapZoom (focal-point), loadComposeDraftFromSegments (id-counter advance). |
learning-derive.test.mjs |
37 | endLearningJob (actual-vs-predicted summary with the >0 guards), _dashboardJobIsActive (terminal-status gate for the whole live-job UI), room count / timeline / banner fallbacks, estimate keying. |
map-texture-toggle-gate.test.mjs |
4 | The SVG-polygon texture toggle only renders where there are SEGMENTS to paint. map-texture-toggle drives mapFloorTextureEnabled, which gates _renderFloorTexturePolygon β called over state.mapSegments(), empty on a raster map β so on every raster map the button sat inert beside the β¨ one that works, under a near-identical name. It was gated on mapActive: whether the user is looking at the map, not whether the thing it controls is drawn. Same shape as issue #82's companion row. [MTG-3] is the regression guard and it is not hypothetical β the first cut put the gate on the OUTER block, which also holds the labels toggle and configure-map button, and would have removed three controls on a raster map with every other test green. Ablations: mapActive-only reds MTG-2 alone; outer-block gating reds MTG-3 alone. |
map-bundle-version.test.mjs |
3 | (runs in the scripts/ job, not test:units.) The map bundle is the one nothing could cache-bust: the panel and cards URLs are minted by _frontend_url.py with ?v=<mtime>, but the map is pulled in by a hard-coded runtime import() in the dashboard card, so a deploy that changed it never reached a browser holding the old copy. [MAPV-3] is the subtle one β the token is a hash of the map bundle's own OUTPUT, so building it after its consumers would hash the PREVIOUS run's file: a token stale by exactly one build, correct-looking in every log. Ablation: dropping ?v= reds MAPV-1 alone. It was never a service worker β measured on the live box, a plain-HTTP LAN origin is not a secure context, so none can register. |
card-theme.test.mjs |
5 | The opt-in VA theme on a dashboard card. [CVT-3] is the one that matters: the theme sensor is found by its vacuum_entity_id ATTRIBUTE, never by slugging sensor.<obj>_theme_state β a derived entity id is precisely the construction that produced issue #81, because HA slugs ids from the TRANSLATED name. Its fixture is a German-slugged sensor sharing no substring with the vacuum. [CVT-5] pins that turning the option OFF repaints with an empty token map rather than returning early: the writer clears by being called, so an early return welds the last palette to the host until a reload. Ablations: the slug lookup reds CVT-2/3/4/5, the early return reds CVT-5 alone. |
mascot-bar-collapse.test.mjs |
5 | ISSUE #82 β the companion CONTROL ROW collapses behind a caret, and the caret survives its own hide rule. The row was gated on isMapViewActive only, so the paw toggle hid the sprite and left every control on screen; two reviews read the paw as the answer and only the reporter's screenshot showed otherwise. [MBC-3] is the one that matters: the caret sits INSIDE the group it collapses, so the renderer's data-action and the stylesheet's :not(...) are a replica pair β rename either alone and the collapse swallows its own control with no way back. Ablation: the half-rename leaves [MBC-1]/[MBC-2] green and only [MBC-3] red. [MBC-4]/[MBC-5] cover the PERSISTED per-robot key: absent storage must read as EXPANDED, so the test is === "1" and not the neighbouring mapAnimalEnabled's !== "0" β copying that inverts the default and hides the row for every existing user on upgrade (ablation-proven), and a throwing localStorage degrades to shown, never to a hidden row with no control to restore it. |
room-editor-matching.test.mjs |
22 | Preset snap-back matcher (_editorFieldsMatchProfile), option-list builder (omit β hide picker), clean-mode / intensity canonicalization, carpet gate. |
run-profiles-steps.test.mjs |
20 | The run-profile STEPS editor draft state (charge-step / room-group authoring buffer): draft wiring, the "capture current room setup" snapshot, and editing an existing profile clones (never mutates) the stored steps. |
steps-order.test.mjs |
20 | The pure step-mutation helpers in steps-order.js β immutable derive-next-array primitives the steps editor rides on; mirrors the backend normalize for save. |
state/resolved-entity.test.mjs |
5 | live:ENT-10 β the card must use the entity the BACKEND resolved, not one it derives itself. batteryLevel() / isCharging() built sensor.${objectId}_battery and binary_sensor.${objectId}_charging from the vacuum's object_id, the same naming assumption ENT-1/ENT-5 fixed in Python β a fifth copy, in a language those fixes cannot reach. Issue #49: the backend resolves the battery sensor and it reads 100 while the card derives an id that does not exist. Pins the precedence, the unchanged derivation fallback, and [RE-4] pins the shipped SOURCE so a green mirror over un-rewired code cannot pass. |
saved-zones-group.test.mjs |
17 | savedZonesGrouped (group under room, live map order, trailing "Unassigned" bucket) and selectedSavedZoneIds. |
access-graph-model.test.mjs |
16 | access-graph-model.js β normalizeRefs (scalar / null / mixed / blanks) + the graph-model derivations. |
steps-manifest.test.mjs |
15 | renderStepsManifest β the pure "Runs As" stepβHTML helper shared by the run-profiles panel and the standalone profile card (per-step-type rendering, room-name lookup + fallback, single-vs-mixed clean-mode hint). |
room-access-logic.test.mjs |
15 | accessEditableRooms (exclude self/dock, hide rooms claimed by another under the single-inbound rule). |
zone-draft.test.mjs |
15 | _rectToNormalized zone coord conversion + multi-zone draft list, and canDrawZone β draw-gate lights up over the live backdrop or an active VA raster (Roborock cv-mode path), still gated by supportsZoneClean. |
external-jobs-group.test.mjs |
13 | externalWizardGroups (v1/v2 segment grouping) + wizard split-map / default-room seeding. |
run-profiles-normalize.test.mjs |
12 | _normalizeRunProfilesPayload (unwrap bare array / profiles / saved_run_profiles fallback; library guard). |
coded-label.test.mjs |
12 | The shared codeβtranslated-label resolver (namespace lookup with params, fallback rules). [CL-11/12] cover the twelve codes the BACKEND's start protection emits, none of which had a key before 2.5.3 β the resolver ran, missed, and fell through to the backend's English message every time, which is a fallback that is deliberate, correct and therefore silent. [CL-11] passes no message, because four of the twelve carry the backend's own wording on purpose (it was already good user-facing English and the key's job there is translation); without a message a fall-through returns the code, so "not the code" means the key resolved. [CL-12] then requires a shipped non-English pack to differ from English, since a key present only in en.js passes [CL-11]. The other half of the gate is tests/unit/test_block_reason_keys.py, which derives the code set by CALLING the producer. |
mascot-facing.test.mjs |
10 | mascotFacingSign β screen-space facing from content motion under map rotation, with a sub-threshold deadband (hold last facing). |
room-profiles-name.test.mjs |
10 | makeRoomProfileName (slug + custom_ prefix + _2/_3 collision suffix) + sorted profile lists. |
core-battery.test.mjs |
9 | batteryState β 5-band classifier with charging override + ordered thresholds, incl. the absent-vs-zero guard. |
maintenance-logic.test.mjs |
9 | findUpkeepItem (case-insensitive kind+component match) and canInvokeMaintenanceReset. |
metrics-logic.test.mjs |
9 | findMetricsSaveCandidate (match on profile_key AND room_slug across the selected source). |
steps-queue-order.test.mjs |
9 | The steps-queue order adapter β reordering the live ad-hoc queue (rooms + charge/wait breaks) as ONE list β room-order writes + recomputed after_index per break. |
affordance-and-warning.test.mjs |
8 | Regression (CENSUS-2): canPauseRun / canResumeRun must not trust a prepended data source that doesn't carry the field. |
clean-mode-options.test.mjs |
8 | Issue #48 card half: the stored DISPLAY label and the adapter TOKEN resolve to one clean-mode option. |
fault-label.test.mjs |
7 | Fault-label resolution (CARD-3): backend sends a KEY, never text; an unrecognised fault falls back to the raw vendor code (honest) rather than blank. |
live-map-url.test.mjs |
7 | _liveMapImageUrl β backdrop URL + camera cache-bust. |
entity-display-name.test.mjs |
7 | EDN-* β the one answer to "what does HA call this entity?". From 2026.11 a name is COMPOSED from its context, so hass.formatEntityName is asked first and the friendly_name attribute is the fallback. [EDN-2] is the load-bearing one and is written as an ablation: it deletes formatEntityName from the hass object, which is the exact shape of every core from the 2025.6.0 floor through 2026.3 β a fallback nobody exercises is indistinguishable from one that does not work. [EDN-3] pins the ARITY: HA is handed the state object and no name argument, because omitting it is what applies HA's own DEFAULT_ENTITY_NAME (parent_device Β· device Β· entity) instead of freezing us to today's built-in composition. |
live-pose-overlay.test.mjs |
7 | Live-pose merge β fresh pose overrides only the moving fields; static segmentation preserved. |
access-issue-label.test.mjs |
6 | Backend access-issue codes resolve to translated sentences with params; unknown codes degrade safely. |
live-trail.test.mjs |
6 | The live pose trail β accumulates anchors while cleaning, de-dups stationary repeats, freezes docked then continues the SAME trace on resume (recharge case), bounded length. |
mascot-dwell.test.mjs |
6 | Dwell-debounced mascot room tracker (state machine). |
room-hit-test.test.mjs |
6 | roomIdAtContentPct β pixel-exact room hit-test (Y-flip + contain letterbox). |
area-label-anchor.test.mjs |
5 | Per-room draggable mΒ² chip anchor. |
map-rotation.test.mjs |
5 | unrotatePct β pointer β content frame on a rotated map. |
review-exclude-reason.test.mjs |
5 | The review exclude-reason resolver β preset chip passes its value, "custom" passes the user's trimmed text (falls back to the literal custom). |
hidden-regions.test.mjs |
4 | Per-map user-drawn masks β accessor, draw gate, rect conversion. |
map-stale.test.mjs |
4 | CARD-2 clause 1: the map-stale selectors driving the dim treatment + "last seen" badge (no snapshot β not stale; fresh source β not stale). |
map-floor-placement.test.mjs |
5 | [MFP-*] β which room the placement control is for, and it exists because the control was attached to three surfaces in a row that could not show it. The last of those was this gate: it keyed on a single selected SVG segment, and the development map has zero segments β its rooms come from the room_pixels raster rids, so the polygon layer is empty, nothing there is selectable, and the panel could never appear however correct every layer behind it was. Measured in the running card before the fix: segments 0, selectedSegmentIds [], render data present at 256Γ245, panel absent from the DOM. The thread through all three misses was checking that a MECHANISM EXISTED rather than that it could FIRE ON REAL DATA, so [MFP-1] is built to catch a relapse: the state it is handed throws from every segment accessor, which means reaching for one cannot quietly work on maps that have them and fail on the ones that don't. [MFP-4] pins that an EMPTY draft is a real placement β Centre β and must not fall back to the saved value. Four ablations; reinstating the segment gate reddens all five cases. |
rooms-floor-fit.test.mjs |
5 | [RFF-*] β the per-room PLACEMENT of a fitted material, fourth field across these dicts and the one that shipped broken. It was clamped, persisted, carried through a map rebuild and read back out of .storage with the right numbers in it, and it vanished on every page reload β because the card does not read the store. It rebuilds its rooms from the room switch's ENTITY ATTRIBUTES, and floor_fit was not among them. Both ends correct, value never arrives: exactly the failure room_entities.py already describes beside floor_material, in a comment written for this situation. So the gate is the HOP. [RFF-3] names an array specifically, because that is the shape a bare typeof === "object" test lets through as a truthy non-placement. [RFF-4] pins that the object is COPIED out of the attributes β the attribute dict is handed out on every state read, and a live reference lets a draft merge write back into what HA handed us, which looks like a placement changing with nobody touching it. Two ablations red: aliasing instead of copying, and the carry dropped. |
rooms-floor-rotation.test.mjs |
5 | [RFR-*] β the per-ROOM map-texture angle, third field to cross these dicts and gated at the hop because the first two both shipped broken there. Per room rather than per material on purpose: rotation describes the HOUSE, so the --evcc-floor-<type>-map-rotate token that already existed could never express a hallway and a living room running different ways. [RFR-3] is the sharp one β the map paint key is ${type}|${degrees}, so a NaN angle stringifies to tile|NaN, a key that matches no decoded texture and never errors, leaving the room flat forever. [RFR-5] pins that two rooms sharing a material but not an angle produce different paint keys, which is the whole point. |
rooms-floor-material-reachability.test.mjs |
4 | [RFMR-*] β a REACHABILITY test, not a behaviour one. floor_material was written correctly and read correctly and still did nothing on the live box, because _normalizeRoom rebuilds the room object field by field and the new field was not in the list β so the value never travelled between two ends that both had passing tests. A test of either end cannot see a missing hop: the producer test builds its own input, the consumer test builds its own room. [RFMR-4] closes the loop by feeding the normalised room to resolveFloorType, so attributes-in β rendered-key-out is pinned on the card side; the python half of the same hop is [AXT-6/7]. |
steps-order-leading-break.test.mjs |
3 | Regression (CARD-6 clause 1): insertChargeStep / insertWaitStep refuse a leading/trailing break (unsupported positions). |
map-room-labels.test.mjs |
2 | Per-vacuum map room-label visibility toggle. |
src/cards/ β standalone-card logic¶
| File | Cases | What it guards |
|---|---|---|
dashboard-dispatch.test.mjs |
23 | The dashboard card's pure run-launcher logic. |
card-frame.test.mjs |
17 | CFR-* + CHP-* β the card FRAME as a three-copy replica set (room card frames with <ha-card>, the other two with a plain div), and the chip geometry they share. [CFR-1] and [CFR-8] are both file-wide COUNTS, and both had to become one: room-card.js holds two :host blocks, and a lazy :host\s*\{[\s\S]*?\} matches the one-liner at the top of the chrome styles, captures nothing and passes whatever you do to the real block β an ablation re-declaring the name reddened nothing. A count cannot be fooled by which block it found. [CFR-13] exists because [CFR-8] was quietly broken: its pattern was built in a template literal, where \s is not an escape and collapses to a literal s, so it compiled as --ha-card-...s*:s*([^;]+); β it matched what we write today and would have MISSED a second declaration written with a space before the colon, i.e. the exact defect it guards. String.raw now, pinned. [CFR-11] pins that the HA rung for background and border colour lives in foundation.js and NOWHERE in a card chain: behind an always-declared token it is dead, ahead of one it inverts VA-vs-HA precedence, and neither failure is visible to a test that only checks the name is present. |
theme-vars.test.mjs |
8 | TVR-* β per-instance card styling from YAML (theme_vars), Chris's ruling 2026-11-16: "YAML can be the winner its set directly after all", with "per isntance cards yes and everything we exposed should be settable". A generic map keyed by token name, so every token the editor exposes β and every one added later β is settable without per-token plumbing. [TVR-2] IS the ruling, as an ordering: applyDynamicTheme and this both write INLINE on the same host and the theme writer removeProperty()s every registry token it does not carry, so running theme_vars first does not merely lose, it is erased on the same tick β and only on cards with va_theme ticked, so both orders read as correct in review. [TVR-6] is the one every "it applies" test passes: without the previous-set bookkeeping a deleted key keeps painting until a reload, so the card visibly disagrees with its own config. [TVR-7] pins the --evcc-animal-* conversion β those are bare hsl() components, so a hex renders the animal black, and only on the YAML path. [TVR-8] had to be rewritten after ablation: it matched a bare mention of animalHslComponents, which the call site satisfies, so removing the import left it green while the card would throw a ReferenceError on first render β the exact mistake made while writing the feature. It now matches an import statement. Nine ablations, each reddening its own case. The round trip (two instances differing, beating a theme, releasing a key) is measured in Chromium against the built bundle on all three cards. |
map-theme.test.mjs |
5 | MAP-THEME-* β the nested map host gets the theme too. <eufy-vacuum-map> is a separate custom element with its own shadow root, and it injects foundationTokens into it; a declaration in an element's own tree beats a value inherited from the card, so the dashboard card painted the VA theme onto itself while the map inside it re-derived every surface from the HA theme. Measured 2026-11-16: the card resolved --evcc-surface-panel to Warm Light's #E7E0D3 while a host injecting the same foundationTokens resolved it to color-mix(in srgb, #1c2127 85%, #f0f2f5 15%) β a dark map box inside a light card, in every screenshot taken from that dashboard. This is the third instance of one shape: styles/apply-theme.js already bridges the same layer onto the modal host and the mounted preview card, and its comment records measuring exactly this. The card already forwarded hass, config, language and the snapshot; the theme was the one thing it did not. [MAP-THEME-1] pins the PREMISE β if the host stops owning a shadow root or stops injecting foundation, the bridge is cargo and these tests should go. [MAP-THEME-3] is the one a single call site passes and reality fails: themed only at creation it drifts on every editor keystroke, themed only on render it paints one frame unthemed, because the map is created after that render. [MAP-THEME-4] refuses an if (va_theme) guard β calling the bridge with enabled=false is not a no-op, it writes an EMPTY map, and that empty write is what REMOVES a previous paint. All five proven by ablation, each reddening its own case and no other. |
zone-geometry.test.mjs |
14 | The card's pure zone-clean geometry (verified vs the real X10 camera). |
map-room-color.test.mjs |
9 | Map room-fill colour resolution (roomFillTokenName / palette / override, normalizeHex) β the frontend mirror of the backend _hex_color_or_none. |
shared-slider.test.mjs |
6 | SLD-* β the Dreame wetness slider's BAND WORD, which the adapter ships as three English labels and sliderRow printed with no lookup. It is four sinks, not one: the rendered word plus the three data-word-* attributes the drag bindings copy from, so [SLD-2] is what stops a fix that reads correctly until the user moves the thumb. [SLD-3] holds the fallback for a custom-declared range (any three words an adapter config names), [SLD-4] is the argument-order bite β tVocabFn was inserted before idPrefix to mirror chipRow, so a stale caller silently loses data-scope and every slider commits to the wrong room β and [SLD-6] pins that both real callers actually pass a translator, because a correct helper with zero callers passes every test about the helper. [SLD-5] is the ablation. |
shared-chips.test.mjs |
4 | CHIP-* β WHICH chip renders as selected in the shared chipRow (issue #48: the comparison was identity, so a room storing the display label "Vacuum and mop" against the token option vacuum_mop lit no chip at all). [CHIP-2] is the guard against fixing that with a fold that matches everything, [CHIP-3] keeps the fold scoped to clean_mode because a brand's suction word is not core's to canonicalize, and [CHIP-4] pins canonicalCleanMode to the backend owner's alias table across the language boundary. |
card-suggestions.test.mjs |
5 | Managed-vacuum detection for the card-config suggestions (companion entities carrying a vacuum_entity_id attribute pointing back at the vacuum). |
zone-repeat.test.mjs |
5 | canZoneRepeat (CARD-6 clause 2) β the zone-repeat capability gate. |
grid-options.test.mjs |
4 | GRID-* β the getGridOptions() each card hands HA's sections view, which stops it warning that the card "may not display correctly with custom sizes". The grid was MEASURED on a live dashboard (24 columns of 21.25px, 8px gaps β the developer docs say twelve and are out of date), and all three cards render at 343px = exactly 12 columns, so columns: 12 restates what they already do and turning this on cannot move anybody's dashboard. [GRID-3] is the one carrying a ruling rather than a measurement: min_columns is deliberately permissive because the narrowest usable width depends on the user's ROOM NAMES and LOCALE β "Kitchen" and "VysΓ‘vΓ‘nΓ a vytΓrΓ‘nΓ" need different room β so a floor derived from English blocks exactly the users who most need to tune it. The red input is re-tightening any floor above HA's own most permissive built-in; raising one silently widens a dashboard the user had already arranged. |
va-theme-wiring.test.mjs |
5 | VTW-* β the opt-in VA theme reaches all three cards a user can add. card-theme.test.mjs next door tests the WRITER and passed completely while the writer had ONE caller and three consumers: a correct function nobody calls passes every audit, the same shape as _roomProfileLabel (zero callers, found by a census). [VTW-2] is the one that matters and it reddens against the code as shipped in 0a763b2a β the room card called the writer THIRTY LINES BELOW its own early return, under a comment explaining that returning early would "strand the last palette on the host". innerHTML = "" clears the card's CHILDREN while the tokens are inline style on the HOST and survive it, and the editor's vacuum-change handler fires room_id: undefined, so changing vacuum takes the render down the empty branch. The guard existed; the shoulder just above it did not. Both [VTW-2] and [VTW-3] were themselves strengthened by ablation: VTW-2 first indexed only the FIRST call site, so adding a second below the clearing branch left it green; VTW-3 first asserted === true appeared SOMEWHERE in the file, so the editor's own occurrence kept it green while the card's read went truthy. Both passed a half-broken file before being re-aimed. Ablations: moving the call below the clearing branch reds VTW-2; !!this._config?.va_theme reds VTW-3; next.va_theme = e.target.checked reds VTW-4 (and VTW-3, correctly); routing it through the default-ON bool() helper reds VTW-5 (and VTW-3). |
| theme-panel-link.test.mjs | 4 | PNL-* β the button in all three card editors that opens the panel's Theme tab, where the tokens a card reads are actually edited. The file is mostly about the two REPLICAS it creates, neither derivable from the other at runtime, both pinned by reading the other side rather than restating it: [PNL-1] reads panel_url_for's f-string out of panels.py (the panel is per vacuum, eufy-vacuum-<object_id>, and Python is what registers it), and [PNL-2] reads VIEWS.THEME out of render-cycle.js (the cards bundle cannot import that file β it drags the whole panel view machinery in). Registered as RNPCW1RC and RN91VM9P in 00c-replicas.md. A drift in either is silent and looks like success: the button renders and navigates, and lands on "panel not found" or on whatever tab was last remembered. [PNL-3] is the reachability guard β the link is withheld unless hass.panels actually holds that panel, because a vacuum can be mid-setup or have had its panel removed while its room switches are still there, and a button that navigates to a 404 is worse than no button. [PNL-4] is the three-editor one that costs a release: adding the markup to an editor and not the handler gives a button that renders, looks right and does nothing, which no test about the helper can see. Five ablations, all bite. |
| card-companion.test.mjs | 6 | CMP-* β show_companion, the issue #82 option that hides the map card's companion totally. 2.7.0 had folded the control row behind a caret and the reporter came back: a collapsed row still takes a line, because the caret is the line. The value here is that this is two gates wearing one name, and each half is individually plausible and individually wrong: the paw button that hides the companion SPRITE lives inside the control row, so gating only the row leaves an animal walking the map with no control able to stop it, and gating only the sprite leaves the row taking the space that was reported. [CMP-4] and [CMP-5] are those halves. [CMP-5] also pins wrap, not replace β an override that returns the option alone silently kills the user's own paw toggle while looking right with the option on β and pins that setMapAnimalEnabled stays un-stubbed, because it writes the SHARED per-vacuum key and a card that merely hid its companion must not overwrite the panel's choice. [CMP-6] is the editor's two halves, where "renders the checkbox" and "saves the checkbox" fail separately and both fail silently. [CMP-1..3] are the !== false default and the reachability link to it: a config written before the option existed carries no key, so truthiness would switch the companion off for every existing user on upgrade. These are text assertions, and the reason is structural, not laziness: the gates live in <eufy-vacuum-map>, which no runtime here can load β node throws on extends HTMLElement at module scope, and harness/build.mjs marks /eufy_vacuum/frontend/* external because the card pulls the map host in by its served URL. That is also why the predicate itself was moved to cards/_shared.js. Pack coverage for the new string is not duplicated here: measured, check:i18n passes with a pack missing the key and [LOCCOV-1] is what fails. All 7 red inputs were injected and each reddened exactly its own test, every restore byte-identical. |
src/theme-tokens/ β token-shape + floor-scoping logic¶
| File | Cases | What it guards |
|---|---|---|
helpers.test.mjs |
32 | makeTokenLabel (key β title-case label) + makeGroupedToken / makeTypedGroupToken (type-validated, finite-range-merge token factories), plus [LEN-*] β normaliseLengthList, issue #83's "or at least default to px". padding: 8 is not valid CSS and is dropped silently, so the number a user types produces no padding and no error. The weight is on what it must NOT touch: [LEN-2] pins that a unitless 0 stays unitless (valid CSS, and what people write), [LEN-5] that an empty box stays empty because empty means UNSET and must keep inheriting through the var() chain, [LEN-6] idempotence so a blur that changes nothing never rewrites the box, and [LEN-8] the two call sites in bindings/theme.js β the input handler coerces what is PERSISTED, the change handler rewrites what the user SEES, and one without the other stores a value the control contradicts. [LEN-4] was re-aimed by an ablation and that is the interesting part: it originally named an explicit if (/[(),]/.test(raw)) return raw guard as its red input, and removing that guard reddened NOTHING β the end-to-end part regex already covered every input the guard was written for. Measured across eleven inputs the guard changed four answers and was WRONG in three, because var(--evcc-space-md) 8 is a legitimate two-part list and the guard blocked exactly the coercion the function exists to perform. The guard was deleted, [LEN-4] now tests the regex that actually holds, [LEN-4b] pins the mixed-list case the guard broke, and [LEN-9] covers the one structural guard left (> 4 parts). |
per-card-tokens.test.mjs |
5 | PCT-* β the PER-CARD rung, Chris's call 2026-11-16 and framed by his reason for it: "yaml is fine for some but most of the reason i made the theme editor is to not need it for most people", so these are real registry tokens with controls rather than a var() a theme author could discover. [PCT-1] exists because the key list is spelled out and the token SHAPE is derived, and those two halves can drift. The keys have to be literals: scripts/check-styles.mjs builds its inventory by TEXT-SCANNING src/theme-tokens/, so keys built at runtime as `--evcc-card-${id}-${thing}` are invisible to it and every var() site reads as dangling β measured, the build failed with exactly 51, which is the site count. The shape stays derived from the shared sibling so a retuned range (this group carries two deliberately explicit ones) cannot diverge from its per-card twin. [PCT-1]'s expectation of which card reads what is stated INDEPENDENTLY of cards.js, because importing READS from the module under test would compare a thing to itself. [PCT-3] is the reachability half β a minted token with no var() site is a control that renders, stores a value and moves nothing, which no test about the token can see. [PCT-4] is the one [PCT-3] cannot do: it pins that the per-card rung sits OUTSIDE the shared one. Invert the two and the shared token always wins, the per-card control can never take effect, and [PCT-3] stays green because both names are still present in the file β proven by ablation, which reddened [PCT-4] alone. [PCT-5] pins an ABSENCE: none of the 34 card tokens may be DECLARED anywhere in src/, because that is the whole YAML path β an undeclared custom property inherits, so a themes.yaml entry reaches the card, and a declaration anywhere above it silently wins instead. The token keeps working in the editor and stops working from YAML, which reads to a user as a mistyped key. It sweeps every non-test .js rather than the three cards: ablated three ways, and the third β a declaration in styles/map.js β is one a three-card version would have missed. |
shadow-value.test.mjs |
8 | SHV-* β taking a box-shadow apart and putting it back, which is what lets the 16 shadow tokens have a real control instead of one text box. [SHV-1] is the test that matters and the corpus is the reason: the 8 values were read off a live install's saved theme before a line of the parser existed, because this control newly activates over data already on disk. 3 are single-layer, 4 two-layer, 1 three-layer β so the five-field control originally proposed would have served 37% and sent the rest back to a text box. The SHIPPED DEFAULTS are all single-layer, which is exactly why measuring those first gave the wrong answer, and [SHV-1] asserts the corpus keeps its [1,1,1,2,2,2,2,3] mix so it cannot quietly become the easy case. [SHV-3] is the one a naive implementation fails: every real value carries an rgba() with three commas of its own, so split(",") shreds a 2-layer value into five. [SHV-5] is the fail-open half β a var() reference must stay a reference, because a control that parsed it would rewrite it into a literal on the first keystroke and destroy the link with nothing on screen to explain why. [SHV-6]/[SHV-7] keep none and empty distinct (empty inherits a shadow, none overrides one, so removing the last layer must write none), and [SHV-8] pins that a spread with no blur emits an explicit 0 blur β otherwise a 1px ring silently becomes a 1px blur, and the ring is in half the real corpus. Six ablations, all bite. |
floor-scope.test.mjs |
14 | detectFloorScope / sliceThemeByTypes / clampThemeScalars β targeted theme export/import (longest-name-wins scoping, out-of-range scalar clamp). |
animals.test.mjs |
4 | Per-animal theme-token shape (editor lists only the tokens an animal themes). |
registry-display-names.test.mjs |
11 | FTL-* / ANM-* / DIV-1 β the two FRONTEND registries whose names reached the user untranslated. Everything else in the i18n census arrives from the backend; the floor textures and animal companions are declared in the card's own code and served assets, so no *_label field was ever involved and the surfaces printed the registry id β the theme editor's floor select showed carpet-high, and the preview's animal column showed cat while the map picker beside it showed Cat. The two completeness gates are why this file exists: both display helpers FALL BACK to a prettified id, so a registry entry with no key renders something plausible, and only a gate can tell "English by design" from "nobody added the key". [FTL-2] reads the preview's curated order back out of the source, because that order is a look decision and so cannot be derived from the registry. [FTL-5] and [ANM-4] are CALL-SITE gates, and [FTL-5] exists because it was missing: ablating the floor select back to ${name} left [FTL-1..4] green, since they test the helper and the helper was still right. [ANM-1/2] pin the one deliberate omission β Mittens is a memorial pet, a proper noun, so she has no key and resolves through the registry label in every language. [ANM-5] pins that a user-dropped animal's label cannot break out of the option it sits in, which the raw interpolation it replaced allowed. [DIV-1] is the one that is not about a missing key but about two PRESENT ones: these registries' nouns are also named by the older vocab.theme_group.* family, in the same theme tab, and the two sets were translated independently a pack at a time β so one animal or one carpet could read two ways on adjacent rows. It declares all 21 surviving divergences with a reason, in two classes (deliberate inflection, which a select option and a category heading legitimately differ on; and the newer value being the better one, where the edit belongs on the older key and so outside the release that noticed). An undeclared divergence is red, a declared one that has converged is red, and the compared guard is red if the keys stop resolving at all β all three proven by ablation, the third because without it the other two would pass over an empty set. A warning the same file now carries in its own comments: [ANM-3]'s helper read labels with /"label":\s*"([^"]*)"/, which the six GENERATED entries satisfy and the hand-written snake.js (label: 'Snake') does not, so the test asserted that the snake declares no label and [ANM-4] asserted that the roster exercises the no-label leg. Both passed; both were describing the regex rather than the roster. |
flatten.test.mjs |
12 | flattenThemeBuckets / hexWithAlpha / alphaApplies β the ONE rule for turning {tokens, colors, alpha} into a CSS-ready map. Guards the compose-not-concatenate invariant (a key in both colors and alpha must bake to 8-char hex, never resolve to the bare alpha number) and the composed / unappliedAlpha accounting that keeps a clean report honest. Eight of the twelve go red against the concatenation this replaced. |
src/textures/ β floor-material render math¶
Pure math + config resolution behind the map's floor-texture view (mask Γ colour Γ opacity compositing and the roomβmaterial mapping). No canvas, no DOM.
| File | Cases | What it guards |
|---|---|---|
floor-texture-compositor.test.mjs |
7 | compositeFloorTexture(w, h, baseColor, layers) β the maskΓcolourΓopacity blend the floor view samples: white mask reveals the layer colour over the opaque base, opacity scales the reveal, mid-grey blends halfway, layers stack bottomβtop, and degenerate inputs (short luma / opacity β€ 0 / missing) are skipped safely. Output stays fully opaque (a floor is a solid surface). |
user-materials-every-bundle.test.mjs |
5 | [UMB-*] β the BUNDLE BOUNDARY, walked as a real import graph rather than grepped from a built artifact. scripts/build-card.mjs emits three independent esbuild bundles, so FLOOR_TEXTURE_REGISTRY is three objects at runtime and merging the drop-in catalogue in the panel teaches only the panel. That shipped: a material could be installed, served, chipped and SAVED onto a room while <eufy-vacuum-map> β a DYNAMIC import of its own bundle β drew the room's plain floor_type, silently, because resolveFloorType falls through for an unknown material by design. [UMB-2] separates reaching the loader from CALLING it; [UMB-3] pins the entry list against the build so a fourth bundle cannot be born with the defect. |
floor-fit.test.mjs |
6 | [FFIT-*] β the geometry a FITTED material is drawn with: the cover factor, the centre, and how far a placement may pan before it stops covering the room. It exists because the arithmetic used to live inside _decodeMaskLum, where it could not be tested β node has no canvas, which is why that function has never had a test and why the whole floor draw is verified only by the visual baselines in CI. Pulled out, the one guarantee everything downstream rests on becomes checkable: tx/ty are fractions of the slack that EXISTS, not pixels or percent, so Β±1 runs the mask's edge up to the room's edge and every value in range still covers the room BY CONSTRUCTION β meaning there is no out-of-range case to detect, clamp or render anywhere else, and the stored number keeps its meaning when the raster resolution or the supersample moves. [FFIT-3] is that guarantee, checked at eleven angles by the room's four corners rather than by re-deriving the formula under test. [FFIT-2] pins the cover itself: it is computed in the SOURCE's frame, because scaling until the rotated image's own bounding box covers the box under-scales and empties the corners β a rect's AABB is larger than the rect. Five ablations, each reddening only its own claim: cover ignoring rotation, slack measured against the buffer instead of the room, slack not floored at zero, the pan not clamped, and a junk scale reaching the transform as NaN. |
floor-mask-canvas.test.mjs |
2 | [FMC-*] β every shipped mask is 2048Γ2048, read out of the PNG headers. The drop-in half was already refused by user_materials.py; the shipped half had nothing, and the top of bindings/map.js said so in as many words for months. It stopped being cosmetic when sample_m arrived: the card divides a real-world measurement by MASK_CANVAS_PX, so a mask at another canvas makes that arithmetic stop describing the file it is applied to. [FMC-2] exists because a directory walk that matched nothing would pass [FMC-1] vacuously. Ablation-proven by rewriting one IHDR width to 1024. |
user-material-scale.test.mjs |
15 | [UMS-*] β a field that was validated, stored and read by NOBODY. scale in material.json was accepted by the python validator, written to catalog.json and carried onto the built material from 1a183bb2, but it sat on the OUTER object while mergeUserMaterials puts only .entry into the registry β and the registry is what _resolveFloorScale reads. Invisible for an ordinary reason: the only material anyone had declared 0.05, which IS the global fallback, so wired and unwired behaved identically. These test REACHABILITY and PRECEDENCE rather than storage β [UMS-2] drives the real resolver and reddens if EITHER half of the wiring goes, [UMS-3] pins that the declared value differs from the global so the suite can actually fail, and [UMS-5] keeps the theme token winning, since a declaration is a default and not a lock. [UMS-9..14] cover the PHYSICAL path that replaced it as the preferred way to size a pack β sample_m, in metres, from which the card derives the scale using the map's own resolution. [UMS-9] asserts the round trip rather than a constant, so the arithmetic bites and not just the number; [UMS-12] pins that two layers declaring the same size resolve EQUAL, which is the registration guarantee a hand-matched pair of raster scales could only reach by accident. All six ablation-proven, each naming the intended test. [UMS-15] came out of the review: a drop-in id may contain an underscore, and the sizing tokens hyphenated it while tokenFor and the python preset namespace use the raw id β so for cork_dark a preset naming the token the card read was REFUSED outright and one naming the token the namespace demands was accepted and inert, with no legal spelling between them. Both are now read, raw first. Its bite is an id containing _, which no earlier case uses. |
floor-texture-resolver.test.mjs |
10 | resolveFloorType(room) (spec {floor_type, carpet_type} β carpet_low/carpet_high; legacy combined forms; hardwood/laminateβwood, graniteβgranite_light aliases; direct registry keys; case/whitespace-insensitive; unknownβdefault) and normalizeFloorRotationDeg(deg) (non-finiteβ0, quantise to 0.1Β° so getComputedStyle noise can't churn the cache, wrap to [-180, 180)). |
src/renderers/ β pure math extracted from render methods¶
These computations previously lived inline in renderX(ctx) methods; they were
extracted into exported pure functions (behaviour-preserving; the render methods
now delegate) so they could be unit-tested off the render path.
| File | Cases | What it guards |
|---|---|---|
theme-parsers.test.mjs |
28 | _parseColorMix / parseScalarThemeValue / alphaPercentFromHex (+ serialize/clamp) β the CSS color-mix + scalar + alpha-hex parsers behind the theme editor. |
map-geometry.test.mjs |
20 | _polygonCentroid (signed-area + degenerate fallback), _savedZoneBbox, _overlayTransform (object-fit:contain letterbox). |
maintenance-derive.test.mjs |
40 | maintenanceDueInBucket(item, now, t) (due-in projection with 3-day / 0.1-h-per-day guards; now/t injected), needs-attention verdict, remaining-percent branch. Plus [FREQ-1..6] on _formatMaintenanceFrequency (added 2026-08-07, when it was found to be dead code its one call site could never reach): sentence case not title case (Π Π°Π· Π² Π½Π΅Π΄Π΅Π»Ρ and Einmal pro Woche must survive unchanged), hyphens preserved while underscores collapse (every 3-6 months is a real bundled value the old [_-]+ class would have mangled), Turkish dotless i (Δ°ki, not Iki), and [FREQ-5] β a language value that is TRUTHY but stringifies to "" must not throw, which is the shape that made String(x \|\| "en") crash the whole view via toLocaleUpperCase(""). These drive the REAL function through applyMaintenanceRenderers, not a transcription of it. Also [LG-*]/[LGK-*] on _localizedGuide (prose and key routing, the latter against the REAL served key packs) and [MIN-*] on _maintenanceItemName β a translated component key beats the backend label, a MISSING one falls through rather than leaking a bare i18n key into the modal title, and [MIN-5] pins the ORDER of the two key families. That order is the one property the real catalogue cannot test: five components have a sensible entry in both, so a real-pack assertion passes whichever answers. vocab.maintenance_component.* must lead, because it is the family the two modal titles already resolve through and it is brand-scoped. |
job-summary.test.mjs |
15 | The Job Summary modal β the surface that closes the gap between the job JSON and what the user is told about a run. |
review-error-badge.test.mjs |
14 | The review list's captured-run-errors (run_errors) badge β surfacing the backend's harvested error rows. |
setup-reconciliation.test.mjs |
12 | CARD-7/RP-019 β the reconciliation review banner (renderReconciliationPanel, driven through the whole renderSetupView() since it's a closure, not a proto method). |
progress-and-format.test.mjs |
6 | Regression (FE-LRN-1 +1): two renderers that showed a plainly wrong thing β the live-progress list's completed/current dispatch fall-through. |
maintenance-census6.test.mjs |
6 | CENSUS-6 β server-baked English reached the user in all 18 locales; the maintenance renderer must translate, not pass through. |
language-control-font.test.mjs |
5 | The typeface picker inside the language control (P3 of the OpenDyslexic accessibility feature). |
review-matcher-clean-mode.test.mjs |
5 | CC-5 β the review profile-matcher's clean-mode chip row comparison. |
review-absent-battery.test.mjs |
4 | REV-6 β an externally-captured run with absent battery must not render "Battery 0". |
review-truncation-note.test.mjs |
4 | REV-5 β the run list is cut to limit (50) while the headline stat counts all runs; the truncation must be said. |
theme-preview-room-card-state.test.mjs |
7 | TPS-* β the theme preview renders REAL room cards with NO state, and renderRoomCard must tolerate that. [TPS-1..3] inject the three distinct shapes of absence (null β the grid default at 8 of 9 call sites; {} β present but no such method; the real _themePreviewState()), because a test for one does not carry the others. [TPS-4/5] keep the predicate load-bearing in both directions, after the first draft asserted the lowercase token and so "passed" against a chip that was there β the chips render title-cased. [TPS-6] is the replica gate RNJE1GDZ: it diffs the state accessors renderRoomCard reads against the set _themePreviewState declares, and fails on drift. That drift took the whole Theme view down for 2.4.0 β d32aa092 added a seventh accessor to the reader and not to the stub, and wrote the reads bare where every sibling read is state?.x?.(). All 7 ablated; the comment-stripping in [TPS-6] is itself ablated, because the gate first matched state?.x?.() out of a comment documenting the convention it enforces. |
stored-setting-vocab.test.mjs |
16 | SSV-* β the panel sinks that printed a room or dock SETTING as the backend's English, in two shapes. Precedence: Station Water, the room-estimate rows and the planned-water tooltip each already had a correct tVocabRaw arm and tested the backend's *_label first, so the localizing arm was only reachable when the label was absent β which the backend never does. Missing call: the map selection bar's per-room summary, the rule editor's setting chips and the native zone-setting selects had no lookup at all. Renders the real renderers against a real shipped pack and reads every expected word out of that pack, so a retranslation does not turn it red. [SSV-4] is the second half of the Station Water bug β the status bucket was matched against the string about to be displayed, so translating the display would have broken the bucket. [SSV-7] keeps Dreame's numeric fine-wetness ("16") passing through untouched, [SSV-9] keeps an axis core has never seen on the adapter's own words, and [SSV-12] covers a double-escape measured live in fr/he. [SSV-13..15] extend it to the enum tank cards and to the maintenance item NAME, which resolved through a different key family than the modal title for the same item on the same screen. [SSV-16] is the one test here that SUPPLIES its own input rather than reading one: the item-name helper's escaped-twin bug is latent only because the ten Latin packs still hold raw English for most of component_label, so it registers a locale carrying French's "RΓ©servoir d'eau propre" instead of waiting for the first translation. All twelve fixes ablated. |
maintenance-water-card.test.mjs |
7 | WTR-* / TNK-* β a device with NO water-level sensor rendered a confident "Empty Β· ~0 ml remaining", from JS coercion rather than missing data (Number(null) is 0, so Number.isFinite was true for a null reading β status replace_now). [WTR-1/1b] are that input; [WTR-3] is the same coercion on tank capacity. The file deliberately echoes i18n keys so it asserts the BRANCH rather than any wording β which means every vocab.* lookup misses by construction, so [TNK-1] pins the FALLBACK leg: the tank-state set is the device's, so a state we have never keyed must still reach the user as its own label. The keyed leg needs a catalogue and lives in stored-setting-vocab.test.mjs [SSV-13]. |
backend-sentence-vocab.test.mjs |
11 | ATT-* / UPK-* / WAT-* / EST-* / REF-* / OA-* β the census bucket whose NAME was the mistake. These eight sinks were triaged as "backend English sentences needing reason-codes, the separate larger job" because they were classified by what the sink printed rather than by what sat beside it; measured against the producers, seven are card-side and three needed no key at all. [ATT-2] covers a live, measured defect: the Base Station subtitle wrapped both arms of its || in one escapeHtml, and of the 17 packs it is the one whose subtitle carries an apostrophe, so that panel shipped dell'attivitΓ . [ATT-3] inherits the absent-is-not-zero rule rather than rediscovering it. [UPK-1] caught a regression in the fix itself: _maintenancePrimaryValue's last resort is the placeholder "Unknown remaining life", so ranking it above the backend chain made an item carrying only a backend summary read as the placeholder β losing information, not localizing it. [ATT-4] and [REF-2] are call-site gates, both added because the ablation refused to go red; [REF-2]'s first version pinned one old spelling and an ablation that wrapped the value in anything else slipped past it. |
rule-editor-vocab.test.mjs |
8 | RUL-* β the rule editor's 22 CARD-LOCAL words. Every other i18n-census sink had a backend *_label beside it, which is what made it findable; these had nothing. ruleOperatorGroups and ruleEntityDescriptor composed their own English in the STATE layer ({label: "State"}, {label: "Is ON"}, category: "boolean") and the renderer printed it β no field to notice, no vocabulary to miss, no key to be absent from. The fix follows state/rooms.js's block reasons: the state returns a CODE, the renderer localizes, the state's English rides along as resolveCodedLabel's message so an operator added without a key reads rather than showing a dotted key ([RUL-4]). [RUL-5] and [RUL-8] read the state layer's whole tables from source instead of walking one entity's chips, because ruleOperatorGroups filters by what the descriptor allows β a binary_sensor never offers the numeric group, so an earlier version could not see code: "numeric" being deleted at all. [RUL-6] is why the four comparison operators are keyed rather than left hardcoded: a bare > is ambiguous in a right-to-left layout, so ar/he carry words while the fifteen LTR packs keep the symbol. |
profile-name-vocab.test.mjs |
13 | PRF-* / EST-* / CHG-* β the saved-profile NAMES, and two derived codes printed bare. A zero-caller story: _builtInProfileI18nKey maps the seven saved-profile keys onto the seven translated rooms.profile_* values and _roomProfileLabel wraps it, but the map was reached from one place (the room editor's chip loop) and the wrapper from nowhere β while three surfaces printed the backend's English profile names beside it. Same shape as the device_id filter behind #77, in a different subsystem. [PRF-1] and [PRF-2] are the two directions of the precedence decision, and it is not "localized first, always": a built-in's backend label is English so the key must beat it, while a user-saved profile's label is the name somebody typed so it must beat a prettified slug. [PRF-8] covers the fallback arm of _localizedProfile, which is every multi-room job β the backend attaches flat setting codes only for a single-room job with an archived room. [PRF-6b], [CHG-2] and [PRF-9] are call-site gates, two of them added because the ablation refused to go red without them; [PRF-6b]'s first draft anchored on the field name and landed on the comment above the call. |
base-station-stat-vocab.test.mjs |
6 | BSV-* β the two Station Status rows CENSUS-6 stopped short of. It fixed the "Dock status" row to resolve the CODE and left "Lifecycle" and "Task" immediately below it reading label ?? code, so both were English in all 17 locales while the row above them was translated β the shoulder just after a guard's window closed. Renders the real card through the real translate() over a shipped pack rather than transcribing the resolution, which is the RNNPSKT7 shape its maintenance-census6 sibling fell into. [BSV-5] records why one fix missed two rows: the three adjacent rows resolve through three different fields from three different producers. [BSV-2] is the ablation; [BSV-6] pins the raw/escaped twin choice to the sink. |
rooms.test.mjs |
4 | confidenceTooltip (CARD-2 clause 3) β finite sample counts fold into the tooltip; a count of 0 still renders; numeric strings coerce. |
i18n-escaping-contract.test.mjs |
4 | live:I18N-1 β the tRaw escaping contract in renderers/shared.js (what escapes, what must not double-escape). |
learning-charge-status.test.mjs |
3 | The live charge banner gates ONLY on liveChargeStatus() β a charge_wait phase has an empty room timeline, so the old queue-gated placement never rendered it. |
learning-zone-status.test.mjs |
3 | The live zone banner β same shape as the charge banner: gated on liveZoneStatus(), never on the room queue. |
run-profiles-unsupported-position.test.mjs |
3 | CARD-6 clause 1 display half β an EXISTING saved profile with a leading/trailing break renders the unsupported-position notice. |
maintenance-clock-modal-host-css.test.mjs |
3 | MHC-* β every evcc-* class the counter picker emits is DEFINED in MODAL_HOST_STYLES, the body-portal cascade that actually renders it (the shadow cascade interpolates that export, so the flow is one-way). Caught .evcc-clock-candidate-main, emitted with no rule in either cascade, on its first run. |
maintenance-clock-candidate-value.test.mjs |
3 | MCV-* β a candidate's reading is rounded to one decimal. The same picker read "414 min" on a Dreame and "206.618888888889 h" on a Roborock; non-numeric states pass through untouched. |
room-estimate-allocated.test.mjs |
2 | CARD-2 clause 2 β the room-estimate modal's ALLOCATED-source labeling (not just default). |
metrics-edge-mopping-capability.test.mjs |
2 | CARD-8 β the "Edge Mopping" subtitle chip must be capability-gated, not shown whenever edge_mopping is truthy. |
card-floor-material-reachability.test.mjs |
5 | [CFM-*] β the same missing hop a FOURTH time, gated on the CARD's view model. floor_material must survive four explicit-field dicts between storage and a pixel (entity attributes β _normalizeRoom β _normalizeRoomDisplayData β _renderFloorTextureLayer), and each rebuilds its object field by field. This one hid in a telling way: the MAP resolves from the state-layer room and was already fixed, so the map painted a room's drop-in while every ROOM CARD for that same room painted its plain floor_type β two surfaces disagreeing about one room, no error, both halves individually fine. [CFM-4] pins that carpet stays sourced from floor_type, so a material a stranger named can neither set nor clear the water guarantee; [CFM-5] pins that a drop-in id goes in the MATERIAL slot, since resolveFloorType yields default for one passed as a floor type. |
theme-preview-user-materials.test.mjs |
5 | [TPU-*] β a token group with no preview is a control surface that answers nothing. A drop-in mints its own editor group and 14 tokens, and all of that worked β but THEME_PREVIEW_REGISTRY is a static map keyed by group NAME listing the seven shipped floor types, and the preview grid is a curated shipped-only order, so the group mounted with no preview beside it and no swatch in the grid. Reads as βthe render is not drivingβ: every control present, nothing responding, and no error β a missing key is simply a group without a preview, which is correct for the many that have none. Pins the animal pattern the floors now follow; each of the three pieces reddens its own case (entry β 1/2/3/5, grid β 4, renderer β 2). |
theme-preview-coverage.test.mjs |
3 | TPC-* β every token group has a preview, or says why not. _renderThemePreviewPane returns "" for a group with no THEME_PREVIEW_REGISTRY entry and the pane then renders nothing, which is indistinguishable from a group whose preview has little to draw β so Map, the largest group at 34 of 434 tokens, has had none since the pane was built and nobody noticed. Map is allowlisted here with a reason about the SURFACE (it is a canvas painted from live raster data the editor does not have, and a drawn mock would be the facsimile trap of RNJE1GDZ); "nobody got round to it" is what [TPC-1] exists to surface rather than record. The value is not Map but the NEXT group: Dashboard Cards was added in this same work and would have shipped previewless but for a deliberate decision, with nothing to say so. [TPC-2] guards the other direction β a preview row left behind by a renamed group is unreachable and makes the coverage count look better than it is, which [TPC-1] cannot see because it only asks whether groups have previews. [TPC-3] is allowlist hygiene, the same clause as gallery-completeness.spec.mjs. A node test, not a harness spec: it compares two registries and needs no browser, so npm run test:units already runs it and no workflow line has to be remembered. The two DYNAMIC group families (animals, user floor materials) are built from the same roster as their preview entries and cannot drift, so they are out of scope by construction. All three ablated β and [TPC-2]'s first ablation renamed a key, which orphaned an entry AND uncovered a live group, reddening two tests; re-run by ADDING an orphan it reddens only its own. |
src/actions/ β service-call wrappers (failure/refusal surfacing)¶
The audit campaign's CARD-1 family: a failed or refused service call must
reach the user, not just the console. callService passes
notifyOnError: false (suppressing HA's own error toast), so these wrappers
are responsible for telling the user β and the two shapes (a throwing call
vs a normal response carrying {success: false, reason}, the operational-
refusal contract) are pinned separately.
Every fake at the hass seam must return the ENVELOPE. hass.callService(...,
returnResponse) resolves to {context, response}, never the bare payload. Until
2026-09-13 all four fixtures below returned it bare β a fixture agreeing with the CALLER,
not the callee β so callService's refusal check, which read result.success off the
ENVELOPE and could therefore never fire, sat under six green cases for months. Wrap fakes
with envelope() from _test-host.mjs. Ablating the unwrap in core.js now turns 8
of these cases red while every no-toast control stays green.
| File | Cases | What it guards |
|---|---|---|
rooms-clear-applied.test.mjs |
8 | Defect #8 β post-apply room mutations (updateRoomFields, persistRoomOrdering) drop the pending applied stepped run profile so Start runs the just-edited FLAT selection, not the saved step sequence. |
core-envelope-shape.test.mjs |
7 | CES-* β the {context, response} ENVELOPE contract: callService returns the UNWRAPPED payload; a null response falls back to the envelope (not null, which would report a save that took as a failure); REPLICA RNGP3ZBE parity with cards/_shared.js::callResponse; the second funnel (_callThemeService) revives; and the predicate stays NARROW β {ok:false}/{updated:false}/{status:"error"} remain their own funnels' business, or one refusal toasts twice. |
core-refusal-shape.test.mjs |
6 | CRS-* β the generic callService wrapper toasts a non-throwing {success: false, reason} response. Fixture returns the real envelope. |
core-service-failure.test.mjs |
6 | A throwing service call surfaces as a toast (was: console.error + resolve null). |
rooms-cancel-through-seam.test.mjs |
6 | The card-cancel bypass β Cancel must call the integration's cancel_active_job, never stock vacuum.return_to_base (which left the tracker believing the job was live). |
fetch-failure-tristate.test.mjs |
5 | A FAILED fetch is not rendered as a confident empty result β "never loaded" / "failed" / "genuinely empty" stay distinct. |
theme-refusal-toast.test.mjs |
5 | CARD-9 β _callThemeService, the single funnel of all ~11 theme actions, toasts the theme services' own refusal shape. |
map-zone-clean-refusal-toast.test.mjs |
4 | MZ-2 β the zone-clean call site routes through the refusal-toasting wrapper (e.g. job_in_progress). |
rooms-start-refusal-toast.test.mjs |
4 | FE-ERR-1 β startCleaning itself routes through the refusal-surfacing wrapper. |
review-snapshot-origin.test.mjs |
3 | getLearningHistorySnapshot forwards EVERY filter param (the origin chip was a silent no-op β destructured away). |
rooms-retry-missed-map-scope.test.mjs |
3 | CARD-5 β retryMissedRooms refuses (map_mismatch) when the incomplete-run log's map disagrees with the active map. |
src/i18n/ and src/styles/¶
| File | Cases | What it guards |
|---|---|---|
i18n/rtl.test.mjs |
10 | isRTL (ar/he/fa/ur/iw/ps) + applyDir + the bidi-isolate (FSI/PDI) behavior of translate β the logic half of the RTL gates. |
i18n/font-store.test.mjs |
8 | FS-* β the per-user typeface store: the coverage gate reads FONT_SUPPORT (never a hardcoded "en"), region tags resolve to their base, unverified locales are refused even when Latin-script, scalar clamps. |
i18n/card4-untranslated-strings.test.mjs |
1 | CARD-4 β the three base-catalog strings that were missing from every shipped locale pack stay present everywhere. |
i18n/locale-key-coverage.test.mjs |
2 | LOCCOV-* β the GENERALISATION of CARD-4: every English key is translated in all 17 packs, not three named ones. check:i18n's default mode reports the fallback count and passes, and nothing in CI runs --strict-coverage, so a key added to en.js and translated nowhere reached users with nothing red. LOCCOV-2 is an ablation: it runs the same check against two injected defects β a new English key in no pack (must add one pair per pack) and an existing key pruned from one pack (must add exactly that pair) β so LOCCOV-1 passing means something. Both deltas are measured against the tree's own baseline, so the ablation still holds mid-wave. |
styles/surface-card-override.test.mjs |
5 | SCO-* β the one derived token a Home Assistant theme may override (issue #83). The reason this file exists is that check-styles.mjs structurally cannot see what it guards: its TOKEN_REF matches var(--evcc-surface-card-override, β¦) fine, but LINT_TARGETS is built by filtering out TOKEN_DEF_FILES, which is exactly new Set(["foundation.js"]) (check-styles.mjs:139-143) β so the one file this mechanism lives in is the one file token-lint does not read, and it still prints "every --evcc-* reference resolves", truthfully, about everything it looked at. A typo in the override name would ship green, and its only symptom would be a theme author's override silently doing nothing β #83 again, caused by us. [SCO-2] is the subtle one: the override is load-bearing by its absence, since an undeclared custom property is what inherits from the document, so declaring it anywhere β even as initial, even "for completeness" β re-closes the door. Ablations: reverting the declaration reds SCO-1; a typo'd override name reds SCO-1 (the case no other gate can reach); declaring the override reds SCO-2; self-referencing the declared property reds SCO-3; adding a second override reds SCO-5. Cascade behaviour itself was measured in headless chromium against the real 10,793-char token string, with the #83 attempt as the control β setting --evcc-surface-card on the document leaves the computed value unmoved, which is what makes the fix a fix rather than a guess. |
styles/typeface-wiring.test.mjs |
6 | live:FONT-1 β the --evcc-font-family token is SET by a rule the shadow tree reads and READ where it resolves (the token was set by a rule nothing read, for two days). |
src/bindings/ and src/controllers/¶
| File | Cases | What it guards |
|---|---|---|
controllers/learning-controller-progress.test.mjs |
19 | getRoomProgressSnapshot (per-room progress flags/percent) and _computeProgressPercent. |
bindings/room-rules-save-reaches-service.test.mjs |
6 | RRS-* β reachability: the rule save/delete bindings actually reach saveRoomRules, which did not exist (call-only since eae291fa), so both sites evaluated to undefined and the drawer closed with no error while the rule vanished. Also pins that an EMPTY list is sent (deleting the last rule is a clear, not a no-op) and that a refusal keeps the drawer open. room-rules-payload.test.mjs could not catch this β it proves the payload is built, never that it reaches a sink. |
bindings/maintenance-clock-response-unwrap.test.mjs |
6 | MCU-* β the maintenance-COUNTER picker's two service calls unwrap .response. The picker rendered "no suitable counter found" over a list of six because it read result.candidates off the envelope; the save path additionally treats {status:"error"} as a refusal rather than a save that took. |
bindings/room-rules-payload.test.mjs |
9 | _buildRulePayload β rule draft β persisted payload (modifier/blocker action, clean_passes 1|2 gate, fan-out filter). |
bindings/setup-reconciliation.test.mjs |
9 | CARD-7/RP-019 β the reconcile-room Update/Dismiss bindings (bare-proto mixin + recorded _onAll handlers). |
bindings/theme-import-rejected.test.mjs |
8 | CARD-9(3) β rejected-keys surfacing at BOTH theme-import entry points. |
bindings/theme-overwrite-confirm.test.mjs |
7 | CARD-9(2) β the Save button's overwrite-confirm dialog (no silent overwrite). |
bindings/map-segments-staleness.test.mjs |
5 | The map-segments slice follows the ACTIVE MAP β not fetched once for the life of the element. |
bindings/room-editor-save-rejection.test.mjs |
4 | _roomEditorSaveWasRejected β a rejected room-editor save is detected and surfaced. |
bindings/rooms-queue-missed-map-scope.test.mjs |
4 | CARD-5 binding side β the missed-rooms retry binding passes the recorded map id into the map-scoped action. |
bindings/theme-preset-confirm.test.mjs |
3 | CARD-9 β preset-chip clicks confirm before discarding a dirty working draft, and re-clicking the already-active theme is a no-op. |
How it's tested¶
Every file uses Node's built-in runner and assertions β no jsdom, no DOM shim:
Two patterns:
- Mixin accessors (
src/state, controllers) β build a stub proto and set only the fields the method reads: - Module functions (
src/cards,src/theme-tokens, the extracted renderer helpers) β import and call directly, likesrc/cards/map-room-color.test.mjs.
Anything that needs a rendered card (DOM, computed styles, visual output) is a render-harness spec instead, not a unit test.
CI¶
npm run test:units runs in
node-tests.yml
on any src/** change, in the pinned Playwright image. So a src/state/ or
src/renderers/ refactor that breaks a derivation fails CI on push. The gate
authority is npm run test:units returning non-zero on any failure β mirroring
pytest tests --no-cov for the Python suite.
The three tracks¶
The frontend has three separate test tracks, none of them pytest:
- Unit tests (this doc) β
npm run test:units, pure logic at the module boundary. - Render harness β
npm run test:harness, the rendered card headless: smoke, visual regression, CVD, shape marks, intake. - i18n / sanitiser / build-script node tests β
npm run check:i18n(scripts/check-i18n.mjs, the translate/escape trust-model incl. the double-escape case),scripts/sanitize-locale.test.mjs(the locale-sanitiser browser gates) andscripts/hash-dir.test.mjs(the cache-bust token: HD-1 line endings must not move it, HD-2/HD-6 a binary file's0D 0Amust not be folded β every shipped texture PNG contains that byte pair). All run innode-tests.yml.
scripts/served-indexes.test.mjs (IDX-*) belongs to this track and guards a
packaging contract rather than logic. __init__.py's _prepare_static_dirs writes
an index.json beside the animal modules and another beside the shipped locale packs
at every HA startup, and the card fetches both at runtime to know what to load.
animals/index.json was gitignored while locales/index.json was not, although one
function writes both from the same rule β so after a card-only HACS update, which
replaces the folder with a zip of the tag, the animals index was simply absent: the
fetch 404'd, the rejection was swallowed, and the map's mascot did not appear until the
next restart. Nothing was red, and a card-only release said no restart was needed.
[IDX-1/2] hold each index against its directory by the generator's own rule,
[IDX-3] holds that both are tracked and that neither is ignored again, and [IDX-4]
pins the two ways manifest.js now survives the disagreement β r.ok before parsing
(the 404 body was HTML, so the original .then(r => r.json()) threw on the body rather
than the status) and allSettled over the loads, because the index is a startup
snapshot and one unserved file used to take every other animal down with it.
[IDX-5] holds the roster's BYTE SHAPE, because two different writers produce it:
__init__.py uses json.dump, whose default separators are ", ", while the
animal-submission workflow writes the same list from Node, where a bare
JSON.stringify emits no spaces. Same list, different bytes β and the cost is not
cosmetic: the bot commits the compact form, then every HA start and every Python-suite
run rewrites it to the spaced form, so the maintainer's tree goes dirty on that path
from the first merged community animal onward and the next submission flips it back.
It asserts on BOTH sides β the workflow's write (red if it stops re-spacing) and the
committed artifact (red if the file is ever stored compact), so a future writer that
gets it wrong some other way is still caught. Nothing in this repo parses workflow
YAML, which is why the source half is a text assertion rather than a behavioural one.
[IDX-3] reads the ignore files directly, with no git subprocess, and it took two
corrections to get there. It first shelled out to git check-ignore, which never
reports a tracked file β so with the index committed, putting the ignore line back
left the suite green: a guard that read as a guard and tested nothing, which is the
same shape it exists to catch. --no-index fixed that locally and CI then rejected
the subprocess outright (fatal: detected dubious ownership β the node job runs in
the pinned container, where the checkout belongs to another user), 127 of 128 passing
with this as the only red. A packaging guard must not depend on a usable git, so it
now walks the ancestor .gitignore files itself and matches the three shapes a rule
can take: the exact path, a bare index.json, and a nested .gitignore in the
directory β that last one being what a root-only scan would miss. Committed-ness is
then covered structurally rather than by asking git: the runner checks out committed
content only and nothing in that job writes either file, so their presence in CI is
the proof.
backend-sentence-vocab.test.mjs [EST-3] is worth singling out for the same reason in
reverse. It drives the pre-job estimate panel's renderer, where [EST-1] beside it
re-implements the renderer's resolveCodedLabel call β and that is exactly why [EST-1]
stayed green while three codes rendered the backend's English in all 17 packs. The panel's
branch is entered by estimate.error || estimate.available === false and those three
arrive under reason, a field the renderer did not read, so code was undefined and
coded-label.js ranks message above its genericKey. Measured by reverting
code: estimate.error || estimate.reason: [EST-3] goes red, [EST-1] passes. A test
of a resolver cannot see a wrong argument at the call site β the census found five
helpers that were right with callers that were not, and this is the sixth. Its producer
half is tests/unit/test_estimate_reason_keys.py (ERK-*, documented in
subsystems/06 β Learning).
scripts/check-animal-pr.test.mjs [APR-8/9/10] cover the other end of the same
change. animals/index.json is the one file under animal-svg/ a community animal PR
may touch, and it has to be: adding an animal necessarily updates the roster, so a gate
that rejects it would deadlock the contributor β rejected for touching it, [IDX-1]-red
for not. Allowing it is paid for by two checks, because the card does
loadScript('animals/' + entry): every entry must be a bare <id>.js name ([APR-10],
which exercises ../../../etc/passwd.js, sub/dir.js and a non-string against the pure
indexProblems helper, so the hostile shapes need no tracked file mutated), and every
module the PR adds must be listed, with a message saying how to fix it ([APR-9]).
animal-submission.yml regenerates the roster in the same commit as the module, so the
bot's own PRs satisfy this without a maintainer step.