Experimental touch - #79
Merged
Merged
Conversation
…ncyWidget.tsx Fix: forward the useSleepEfficiency error to WidgetShell so a failed request surfaces a QueryError instead of the misleading 'No sleep efficiency data' empty state (matching RouteEfficiencyWidget/RegenEfficiencyWidget). Add a comprehensive Vitest + RTL suite covering vehicle resolution, loading/empty/error states, the populated gauge + stats, the asleep/offline sleep-total filter, gauge colour thresholds, null-safety, the compact layout, the help-tooltip a11y label, and the freshness refresh interaction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add co-located Vitest coverage for ALERTS_TOUR (definition metadata, step shape, routeMatch regex + registry integration, and onShow navigation incl. same-page no-op and pushState-throw resilience). Harden navigate() so a history.pushState SecurityError inside onShow can no longer bubble out of the useTour effect and crash the walkthrough. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Widget.tsx Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Register the real past-tense automation audit actions the Go backend writes to audit_logs (internal/automation/audit.go: created/updated/deleted/enabled/disabled/re_enabled/test_run/undo/imported/exported/executed/failed/auto_disabled). The registry only had imperative keys (automation.create/update/delete) that never match a real feed entry, so every automation event collapsed onto the generic fallback. Additive change: existing entries and tests are untouched; adds matching i18n keys in en.json and tests asserting each action resolves to its own visual, failures flag distinctly, and unlisted verbs still degrade to the domain entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Widget.tsx Fix two real unit-conversion bugs surfaced by the new tests: - Distance: distanceKm (km) was fed straight into convertDistanceFromSI (which expects SI metres), skewing values ~1609x (62 mi rendered as 0.0). Now lifts km -> SI metres -> display unit via the lib. - Efficiency: Wh/km was double-converted (MI_TO_KM then *1.609344), wrong in both unit branches. Now scaled once by the lib-derived km-per-display-unit span (250 Wh/km -> 402 Wh/mi / 250 Wh/km). Harden: keep cached metrics on background-refetch error (error && !data), stable useCallback refresh handler, drop unused UNITS import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…idget.tsx Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…VisualWidget.tsx Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ur.ts Add a comprehensive co-located Vitest suite covering AUTOMATIONS_TOUR metadata, registry wiring, step ordering/well-formedness, routeMatch regex, and the first step's onShow navigation (off-route push, already-on-route no-op, and history-failure paths). Harden the internal navigate() helper: wrap history.pushState + popstate dispatch in try/catch so a SecurityError or throwing listener cannot escape the React effect that runs onShow and tear down the tour overlay. Mirrors the defensive style in @/lib/tourRegistry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add getStateConfig(map, state, fallbackLabel?) — a null-safe, prototype-pollution-safe resolver returning a neutral fallback StateConfig (never undefined) so callers can read .label/.color/.variant without a guard. Mirrors the enums.ts / FSMBadge / getActivityVisual fallback idiom; reuses a module-level singleton on the hot path. Add comprehensive co-located Vitest coverage for every export: data integrity across all six state maps (valid hex color, valid variant, non-empty label), a backend-FSM drift guard on vehicleStates, and full getStateConfig behaviour — exact hits, unknown/null/undefined/empty fallback, custom fallback label, prototype-key regression, purity and the StateConfig shape contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…idget.tsx Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add comprehensive Vitest coverage for the charging onboarding tour: identity/shape, launcher-only (no autoStart), registry resolution, step well-formedness + unique ordered spotlight targets, routeMatch RegExp accept/reject, and the onShow imperative-navigation side effects (pushState + popstate), the no-op guard when already on-route, and the invariant that every navigating step lands on a path its own routeMatch covers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…orsWidget.tsx Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…alysis.ts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a comprehensive co-located Vitest suite covering every runtime export of the charge-session FSM (states, entries/theming, triggers, guards, transitions, edges, disallowed<->coverage consistency, coverage matrix, scenarios, FSM assembly + registry integration, and ChargeSignalContext shape). Fix a latent coverage-matrix bug: the four CHARGE_SESSION_DISALLOWED pairs were marked null instead of 'disallowed', so isValidTransition() reported them as ambiguous 'no info' rather than forbidden-with-reason. Align them to 'disallowed' to match the vehicle FSM contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add comprehensive co-located Vitest suite (27 cases) covering deriveEdges and isValidTransition plus every exported FSM type contract. Harden deriveEdges with a null-safe input guard and a collision-safe JSON composite dedup key, and make isValidTransition null-safe when the coverage matrix is missing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add direct whole-module coverage for the vehicle FSM (states, entries, labels, triggers, guards, transitions, disallowed, coverage matrix, truth table, scenarios, edges, FSM wiring, signal context, deriveVehicleStatus) with trigger-level truth-table/transition consistency checks stronger than the registry sweep. Fix deriveVehicleStatus JSDoc: it claimed an 'offline fallback' but returns 'online' when a state object exists without a stronger signal (matches the tested twin in api/types.ts). Comment corrected; behaviour unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…vation
The per-unit gate only ran 'go test -race' on each unit's own package, so
cross-package regressions surfaced only in the aggregate 'go test -race ./...'
validation. Fixes:
- api/{energy,teslachargehist,teslachargesess,teslaenergylivestatus,
teslauserconfig,teslauserorder,teslauserprofile,vehicleaccess}: handler
construction tests passed nil pools into eager, nil-hostile constructors
(db.Pool nil-panic / 'db must not be nil'). Pass construction-safe
&database.DB{} / &tesla.Client{} instead.
- adapter/postgres: tripRepository used a concrete *pgxpool.Pool field while
every sibling repo uses the pgxPool interface seam; align it so the fake
pool injects, and wrap CollectRows errors with context ('collecting trips
for vehicle') to match the getters.
- api/apiauthctx: add the arch-required doc.go // Layer: handler (package was
extracted by an elevation unit that fixed a real 403 bug but omitted doc.go).
- web/src/ai: regenerate stale aigen mirrors (pre-existing drift) via
'go run ./tools/aigen'.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
30 elevation-added FE test files passed in isolation (the per-unit gate ran only that file) but failed in the full 'vitest run' because later units hardened shared components/hooks/formatting, leaving stale expectations. Fixed all 30 to assert current behaviour; corrected real source bugs found along the way: - cost-analysis useCostAnalysisData: fix double distance conversion (was metres->miles before a display fn that converts again) — pass SI metres directly; add null-safety + finite guards. - useVehiclePhoto, BreadcrumbOverridesContext, AutomationBuilderPage, ExportStatusWidget, TirePressureVisualWidget, TripReplayPage, InfoTile, TelemetryGrid: null-safety / merge / unit-display hardening surfaced by tests. Full suite: 1574 test files / 23021 tests pass; tsc --noEmit clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #
Type of Change
Checklist
Screenshots (if applicable)