]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(test-isolation): replace mock.reset() with mock.restoreAll() in auth tests
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 16:56:29 +0000 (17:56 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 16:56:29 +0000 (17:56 +0100)
- 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.

tests/TEST_STYLE_GUIDE.md
tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts
tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts
tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts
tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts
tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts
tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts
tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts

index db9bde70f241574b5c628dfe0cb9e3e6c77d5e88..886c407b2876798e547cdb5150acc48c609f25a6 100644 (file)
@@ -284,16 +284,6 @@ The following utilities are available for reuse across test files:
 | `waitForCondition()`                    | `helpers/StationHelpers.ts`          | Async condition waiting with timeout         |
 | `cleanupChargingStation()`              | `helpers/StationHelpers.ts`          | Proper station cleanup for afterEach         |
 | Auth factories                          | `ocpp/auth/helpers/MockFactories.ts` | Auth-specific mock creation                  |
-| -----------------------------           | ------------------------------------ | -----------------------------------------    |
-| `createMockChargingStation()`           | `ChargingStationTestUtils.ts`        | Lightweight mock station stub                |
-| `createChargingStation()`               | `ChargingStationFactory.ts`          | Full test station with OCPP services         |
-| `createConnectorStatus()`               | `helpers/StationHelpers.ts`          | ConnectorStatus factory with defaults        |
-| `MockWebSocket`                         | `mocks/MockWebSocket.ts`             | WebSocket simulation with message capture    |
-| `MockIdTagsCache`                       | `mocks/MockCaches.ts`                | In-memory IdTags cache mock                  |
-| `MockSharedLRUCache`                    | `mocks/MockCaches.ts`                | In-memory LRU cache mock                     |
-| `waitForCondition()`                    | `helpers/StationHelpers.ts`          | Async condition waiting with timeout         |
-| `cleanupChargingStation()`              | `helpers/StationHelpers.ts`          | Proper station cleanup for afterEach         |
-| Auth factories                          | `ocpp/auth/helpers/MockFactories.ts` | Auth-specific mock creation                  |
 
 **DO NOT duplicate these utilities.** Import and reuse them.
 
index 4fd434ce9667db08754213f374334c10d812426b..be49d7001b2a3a8145c40d689389acdba277883f 100644 (file)
@@ -51,7 +51,7 @@ await describe('OCPP Authentication Integration Tests', async () => {
   })
 
   afterEach(() => {
-    mock.reset()
+    mock.restoreAll()
   })
 
   await describe('OCPP 1.6 Authentication Flow', async () => {
index be24f97d03bf941858eed0a45f6d661d67b9d5b7..75032da5cbc7e4f2e029b72bd68947c7cd28cc43 100644 (file)
@@ -57,7 +57,7 @@ await describe('OCPP16AuthAdapter', async () => {
   })
 
   afterEach(() => {
-    mock.reset()
+    mock.restoreAll()
   })
 
   await describe('constructor', async () => {
index 41f8c8e075c0f63276006d2c1575523d9ab1aef4..1871c139d8e573cac492b0638af3e2faf2001bfd 100644 (file)
@@ -44,7 +44,7 @@ await describe('OCPP20AuthAdapter', async () => {
   })
 
   afterEach(() => {
-    mock.reset()
+    mock.restoreAll()
   })
 
   await describe('constructor', async () => {
index 247d17910db5c197757a093a70186ec62ea3fe7c..54ca9e4bcfa9e57b2fbf1e544b57df03e0725bdb 100644 (file)
@@ -39,7 +39,7 @@ await describe('InMemoryAuthCache - G03.FR.01 Conformance', async () => {
   })
 
   afterEach(() => {
-    mock.reset()
+    mock.restoreAll()
   })
 
   await describe('G03.FR.01.001 - Cache Hit Behavior', async () => {
index 9ce11570cb12806b687c57e4445180aa7df49f63..195ebf8bdf63140109416902cd071a8b44f8b26f 100644 (file)
@@ -57,7 +57,7 @@ await describe('CertificateAuthStrategy', async () => {
   })
 
   afterEach(() => {
-    mock.reset()
+    mock.restoreAll()
   })
 
   await describe('constructor', async () => {
index 0c5e0438e98c09df918bf6ebcabe91b40ce6a53f..50ae6b7dec5cbcbf31b430b8102905a4dc7bd024 100644 (file)
@@ -38,7 +38,7 @@ await describe('LocalAuthStrategy', async () => {
   })
 
   afterEach(() => {
-    mock.reset()
+    mock.restoreAll()
   })
 
   await describe('constructor', async () => {
index 6f485b12ec4dfd5d5cbed35c5da876711c336833..2d57bec1b26a141bc59ac602027928ea47b1f9d1 100644 (file)
@@ -44,7 +44,7 @@ await describe('RemoteAuthStrategy', async () => {
   })
 
   afterEach(() => {
-    mock.reset()
+    mock.restoreAll()
   })
 
   await describe('constructor', async () => {