From: Jérôme Benoit Date: Sat, 28 Feb 2026 17:13:24 +0000 (+0100) Subject: fix(test-isolation): make OCPP20VariableManager tests self-contained X-Git-Tag: v3~80 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=413595441278a30f6150f3f42e05775a5537e805;p=e-mobility-charging-stations-simulator.git 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. --- diff --git a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts index 95648da0..a846801c 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts @@ -1263,6 +1263,17 @@ await describe('B05/B06 - OCPP20VariableManager test suite', async () => { }) await it('should keep FileTransferProtocols value unchanged after rejected update attempt', () => { + // First ensure the configuration key exists by calling getVariables (triggers self-check) + // Each test gets a fresh mockChargingStation, so we must initialize the configuration key + const initGet = manager.getVariables(mockChargingStation, [ + { + component: { name: OCPP20ComponentName.OCPPCommCtrlr }, + variable: { name: OCPP20RequiredVariableName.FileTransferProtocols }, + }, + ])[0] + expect(initGet.attributeStatus).toBe(GetVariableStatusEnumType.Accepted) + expect(initGet.attributeValue).toBe('HTTPS,FTPS,SFTP') + const beforeCfg = getConfigurationKey( mockChargingStation, OCPP20RequiredVariableName.FileTransferProtocols as unknown as VariableType['name'] @@ -1601,6 +1612,15 @@ await describe('B05/B06 - OCPP20VariableManager test suite', async () => { }) await it('should preserve OrganizationName value after resetRuntimeOverrides()', () => { + // First set OrganizationName to ensure it's persisted (test must be self-contained) + manager.setVariables(mockChargingStation, [ + { + attributeValue: 'PersistenceTestOrgName', + component: { name: OCPP20ComponentName.SecurityCtrlr }, + variable: { name: OCPP20RequiredVariableName.OrganizationName }, + }, + ]) + // Now reset runtime overrides manager.resetRuntimeOverrides() const res = manager.getVariables(mockChargingStation, [ { @@ -1609,8 +1629,8 @@ await describe('B05/B06 - OCPP20VariableManager test suite', async () => { }, ])[0] expect(res.attributeStatus).toBe(GetVariableStatusEnumType.Accepted) - // Value should persist as 'NewOrgName' from previous test (OCPP 2.0.1 compliant persistence) - expect(res.attributeValue).toBe('NewOrgName') + // Value should persist as 'PersistenceTestOrgName' after resetRuntimeOverrides (OCPP 2.0.1 compliant persistence) + expect(res.attributeValue).toBe('PersistenceTestOrgName') }) await it('should create configuration key for instance-scoped MessageAttemptInterval and persist Actual value (Actual-only, no MinSet/MaxSet)', () => {