]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(simulator): seed numberOfPhases default into stationInfo (#2078)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 11 Aug 2026 22:09:54 +0000 (00:09 +0200)
committerGitHub <noreply@github.com>
Tue, 11 Aug 2026 22:09:54 +0000 (00:09 +0200)
commit4fb658ce70d18d728e58b02dcb8e22451aedf163
treecc99d426623abf521a028fbdbc93150bc7b18117
parent9337eafab836a76c239e391ebef841aab6655157
fix(simulator): seed numberOfPhases default into stationInfo (#2078)

* fix(simulator): seed numberOfPhases default into stationInfo

The derived numberOfPhases default (AC: 3, DC: 0) lived only in the
getNumberOfPhases getter and was never written to stationInfo. Raw
consumers of stationInfo — the UI data payload (buildChargingStationDataPayload)
and the persisted configuration file — therefore received an undefined
numberOfPhases, so the Web UI showed an empty placeholder instead of the
effective phase count.

Seed stationInfo.numberOfPhases via the existing getNumberOfPhases getter
in getStationInfo, post-merge and source-agnostic, so both freshly
template-derived and already-persisted (legacy) configurations are fixed.
Idempotent: an explicit AC template value is preserved (?? 3), DC pins 0.
Backend consumers keep reading the getter and are invariant.

* test(simulator): align numberOfPhases test names with should-prefix convention

* test(simulator): cover DC phase pinning and persisted-config backfill

Add two discriminant cases to the numberOfPhases seeding suite:
- DC pins numberOfPhases to 0 even when the template sets a value
- a persisted configuration predating the field is backfilled on reload
  (the file-sourced path that motivated seeding in the orchestrator)

* docs(simulator): harmonize numberOfPhases seeding review nits

- reuse the canonical flushMicrotasks test helper instead of a local
  node:timers/promises import
- expand the test @file description to cover DC pinning and legacy backfill
- align the seed comment terminology on "backfill"

* test(simulator): dedupe test baseName literal into a constant

* docs(simulator): tighten seeding comments (drop getter paraphrase)

* docs(simulator): fix backfill comment accuracy and align seed wording

* test(simulator): inline baseName to match sibling station-test convention

* test(simulator): consolidate real-station-from-template scaffolding into a shared helper

Six charging-station tests each hand-rolled the same temp-dir template
scaffolding to build a real ChargingStation (the mock factory bypasses
initialize()/getStationInfo()). Extract writeStationTemplate/copyStationTemplate/
createStationFromTemplate/cleanupStationTemplates into StationHelpers.realStation,
migrate all six tests, and document the helper in TEST_STYLE_GUIDE.

* test(simulator): share temp-file and singleton-reset test helpers

Extract the mkdtemp/write/cleanup boilerplate into tests/helpers/TempFiles.ts
(createTempDir/writeTempFile/cleanupTempDirs) and a resetSingleton() helper into
TestLifecycleHelpers, then migrate the file-I/O tests (IdTagsCache, EvProfiles,
JsonFileStorage, Configuration-HotReload, FileUtils, UIMCPServer integration) and
the singleton-reset tests (Bootstrap, SharedLRUCache, IdTagsCache) onto them.

* docs(test): document TempFiles helpers and resetSingleton in the style guide
20 files changed:
src/charging-station/ChargingStation.ts
tests/TEST_STYLE_GUIDE.md
tests/charging-station/Bootstrap.test.ts
tests/charging-station/ChargingStation-ConfigurationTemplateIsolation.test.ts
tests/charging-station/ChargingStation-ConversionEfficiency.test.ts
tests/charging-station/ChargingStation-NumberOfPhases.test.ts [new file with mode: 0644]
tests/charging-station/ChargingStation-Reconnect.test.ts
tests/charging-station/ChargingStation-ResetCancellation.test.ts
tests/charging-station/ChargingStation-ResetIdentity.test.ts
tests/charging-station/IdTagsCache.test.ts
tests/charging-station/SharedLRUCache.test.ts
tests/charging-station/helpers/StationHelpers.realStation.ts [new file with mode: 0644]
tests/charging-station/helpers/StationHelpers.ts
tests/charging-station/meter-values/EvProfiles.test.ts
tests/charging-station/ui-server/UIMCPServer-Integration.test.ts
tests/helpers/TempFiles.ts [new file with mode: 0644]
tests/helpers/TestLifecycleHelpers.ts
tests/performance/storage/JsonFileStorage.test.ts
tests/utils/Configuration-HotReload.test.ts
tests/utils/FileUtils.test.ts