]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test: remove 24 tautological enum value assertion tests
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 13 Mar 2026 16:29:36 +0000 (17:29 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 13 Mar 2026 16:29:36 +0000 (17:29 +0100)
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).

tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts
tests/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.test.ts
tests/charging-station/ocpp/auth/types/AuthTypes.test.ts
tests/types/ConfigurationData.test.ts [deleted file]
tests/utils/ChargingStationConfigurationUtils.test.ts

index e6d9281c563663fb2fdffdf81d320a6a6d23a6f0..c8f743cb697f71174a21276f98e346f2482279ae 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * @file Tests for ChargingStationWorkerBroadcastChannel
- * @description Verifies OCPP 2.0.1 UIService pipeline integration: enums, mappings,
+ * @description Verifies OCPP 2.0.1 UIService pipeline integration: mappings,
  * response status logic, payload building, and handler routing for the 8 new broadcast
- * channel procedures. 59 tests across 7 groups.
+ * channel procedures.
  */
 
 import assert from 'node:assert/strict'
@@ -104,98 +104,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => {
   })
 
   // ==========================================================================
-  // Group 1: ProcedureName enum — 8 new OCPP 2.0.1 entries (8 tests)
-  // ==========================================================================
-
-  await describe('ProcedureName enum OCPP 2.0.1 entries', async () => {
-    await it('should have GET_15118_EV_CERTIFICATE in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.GET_15118_EV_CERTIFICATE, 'get15118EVCertificate')
-    })
-
-    await it('should have GET_CERTIFICATE_STATUS in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.GET_CERTIFICATE_STATUS, 'getCertificateStatus')
-    })
-
-    await it('should have LOG_STATUS_NOTIFICATION in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.LOG_STATUS_NOTIFICATION, 'logStatusNotification')
-    })
-
-    await it('should have NOTIFY_CUSTOMER_INFORMATION in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.NOTIFY_CUSTOMER_INFORMATION, 'notifyCustomerInformation')
-    })
-
-    await it('should have NOTIFY_REPORT in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.NOTIFY_REPORT, 'notifyReport')
-    })
-
-    await it('should have SECURITY_EVENT_NOTIFICATION in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.SECURITY_EVENT_NOTIFICATION, 'securityEventNotification')
-    })
-
-    await it('should have SIGN_CERTIFICATE in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.SIGN_CERTIFICATE, 'signCertificate')
-    })
-
-    await it('should have TRANSACTION_EVENT in ProcedureName enum', () => {
-      assert.strictEqual(ProcedureName.TRANSACTION_EVENT, 'transactionEvent')
-    })
-  })
-
-  // ==========================================================================
-  // Group 2: BroadcastChannelProcedureName enum — 8 new OCPP 2.0.1 entries (8 tests)
-  // ==========================================================================
-
-  await describe('BroadcastChannelProcedureName enum OCPP 2.0.1 entries', async () => {
-    await it('should have GET_15118_EV_CERTIFICATE in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(
-        BroadcastChannelProcedureName.GET_15118_EV_CERTIFICATE,
-        'get15118EVCertificate'
-      )
-    })
-
-    await it('should have GET_CERTIFICATE_STATUS in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(
-        BroadcastChannelProcedureName.GET_CERTIFICATE_STATUS,
-        'getCertificateStatus'
-      )
-    })
-
-    await it('should have LOG_STATUS_NOTIFICATION in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(
-        BroadcastChannelProcedureName.LOG_STATUS_NOTIFICATION,
-        'logStatusNotification'
-      )
-    })
-
-    await it('should have NOTIFY_CUSTOMER_INFORMATION in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(
-        BroadcastChannelProcedureName.NOTIFY_CUSTOMER_INFORMATION,
-        'notifyCustomerInformation'
-      )
-    })
-
-    await it('should have NOTIFY_REPORT in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(BroadcastChannelProcedureName.NOTIFY_REPORT, 'notifyReport')
-    })
-
-    await it('should have SECURITY_EVENT_NOTIFICATION in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(
-        BroadcastChannelProcedureName.SECURITY_EVENT_NOTIFICATION,
-        'securityEventNotification'
-      )
-    })
-
-    await it('should have SIGN_CERTIFICATE in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(BroadcastChannelProcedureName.SIGN_CERTIFICATE, 'signCertificate')
-    })
-
-    await it('should have TRANSACTION_EVENT in BroadcastChannelProcedureName enum', () => {
-      assert.strictEqual(BroadcastChannelProcedureName.TRANSACTION_EVENT, 'transactionEvent')
-    })
-  })
-
-  // ==========================================================================
-  // Group 3: ProcedureNameToBroadCastChannelProcedureNameMapping — 8 new entries (8 tests)
+  // Group 1: ProcedureNameToBroadCastChannelProcedureNameMapping — 8 new entries (8 tests)
   // ==========================================================================
 
   await describe('ProcedureNameToBroadCastChannelProcedureNameMapping OCPP 2.0.1 entries', async () => {
@@ -265,7 +174,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => {
   })
 
   // ==========================================================================
-  // Group 4: commandResponseToResponseStatus — 4 new command response cases (18 tests)
+  // Group 2: commandResponseToResponseStatus — 4 new command response cases (18 tests)
   // ==========================================================================
 
   await describe('commandResponseToResponseStatus OCPP 2.0.1 commands', async () => {
@@ -625,7 +534,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => {
   })
 
   // ==========================================================================
-  // Group 5: buildRequestPayload — OCPP 2.0.1 certificate passthrough (3 tests)
+  // Group 3: buildRequestPayload — OCPP 2.0.1 certificate passthrough (3 tests)
   // ==========================================================================
 
   await describe('buildRequestPayload OCPP 2.0.1 certificate passthrough', async () => {
@@ -684,7 +593,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => {
   })
 
   // ==========================================================================
-  // Group 6: commandHandler dispatch pipeline — verify full dispatch (8 tests)
+  // Group 4: commandHandler dispatch pipeline — verify full dispatch (8 tests)
   // ==========================================================================
 
   await describe('commandHandler OCPP 2.0.1 dispatch pipeline', async () => {
@@ -786,7 +695,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => {
   })
 
   // ==========================================================================
-  // Group 7: requestHandler full pipeline — exercise handler dispatch via message events (6 tests)
+  // Group 5: requestHandler full pipeline — exercise handler dispatch via message events (6 tests)
   // ==========================================================================
 
   await describe('requestHandler full pipeline OCPP 2.0.1', async () => {
index c1ef186884763e8bde29b3b9bc35cc33d00b6886..1090c4d2c7405c92963f504e19aae288582e8d03 100644 (file)
@@ -58,8 +58,7 @@ await describe('OCPPAuthServiceFactory', async () => {
 
       try {
         await OCPPAuthServiceFactory.getInstance(mockStation)
-        // If we get here, the test should fail
-        assert.strictEqual(true, false) // Force failure
+        assert.fail('Expected getInstance to throw for station without stationInfo')
       } catch (error) {
         assert.ok(error instanceof Error)
         assert.ok(error.message.includes('OCPP version not found in charging station'))
index 999afcdcdb3ea33d8412b3eda1612cf2e7e4e662..9ff15c616f23817506b84fcb712139d6814491e8 100644 (file)
@@ -8,7 +8,6 @@ import { afterEach, describe, it } from 'node:test'
 import {
   AuthContext,
   AuthenticationError,
-  AuthenticationMethod,
   AuthErrorCode,
   AuthorizationStatus,
   IdentifierType,
@@ -298,39 +297,4 @@ await describe('AuthTypes', async () => {
       assert.strictEqual(identifier.certificateHashData?.hashAlgorithm, 'SHA256')
     })
   })
-
-  await describe('Enums', async () => {
-    await it('should have correct AuthContext values', () => {
-      assert.strictEqual(AuthContext.TRANSACTION_START, 'TransactionStart')
-      assert.strictEqual(AuthContext.TRANSACTION_STOP, 'TransactionStop')
-      assert.strictEqual(AuthContext.REMOTE_START, 'RemoteStart')
-      assert.strictEqual(AuthContext.REMOTE_STOP, 'RemoteStop')
-      assert.strictEqual(AuthContext.RESERVATION, 'Reservation')
-      assert.strictEqual(AuthContext.UNLOCK_CONNECTOR, 'UnlockConnector')
-    })
-
-    await it('should have correct AuthenticationMethod values', () => {
-      assert.strictEqual(AuthenticationMethod.LOCAL_LIST, 'LocalList')
-      assert.strictEqual(AuthenticationMethod.REMOTE_AUTHORIZATION, 'RemoteAuthorization')
-      assert.strictEqual(AuthenticationMethod.CACHE, 'Cache')
-      assert.strictEqual(AuthenticationMethod.CERTIFICATE_BASED, 'CertificateBased')
-      assert.strictEqual(AuthenticationMethod.OFFLINE_FALLBACK, 'OfflineFallback')
-    })
-
-    await it('should have correct AuthorizationStatus values', () => {
-      assert.strictEqual(AuthorizationStatus.ACCEPTED, 'Accepted')
-      assert.strictEqual(AuthorizationStatus.BLOCKED, 'Blocked')
-      assert.strictEqual(AuthorizationStatus.EXPIRED, 'Expired')
-      assert.strictEqual(AuthorizationStatus.INVALID, 'Invalid')
-      assert.strictEqual(AuthorizationStatus.CONCURRENT_TX, 'ConcurrentTx')
-    })
-
-    await it('should have correct IdentifierType values', () => {
-      assert.strictEqual(IdentifierType.ID_TAG, 'IdTag')
-      assert.strictEqual(IdentifierType.CENTRAL, 'Central')
-      assert.strictEqual(IdentifierType.LOCAL, 'Local')
-      assert.strictEqual(IdentifierType.E_MAID, 'eMAID')
-      assert.strictEqual(IdentifierType.KEY_CODE, 'KeyCode')
-    })
-  })
 })
diff --git a/tests/types/ConfigurationData.test.ts b/tests/types/ConfigurationData.test.ts
deleted file mode 100644 (file)
index 81d9d6c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file Tests for ConfigurationData
- * @description Unit tests for configuration data types and enumerations
- */
-import assert from 'node:assert/strict'
-import { afterEach, describe, it } from 'node:test'
-
-import {
-  ApplicationProtocolVersion,
-  ConfigurationSection,
-  SupervisionUrlDistribution,
-} from '../../src/types/ConfigurationData.js'
-import { standardCleanup } from '../helpers/TestLifecycleHelpers.js'
-
-await describe('ConfigurationData', async () => {
-  afterEach(() => {
-    standardCleanup()
-  })
-
-  await it('should define ConfigurationSection enumeration values', () => {
-    assert.strictEqual(ConfigurationSection.log, 'log')
-    assert.strictEqual(ConfigurationSection.performanceStorage, 'performanceStorage')
-    assert.strictEqual(ConfigurationSection.uiServer, 'uiServer')
-    assert.strictEqual(ConfigurationSection.worker, 'worker')
-  })
-
-  await it('should define SupervisionUrlDistribution enumeration values', () => {
-    assert.strictEqual(
-      SupervisionUrlDistribution.CHARGING_STATION_AFFINITY,
-      'charging-station-affinity'
-    )
-    assert.strictEqual(SupervisionUrlDistribution.RANDOM, 'random')
-    assert.strictEqual(SupervisionUrlDistribution.ROUND_ROBIN, 'round-robin')
-  })
-
-  await it('should define ApplicationProtocolVersion enumeration values', () => {
-    assert.strictEqual(ApplicationProtocolVersion.VERSION_11, '1.1')
-    assert.strictEqual(ApplicationProtocolVersion.VERSION_20, '2.0')
-  })
-})
index 3168b7ed14295f872dfe0edb40946be870ceb2b5..961d20fda53e9e7ed979ee820f4d1479fd9a92cd 100644 (file)
@@ -48,13 +48,6 @@ await describe('ChargingStationConfigurationUtils', async () => {
     standardCleanup()
   })
 
-  await describe('OutputFormat', async () => {
-    await it('should have correct enum values', () => {
-      assert.strictEqual(OutputFormat.configuration, 'configuration')
-      assert.strictEqual(OutputFormat.worker, 'worker')
-    })
-  })
-
   await describe('buildConnectorsStatus', async () => {
     await it('should strip internal transaction fields from connectors', () => {
       const noop = (): void => {