Jérôme Benoit [Mon, 16 Mar 2026 23:02:44 +0000 (00:02 +0100)]
ci: move coverage/lint/typecheck/sonar pipeline from Node 22.x to 24.x
Node 22 --experimental-test-coverage has known bugs (nodejs/node#55510)
that cause false CI failures. Move all gated steps (coverage, lint,
typecheck, SonarCloud, dependency review) to Node 24.x. Node 22 remains
in the test matrix for regular pnpm test runs.
Jérôme Benoit [Mon, 16 Mar 2026 21:56:52 +0000 (22:56 +0100)]
fix(tests): add second flushMicrotasks for RequestStopTransaction listener
The async chain in requestStopTransaction traverses a dynamic import()
in checkConnectorStatusTransition (OCPPServiceUtils), which may resolve
after the first setImmediate on macOS + Node 22. A second flush ensures
the StatusNotification call completes before the assertion.
Jérôme Benoit [Mon, 16 Mar 2026 21:56:52 +0000 (22:56 +0100)]
fix(tests): add second flushMicrotasks for RequestStopTransaction listener
The async chain in requestStopTransaction traverses a dynamic import()
in checkConnectorStatusTransition (OCPPServiceUtils), which may resolve
after the first setImmediate on macOS + Node 22. A second flush ensures
the StatusNotification call completes before the assertion.
Jérôme Benoit [Mon, 16 Mar 2026 21:36:24 +0000 (22:36 +0100)]
test: harmonize event listener test pattern across OCPP command test files (#1730)
* test: harmonize event listener test pattern across OCPP command test files
Add event listener test sections to 7 OCPP incoming request command test
files (4 OCPP 1.6, 3 OCPP 2.0) following the reference pattern from
RequestStopTransaction, TriggerMessage, UpdateFirmware, and GetLog tests.
Each listener section contains: registration test, accepted-fires test,
rejected-not-fires test, and error-graceful test.
Also restructures CustomerInformation to wrap existing listener tests in a
properly named describe block, and adds createOCPP16ListenerStation helper
to OCPP16TestUtils.ts.
- Extract createOCPP20ListenerStation to OCPP20TestUtils.ts, removing
duplication between RequestStart and RequestStop test files
- Replace inline import('node:test').mock.fn with top-level mock import
in RemoteStartTransaction tests
- Remove redundant mock.reset() from 3 listener afterEach blocks —
standardCleanup() already calls mock.restoreAll()
- Replace all await Promise.resolve() with flushMicrotasks() across 5
OCPP 2.0 test files for more robust async side-effect flushing
* fix(tests): replace remaining await Promise.resolve() with flushMicrotasks()
8 occurrences in 5 files (3 OCPP16, 2 OCPP20) missed in the initial
review fix. Now all listener tests use flushMicrotasks() consistently.
- Fix import paths in 7 OCPP 2.0 test files: ../../../../tests/helpers/
→ ../../../helpers/ (correct relative path, consistent with 35 sibling
files in the same directory)
- Add eventType assertion in RequestStartTransaction listener test to
verify TransactionEvent(Started) per E02.FR.01
- Add flushMicrotasks() to RequestStopTransaction listener test for
consistent emit→flush→assert pattern
* refactor(tests): move mock.method to beforeEach and parameterize trigger tests
- Move duplicated mock.method calls into listener beforeEach blocks
in 5 files (UpdateFirmware, GetLog, GetBaseReport, CustomerInfo,
Firmware). Rejection tests override inline. Net -147 lines.
- Parameterize OCPP16 + OCPP20 TriggerMessage trigger-fires tests
using data-driven triggerCases arrays (already done in prior commit,
this commit includes the Firmware mock cleanup).
* style(tests): remove inconsistent separator comment in RemoteStopUnlock
The listener section had a '// ───' separator not used in any of
the other 10 test files. The await describe block is sufficient.
* docs(tests): add summary line to startTransaction JSDoc
* docs(tests): add event listener testing section to TEST_STYLE_GUIDE
Add §11 documenting the established listener test pattern: emit()
direct, flushMicrotasks(), listenerCount first, accepted/rejected/error
triad, mock.method in beforeEach. Add listener station factories to
§9 mock factories table and flushMicrotasks to §10 utility table.
* docs(tests): fix incorrect mock API in §11 code example
Replace Jest-style mockImplementation() with Node.js test runner
mock.method() override pattern matching actual test code.
* fix(tests): align all 112 test files with TEST_STYLE_GUIDE
- Move @file JSDoc headers above first import in 3 files (GetVariables,
MessageChannelUtils, Utils)
- Replace await Promise.resolve() with flushMicrotasks() in
AutomaticTransactionGenerator
- Replace 6 setTimeout(resolve, 50) hacks with flushMicrotasks() in
ChargingStationWorkerBroadcastChannel
- Document spec traceability prefix exception (G03.FR.xx, G04.INT.xx)
in TEST_STYLE_GUIDE §1 naming conventions
* docs(tests): align TEST_STYLE_GUIDE with actual test infrastructure
- Fix createMockChargingStation location (ChargingStationTestUtils →
helpers/StationHelpers)
- Add 7 widely-used factories to §9 table (10+ usages each)
- Remove unused expectAcceptedAuthorization from §9 auth table
- All locations verified against actual exports
- Core Principles: clarify assert.ok is for boolean/existence only
- §5: add missing quotes around glob in test script (matches package.json)
- §10: restore setupConnectorWithTransaction/clearConnectorTransaction
(27 usages across test suite — should not have been removed)
Jérôme Benoit [Mon, 16 Mar 2026 17:58:26 +0000 (18:58 +0100)]
refactor(tests): separate handler/listener tests and remove setTimeout hacks
Align TriggerMessage, UpdateFirmware, and GetLog test files with the
RequestStopTransaction reference pattern:
- Split into 'Handler validation' + 'event listener' describe groups
- Replace raw setTimeout delays with withMockTimers where needed
- Use emit() directly for listener tests (no wrapper helpers)
- Follows TEST_STYLE_GUIDE.md conventions
Jérôme Benoit [Mon, 16 Mar 2026 16:54:02 +0000 (17:54 +0100)]
refactor(ocpp): harmonize post-response event listener pattern across stacks
Move post-response logic from inline handler to event listeners:
- OCPP16 UpdateFirmware: fire-and-forget in handler → event listener
matching OCPP20 UpdateFirmware pattern
- OCPP20 RequestStopTransaction: await in handler → event listener
matching OCPP16 RemoteStopTransaction pattern
All commands with post-response behavior now use the same pattern:
handler validates and returns response, event listener performs
the async action after the response is sent to the CSMS.
Jérôme Benoit [Mon, 16 Mar 2026 16:28:14 +0000 (17:28 +0100)]
refactor(ocpp20): move TransactionEvent(Started) to event listener pattern
Move sendTransactionEvent(Started) and startTxUpdatedInterval from
inside handleRequestStartTransaction to a post-response event
listener in the constructor, matching the OCPP 1.6
RemoteStartTransaction pattern where the handler validates and
returns Accepted, then an event triggers the actual StartTransaction
message send.
Jérôme Benoit [Mon, 16 Mar 2026 15:54:52 +0000 (16:54 +0100)]
fix(ocpp): graceful OCPPError fallback instead of throw in buildMessageToSend
Replace defensive throw with OCPPError construction when messagePayload
is not an OCPPError instance. Uses InternalError code per OCPP-J §4.2.3.
Harmonizes with the ternary instanceof pattern used at L452/503 in the
same file for errorDetails extraction.
Jérôme Benoit [Mon, 16 Mar 2026 15:20:23 +0000 (16:20 +0100)]
fix(ocpp20): send actual MeterValues on trigger and block sessions during firmware update
- F06.FR.06: TriggerMessage for MeterValues now sends TransactionEvent(Updated)
with actual meter readings for each EVSE with active transactions instead
of hardcoded value: 0
- L01.FR.07: UpdateFirmware sets idle EVSE connectors to Unavailable when
AllowNewSessionsPendingFirmwareUpdate is absent or false, preventing new
sessions while waiting for active transactions to end before installing
Jérôme Benoit [Mon, 16 Mar 2026 14:58:06 +0000 (15:58 +0100)]
fix(ocpp20): send TransactionEvent(Started) on RequestStartTransaction (E02.FR.01)
The handler accepted remote start transactions without notifying the
CSMS via TransactionEvent. Per E02.FR.01, the CS SHALL send
TransactionEvent with eventType=Started when a transaction begins.
Also starts meter values interval for the new transaction.
Jérôme Benoit [Mon, 16 Mar 2026 13:09:55 +0000 (14:09 +0100)]
refactor(ocpp20): remove redundant lastFirmwareStatus from per-station state
lastFirmwareStatus in the WeakMap was a duplicate of
stationInfo.firmwareStatus (now written by sendFirmwareStatusNotification).
TriggerMessage now uses hasFirmwareUpdateInProgress() to determine
whether to send Idle or the current intermediate state, which also
fixes a bug where failure end states (DownloadFailed, InstallationFailed,
etc.) were returned instead of Idle.
Jérôme Benoit [Mon, 16 Mar 2026 12:36:04 +0000 (13:36 +0100)]
refactor: use union types consistently in common code and tests
- OCPPServiceUtils: use SampledValue union in generics, use
StatusNotificationRequest union in satisfies, remove unused
OCPP20StatusNotificationRequest import
- BroadcastChannel: use MeterValuesRequest/Response unions
- OCPPServiceUtils-validation.test: OCPP16MessageTrigger → MessageTrigger,
remove redundant casts
Jérôme Benoit [Mon, 16 Mar 2026 12:27:33 +0000 (13:27 +0100)]
refactor(ocpp): use union types in common code where possible
- OCPPServiceUtils: use SampledValue union in generic constraints
instead of inline OCPP16SampledValue | OCPP20SampledValue union;
use StatusNotificationRequest union in satisfies check
- BroadcastChannel: use MeterValuesRequest/Response unions instead
of OCPP20-specific types in version-dispatched handleMeterValues
Stack-specific types remain in version-switch branches where
TypeScript requires narrowed types for array push operations.
Jérôme Benoit [Mon, 16 Mar 2026 12:20:30 +0000 (13:20 +0100)]
refactor(tests): use union types instead of stack-specific types in common tests
Replace OCPP16RequestCommand → RequestCommand,
OCPP16IncomingRequestCommand → IncomingRequestCommand, and
OCPP20RequestCommand → RequestCommand in test files outside
stack-specific directories. Remove redundant 'as Type' casts
that were bridging the gap.
Jérôme Benoit [Mon, 16 Mar 2026 12:11:41 +0000 (13:11 +0100)]
refactor(ocpp20): prefix OperationalStatusEnumType with OCPP20
Last unprefixed OCPP 2.0 type participating in a common union.
OperationalStatusEnumType → OCPP20OperationalStatusEnumType
matching the OCPP16AvailabilityType counterpart in the
AvailabilityType union.
Jérôme Benoit [Mon, 16 Mar 2026 12:00:33 +0000 (13:00 +0100)]
refactor(ocpp20): prefix FirmwareStatusEnumType, extend FirmwareStatus union
- Rename FirmwareStatusEnumType → OCPP20FirmwareStatusEnumType per
existing OCPP16FirmwareStatus naming convention
- Extend FirmwareStatus union to include all OCPP 2.0.1 firmware states
- Extend FirmwareStatusNotificationRequest to union both versions
- Write firmwareStatus to stationInfo in sendFirmwareStatusNotification
fixing hasFirmwareUpdateInProgress which was always returning false
- Stack-specific code uses OCPP20FirmwareStatusEnumType, common code
uses generic FirmwareStatus union
Jérôme Benoit [Mon, 16 Mar 2026 00:20:36 +0000 (01:20 +0100)]
fix(ocpp16): reject float values for integer configuration keys per spec §5.3
Replace convertToInt (parseInt — silently truncates 3.7 to 3) with
Number.isInteger check. The spec §9.1 defines these keys as Type:
integer, and §5.3 requires Rejected for values that do not conform
to the expected format.
Jérôme Benoit [Sun, 15 Mar 2026 23:59:05 +0000 (00:59 +0100)]
fix(ocpp16): return Idle in TriggerMessage when not actively uploading/updating
Per spec §4.4/§7.24 and §4.5/§7.25, Idle SHALL only be sent via
TriggerMessage when not busy. The code was returning stale terminal
statuses (Uploaded, UploadFailed, Installed, etc.) instead of Idle.
- DiagnosticsStatusNotification: return Uploading only when actively
uploading, Idle otherwise (fixes stale Uploaded/UploadFailed)
- FirmwareStatusNotification: return Downloading/Downloaded/Installing
only when in progress, Idle otherwise (fixes stale Installed/Failed)
- UpdateFirmware guard: allow retry after DownloadFailed or
InstallationFailed instead of blocking all non-Installed statuses
Jérôme Benoit [Sun, 15 Mar 2026 23:13:20 +0000 (00:13 +0100)]
refactor: replace 54 unsafe error casts with instanceof guards
All 'error as Error', 'error as OCPPError', and 'error as
NodeJS.ErrnoException' casts replaced with proper instanceof
type narrowing across 16 files. Uses the pattern already
established in the auth strategies module:
error instanceof Error ? error.message : String(error)
For call sites that pass error objects to functions, wraps
non-Error values: error instanceof Error ? error : new Error(String(error))
Jérôme Benoit [Sun, 15 Mar 2026 22:57:20 +0000 (23:57 +0100)]
refactor(ocpp): extract responseHandler and incomingRequestHandler into base classes
Both methods were 95% identical across OCPP 1.6 and 2.0 subclasses
(~160 lines of pure duplication). Move the shared logic into the base
classes, parameterized by 3 abstract properties each subclass provides:
- bootNotificationRequestCommand / pendingStateBlockedCommands
- csmsName ('central system' vs 'CSMS')
- isRequestCommandSupported / isIncomingRequestCommandSupported
Zero behavior change — pure refactoring validated by 1853 passing tests.
Jérôme Benoit [Sun, 15 Mar 2026 22:37:22 +0000 (23:37 +0100)]
fix(ocpp): use per-subclass singleton map to prevent version collision
The singleton instance was stored as a single static field on the base
class. In mixed OCPP 1.6/2.0 workers, the first getInstance() call
wins — subsequent calls for a different version silently return the
wrong instance cast via 'as T'.
Replace with Map<Constructor, Instance> keyed by the concrete subclass
constructor. Each version now gets its own singleton entry. Zero
changes needed in subclasses or calling code.
Jérôme Benoit [Sun, 15 Mar 2026 22:24:20 +0000 (23:24 +0100)]
fix(charging-station): add try/finally guards to lifecycle methods
Prevent zombie state flags when exceptions occur:
- start(): wrap in try/finally to always reset starting=false
- stop(): wrap in try/finally to always reset stopping=false
- reset(): catch stop() failure and abort instead of proceeding
with sleep+start on a half-stopped station
- delete(): catch stop() failure so cleanup always proceeds
Jérôme Benoit [Sun, 15 Mar 2026 20:43:50 +0000 (21:43 +0100)]
chore(ocpp-server): migrate pyproject.toml to PEP 621 project metadata
Move name, version, description, authors, readme from deprecated
[tool.poetry.*] to [project.*] per PEP 621. Move dependencies from
[tool.poetry.dependencies] to [project.dependencies] with PEP 508
specifiers. Set requires-python to >=3.12,<4.0 to match ocpp package
constraint. Regenerate poetry.lock.
Jérôme Benoit [Sun, 15 Mar 2026 20:29:21 +0000 (21:29 +0100)]
fix(tests): remove stale optional chaining on now-required variableAttribute
ReportDataType.variableAttribute was made required in 429cdbe3 but
test files still used ?. and ?? [] on the field. The stale eslint
cache masked these errors locally; CI (no cache) correctly rejected.
Jérôme Benoit [Sun, 15 Mar 2026 20:16:10 +0000 (21:16 +0100)]
fix(ocpp20): implement proper M04.FR.06 guard via isChargingStationCertificateHash
The previous M04.FR.06 guard was ineffective: it called
getInstalledCertificates() which scans root cert directories and
maps types via mapInstallTypeToGetType(), which has no case for
ChargingStationCertificate (stored via CertificateSigned, not
InstallCertificate). The V2GCertificateChain filter never matched.
Add isChargingStationCertificateHash() to OCPP20CertificateManager
that directly scans the ChargingStationCertificate directory and
compares certificate hashes. Use it in handleRequestDeleteCertificate
for a reliable M04.FR.06 guard.
Jérôme Benoit [Sun, 15 Mar 2026 20:04:35 +0000 (21:04 +0100)]
fix(ocpp20): remediate 4 conformance findings from cross-audit
- M04.FR.06: Narrow DeleteCertificate guard to V2GCertificateChain type
only, allowing legitimate deletion of root certificates (CSMSRoot,
ManufacturerRoot, MORootCert, V2GRoot)
- B09.FR.05: Use InvalidConfSlot reasonCode per errata 2025-09 when
configurationSlot is not in NetworkConfigurationPriority list
- B09.FR.04/FR.31: Check AllowSecurityProfileDowngrade variable before
rejecting downgrades — allow 3→2 when true, never allow to profile 1
(errata 2025-09 §2.12)
- L01.FR.06: Wait for active transactions to end before commencing
firmware installation via polling loop in lifecycle simulation
Jérôme Benoit [Sun, 15 Mar 2026 19:22:37 +0000 (20:22 +0100)]
refactor(ocpp16): track diagnosticsStatus and extract composite schedule helper
- Add diagnosticsStatus to ChargingStationInfo, set at each
DiagnosticsStatusNotification send point (Uploading, Uploaded,
UploadFailed). TriggerMessage now reports actual diagnostics status
instead of hardcoded Idle, mirroring the firmwareStatus pattern.
- Extract composeCompositeSchedule() private method, eliminating
~120 lines of duplicated profile preparation logic between the
connectorId=0 and connectorId>0 branches of GetCompositeSchedule.
Jérôme Benoit [Sun, 15 Mar 2026 18:53:54 +0000 (19:53 +0100)]
fix(ocpp16): fix StopTransaction unit schema and ChargingSchedule field name
- Add missing 'Celsius' to StopTransaction.json unit enum (M-2/SP-1)
The runtime schema had only 'Celcius' (legacy typo) while the OCA
official schema has both. TS enum produces 'Celsius' which was
rejected by AJV when ocppStrictCompliance was enabled.
- Rename minChargeRate to minChargingRate in OCPP16ChargingSchedule (RST-01)
Field name typo caused JSON serialization mismatch with spec §7.13
and schema 'minChargingRate', breaking SetChargingProfile and
GetCompositeSchedule payloads.
Jérôme Benoit [Sun, 15 Mar 2026 18:23:00 +0000 (19:23 +0100)]
fix(ocpp20): clean up VariableManager mappings cache on station stop
invalidateMappingsCache was never called on station stop, leaking
invalidVariables and validatedStations entries for each stopped station.
Call it alongside resetRuntimeOverrides in stop() for complete cleanup.
Jérôme Benoit [Sun, 15 Mar 2026 18:19:07 +0000 (19:19 +0100)]
fix(ocpp20): isolate VariableManager overrides per station
runtimeOverrides, minSetOverrides, and maxSetOverrides were stored as flat
Maps on the singleton OCPP20VariableManager, causing SetVariables on one
station to affect all others sharing the same service instance.
Apply the same Map<stationId, Map<key, value>> pattern already used by
invalidVariables in the same class. resetRuntimeOverrides now accepts
optional stationId, matching the invalidateMappingsCache API.
Jérôme Benoit [Sun, 15 Mar 2026 18:04:39 +0000 (19:04 +0100)]
refactor(ocpp20): isolate per-station state with WeakMap instead of singleton properties
Per-station state (firmware update tracking, report cache, connector status
backup) was incorrectly stored as flat properties on the singleton
OCPP20IncomingRequestService, causing cross-station pollution when multiple
stations share the same service instance.
Introduce OCPP20PerStationState interface and a WeakMap<ChargingStation, ...>
to properly isolate state per station, matching the stateless service pattern
used by OCPP16IncomingRequestService. State is lazily initialized and
automatically garbage collected when the station is released.
Jérôme Benoit [Sat, 14 Mar 2026 22:46:56 +0000 (23:46 +0100)]
fix(renovate): enable Poetry dependency detection for OCPP2 mock server
Override :ignoreModulesAndTests preset to remove **/tests/** from
ignorePaths, allowing Renovate to discover tests/ocpp-server/pyproject.toml
and manage its Python/Poetry dependencies.
Jérôme Benoit [Sat, 14 Mar 2026 00:15:41 +0000 (01:15 +0100)]
docs: fix root README coherence with codebase
- Add missing NotifyCustomerInformation to OCPP 2.0.x section
- Add undocumented station template fields (iccid, imsi,
meterSerialNumberPrefix, meterType)
- List all available OCPP command procedure names in UI Protocol section
with separate OCPP 1.6 and 2.0.x lists
- Update copyright year to 2026 in README and LICENSE
Jérôme Benoit [Fri, 13 Mar 2026 21:08:30 +0000 (22:08 +0100)]
fix(ocpp-server): share charge_points set across connections and harden test quality
- Fix charge_points set created per-connection instead of shared across
all connections via ServerConfig
- Remove AuthConfig.__getitem__ dict-compat hack and isinstance(dict)
coercion branch from ChargePoint.__init__
- Migrate all test fixtures from raw dicts to AuthConfig instances
- Replace 11 weak 'assert X is not None' with typed assertions
(isinstance, enum equality)
- Hoist Action import to module level in test_server.py
- Add centralized error handling in _send_command dispatch for
TimeoutError, OCPPError, and ConnectionClosed
- Make host/port configurable via --host and --port CLI args
- Make boot notification status configurable via --boot-status
- Make TransactionEvent total cost configurable via --total-cost
- Extract server defaults as module-level constants
- Fix asyncio.iscoroutine() deprecation in timer.py: use
inspect.iscoroutinefunction() + inspect.isawaitable() for Python 3.14+
- Add proper type annotations and docstrings to timer.py
- Add pytest-asyncio for async handler testing (82 tests total)
- Add async tests for all 15 incoming OCPP handlers
- Add error handling tests for command dispatch layer
- Add tests for configurable boot_status and total_cost
- Update README with new server and charging behavior CLI options
Jérôme Benoit [Fri, 13 Mar 2026 18:39:58 +0000 (19:39 +0100)]
feat(ocpp-server): overhaul OCPP 2.0.1 mock server with full command coverage
- Add 4 new @on handlers: Get15118EVCertificate, GetCertificateStatus,
SignCertificate, NotifyCustomerInformation
- Add 9 new outgoing commands: CertificateSigned, CustomerInformation,
DeleteCertificate, GetInstalledCertificateIds, GetLog,
GetTransactionStatus, InstallCertificate, SetNetworkProfile,
UpdateFirmware (20 total)
- Fix camelCase key access bug in authorize/transaction handlers
(ocpp library converts to snake_case)
- Extract _resolve_auth_status() to eliminate duplicated auth logic
- Replace ConnectionError with InternalError for offline simulation
- Use set.discard() instead of set.remove() for safe cleanup
- Add match default case for unknown TransactionEvent types
- Modernize type hints: Optional[X] -> X | None
- Rewrite test suite with pytest (51 tests, 4 test classes)
- Update ruff to ^0.15, add pytest ^8 dev dependency
- Update README with all 20 outgoing commands and 15 incoming handlers
Jérôme Benoit [Fri, 13 Mar 2026 16:29:36 +0000 (17:29 +0100)]
test: remove 24 tautological enum value assertion tests
Remove tests that assert compile-time constant enum values (e.g.
EnumName.MEMBER === 'hardcodedString'), which always pass by definition
and exercise no production code.
- Delete ConfigurationData.test.ts (3 tautological tests)
- Remove ProcedureName/BroadcastChannelProcedureName enum groups (16 tests)
- Remove AuthTypes Enums block (4 tests)
- Remove OutputFormat enum test (1 test)
- Fix assert.strictEqual(true, false) to assert.fail() in OCPPAuthServiceFactory
All quality gates pass. Coverage unchanged (1800 tests, 0 failures).
* feat(broadcast-channel): add OCPP 2.0.1 command handlers and response mapping
- Add 8 new command handlers: get15118EVCertificate, getCertificateStatus,
logStatusNotification, notifyCustomerInformation, notifyReport,
securityEventNotification, signCertificate, transactionEvent
- Update CommandResponse type union with 4 OCPP 2.0.1 response types
- Add 4 commandResponseToResponseStatus cases for non-empty responses
- Fix METER_VALUES handler: add OCPP 2.0.1 passthrough branch (version-detected)
- Fire-and-forget commands handled automatically by isEmpty bailout
* fix(ocpp2): add missing certificate commands to buildRequestPayload
Add SIGN_CERTIFICATE, GET_15118_EV_CERTIFICATE, GET_CERTIFICATE_STATUS
to the passthrough case group — these previously fell to the default
branch which threw OCPPError(NOT_SUPPORTED)
Add 45 tests across 6 groups covering:
- ProcedureName enum: 8 new OCPP 2.0.1 entries
- BroadcastChannelProcedureName enum: 8 new OCPP 2.0.1 entries
- ProcedureNameToBroadCastChannelProcedureNameMapping: 8 new entries
- BroadcastChannelRequestPayload: OCPP 2.0.1 optional fields
- commandResponseToResponseStatus: 4 new command response cases
- commandHandlers Map: 8 new entries registered
* style: fix perfectionist ordering in broadcast channel handler and tests
* [autofix.ci] apply automated fixes
* test(broadcast-channel): add buildRequestPayload and behavioral handler tests
Add Group 7 (buildRequestPayload certificate passthrough) and Group 8
(commandHandlers behavioral) tests addressing audit findings:
- 3 tests verify GET_15118_EV_CERTIFICATE, GET_CERTIFICATE_STATUS, and
SIGN_CERTIFICATE payloads pass through unchanged
- 8 tests verify each OCPP 2.0.1 handler invokes requestHandler with the
correct RequestCommand enum value
Total: 56 tests in file, 1816 across suite.
* [autofix.ci] apply automated fixes
* refactor(test): remove redundant test groups from broadcast channel tests
Remove Group 4 (BroadcastChannelRequestPayload tautological - type system
already enforces at compile time) and Group 6 (commandHandlers existence -
fully subsumed by Group 8 behavioral tests that verify both existence and
correct RequestCommand routing).
- Add explicit commandResponseToResponseStatus cases for 4 fire-and-forget
commands (LogStatusNotification, NotifyCustomerInformation, NotifyReport,
SecurityEventNotification) using isEmpty pattern matching existing
MeterValues/StatusNotification behavior
- Tighten BroadcastChannelRequestPayload types: idToken uses
OCPP20IdTokenType, rename transactionData to transactionInfo with
OCPP20TransactionType per OCPP 2.0.1 spec
- Add OCPP20AuthorizationStatusEnumType to barrel export in types/index.ts,
switch deep imports to barrel imports in source and test files
- Add 8 tests for fire-and-forget commandResponseToResponseStatus coverage
- Fix cspell warnings in test mock data strings
* test: improve OCPP 2.0.1 broadcast channel coverage with dispatch and pipeline tests
Add commandHandler dispatch pipeline tests (Group 6) and requestHandler
full pipeline tests (Group 7) to exercise handler closure bodies through
the actual dispatch path. Convert Group 6 from direct Map.get() to
commandHandler() method dispatch for better V8 coverage tracking.
59 tests across 7 groups (was 53 tests across 6 groups).
* refactor(broadcast-channel): extract handler closures to named private methods
Extract 17 async handler closures from the Map constructor into named
private methods with .bind(this) references. This improves V8 coverage
tracking accuracy for arrow function closures inside Map constructor
arrays, where tsx/esbuild source map misalignment causes inconsistent
coverage attribution.
No behavioral changes — all handlers execute the same logic.
* [autofix.ci] apply automated fixes
* test(broadcast-channel): add mapping completeness validation for UI service command pipeline
* [autofix.ci] apply automated fixes
* refactor(types): remove unused OCPP 2.0 fields from BroadcastChannelRequestPayload
Jérôme Benoit [Thu, 12 Mar 2026 23:04:47 +0000 (00:04 +0100)]
test(ocpp): add schema registration coverage tests for OCPP 1.6 and 2.0
Verify every command enum value has its request and response schemas
registered in ServiceUtils, and that all referenced schema files exist
on disk. Prevents regressions where a command is implemented but its
schema registration is forgotten.
Jérôme Benoit [Thu, 12 Mar 2026 22:56:04 +0000 (23:56 +0100)]
fix(ocpp2): add missing outgoing schema entries for certificate commands
Register Get15118EVCertificate, GetCertificateStatus, and SignCertificate
in OCPP20ServiceUtils.outgoingRequestSchemaNames to ensure JSON schema
validation for these certificate management commands.
Jérôme Benoit [Thu, 12 Mar 2026 22:42:20 +0000 (23:42 +0100)]
refactor(ocpp): remove dead parseJsonSchemaFile overrides and standardize validation
- Delete unused parseJsonSchemaFile overrides from OCPP16/20ServiceUtils
(createPayloadValidatorMap already passes version via options)
- Remove orphaned JSONSchemaType and JsonType imports
- Standardize null-validator return to false in OCPPRequestService
(consistent with OCPPIncomingRequestService and OCPPResponseService)
- Change validateRequestPayload and validateIncomingRequestResponsePayload
visibility from private to protected (consistent with other base classes)
Jérôme Benoit [Thu, 12 Mar 2026 22:31:30 +0000 (23:31 +0100)]
refactor(ocpp): harmonize JSON schema payload validation across OCPP stacks
- Absorb missing-validator null guard into base class methods, eliminating
4 identical private validatePayload wrappers and their bind() calls
- Remove dead code (unreachable isValid branches in ResponseService wrappers)
- Make parseJsonSchemaFile throw on failure instead of silently returning {},
preventing validators that accept everything as a security bypass
- Add dual-path schema resolution for production (esbuild) and test (tsx)
- Align OCPP 1.6 schema map construction with OCPP 2.0 registry pattern,
replacing ~200 lines of verbose inline entries with declarative registries
- Collapse 4 identical payload options factory methods into 1 per version
* feat(ocpp2): implement UpdateFirmware and FirmwareStatusNotification
Add UpdateFirmware (CSMS→CS) incoming request handler with simulated
firmware update lifecycle state machine (Downloading → Downloaded →
SignatureVerified → Installing → Installed) and FirmwareStatusNotification
(CS→CSMS) outgoing command.
- Handle UPDATE_FIRMWARE incoming request, return Accepted status
- Simulate firmware update lifecycle via chained setTimeout calls
- Send FirmwareStatusNotification at each state transition
- Check firmware.signature presence for SignatureVerified state
- Add testable interfaces for both handler and request service
- Add 8 tests (5 for UpdateFirmware, 3 for FirmwareStatusNotification)
* feat(ocpp2): implement GetLog and LogStatusNotification
- Add GetLog incoming request handler with simulated upload lifecycle
(Uploading → Uploaded via chained setTimeout)
- Add LogStatusNotification outgoing command in RequestService
- Register handleResponseLogStatusNotification in ResponseService
- Update testable interfaces with new handler and request method
- Add 4 GetLog tests (DiagnosticsLog, SecurityLog, requestId, retries)
- Add 3 LogStatusNotification tests (Uploading, requestId, empty response)
- All quality gates pass: lint, typecheck, build, 1737 tests
* feat(ocpp2): expand TriggerMessage handler with new trigger types
* docs: update README with OCPP 2.0.1 Core certification commands
* style(ocpp2): fix space-before-function-paren in TriggerMessage handler and test
* fix(ocpp2): add missing case branches in buildRequestPayload for new commands
buildRequestPayload throws NOT_SUPPORTED for FirmwareStatusNotification,
LogStatusNotification, MeterValues, NotifyCustomerInformation, and
SecurityEventNotification since they have no case branches. This causes
guaranteed runtime failures when TriggerMessage invokes requestHandler
for these commands.
Add pass-through case branches matching the existing pattern used by
other notification commands.
* fix(ocpp2): use zero-based seqNo in NotifyCustomerInformation per OCPP 2.0.1 spec
* fix(ocpp2): stop only specific transaction in handleResponseTransactionEvent
handleResponseTransactionEvent was stopping ALL active transactions when
any rejected idTokenInfo.status arrived. Per OCPP 2.0.1 spec (D01/D05),
only the specific transaction referenced by the TransactionEvent request
should be stopped.
Extract the transactionId from the request payload and use
getConnectorIdByTransactionId/getEvseIdByTransactionId to find and stop
only the affected transaction.
* fix(ocpp2): set idle EVSEs Inoperative immediately on CS-level ChangeAvailability per G03.FR.04
- Add delay between Downloaded and SignatureVerified in firmware update lifecycle per J01
- Add missing JSDoc for requestLogStatusNotification in testable interface
- Convert 4 arrow function handlers to regular methods for consistency with pre-existing handlers
- Replace duplicated delay() functions with shared sleep() utility
- Extract handleEvseChangeAvailability and handleCsLevelInoperative to
reduce cognitive complexity of handleRequestChangeAvailability
- Extract hasAnyActiveTransaction to eliminate nested loops
- Fix negated conditions and nested template literals
* refactor(ocpp2): deduplicate validator configs via shared schema name maps
- Extract incomingRequestSchemaNames and outgoingRequestSchemaNames as
single source of truth for command-to-schema mappings
- Generate request/response configs from shared maps, eliminating 96
lines of structural duplication flagged by SonarCloud
- Fix remaining negated conditions in ternary expressions
* fix(test): deduplicate MeterValues call, add multi-EVSE isolation test
* fix(ocpp2): eliminate double status notification, document messagesInQueue
* test(ocpp2): align test files with TEST_STYLE_GUIDE conventions
* fix: comply with E14.FR.06 and harmonize statusInfo
Added 26 null guards (if + assert.fail) after getConnectorStatus() and
nullable field accesses to satisfy both TypeScript strict null checks
and ESLint.
* test: migrate all remaining test files from @std/expect to node:assert/strict
Migrate 82 remaining test files (OCPP 2.0, auth, charging-station,
UI server, utils, worker, performance, exception, types) from
@std/expect to node:assert/strict.
Remove @std/expect JSR dependency from package.json to fix CI 404
errors on npm.jsr.io.
All 1694 tests pass, lint clean, TSC clean.
* chore: update lockfile after removing @std/expect dependency
* docs: update test style guide and config to reflect node:assert/strict migration
* test(ocpp16): eliminate as-unknown-as casts and add missing AAA comments
Create typed helpers in OCPP16TestUtils (setMockRequestHandler,
dispatchResponse, createMeterValuesTemplate, createCommandsSupport)
to encapsulate type casts in one place instead of 26 inline casts
across 8 test files.
Add Arrange/Act/Assert comments to 5 tests in
OCPP16ServiceUtils.test.ts that have 3+ logical setup steps.
All 1694 tests pass, lint clean, TSC clean.
* fix(test): use real enum value instead of as-any cast in AuthHelpers.test.ts
Use AuthorizationStatus.NO_CREDIT (unhandled by getStatusMessage
switch) to test the default branch, removing the as-any cast and
eslint-disable comment that caused CI autofix failure.
Jérôme Benoit [Mon, 9 Mar 2026 18:49:48 +0000 (19:49 +0100)]
fix: migrate JSR dependency from legacy npm:@jsr/ to native jsr: protocol
Replace the legacy npm compatibility layer approach with pnpm's native
jsr: protocol support (available since pnpm 10.9.0) to fix 404 errors
when fetching @jsr/std__assert tarballs from npm.jsr.io.
- package.json: use jsr:@std/expect specifier instead of npm:@jsr/std__expect
- package.json, ui/web/package.json: bump engines.pnpm to >=10.9.0
- .npmrc: remove @jsr:registry=https://npm.jsr.io (no longer needed)
- pnpm-lock.yaml: regenerated with native JSR resolution