]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(simulator): seed autoRegister and ocppProtocol defaults into stationInfo (#2082)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 14 Aug 2026 13:39:35 +0000 (15:39 +0200)
committerGitHub <noreply@github.com>
Fri, 14 Aug 2026 13:39:35 +0000 (15:39 +0200)
commit2cc95879ce5519b7a1e1df12c43e3bc713420939
tree7dc411d660263b4d0c246507d6f3ecd6b8903cb1
parent6495e7a8359b69f26c5b677fc90c6d8c5d43b737
fix(simulator): seed autoRegister and ocppProtocol defaults into stationInfo (#2082)

* fix(simulator): seed autoRegister and ocppProtocol defaults into stationInfo

autoRegister and ocppProtocol had no default, so a template omitting them
left stationInfo carrying undefined for both. Raw consumers of stationInfo
— the UI data payload (buildChargingStationDataPayload) and the persisted
configuration — therefore received undefined, so the Web UI station details
showed an empty placeholder for Auto Register and OCPP Protocol.

Both are static defaults (no derivation), so seed them in DEFAULT_STATION_INFO
(autoRegister: false, ocppProtocol: OCPPProtocol.JSON) alongside currentOutType
and ocppVersion. getStationInfo applies them via
mergeDeepRight(DEFAULT_STATION_INFO, stationInfo), so an explicit template/file
value or option still wins (idempotent, no clobber) and a persisted config
predating the fields is backfilled on reload. Export OCPPProtocol from the
types barrel to keep Constants.ts importing types from a single source, as
OCPPVersion already does.

Runtime-neutral: ocppProtocol has no runtime read; the autoRegister === true
guards are unaffected by false vs undefined; the getHeartbeatInterval warn
guarded by === false is unreachable in the initialized pipeline because
initializeOcppConfiguration always seeds the HeartbeatInterval key first.

* refactor(test): extract persisted-config resolution into realStation helpers

The persisted configuration file/dir resolution from a real-station template
was inlined and duplicated across three suites (AutoRegisterOcppProtocol,
NumberOfPhases, ResetIdentity). Extract persistedConfigurationDir and
resolvePersistedConfigurationFile into StationHelpers.realStation.ts (single
source of truth for the temp-dir layout) and migrate all three call sites.
resolvePersistedConfigurationFile throws a descriptive error when no config
exists yet, replacing the silent `?? ''` fallback (which degraded into EISDIR).

Group the helper by concern (temp-dir lifecycle / construction / persisted-config
resolution) with section headers, and document the two new helpers in
TEST_STYLE_GUIDE.md.

* docs(test): harmonize helper-table param placeholders in TEST_STYLE_GUIDE
src/types/index.ts
src/utils/Constants.ts
tests/TEST_STYLE_GUIDE.md
tests/charging-station/ChargingStation-AutoRegisterOcppProtocol.test.ts [new file with mode: 0644]
tests/charging-station/ChargingStation-NumberOfPhases.test.ts
tests/charging-station/ChargingStation-ResetIdentity.test.ts
tests/charging-station/helpers/StationHelpers.realStation.ts