]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
feat(ocpp2): integrate all 8 missing OCPP 2.0.1 outgoing commands into UIService...
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 13 Mar 2026 15:54:08 +0000 (16:54 +0100)
committerGitHub <noreply@github.com>
Fri, 13 Mar 2026 15:54:08 +0000 (16:54 +0100)
commitf1aba941898b9a55cf4f90f86072abcf11cf1ec9
treeb943bf2c5b0d5a1d47b57bd57f792fc96788476c
parent293588f1f28cb59d67ce3ea1aff16a91ae92ed0a
feat(ocpp2): integrate all 8 missing OCPP 2.0.1 outgoing commands into UIService/BroadcastChannel pipeline (#1718)

* feat(types): add OCPP 2.0.1 UI procedure and broadcast channel enums

- Add 8 new ProcedureName entries (get15118EVCertificate, getCertificateStatus, logStatusNotification, notifyCustomerInformation, notifyReport, securityEventNotification, signCertificate, transactionEvent)
- Mirror same 8 entries in BroadcastChannelProcedureName
- Extend BroadcastChannelRequestPayload with optional OCPP 2.0.1 fields (eventType, evseId, idToken, transactionData)

* feat(ui-service): wire OCPP 2.0.1 commands through UI service pipeline

Add 8 new ProcedureNameToBroadCastChannelProcedureNameMapping entries for:
get15118EVCertificate, getCertificateStatus, logStatusNotification,
notifyCustomerInformation, notifyReport, securityEventNotification,
signCertificate, transactionEvent

* 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)

* test(broadcast-channel): add OCPP 2.0.1 UIService pipeline integration tests

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).

45 tests across 6 groups, 1805 total suite.

* fix: address PR review comments — tighten types, add fire-and-forget response cases, barrel export

- 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

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/charging-station/ui-server/ui-services/AbstractUIService.ts
src/types/UIProtocol.ts
src/types/WorkerBroadcastChannel.ts
src/types/index.ts
tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts [new file with mode: 0644]