]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/log
e-mobility-charging-stations-simulator.git
7 days agotest(utils): audit — overhaul existing, add 3 new test files, data-driven coverage
Jérôme Benoit [Fri, 6 Mar 2026 22:05:35 +0000 (23:05 +0100)] 
test(utils): audit — overhaul existing, add 3 new test files, data-driven coverage

7 days agorefactor(utils): audit fixes — dedup, data-driven config, lazy logger, DRY
Jérôme Benoit [Fri, 6 Mar 2026 20:50:55 +0000 (21:50 +0100)] 
refactor(utils): audit fixes — dedup, data-driven config, lazy logger, DRY

7 days agofix(performance-storage): make MikroORM integration work (#1701)
Jérôme Benoit [Fri, 6 Mar 2026 14:48:07 +0000 (15:48 +0100)] 
fix(performance-storage): make MikroORM integration work (#1701)

* fix(performance-storage): make MikroORM integration work

Fix MikroORM performance storage integration by addressing:
- Fork EntityManager per operation (prevents identity map accumulation)
- Pass entity class to em.upsert() (MikroORM v6 API)
- Add schema generation in open() (table creation)
- Fix entity: add tableName, JSON type for statisticsData
- Add connection validation before operations
- Use direct entity class import instead of fragile glob paths
- Ensure SQLite directory exists before ORM init
- Fix type-only import to value import (verbatimModuleSyntax)

Closes #42

* fix(performance-storage): address PR review feedback

- Swap setPerformanceStatistics/checkDBConnection call order to match
  MongoDBStorage pattern (in-memory stats updated first so UI stays
  current even when DB is down)
- Close ORM connection on schema updateSchema() failure to prevent
  resource leak when init succeeds but schema generation fails

* test(performance-storage): add unit tests for MikroOrmStorage

Add 18 tests covering constructor, close, storePerformanceStatistics,
and error handling. Uses mock ORM to avoid sqlite3 native binding
dependency in CI (--ignore-scripts). Explicit decorator types on
PerformanceRecord for tsx/esbuild compatibility.

* refactor(tests): harmonize MikroOrmStorage tests with project conventions

Use TestableMikroOrmStorage subclass with Reflect.get/set (matches
UIHttpServer pattern). Replace toBeGreaterThan with exact toBe counts.
Use .mock.calls.length consistently. Remove constructor tests that
tested implementation details.

* refactor(performance-storage): migrate from @mikro-orm/sqlite to @mikro-orm/better-sqlite

The sqlite3 native bindings used by @mikro-orm/sqlite are broken on
Node v24 (no prebuilt binaries for ABI v137, node-gyp@8.4.1 cannot
compile with Python 3.13). Replace with better-sqlite3 which provides
an identical MikroORM API surface while using a more portable native
binding.

* test(performance-storage): add integration tests for MikroOrmStorage

Add 6 integration tests that exercise real SQLite database operations
(open, persist, upsert, JSON serialization, close/reopen, multi-record).
Tests detect better-sqlite3 availability at module load and skip
gracefully via { skip: SKIP_SQLITE } when the native binding is not
built (e.g. CI with --ignore-scripts).

* fix(performance-storage): use caret version for @mikro-orm/better-sqlite and fix test JSDoc order

Use ^6.6.8 (caret) consistently across all @mikro-orm/* packages to
prevent version skew when updating dependencies. MikroORM requires all
packages be on the same version.

Also move @file JSDoc block before all imports in the test file to
match project conventions.

* refactor(performance-storage): extract ensureDBDirectory into Storage base class and audit fixes

Move duplicated directory creation logic from JsonFileStorage and
MikroOrmStorage into a shared protected method in the abstract Storage
base class. Place the call inside the existing switch case instead of
a separate if block.

Also use ^6.6.8 (caret) consistently for @mikro-orm/better-sqlite and
fix test JSDoc ordering to match project conventions.

* refactor(performance-storage): factorize serialization into base class and fix MongoDBStorage

- Extract serializePerformanceStatistics() into Storage base class (DRY)
- Update MikroOrmStorage to use shared serialization method
- Fix MongoDBStorage: remove unnecessary optional client, use shared
  serialization for CircularBuffer, remove eslint-disable comments,
  rename connected to opened for lifecycle clarity
- Add 20 unit tests for MongoDBStorage mirroring MikroOrmStorage pattern

* refactor(performance-storage): harmonize storage implementations

- Remove 2 eslint-disable comments in Storage.handleDBStorageError by
  using nullish coalescing and proper string typing
- Simplify handleDBStorageError params default spread
- Refactor JsonFileStorage.checkPerformanceRecordsFile to return fd,
  eliminating non-null assertion and eslint-disable
- Remove eslint-disable in StorageFactory by casting enum to string
- Fix StorageFactory.getStorage return type: Storage (not | undefined)
- Update None.ts copyright year to 2025 for consistency

* refactor(tests): extract buildTestStatistics into shared StorageTestHelpers

* fix(lint): remove unnecessary optional chain after StorageFactory return type fix

7 days agochore(deps): update docker/setup-buildx-action action to v4 (#1703)
renovate[bot] [Fri, 6 Mar 2026 12:07:53 +0000 (13:07 +0100)] 
chore(deps): update docker/setup-buildx-action action to v4 (#1703)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
7 days agofix(deps): update all non-major dependencies (#1702)
renovate[bot] [Fri, 6 Mar 2026 12:05:10 +0000 (13:05 +0100)] 
fix(deps): update all non-major dependencies (#1702)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
8 days agofix(charging-station): audit fixes — error handling, OCPP conformance, DRY, type...
Jérôme Benoit [Thu, 5 Mar 2026 21:56:43 +0000 (22:56 +0100)] 
fix(charging-station): audit fixes — error handling, OCPP conformance, DRY, type safety

- Replace .catch(EMPTY_FUNCTION) with proper error logging (F-001/F-002/F-003)
- Add fail-closed security comment in UIServerSecurity (F-004)
- Convert FIXME to actionable TODO in Bootstrap (F-005)
- Implement relative charging profile duration handling per K01.FR.41-42 (F-006)
- Restart heartbeat and WebSocket ping on template change (F-007)
- Consolidate repeated type casts in convertDeprecatedTemplateKey (F-008)
- Remove duplicate console.warn calls and unused chalk import in UIServerFactory (F-010)
- Extract logPrefix to AbstractUIServer base class, removing duplicates (F-011)
- Extract matchesConfigurationKey predicate in ConfigurationKeyUtils (F-012)
- Add failure counter and error summary for reservation removal (F-013)

8 days agochore: lock file maintenance
Jérôme Benoit [Thu, 5 Mar 2026 21:00:13 +0000 (22:00 +0100)] 
chore: lock file maintenance

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
8 days agofix(ocpp): remove invalid additionalProperties/additionalItems from OCPP 1.6 and...
Jérôme Benoit [Thu, 5 Mar 2026 20:55:26 +0000 (21:55 +0100)] 
fix(ocpp): remove invalid additionalProperties/additionalItems from OCPP 1.6 and 2.0 JSON schemas

Remove `"additionalProperties": false` from enum/string type definitions
where it is semantically invalid (only applies to objects), and
`"additionalItems": false` where `items` is a single schema (not a tuple),
fixing AJV 8 strict mode errors at runtime.

8 days agofix(deps): update dependency tar to ^7.5.10 (#1700)
renovate[bot] [Thu, 5 Mar 2026 20:24:39 +0000 (21:24 +0100)] 
fix(deps): update dependency tar to ^7.5.10 (#1700)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
8 days agofix(ocpp): auth cache spec compliance (R0–R17) (#1699)
Jérôme Benoit [Thu, 5 Mar 2026 20:24:20 +0000 (21:24 +0100)] 
fix(ocpp): auth cache spec compliance (R0–R17) (#1699)

* fix(ocpp): wire auth cache into strategies and fix default configuration

* fix(ocpp): add isCacheable dead code note and cache wiring test

* fix(ocpp): cache all authorization statuses per OCPP spec (R1)

- Remove ACCEPTED-only guard in RemoteAuthStrategy: now caches ALL
  authorization statuses (BLOCKED, EXPIRED, INVALID) per OCPP 1.6 §3.5.1
  and OCPP 2.0.1 AuthCacheCtrlr
- Simplify isCacheable() to always return true — all statuses cacheable
- Update AuthHelpers tests to reflect all-statuses policy (T4.05-T4.09)
- Add RemoteAuthStrategy tests for BLOCKED/EXPIRED/INVALID caching (T4.01-T4.04)

* fix(ocpp): status-aware eviction, TTL reset, expired lifecycle (R2, R5, R10, R16)

* fix(ocpp): exclude local auth list identifiers from cache (R17)

* fix(ocpp): periodic cache cleanup and bounded rate limits (R8, R9)

* fix(ocpp): make resetStats public and preserve stats across clear (R14, R15)

* test(ocpp): integration tests for auth cache spec compliance (T12)

* [autofix.ci] apply automated fixes

* fix(ocpp): address PR #1699 review feedback (F1-F9)

- F1: increment stats.hits for expired cache entries in get()
- F2: use captured 'now' timestamp in set() LRU update
- F3: two-phase expiration in runCleanup() (transition then delete)
- F4: guard cleanupIntervalSeconds with > 0 (NaN protection)
- F5: forward localAuthListManager to RemoteAuthStrategy
- F6: apply absolute 24h lifetime cap in expired-transition branch
- F7: guard local auth list query with config.localAuthListEnabled
- F8: mask identifier in debug logs (first 8 chars only)
- F9: remove dead isCacheable() method and its tests

* refactor(test): replace inline setTimeout with shared sleep helper

* [autofix.ci] apply automated fixes

* fix(ocpp): replace redundant Promise.resolve returns in async methods

* fix(auth): make AuthCache interface synchronous and remove all Promise wrappers

BREAKING CHANGE: AuthCache interface methods (get, set, remove, clear,
getStats) are now synchronous. OCPPAuthService.clearCache() and
invalidateCache() return void instead of Promise<void>.

- Remove async/Promise wrappers from AuthCache interface and InMemoryAuthCache
- Make OCPPAuthService clearCache/invalidateCache return void
- Update all strategies (Local/Remote) to use sync cache operations
- Remove await from all sync cache calls in source and test files
- Fix mock factories to use sync signatures with /* empty */ bodies
- Widen TTL timing margins in InMemoryAuthCache tests to reduce flakiness
- Fix JSDoc annotations in TestLifecycleHelpers and InMemoryAuthCache

* refactor(auth): eliminate all Promise.resolve() from auth module

Replace Promise.resolve() wrappers with proper sync/async signatures:
- Update AuthStrategy interface: getStats() returns sync Record, initialize() returns sync void
- Update OCPPAuthService interface: getStats() returns sync AuthStats
- Convert strategy getStats()/initialize()/cleanup() implementations to sync
- Convert adapter sync methods (convertToUnifiedIdentifier, convertFromUnifiedIdentifier,
  getConfigurationSchema, validateConfiguration) from async to sync
- Update OCPPAuthServiceImpl to match sync interface signatures
- Update OCPPAuthIntegrationTest to match sync interface
- Align all test mocks with exact interface signatures (sync mocks for sync
  interfaces, async mocks for async interfaces)
- Remove all eslint-disable require-await comments from test files

* fix(auth): resolve all lint errors for CI compliance

- Reorder union types to satisfy perfectionist/sort-union-types
- Remove @returns JSDoc from void functions (jsdoc/require-returns-check)
- Make OCPP16/20 adapter sync methods non-async (require-await)
- Fix all mock signatures to match interface contracts exactly
- Replace async mock lambdas with new Promise<T> pattern
- Fix no-confusing-void-expression in test assertions
- Sort named imports alphabetically (perfectionist/sort-named-imports)
- Add missing await for floating promise in test (no-floating-promises)

* [autofix.ci] apply automated fixes

* fix(auth): remove eslint-disable added by us, use expect().not.toThrow() pattern

* ci: trigger CI run

* refactor(auth): apply code review corrections (fixes 1-10)

Fix validators, convert static classes to modules,
improve cache configurability, fix test configs,
replace sleep with mock timers, fix Promise leak,
move integration test helper to tests/helpers.

* fix(auth): resolve all 35 JSDoc lint warnings for clean lint gate

* fix(auth): address cross-validated audit findings (C1-C3, M1-M6, minor fixes)

- C1: fix timer leak in performRemoteAuthorization (clearTimeout on success/catch)
- C2: document LocalAuthListManager stub with TODO, mark §3.5.3 guard inactive
- C3: expand factory gate to check all three auth feature flags
- M1: change RemoteAuthStrategy.canHandle to use remoteAuthorization config flag
- M2: add AuthenticationMethod.NONE enum for all-strategies-fail fallback
- M4: add NO_AUTHORIZATION to OCPP20AuthAdapter validTypes
- M3: wire hasExplicitTtl into CacheEntry for CSMS-provided TTL preservation
- M6: filter NoAuthorization/Central identifiers from cache (C02.FR.03, C03.FR.02)
- m3: fix boundRateLimitsMap to evict in loop until within threshold
- m4: stop counting expired entries as cache hits
- m7: clamp TTL to [0, maxAbsoluteLifetime] range
- m8: enforce maxEntries >= 1 in constructor

* refactor(auth): use sleep() utility instead of raw Promise setTimeout

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
9 days agochore(deps): lock file maintenance (#1696)
renovate[bot] [Wed, 4 Mar 2026 12:39:19 +0000 (13:39 +0100)] 
chore(deps): lock file maintenance (#1696)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
9 days agochore(deps): update all non-major dependencies (#1698)
renovate[bot] [Wed, 4 Mar 2026 12:00:56 +0000 (13:00 +0100)] 
chore(deps): update all non-major dependencies (#1698)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
10 days agofix(tests): address audit findings — assertion consistency, JSDoc, DRY, try/finally
Jérôme Benoit [Tue, 3 Mar 2026 20:26:08 +0000 (21:26 +0100)] 
fix(tests): address audit findings — assertion consistency, JSDoc, DRY, try/finally

- Replace expect(a === b).toBe(false) with expect(a).not.toBe(b) (IdTagsCache)
- Add explicit assertions to smoke tests (SimpleHandlers)
- Wrap state injection in try/finally (Configuration)
- Extract createStationWithRequestHandler helper, use mock.method() (connectorStatus)
- Fill empty JSDoc @param descriptions across 5 files
- Rename makeStationStub → makeStationMock, merge duplicate import (pure)
- Fix misleading test name 'is empty' → 'is null' (validation)
- Extract getConnectorStatus/getHandleStartTransactionResponse helpers (ATG)
- Fix perfectionist/sort-modules and sort-imports ordering

10 days agotest: add AutomaticTransactionGenerator tests
Jérôme Benoit [Tue, 3 Mar 2026 19:51:03 +0000 (20:51 +0100)] 
test: add AutomaticTransactionGenerator tests

Add tests for the ATG singleton covering instance lifecycle (create,
delete, same-instance), start/stop state machine with guards, connector
stop behavior, and handleStartTransactionResponse counter updates for
accepted and rejected transactions.

10 days agotest: add Configuration utility tests
Jérôme Benoit [Tue, 3 Mar 2026 19:50:48 +0000 (20:50 +0100)] 
test: add Configuration utility tests

Add tests for the static Configuration class covering section retrieval
with defaults (log, worker, uiServer, performanceStorage), supervision
URL distribution, worker pool detection, and error handling for unknown
configuration sections.

10 days agotest: add IdTagsCache tests
Jérôme Benoit [Tue, 3 Mar 2026 19:50:34 +0000 (20:50 +0100)] 
test: add IdTagsCache tests

Add tests for the RFID tag cache singleton covering lazy file loading,
ROUND_ROBIN/RANDOM/CONNECTOR_AFFINITY distribution algorithms,
cache population, and cleanup of cache entries and addressable indexes.

10 days agotest: add SharedLRUCache tests
Jérôme Benoit [Tue, 3 Mar 2026 19:50:20 +0000 (20:50 +0100)] 
test: add SharedLRUCache tests

Add tests for the LRU cache singleton covering template and configuration
CRUD operations, cacheability validation for configurations with empty
fields, and cache clear behavior.

10 days agotest(ocpp): add OCPPServiceUtils authorization wrapper tests
Jérôme Benoit [Tue, 3 Mar 2026 19:50:04 +0000 (20:50 +0100)] 
test(ocpp): add OCPPServiceUtils authorization wrapper tests

Add tests for isIdTagAuthorized and isIdTagAuthorizedUnified functions
covering local auth list, remote authorization, OCPP 2.0 unified auth
dispatch, and error fallback paths.

10 days agotest(ocpp): add OCPPServiceUtils connector status management tests
Jérôme Benoit [Tue, 3 Mar 2026 19:49:46 +0000 (20:49 +0100)] 
test(ocpp): add OCPPServiceUtils connector status management tests

Add tests for sendAndSetConnectorStatus and restoreConnectorStatus
functions covering StatusNotification sending, connector status updates,
event emission, and reservation-based status restoration.

10 days agotest(ocpp): add OCPPServiceUtils command support validation tests
Jérôme Benoit [Tue, 3 Mar 2026 18:46:40 +0000 (19:46 +0100)] 
test(ocpp): add OCPPServiceUtils command support validation tests

Test isIncomingRequestCommandSupported,
isRequestCommandSupported, isMessageTriggerSupported
with 12 tests covering all support config branches.

10 days agotest(ocpp): add OCPPServiceUtils pure function tests
Jérôme Benoit [Tue, 3 Mar 2026 18:38:07 +0000 (19:38 +0100)] 
test(ocpp): add OCPPServiceUtils pure function tests

Test getMessageTypeString, ajvErrorsToErrorType,
convertDateToISOString, isConnectorIdValid — 19 tests
covering the shared base layer with zero mocking.

10 days agotest(ocpp2.0): add Heartbeat, NotifyReport, StatusNotification response tests
Jérôme Benoit [Tue, 3 Mar 2026 18:24:40 +0000 (19:24 +0100)] 
test(ocpp2.0): add Heartbeat, NotifyReport, StatusNotification response tests

Grouped in single file as all three handlers are
trivial (log-only). Completes OCPP 2.0 response
handler coverage from 20% to 100%.

10 days agotest(ocpp2.0): add BootNotification response handler tests
Jérôme Benoit [Tue, 3 Mar 2026 18:09:21 +0000 (19:09 +0100)] 
test(ocpp2.0): add BootNotification response handler tests

Test all 6 branches of handleResponseBootNotification:
ACCEPTED/PENDING/REJECTED status, interval handling,
missing interval, and invalid status.

10 days agofix: quote test glob so /bin/sh delegates to Node
Jérôme Benoit [Tue, 3 Mar 2026 18:09:09 +0000 (19:09 +0100)] 
fix: quote test glob so /bin/sh delegates to Node

The shell /bin/sh does not support recursive ** globs.
Only 18/65 test files were running. Quoting the
pattern lets Node resolve it, running all 65 files.

10 days agofix(tests): rename test cases to 'should [verb]' convention
Jérôme Benoit [Tue, 3 Mar 2026 17:47:56 +0000 (18:47 +0100)] 
fix(tests): rename test cases to 'should [verb]' convention

Rename 17 test names across 3 files to follow
TEST_STYLE_GUIDE.md naming convention.

10 days agofix(tests): add missing @file headers and standardCleanup()
Jérôme Benoit [Tue, 3 Mar 2026 17:42:33 +0000 (18:42 +0100)] 
fix(tests): add missing @file headers and standardCleanup()

Add mandatory @file JSDoc headers to 3 test files and
standardCleanup() afterEach to 2 test files per
TEST_STYLE_GUIDE.md sections 2 and 3.

10 days agorefactor(ocpp2): OCPP 2.0.1 audit fixes — spec compliance, type safety, test coverage...
Jérôme Benoit [Tue, 3 Mar 2026 17:08:43 +0000 (18:08 +0100)] 
refactor(ocpp2): OCPP 2.0.1 audit fixes — spec compliance, type safety, test coverage (#1697)

* feat(ocpp2): add TriggerMessage, UnlockConnector and TransactionEvent types

* fix(tests): resolve pre-existing LSP type errors in test infrastructure

* refactor(ocpp2): extract enforceMessageLimits utility to eliminate DRY violation

* refactor(ocpp2): dynamic isComponentValid and fix OCPP 1.6 key usage

* feat(ocpp2): handle TransactionEventResponse fields

* feat(ocpp2): implement TriggerMessage/UnlockConnector handlers and Reset hardening

- Implement TriggerMessage handler (F06): supports BootNotification,
  Heartbeat, and StatusNotification triggers with EVSE targeting
- Implement UnlockConnector handler (F05): full spec compliance with
  Unlocked, UnlockFailed, OngoingAuthorizedTransaction, UnknownConnector
  response statuses
- Add AllowReset variable check and firmware update blocking to Reset handler
- Add 4 missing schema validations for certificate commands
- Add TriggerMessage/UnlockConnector schema validator configs
- Document RFC 6960 DER encoding deviation in computeCertificateHash

* refactor(ocpp2): eliminate unsafe type casts in handlers and VariableManager

- Add private toHandler() helper in OCPP20IncomingRequestService that concentrates
  the single 'as unknown as IncomingRequestHandler' cast with documentation comment
- Replace 13 per-binding casts in constructor with this.toHandler() calls
- Remove 15 'as unknown as StandardParametersKey' casts from OCPP20VariableManager —
  string is already a member of ConfigurationKeyType, no cast needed
- Remove now-unused import of StandardParametersKey from OCPP20VariableManager

* feat(ocpp2): expose TriggerMessage and UnlockConnector handlers in testable interface

* test(ocpp2): add TriggerMessage handler tests (F06) — 14 tests

* test(ocpp2): add UnlockConnector handler tests (F05) — 9 tests

* test(ocpp2): add TransactionEventResponse handler tests (E01-E04) — 7 tests

* test(ocpp2): fix firmware blocking tests and add AllowReset variable guard tests (T22) — 25 tests

* fix(ocpp2): add AJV strict:false and schema validation unit tests (T21)

- Set strict:false in all three AJV constructors (IncomingRequest, Request,
  Response) to allow OCPP 2.0 schemas that use additionalItems without
  array items (a draft-07 pattern AJV 8 strict mode rejects at compile time)
- Replace integration-style schema tests (blocked by tsx path resolution)
  with direct AJV schema unit tests: load schemas from src/assets directly,
  compile with AJV, verify invalid payloads are rejected — 15 tests pass

* fix(ocpp2): correct registry key separator in isComponentValid (T5-bugfix)

The `#validComponentNames` set was built using split('/') but registry keys
use '::' as separator (e.g. 'AlignedDataCtrlr::Available'). This caused the
set to contain full keys like 'AlignedDataCtrlr::Available' instead of just
component names like 'AlignedDataCtrlr', making isComponentValid return false
for all components and causing UnknownComponent responses for all Set/GetVariables.

Also update the EVSE test to assert UnknownVariable (not UnknownComponent) since
EVSE is a valid component in the registry but AuthorizeRemoteStart is not one of
its variables.

* test(ocpp2): add enforceMessageLimits utility tests (T23) — 14 tests

* test(ocpp2): add integration tests for multi-command flows (T24) — 6 tests

* fix(ocpp2): add error diagnostics, additionalInfo fields, and async timeout guard (T25)

* fix(ocpp2): resolve tsc type errors in UUIDv4 cast, override modifier, and mock cast (F1)

* fix(ocpp2): add try/catch to TriggerMessage and UnlockConnector handlers, add integration test

- Add try/catch blocks to handleRequestTriggerMessage and
  handleRequestUnlockConnector following the handleRequestReset
  golden pattern with structured error responses
- Add 4th integration test: SetVariables on unknown component
  returns rejected, GetVariables confirms unknown component

* fix(ocpp2): address PR review findings — remove dead code, consolidate types, fix test mock

* fix(ocpp2): spec compliance — F06.FR.17 BootNotification guard, F05.FR.02 connector-level tx check

- TriggerMessage: reject BootNotification trigger when last boot was
  already Accepted per F06.FR.17 (returns Rejected + NotEnabled)
- UnlockConnector: check transaction on the specific target connector
  instead of all EVSE connectors per F05.FR.02
- Add 3 new tests covering both spec requirements

* fix(ocpp2): address code review — timer leak, diagnostic logging, TODO annotation

- Fix withTimeout timer leak: clear setTimeout when promise resolves first
- readMessageLimits: replace empty catch with logger.debug diagnostic
- handleResponseTransactionEvent: add TODO noting log-only is intentional,
  future work should act on idTokenInfo.status and chargingPriority

* style: fix jsdoc warnings in OCPP 2.0 handlers and tests

Add missing @returns tags and @param descriptions to satisfy
jsdoc/require-returns and jsdoc/require-param-description ESLint rules.
Replace empty JSDoc blocks with minimal valid documentation to satisfy
jsdoc/require-jsdoc rule. Achieves 0 lint warnings matching main branch
baseline.

* fix(types): reduce tsc errors to zero and fix all lint warnings

Eliminate all TypeScript compiler errors across src/ and test files by
fixing type mismatches, adding missing type annotations, and correcting
union type handling. Fix remaining ESLint issues including no-base-to-string
in ChargingProfile id extraction and jsdoc/tag-lines formatting.

* fix(ocpp2): fix AllowReset dead code, evseId===0 routing, and EVSE-scoped connector lookup

- AllowReset check now resolves via OCPP20VariableManager (runtime value) instead of static registry defaultValue
- Reset handler evseId===0 now routes to full station reset instead of EVSE-specific path
- TriggerMessage StatusNotification uses EVSE-scoped connector lookup instead of global getConnectorStatus

* ci: add typecheck step (tsc --noEmit --skipLibCheck) to CI pipeline

esbuild does not surface type errors at build time, so this catches
regressions before build+test. Runs on ubuntu/node-22 alongside lint.

* fix(ocpp2): remove DiagnosticsStatusNotification from MessageTriggerEnumType

This value is OCPP 1.6 only and not part of the OCPP 2.0.1 spec
(absent from TriggerMessageRequest.json schema).

* docs(readme): align OCPP 2.0.x section with spec and actual code

- Fix section letters to match OCPP 2.0.1 spec (A→B, B→C, C→G, etc.)
- Reorder sections to match spec block order (B,C,D,E,F,G,L,M,P)
- Add missing implemented commands: TriggerMessage, UnlockConnector,
  Get15118EVCertificate, GetCertificateStatus
- Move GetVariables/SetVariables from Monitoring to B. Provisioning
- Replace stale 'variables not implemented' note with actual support listing

* fix(ocpp2): add missing AJV response validators for 7 incoming request commands

CALLRESULT payloads were not validated against JSON schemas for
CertificateSigned, DeleteCertificate, GetInstalledCertificateIds,
GetVariables, InstallCertificate, Reset, and SetVariables.

All schema files already existed; only the validator map registration
was missing. Aligns OCPP 2.0 with OCPP 1.6 which validates all
incoming request responses (17/17).

* style(ocpp2): harmonize comment style with existing OCPP 1.6 sparse convention

Remove ~135 paraphrase/over-comments from OCPP 2.0 source files that
described what the next line obviously does. Keeps spec references
(C11.FR.04, F06.FR.17, OCPP 2.0.1 §2.10), TODO annotations, RFC 6960
deviation notes, eslint-disable directives, and terse comments matching
the existing OCPP 1.6 style. Test @file/@description headers preserved
per test style guide.

* [autofix.ci] apply automated fixes

* fix(ocpp2): correct spec references and harmonize format

- Fix wrong FR code: F03.FR.09 (triggerReason) → F03.FR.04 (meter
  values in TransactionEvent Ended)
- Harmonize FR comment format to 'X00.FR.00: description' style
- Harmonize section references to § symbol (was mixed Section/§)
- Harmonize RFC references to 'RFC 6960 §4.1.1' (was missing §)

* fix(ocpp): remove redundant strict:false from AJV instances

keywords: ['javaType'] already declares the custom keyword, making
strict:false unnecessary. Removing it enables AJV strict mode (default
since v7), which will flag any future non-standard schema keywords
instead of silently ignoring them.

* fix(types): make MeterValuesRequest/Response version-agnostic union types

Remove versioned OCPP16MeterValue import and casts from ChargingStation.ts,
following the established pattern of using union types outside the OCPP stack.

* fix(types): remove versioned type imports from Helpers.ts

Add ChargingSchedule union type, replace satisfies with version-agnostic
BootNotificationRequest, and rename getOCPP16ChargingSchedule to
getSingleChargingSchedule with union return type.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
11 days agorefactor(test): remove duplicate test coverage in error test files
Jérôme Benoit [Mon, 2 Mar 2026 14:47:11 +0000 (15:47 +0100)] 
refactor(test): remove duplicate test coverage in error test files

11 days agorefactor(test): audit-driven test quality improvements
Jérôme Benoit [Mon, 2 Mar 2026 14:36:12 +0000 (15:36 +0100)] 
refactor(test): audit-driven test quality improvements

- Add edge case tests for BaseError, OCPPError, ElectricUtils, AsyncLock, StatisticUtils
- Replace real timers with withMockTimers in UIServerSecurity rate limiter tests
- Add 'Date' to MockableTimerAPI type for Date.now() mocking support
- Factor duplicated OCPP 2.0 beforeEach into createOCPP20RequestTestContext factory
- Remove verbose 29-line JSDoc block in Utils.test.ts

11 days agofix(deps): update all non-major dependencies (#1695)
renovate[bot] [Mon, 2 Mar 2026 14:17:00 +0000 (15:17 +0100)] 
fix(deps): update all non-major dependencies (#1695)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
12 days agofix(tests): use import type for type-only imports in ESM
Jérôme Benoit [Sun, 1 Mar 2026 23:13:27 +0000 (00:13 +0100)] 
fix(tests): use import type for type-only imports in ESM

Use 'import type' for MockChargingStation imports to fix Windows ESM
module resolution which requires explicit type imports for re-exported
types.

12 days agofix(tests): use inline type exports to fix Windows ESM compatibility
Jérôme Benoit [Sun, 1 Mar 2026 23:04:02 +0000 (00:04 +0100)] 
fix(tests): use inline type exports to fix Windows ESM compatibility

Consolidate separate 'export type' and 'export' re-exports into single
export block with inline 'type' keyword. This ensures proper ESM module
resolution on Windows where Node.js strictly validates named exports.

Reverts the workaround of splitting imports in OCPP20TestUtils.ts since
the root cause (improper re-export pattern) is now fixed at source.

12 days agofix(tests): separate type import for Windows ESM compatibility
Jérôme Benoit [Sun, 1 Mar 2026 22:56:10 +0000 (23:56 +0100)] 
fix(tests): separate type import for Windows ESM compatibility

Split mixed import to use 'import type' for MockChargingStation type.
Windows Node.js ESM module resolution strictly enforces that type-only
exports cannot be imported as values in mixed import statements.

12 days agorefactor(test): remove local certificate aliases, use consolidated constants directly
Jérôme Benoit [Sun, 1 Mar 2026 22:49:40 +0000 (23:49 +0100)] 
refactor(test): remove local certificate aliases, use consolidated constants directly

12 days agorefactor(test): consolidate certificate constants and factory functions
Jérôme Benoit [Sun, 1 Mar 2026 22:40:35 +0000 (23:40 +0100)] 
refactor(test): consolidate certificate constants and factory functions

- Create OCPP20CertificateTestData.ts with shared certificate constants
- Add createMockCertificateHashData, createMockCertificateHashDataChain,
  createMockOCSPRequestData factory functions to OCPP20TestUtils.ts
- Migrate 5 test files to use consolidated imports
- Remove duplicate local certificate definitions and factory functions

12 days agorefactor(test): remove duplicate MockChargingStation interface from MockFactories
Jérôme Benoit [Sun, 1 Mar 2026 22:24:35 +0000 (23:24 +0100)] 
refactor(test): remove duplicate MockChargingStation interface from MockFactories

- Delete unused MockChargingStation interface (duplicate of StationHelpers.ts)
- Delete unused createMockAuthChargingStation factory function
- Keep createMockAuthServiceTestStation which is actively used (34 calls)

12 days agorefactor(test): harmonize mockStation naming across all test files
Jérôme Benoit [Sun, 1 Mar 2026 22:19:09 +0000 (23:19 +0100)] 
refactor(test): harmonize mockStation naming across all test files

12 days agorefactor(test): consolidate MockChargingStation type and clean Reset tests
Jérôme Benoit [Sun, 1 Mar 2026 22:15:55 +0000 (23:15 +0100)] 
refactor(test): consolidate MockChargingStation type and clean Reset tests

- Merge TestableChargingStation + MockResetChargingStation into MockChargingStation
- Remove duplicate re-exports from OCPP20TestUtils
- Eliminate redundant variable pairs in Reset tests
- Use ResetTestFixtures.createStandardStation() for setup
- Harmonize comments to FR reference style

12 days agorefactor(test): harmonize test file headers and fix async patterns
Jérôme Benoit [Sun, 1 Mar 2026 21:38:38 +0000 (22:38 +0100)] 
refactor(test): harmonize test file headers and fix async patterns

- Remove copyright headers from test files (align with JSDoc-only)
- Replace copyright with JSDoc headers in helper/constant files
- Fix AsyncLock.test.ts Promise anti-pattern (proper async/await)
- Add magic number constants to ChargingStationTestConstants.ts
- Fix semantic duplication with TEST_ONE_HOUR_SECONDS

12 days agofix(test): investigate Windows CI hang (#1694)
Jérôme Benoit [Sun, 1 Mar 2026 12:23:57 +0000 (13:23 +0100)] 
fix(test): investigate Windows CI hang (#1694)

* fix(test): add --test-force-exit to prevent Windows CI hang

Windows CI was hanging after test completion due to Node.js's handling of
stdout/stderr on Windows. On Windows, stdio uses Named Pipes (Sockets) that
remain 'ref'd' and keep the event loop alive, unlike Unix where file
descriptors are auto-unref'd.

The --test-force-exit flag is the official Node.js solution for this
Windows-specific behavior (see Node.js issue #49925).

Also fixes:
- createMockAuthorizationResult signature to accept only overrides parameter
- Remove setImmediate from mock.timers in Reset test (not needed)

* fix(test): wrap multiple describe blocks in parent for --test-force-exit compatibility

Node.js test runner with --test-force-exit has issues with multiple top-level
await describe() blocks. Wrapping both 'Error Recovery and Resilience' and
'Message Buffering' describe blocks in a parent 'ChargingStation Resilience'
describe block fixes the 'Promise resolution is still pending' errors.

* fix(test): wrap OCPP20 test describe blocks for --test-force-exit compatibility

Same fix as ChargingStation-Resilience.test.ts - wrapping multiple top-level
await describe() blocks in a parent describe block to fix Windows CI hang.

* fix(tests): add missing deleteIdTags method to MockIdTagsCache

The MockIdTagsCache mock was missing the deleteIdTags() method that exists
on the real IdTagsCache class. This caused ClearCache tests to fail when
the method was called during test execution.

* fix(tests): improve test isolation for OCPP 2.0 tests

- Add ocppConfiguration with configurationKey to GetBaseReport test setup
  so ConfigurationInventory reports have data to return
- Add ocppConfiguration with HeartbeatInterval and WebSocketPingInterval
  to VariableManager test setup for proper isolation
- Fix MessageTimeout test expectations to use seconds (OCPP 2.0 unit)
  instead of milliseconds (station.getConnectionTimeout())

These changes ensure tests pass when run individually or in any order,
which is required for --test-force-exit on Windows.

* refactor(tests): use constants instead of hardcoded values in GetBaseReport test

Replace hardcoded '60' and '30' values with proper constant references:
- HeartbeatInterval: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL)
- MeterValueSampleInterval: millisecondsToSeconds(Constants.DEFAULT_METER_VALUES_INTERVAL)

This follows the single source of truth principle from TEST_STYLE_GUIDE.md
and maintains consistency with OCPP20VariableManager.test.ts.

* docs(tests): document Windows CI constraints and --test-force-exit

Add section 5 'Platform-Specific Considerations' to TEST_STYLE_GUIDE.md:
- Explain why --test-force-exit is needed (Windows Named Pipes behavior)
- Document single top-level describe block requirement
- Update section numbers and summary accordingly

This documents the root cause and solution for the Windows CI hang issue.

13 days agorefactor(test): remove more implementation history from comments
Jérôme Benoit [Sun, 1 Mar 2026 01:42:59 +0000 (02:42 +0100)] 
refactor(test): remove more implementation history from comments

13 days agorefactor(test): remove implementation history from comments
Jérôme Benoit [Sun, 1 Mar 2026 01:41:36 +0000 (02:41 +0100)] 
refactor(test): remove implementation history from comments

Comments should describe what the code does, not how it evolved.

13 days agorefactor: restore initial mock reset code
Jérôme Benoit [Sun, 1 Mar 2026 01:24:07 +0000 (02:24 +0100)] 
refactor: restore initial mock reset code

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
13 days agofix(test): remove redundant standardCleanup() from nested afterEach
Jérôme Benoit [Sun, 1 Mar 2026 01:08:26 +0000 (02:08 +0100)] 
fix(test): remove redundant standardCleanup() from nested afterEach

UIHttpServer and OCPP20AuthAdapter tests had nested describes with
afterEach blocks calling standardCleanup(), duplicating the outer
afterEach cleanup. This could cause mock.restoreAll() to be called
twice per test, potentially causing issues on Windows.

13 days agofix(test): remove redundant nested afterEach in Reset test causing Windows hang
Jérôme Benoit [Sun, 1 Mar 2026 01:05:37 +0000 (02:05 +0100)] 
fix(test): remove redundant nested afterEach in Reset test causing Windows hang

The Reset test had nested describes (B11, B12) with their own afterEach
calling standardCleanup(), plus an outer afterEach calling mock.timers.reset()
then standardCleanup(). This caused mock.restoreAll() to be called twice
per test with timer reset in between - leaving MockTracker in inconsistent
state on Windows.

Also harmonize StationHelpers cleanup to use '= undefined' consistently
instead of mixing with 'delete'.

13 days agofix(tests): restore standardCleanup in SetVariables test
Jérôme Benoit [Sun, 1 Mar 2026 00:54:48 +0000 (01:54 +0100)] 
fix(tests): restore standardCleanup in SetVariables test

13 days agofix(tests): remove standardCleanup from SetVariables test to fix Windows hang
Jérôme Benoit [Sun, 1 Mar 2026 00:36:21 +0000 (01:36 +0100)] 
fix(tests): remove standardCleanup from SetVariables test to fix Windows hang

13 days agofix(tests): prevent Windows CI hang by moving timer reset to test that enables it
Jérôme Benoit [Sun, 1 Mar 2026 00:30:36 +0000 (01:30 +0100)] 
fix(tests): prevent Windows CI hang by moving timer reset to test that enables it

- Remove mock.timers.reset() from standardCleanup()
- Add explicit mock.timers.reset() to Reset test afterEach
- Fix Reset test: wrap orphaned code into proper it() block

13 days agofix(tests): cleanup ALL private intervals in cleanupChargingStation
Jérôme Benoit [Sun, 1 Mar 2026 00:07:09 +0000 (01:07 +0100)] 
fix(tests): cleanup ALL private intervals in cleanupChargingStation

Adds cleanup for:
- wsPingSetInterval (private) - WebSocket ping timer
- flushMessageBufferSetInterval (private) - message buffer flush timer
- transactionTxUpdatedSetInterval - OCPP 2.0 transaction update timer

These uncleaned intervals were keeping the Node.js event loop alive,
causing Windows CI tests to hang indefinitely.

13 days agofix(tests): restore ping() method and cleanup wsPingSetInterval
Jérôme Benoit [Sat, 28 Feb 2026 23:59:52 +0000 (00:59 +0100)] 
fix(tests): restore ping() method and cleanup wsPingSetInterval

Fixes Windows CI hang caused by:
- Missing wsPingSetInterval cleanup in cleanupChargingStation()
- Removed ping()/pong() methods that ChargingStation.ts still calls

The WebSocket ping interval was never cleared during test cleanup,
keeping the Node.js event loop alive indefinitely on Windows.

13 days agofix(tests): remove unused mock imports after cleanup refactor
Jérôme Benoit [Sat, 28 Feb 2026 23:54:34 +0000 (00:54 +0100)] 
fix(tests): remove unused mock imports after cleanup refactor

Removed ', mock' from imports in 31 test files where mock.restoreAll()
was previously removed but the import remained, causing ESLint
'no-unused-vars' errors.

13 days agorefactor(tests): use TEST_CHARGING_STATION_BASE_NAME constant consistently
Jérôme Benoit [Sat, 28 Feb 2026 23:29:22 +0000 (00:29 +0100)] 
refactor(tests): use TEST_CHARGING_STATION_BASE_NAME constant consistently

13 days agorefactor(tests): remove aliases, extract time constants, fix naming and lint issues
Jérôme Benoit [Sat, 28 Feb 2026 23:25:52 +0000 (00:25 +0100)] 
refactor(tests): remove aliases, extract time constants, fix naming and lint issues

13 days agorefactor(tests): restructure TEST_STYLE_GUIDE and use centralized constants
Jérôme Benoit [Sat, 28 Feb 2026 22:39:20 +0000 (23:39 +0100)] 
refactor(tests): restructure TEST_STYLE_GUIDE and use centralized constants

- Rewrite TEST_STYLE_GUIDE.md: 691 → 295 lines, logical sections, no redundancy
- Fix toBeTruthy() → toBeDefined() for strict assertions
- Add test constants (TEST_ID_TAG, TEST_TRANSACTION_ID, TEST_TRANSACTION_ENERGY_WH)
- Update test files to use centralized constants instead of inline values

13 days agodocs: update TEST_STYLE_GUIDE with standardCleanup and describe naming conventions
Jérôme Benoit [Sat, 28 Feb 2026 22:22:22 +0000 (23:22 +0100)] 
docs: update TEST_STYLE_GUIDE with standardCleanup and describe naming conventions

13 days agotest: add standardCleanup() and fix import ordering in test files
Jérôme Benoit [Sat, 28 Feb 2026 22:18:51 +0000 (23:18 +0100)] 
test: add standardCleanup() and fix import ordering in test files

13 days agodocs(tests): fix TEST_STYLE_GUIDE to match actual codebase
Jérôme Benoit [Sat, 28 Feb 2026 21:57:32 +0000 (22:57 +0100)] 
docs(tests): fix TEST_STYLE_GUIDE to match actual codebase

- Remove non-existent waitForChargingStationState reference
- Remove duplicate table rows (cleanupChargingStation, Auth factories)
- Fix factory name: createChargingStation -> createMockChargingStation
- Fix destructuring pattern: { station } = createMockChargingStation()
- Add missing utilities to table (resetChargingStationState, etc.)
- Update import examples to match actual API

13 days agorefactor(tests): remove unused constants and add missing JSDoc
Jérôme Benoit [Sat, 28 Feb 2026 21:51:29 +0000 (22:51 +0100)] 
refactor(tests): remove unused constants and add missing JSDoc

- Remove 63 unused constants from ChargingStationTestConstants.ts (73% cleanup)
- Add JSDoc to 7 factory functions in UIServerTestUtils.ts
- Remove duplicate JSDoc comment in StationHelpers.ts

13 days agodocs(tests): update TEST_STYLE_GUIDE to reflect current utilities
Jérôme Benoit [Sat, 28 Feb 2026 21:43:04 +0000 (22:43 +0100)] 
docs(tests): update TEST_STYLE_GUIDE to reflect current utilities

- Remove duplicate createMockChargingStation entries
- Replace waitForCondition with waitForChargingStationState
- Update import examples to match current exports

13 days agodocs(tests): add missing JSDoc param descriptions and returns
Jérôme Benoit [Sat, 28 Feb 2026 21:41:39 +0000 (22:41 +0100)] 
docs(tests): add missing JSDoc param descriptions and returns

13 days agorefactor(tests): cleanup unused exports and consolidate testable classes
Jérôme Benoit [Sat, 28 Feb 2026 21:39:32 +0000 (22:39 +0100)] 
refactor(tests): cleanup unused exports and consolidate testable classes

- Remove unused exports from UIServerTestUtils
- Remove unused ping()/pong() from MockWebSocket
- Remove waitForCondition from StationHelpers
- Consolidate TestableUIWebSocketServer into UIServerTestUtils
- Remove createMockOCPP20TransactionTestStation wrapper
- Add _brand to MockSharedLRUCache to fix static-only class lint

13 days ago[autofix.ci] apply automated fixes
autofix-ci[bot] [Sat, 28 Feb 2026 21:26:58 +0000 (21:26 +0000)] 
[autofix.ci] apply automated fixes

13 days agorefactor(tests): remove deprecated code and backward compatibility
Jérôme Benoit [Sat, 28 Feb 2026 21:24:07 +0000 (22:24 +0100)] 
refactor(tests): remove deprecated code and backward compatibility

- Remove unused createUIProtocolMock from MockWebSocket.ts
- Remove backward compat re-exports from UIServerTestUtils.ts
- Migrate all evsesCount usages to evseConfiguration.evsesCount
- Remove deprecated evsesCount option from MockChargingStationOptions
- Simplify determineEvseUsage function

13 days agorefactor(tests): consolidate MockUIService classes and remove redundant subclass
Jérôme Benoit [Sat, 28 Feb 2026 21:16:52 +0000 (22:16 +0100)] 
refactor(tests): consolidate MockUIService classes and remove redundant subclass

- Replace MockUIServiceBroadcast, MockUIServiceError, MockUIServiceNonBroadcast
  with single createMockUIService(MockUIServiceMode) factory
- Remove redundant MockWebSocket subclass from UIServerTestUtils.ts
- Re-export createUIProtocolMock as createMockUIWebSocket for UI testing
- Update UIWebSocketServer.test.ts to use new factories

13 days agorefactor(tests): remove deprecated identifier factories
Jérôme Benoit [Sat, 28 Feb 2026 21:12:34 +0000 (22:12 +0100)] 
refactor(tests): remove deprecated identifier factories

- Migrate createMockOCPP16Identifier to createMockIdentifier
- Migrate createMockOCPP20Identifier to createMockIdentifier
- Delete deprecated functions from MockFactories.ts
- Fix import order in LocalAuthStrategy.test.ts

13 days agorefactor(tests): consolidate duplicate mock factories
Jérôme Benoit [Sat, 28 Feb 2026 21:04:13 +0000 (22:04 +0100)] 
refactor(tests): consolidate duplicate mock factories

- Extract createMockCertificateManager to OCPP20TestUtils.ts (was duplicated 4x)
- Consolidate 5 createMock*AuthorizationResult into single parameterized factory
- Add createMockIdentifier with OCPP version parameter (deprecate version-specific ones)
- Remove unused wrapper functions from certificate test files

Reduces code duplication and improves maintainability.

13 days agofix(tests): resolve all ESLint errors in factory consolidation
Jérôme Benoit [Sat, 28 Feb 2026 20:46:29 +0000 (21:46 +0100)] 
fix(tests): resolve all ESLint errors in factory consolidation

- Fix incorrect import paths (../../../ -> ../../ChargingStationTestUtils.js)
- Replace remaining createChargingStation() calls with createMockChargingStation()
- Remove obsolete TestChargingStation type references
- Remove unused variables and duplicate declarations
- Update type annotations for mock stations

All 291 tests pass, 0 ESLint errors.

13 days agodocs(tests): update TEST_STYLE_GUIDE to reference new factory
Jérôme Benoit [Sat, 28 Feb 2026 20:04:10 +0000 (21:04 +0100)] 
docs(tests): update TEST_STYLE_GUIDE to reference new factory

- Updated TEST_STYLE_GUIDE.md to use createMockChargingStation
- Fixed comment in ChargingStationTestUtils.ts
- Removed references to deleted ChargingStationFactory.ts

Final cleanup complete

13 days agorefactor(tests): fix TypeScript errors in auth and variable manager tests
Jérôme Benoit [Sat, 28 Feb 2026 20:02:51 +0000 (21:02 +0100)] 
refactor(tests): fix TypeScript errors in auth and variable manager tests

- Fixed OCPPAuthIntegration.test.ts to use createMockChargingStation with destructuring
- Corrected import path in AuthComponentFactory.test.ts (../../../../ → ../../../)
- Fixed OCPP20VariableManager.test.ts type errors by properly extracting .station property
- All 291 tests passing
- Zero migration-related TypeScript compilation errors

Task 9 complete

13 days agorefactor(tests): delete deprecated ChargingStationFactory and fix remaining imports
Jérôme Benoit [Sat, 28 Feb 2026 19:54:21 +0000 (20:54 +0100)] 
refactor(tests): delete deprecated ChargingStationFactory and fix remaining imports

- Deleted ChargingStationFactory.ts and ChargingStationFactory.test.ts
- Fixed broken imports in 3 utility test files (ConfigurationKeyUtils, Helpers, ErrorUtils)
- Migrated remaining createChargingStation() calls to createMockChargingStation()
- Added createMockChargingStationTemplate() support in StationHelpers
- All 291 tests passing

Task 8 complete

13 days agorefactor(tests): migrate all test files to createMockChargingStation
Jérôme Benoit [Sat, 28 Feb 2026 19:34:22 +0000 (20:34 +0100)] 
refactor(tests): migrate all test files to createMockChargingStation

- Migrated 20 OCPP 2.0 test files to use createMockChargingStation
- Migrated 4 utility test files to use consolidated imports
- Added createChargingStation and createChargingStationTemplate re-exports to ChargingStationTestUtils
- All 291 tests passing

Tasks 3-7 complete

13 days agorefactor(tests): migrate OCPP20TestUtils to createMockChargingStation
Jérôme Benoit [Sat, 28 Feb 2026 18:42:13 +0000 (19:42 +0100)] 
refactor(tests): migrate OCPP20TestUtils to createMockChargingStation

13 days agorefactor(tests): extend MockChargingStationOptions with all factory options
Jérôme Benoit [Sat, 28 Feb 2026 18:31:44 +0000 (19:31 +0100)] 
refactor(tests): extend MockChargingStationOptions with all factory options

- Add missing options: connectionTimeout, connectorDefaults, evseConfiguration,
  ocppConfiguration, ocppIncomingRequestService, ocppRequestService, starting,
  stationInfo, websocketPingInterval
- Add MockOCPPIncomingRequestService and MockOCPPRequestService interfaces
- Update createMockChargingStation() to handle new options
- Add EVSE auto-detection: if stationInfo.ocppVersion is VERSION_20 or VERSION_201,
  set useEvses = true
- Export new interfaces from ChargingStationTestUtils.ts

13 days agochore: update minimatch to 10.2.4
Jérôme Benoit [Sat, 28 Feb 2026 18:17:48 +0000 (19:17 +0100)] 
chore: update minimatch to 10.2.4

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
13 days agochore: update minimatch to 10.2.4 and 3.1.5
Jérôme Benoit [Sat, 28 Feb 2026 18:09:08 +0000 (19:09 +0100)] 
chore: update minimatch to 10.2.4 and 3.1.5

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
13 days agorefactor(tests): standardize cleanup and strict equality
Jérôme Benoit [Sat, 28 Feb 2026 17:43:48 +0000 (18:43 +0100)] 
refactor(tests): standardize cleanup and strict equality

- Migrate 15 test files to use standardCleanup() from TestLifecycleHelpers
- Replace all 27 .toEqual() with .toStrictEqual() across 10 files
- Fix import path in OCPP20CertificateManager.test.ts

This completes P0 (cleanup standardization) and P1 (strict equality)
from the test audit. All 291 tests pass.

13 days agofix(test-isolation): make OCPP20VariableManager tests self-contained
Jérôme Benoit [Sat, 28 Feb 2026 17:13:24 +0000 (18:13 +0100)] 
fix(test-isolation): make OCPP20VariableManager tests self-contained

- FileTransferProtocols: init config key via getVariables first
- OrganizationName: set value explicitly instead of relying on previous test

Each test initializes its own state via fresh mockChargingStation from beforeEach.
Fixes Windows CI failure caused by test execution order assumptions.

13 days agorefactor(tests): move mock creation from it() to beforeEach()
Jérôme Benoit [Sat, 28 Feb 2026 17:05:27 +0000 (18:05 +0100)] 
refactor(tests): move mock creation from it() to beforeEach()

- Refactor OCPPAuthServiceImpl.test.ts: declare mocks at describe level, initialize in beforeEach()
- Refactor OCPPAuthServiceFactory.test.ts: same pattern for consistency
- Refactor InMemoryAuthCache.test.ts: move common mockResult to beforeEach()

Aligns with TEST_STYLE_GUIDE.md recommendation for test isolation pattern.

13 days agofix(test-isolation): replace mock.reset() with mock.restoreAll() in auth tests
Jérôme Benoit [Sat, 28 Feb 2026 16:56:29 +0000 (17:56 +0100)] 
fix(test-isolation): replace mock.reset() with mock.restoreAll() in auth tests

- Replace incorrect mock.reset() with mock.restoreAll() in 7 auth test files
- Remove duplicate table rows in TEST_STYLE_GUIDE.md (lines 287-296)

Ensures proper mock cleanup between tests to prevent cross-test pollution.

13 days agorefactor(tests): harmonize test suite structure and eliminate duplication
Jérôme Benoit [Sat, 28 Feb 2026 16:41:55 +0000 (17:41 +0100)] 
refactor(tests): harmonize test suite structure and eliminate duplication

- Consolidate 5 TransactionEvent variant files into single parameterized test
- Reduce OCPPAuthIntegration.test.ts scope (422→196 lines, focus on integration)
- Remove duplicate resetConnectorTransactionStates function, use shared utility
- Merge OCPP20AuthAdapter-Offline.test.ts into main adapter test file
- Add beforeEach hooks for mock initialization in ChargingStation tests
- Standardize OCPP requirement codes in describe blocks (I02-I04, G03)
- Consolidate eslint-disable comments with explanatory reasons
- Fix JSDoc header positions in OCPP 2.0 test files
- Use standardCleanup() for consistent timer mock reset

Net reduction: ~400 lines of test code while maintaining full coverage

13 days agofix(test-type-safety): remove unsafe type casts and add factory helper
Jérôme Benoit [Sat, 28 Feb 2026 16:08:14 +0000 (17:08 +0100)] 
fix(test-type-safety): remove unsafe type casts and add factory helper

Phase 1 (Type Safety):
- Remove 16 'undefined as unknown as' casts from 8 auth test files
- Add createStationWithCertificateManager() helper to OCPP20TestUtils
- Migrate 3 certificate test files to use the new type-safe helper

Phase 2 (Enhancements):
- Add explanatory comments to 9 ESLint override directives
- Update TEST_STYLE_GUIDE.md with new factory documentation

13 days ago[autofix.ci] apply automated fixes
autofix-ci[bot] [Sat, 28 Feb 2026 15:51:04 +0000 (15:51 +0000)] 
[autofix.ci] apply automated fixes

13 days agofix(test-isolation): move mock instances to beforeEach in OCPP 2.0 tests
Jérôme Benoit [Sat, 28 Feb 2026 15:48:00 +0000 (16:48 +0100)] 
fix(test-isolation): move mock instances to beforeEach in OCPP 2.0 tests

Move module-level mock instances inside beforeEach blocks to ensure
proper test isolation per TEST_STYLE_GUIDE.md requirements.

- 11 IncomingRequestService test files fixed
- 1 VariableManager test file fixed
- 1 ServiceUtils-TransactionEvent test file fixed
- 1 TestUtils file updated with JSDoc documentation

Each test now gets fresh mock instances, eliminating potential
cross-test state contamination.

13 days agofix(test-isolation): move mock creation to beforeEach in CableFirst test
Jérôme Benoit [Sat, 28 Feb 2026 15:36:56 +0000 (16:36 +0100)] 
fix(test-isolation): move mock creation to beforeEach in CableFirst test

- Move mockChargingStation initialization from module level to beforeEach()
- Declare mockChargingStation as let at describe scope per TEST_STYLE_GUIDE.md
- Ensures each test receives fresh mock instances
- Fixes CRITICAL test isolation violation per test audit
- All 12 tests in E02 - Cable-First Transaction Flow pass

13 days agorefactor(tests): add shared test helpers and fixtures for DRY compliance
Jérôme Benoit [Sat, 28 Feb 2026 14:31:06 +0000 (15:31 +0100)] 
refactor(tests): add shared test helpers and fixtures for DRY compliance

- Add timer helpers (withMockTimers, createTimerScope) in TestLifecycleHelpers.ts
- Add auth mock factories (createTestAuthConfig, createMockAuthCache, etc.) in MockFactories.ts
- Add transaction fixtures (IdTokenFixtures, TransactionContextFixtures) in OCPP20TestUtils.ts
- Add request tracking helper (createMockStationWithRequestTracking) for OCPP tests
- Refactor AuthStrategy tests to use shared factories (~490 LOC saved)
- Refactor TransactionEvent tests to use shared fixtures and helpers

14 files changed, 585 insertions(+), 752 deletions(-) = 167 net LOC saved

13 days agorefactor(tests): remove eslint-disable and fix type safety issues
Jérôme Benoit [Sat, 28 Feb 2026 14:06:42 +0000 (15:06 +0100)] 
refactor(tests): remove eslint-disable and fix type safety issues

- Remove file-level eslint-disable comments from OCPP 2.0 transaction tests
- Replace `as any` casts with proper TypeScript types (ChargingStation, SentRequest)
- Fix test isolation by moving state reset to beforeEach hooks
- Use `stationInfo = undefined` pattern instead of delete with any cast
- Remove unnecessary async keywords and optional chains per lint rules

13 days agochore(deps): update all non-major dependencies (#1692)
renovate[bot] [Sat, 28 Feb 2026 14:26:14 +0000 (14:26 +0000)] 
chore(deps): update all non-major dependencies (#1692)

* chore(deps): update all non-major dependencies

* [autofix.ci] apply automated fixes

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
13 days agodocs(tests): enhance TEST_STYLE_GUIDE with async patterns and best practices
Jérôme Benoit [Sat, 28 Feb 2026 13:26:32 +0000 (14:26 +0100)] 
docs(tests): enhance TEST_STYLE_GUIDE with async patterns and best practices

- Add Testing Philosophy section with core principles
- Add Async Testing Patterns section (async/await, Promise rejection, timeout)
- Add Error & Exception Testing section with examples
- Soften AAA comments rule (required for complex, optional for simple tests)
- Add anti-pattern #6: Non-strict assertions guidance
- Align with Node.js test runner best practices 2024-2025

13 days agodocs: reference TEST_STYLE_GUIDE.md in AI agent instructions
Jérôme Benoit [Sat, 28 Feb 2026 13:13:52 +0000 (14:13 +0100)] 
docs: reference TEST_STYLE_GUIDE.md in AI agent instructions

13 days agorefactor(tests): remove file-level eslint-disable and fix as any casts
Jérôme Benoit [Sat, 28 Feb 2026 13:09:50 +0000 (14:09 +0100)] 
refactor(tests): remove file-level eslint-disable and fix as any casts

- Remove blanket eslint-disable comments from OCPP 2.0 test files
- Fix improper 'as any' casts in afterEach cleanup (use union types)
- Add targeted inline eslint-disable-next-line for legitimate test cases
  (testing null/undefined inputs for edge case validation)

2 weeks agorefactor(tests): improve test isolation and remove dead code
Jérôme Benoit [Fri, 27 Feb 2026 22:54:59 +0000 (23:54 +0100)] 
refactor(tests): improve test isolation and remove dead code

- Fix module-level state sharing in 6 OCPP 2.0 RequestService tests
- Remove unused createMockTemplate function from StationHelpers
- Remove unused TestStationHelper, TestTimerHelper, TestEnvironmentHelper classes (206 LOC)
- Add createMockAuthCache and createMockOCPPAdapter factories
- Update TEST_STYLE_GUIDE.md with test isolation best practices
- Clean up orphaned imports after dead code removal

2 weeks agorefactor(tests): add testable interface to eliminate eslint-disable comments
Jérôme Benoit [Fri, 27 Feb 2026 22:31:29 +0000 (23:31 +0100)] 
refactor(tests): add testable interface to eliminate eslint-disable comments

- Add TestableOCPP20RequestService interface and factory function
- Remove file-level eslint-disable from 3 OCPP20RequestService test files
- Use type assertions instead of generic type parameters for type safety
- Follows TEST_STYLE_GUIDE.md recommendation for testable interfaces

2 weeks agotest: add afterEach cleanup to all test files
Jérôme Benoit [Fri, 27 Feb 2026 22:14:12 +0000 (23:14 +0100)] 
test: add afterEach cleanup to all test files

Add afterEach with mock.restoreAll() to 27 test files.
Ensures 100% coverage for mock cleanup (63/63 files).
Prevents test pollution between test runs.
Follows TEST_STYLE_GUIDE.md standards.

2 weeks agotest: harmonize test names and add mock factories
Jérôme Benoit [Fri, 27 Feb 2026 22:03:44 +0000 (23:03 +0100)] 
test: harmonize test names and add mock factories

- Replace 164 'should verify' patterns with descriptive test names
- Add createLoggerMocks() and createConsoleMocks() to TestLifecycleHelpers
- Add afterEach cleanup to ErrorUtils, WorkerUtils, ConfigurationUtils tests
- Align all test names with TEST_STYLE_GUIDE.md conventions

2 weeks agotest: improve test suite quality and add lifecycle helpers
Jérôme Benoit [Fri, 27 Feb 2026 21:45:03 +0000 (22:45 +0100)] 
test: improve test suite quality and add lifecycle helpers

- Add TestLifecycleHelpers module with reusable setup/cleanup classes
- Add afterEach hooks to prevent test pollution
- Fix lint errors and add complete JSDoc documentation
- Update TEST_STYLE_GUIDE with acceptable eslint-disable patterns
- Rename OCPP20AuthAdapter.offline.test.ts for naming consistency

2 weeks agorefactor(tests): harmonize test naming and consolidate utilities
Jérôme Benoit [Fri, 27 Feb 2026 21:14:24 +0000 (22:14 +0100)] 
refactor(tests): harmonize test naming and consolidate utilities

- Standardize test names to 'should [verb]' lowercase pattern
- Extract createConnectorStatus() as shared utility
- Remove duplicate MockWebSocket and waitForCondition()
- Update TEST_STYLE_GUIDE.md with shared utilities table

2 weeks agofix(tests): fix wrong constant name imports in GetVariables and SetVariables tests
Jérôme Benoit [Fri, 27 Feb 2026 20:45:03 +0000 (21:45 +0100)] 
fix(tests): fix wrong constant name imports in GetVariables and SetVariables tests

2 weeks agofix(tests): fix Windows CI - separate type vs value imports correctly
Jérôme Benoit [Fri, 27 Feb 2026 20:39:11 +0000 (21:39 +0100)] 
fix(tests): fix Windows CI - separate type vs value imports correctly

2 weeks agofix(tests): fix Windows CI failures - separate value imports from type imports
Jérôme Benoit [Fri, 27 Feb 2026 20:31:32 +0000 (21:31 +0100)] 
fix(tests): fix Windows CI failures - separate value imports from type imports

2 weeks agofix(tests): fix Windows CI failures - type import and test assertion
Jérôme Benoit [Fri, 27 Feb 2026 20:25:49 +0000 (21:25 +0100)] 
fix(tests): fix Windows CI failures - type import and test assertion