From: Jérôme Benoit Date: Sat, 28 Feb 2026 20:02:51 +0000 (+0100) Subject: refactor(tests): fix TypeScript errors in auth and variable manager tests X-Git-Tag: ocpp-server@v3.0.0~72 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2ac610b112eff9c01dcfce2d4511183d033fb5d5;p=e-mobility-charging-stations-simulator.git 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 --- diff --git a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts index 1d8eb1c4..2bed59d4 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts @@ -11,6 +11,7 @@ import { deleteConfigurationKey, getConfigurationKey, } from '../../../../src/charging-station/ConfigurationKeyUtils.js' +import type { ChargingStation } from '../../../../src/charging-station/ChargingStation.js' import { createTestableVariableManager } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js' import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js' import { VARIABLE_REGISTRY } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableRegistry.js' @@ -64,7 +65,7 @@ function buildWsExampleUrl (targetLength: number, fillerChar = 'a'): string { await describe('B05/B06 - OCPP20VariableManager test suite', async () => { // Type declaration for mock ChargingStation - let station: ReturnType + let station: ChargingStation // Initialize mock ChargingStation before each test beforeEach(() => { @@ -1404,7 +1405,7 @@ await describe('B05/B06 - OCPP20VariableManager test suite', async () => { await describe('Unsupported MinSet/MaxSet attribute tests', async () => { const manager = OCPP20VariableManager.getInstance() - const station = createChargingStation({ + const { station } = createMockChargingStation({ baseName: 'MMStation', connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, diff --git a/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts b/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts index 33e45074..0b577459 100644 --- a/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts +++ b/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts @@ -15,7 +15,7 @@ import { IdentifierType, } from '../../../../src/charging-station/ocpp/auth/types/AuthTypes.js' import { OCPPVersion } from '../../../../src/types/ocpp/OCPPVersion.js' -import { createChargingStation } from '../../ChargingStationTestUtils.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createMockAuthRequest, createMockOCPP16Identifier, @@ -28,7 +28,7 @@ await describe('OCPP Authentication Integration Tests', async () => { beforeEach(() => { // Create mock charging station with OCPP 1.6 configuration - mockChargingStation16 = createChargingStation({ + const result16 = createMockChargingStation({ baseName: 'TEST_AUTH_CS_16', connectorsCount: 2, stationInfo: { @@ -37,9 +37,10 @@ await describe('OCPP Authentication Integration Tests', async () => { templateName: 'test-auth-template', }, }) + mockChargingStation16 = result16.station // Create mock charging station with OCPP 2.0 configuration - mockChargingStation20 = createChargingStation({ + const result20 = createMockChargingStation({ baseName: 'TEST_AUTH_CS_20', connectorsCount: 2, stationInfo: { @@ -48,6 +49,7 @@ await describe('OCPP Authentication Integration Tests', async () => { templateName: 'test-auth-template', }, }) + mockChargingStation20 = result20.station }) afterEach(() => { diff --git a/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts b/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts index c04076ab..5347d944 100644 --- a/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts +++ b/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts @@ -10,7 +10,7 @@ import type { AuthConfiguration } from '../../../../../src/charging-station/ocpp import { AuthComponentFactory } from '../../../../../src/charging-station/ocpp/auth/factories/AuthComponentFactory.js' import { OCPPVersion } from '../../../../../src/types/ocpp/OCPPVersion.js' -import { createMockChargingStation } from '../../../../ChargingStationTestUtils.js' +import { createMockChargingStation } from '../../../ChargingStationTestUtils.js' import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' await describe('AuthComponentFactory', async () => {