From: Jérôme Benoit Date: Sat, 28 Feb 2026 20:46:29 +0000 (+0100) Subject: fix(tests): resolve all ESLint errors in factory consolidation X-Git-Tag: v3~70 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4024bd28fb09d8c7c4b520cc26d1f53c345f62be;p=e-mobility-charging-stations-simulator.git 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. --- diff --git a/tests/charging-station/Helpers.test.ts b/tests/charging-station/Helpers.test.ts index 3ae8df8a..afbed311 100644 --- a/tests/charging-station/Helpers.test.ts +++ b/tests/charging-station/Helpers.test.ts @@ -33,8 +33,8 @@ import { type Reservation, } from '../../src/types/index.js' import { logger } from '../../src/utils/Logger.js' -import { createMockChargingStation, createMockChargingStationTemplate } from './ChargingStationTestUtils.js' import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' +import { createMockChargingStation, createMockChargingStationTemplate } from './ChargingStationTestUtils.js' await describe('Helpers test suite', async () => { const baseName = 'CS-TEST' diff --git a/tests/charging-station/helpers/StationHelpers.ts b/tests/charging-station/helpers/StationHelpers.ts index 070a8c15..2e61b339 100644 --- a/tests/charging-station/helpers/StationHelpers.ts +++ b/tests/charging-station/helpers/StationHelpers.ts @@ -854,12 +854,27 @@ export function createMockChargingStation ( webSocket: mockWebSocket, } + const typedStation: ChargingStation = station as unknown as ChargingStation + return { mocks, - station: station as unknown as ChargingStation, + station: typedStation, } } +/** + * Create a mock charging station template for testing + * @param baseName - Base name for the template + * @returns ChargingStationTemplate with minimal required properties for testing + */ +export function createMockChargingStationTemplate ( + baseName: string = TEST_CHARGING_STATION_BASE_NAME +): ChargingStationTemplate { + return { + baseName, + } as ChargingStationTemplate +} + /** * Reset a ChargingStation to its initial state * @@ -975,16 +990,3 @@ function resetConnectorStatus (status: ConnectorStatus, isConnectorZero: boolean status.transactionSetInterval = undefined } } - -/** - * Create a mock charging station template for testing - * @param baseName - Base name for the template - * @returns ChargingStationTemplate with minimal required properties for testing - */ -export function createMockChargingStationTemplate ( - baseName: string = TEST_CHARGING_STATION_BASE_NAME -): ChargingStationTemplate { - return { - baseName, - } as ChargingStationTemplate -} diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts index 18b3e74a..ded401fa 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts @@ -24,8 +24,8 @@ import { OCPPVersion, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' const VALID_PEM_CERTIFICATE = `-----BEGIN CERTIFICATE----- MIIBkTCB+wIJAKHBfpvPA0GXMA0GCSqGSIb3DQEBCwUAMBExDzANBgNVBAMMBnRl @@ -74,15 +74,6 @@ interface MockCertificateManager extends OCPP20CertificateManagerInterface { validateCertificateFormat: Mock<(cert: string) => boolean> } -/** - * Test-specific ChargingStation interface with certificate management - * Extends ChargingStation with properties needed for certificate tests - */ -interface TestableChargingStationWithCertificate extends ChargingStation { - certificateManager?: MockCertificateManager - closeWSConnection?: Mock<() => void> -} - const createMockCertificateManager = ( options: { storeCertificateError?: Error diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts index 8dab1628..54256f88 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts @@ -6,13 +6,15 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js' import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js' import { OCPPAuthServiceFactory } from '../../../../src/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.js' import { GenericStatus, OCPPVersion } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' await describe('C11 - Clear Authorization Data in Authorization Cache', async () => { afterEach(() => { @@ -96,9 +98,7 @@ await describe('C11 - Clear Authorization Data in Authorization Cache', async () await it('should NOT call idTagsCache.deleteIdTags() on ClearCache request', async () => { // Verify that IdTagsCache is not touched let deleteIdTagsCalled = false - const originalDeleteIdTags = station.idTagsCache.deleteIdTags.bind( - station.idTagsCache - ) + const originalDeleteIdTags = station.idTagsCache.deleteIdTags.bind(station.idTagsCache) Object.assign(station.idTagsCache, { deleteIdTags: () => { diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts index a8c64efd..28ca9d66 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts @@ -6,6 +6,7 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js' import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js' @@ -19,8 +20,8 @@ import { ReasonCodeEnumType, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createStationWithCertificateManager } from './OCPP20TestUtils.js' const VALID_CERTIFICATE_HASH_DATA = { diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts index e5f67238..d287f53a 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts @@ -5,6 +5,8 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { addConfigurationKey, setConfigurationKeyValue, @@ -28,7 +30,6 @@ import { import { StandardParametersKey } from '../../../../src/types/ocpp/Configuration.js' import { Constants } from '../../../../src/utils/index.js' import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGE_POINT_MODEL, TEST_CHARGE_POINT_SERIAL_NUMBER, @@ -36,6 +37,7 @@ import { TEST_CHARGING_STATION_BASE_NAME, TEST_FIRMWARE_VERSION, } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' await describe('B07 - Get Base Report', async () => { let station: ChargingStation @@ -98,10 +100,7 @@ await describe('B07 - Get Base Report', async () => { }) await it('should include registry variables with Actual attribute only for unsupported types', () => { - const reportData = testableService.buildReportData( - station, - ReportBaseEnumType.FullInventory - ) + const reportData = testableService.buildReportData(station, ReportBaseEnumType.FullInventory) const heartbeatEntry = reportData.find( (item: ReportDataType) => item.variable.name === (OCPP20OptionalVariableName.HeartbeatInterval as string) && @@ -208,10 +207,7 @@ await describe('B07 - Get Base Report', async () => { // FR: B08.FR.07 await it('should build correct report data for FullInventory with station info', () => { - const reportData = testableService.buildReportData( - station, - ReportBaseEnumType.FullInventory - ) + const reportData = testableService.buildReportData(station, ReportBaseEnumType.FullInventory) expect(Array.isArray(reportData)).toBe(true) expect(reportData.length).toBeGreaterThan(0) @@ -240,10 +236,7 @@ await describe('B07 - Get Base Report', async () => { // FR: B08.FR.08 await it('should build correct report data for SummaryInventory', () => { - const reportData = testableService.buildReportData( - station, - ReportBaseEnumType.SummaryInventory - ) + const reportData = testableService.buildReportData(station, ReportBaseEnumType.SummaryInventory) expect(Array.isArray(reportData)).toBe(true) expect(reportData.length).toBeGreaterThan(0) @@ -275,24 +268,18 @@ await describe('B07 - Get Base Report', async () => { // Use members exceeding 10 chars total; exclude removed RTC/Manual. const longValue = 'Heartbeat,NTP,GPS,RealTimeClock,MobileNetwork,RadioTimeTransmitter' // Set Actual (SequenceList). Should accept full value internally. - const setResult: OCPP20SetVariableResultType[] = variableManager.setVariables( - station, - [ - { - attributeType: AttributeEnumType.Actual, - attributeValue: longValue, - component: { name: OCPP20ComponentName.ClockCtrlr }, - variable: { name: OCPP20RequiredVariableName.TimeSource }, - }, - ] - ) + const setResult: OCPP20SetVariableResultType[] = variableManager.setVariables(station, [ + { + attributeType: AttributeEnumType.Actual, + attributeValue: longValue, + component: { name: OCPP20ComponentName.ClockCtrlr }, + variable: { name: OCPP20RequiredVariableName.TimeSource }, + }, + ]) expect(setResult[0].attributeStatus).toBe('Accepted') // Build report; value should be truncated to length 10 - const reportData = testableService.buildReportData( - station, - ReportBaseEnumType.FullInventory - ) + const reportData = testableService.buildReportData(station, ReportBaseEnumType.FullInventory) const timeSourceEntry = reportData.find( (item: ReportDataType) => item.variable.name === (OCPP20RequiredVariableName.TimeSource as string) && diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts index 74d2a6b6..494815d4 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts @@ -6,6 +6,7 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js' import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js' @@ -21,8 +22,8 @@ import { OCPPVersion, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createStationWithCertificateManager } from './OCPP20TestUtils.js' const createMockCertificateHashData = (serialNumber = '123456789'): CertificateHashDataType => ({ @@ -256,7 +257,7 @@ await describe('I04 - GetInstalledCertificateIds', async () => { await describe('Certificate Manager Missing', async () => { await it('should return NotFound when certificate manager is not available', async () => { - const stationWithoutCertManager = createChargingStation({ + const { station: stationWithoutCertManager } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts index b3164f11..9ff24a46 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts @@ -25,7 +25,7 @@ import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers. import { TEST_CHARGING_STATION_BASE_NAME, TEST_CONNECTOR_ID_VALID_INSTANCE, - } from '../../ChargingStationTestConstants.js' +} from '../../ChargingStationTestConstants.js' import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { resetLimits, diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts index 36595afa..d396821d 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts @@ -19,8 +19,8 @@ import { OCPPVersion, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createStationWithCertificateManager } from './OCPP20TestUtils.js' const VALID_PEM_CERTIFICATE = `-----BEGIN CERTIFICATE----- @@ -74,7 +74,6 @@ await describe('I03 - InstallCertificate', async () => { mock.restoreAll() }) - let station: ChargingStation let mockChargingStation: ChargingStation let stationWithCertManager: ChargingStationWithCertificateManager let incomingRequestService: OCPP20IncomingRequestService @@ -92,7 +91,7 @@ await describe('I03 - InstallCertificate', async () => { }, websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL, }) - station = initialStation + mockChargingStation = initialStation mockChargingStation = initialStation // Use factory function to create station with certificate manager diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts index 355da7db..80c724d2 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts @@ -23,8 +23,8 @@ import { } from '../../../../src/types/ocpp/2.0/Transaction.js' import { Constants } from '../../../../src/utils/index.js' import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createMockAuthService } from '../auth/helpers/MockFactories.js' import { resetConnectorTransactionState, diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts index 10a0aa6a..331f0cf4 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts @@ -30,8 +30,8 @@ import { } from '../../../../src/types/ocpp/2.0/Transaction.js' import { Constants } from '../../../../src/utils/index.js' import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createMockAuthService } from '../auth/helpers/MockFactories.js' import { resetConnectorTransactionState, @@ -308,7 +308,7 @@ await describe('F03 - Remote Stop Transaction', async () => { await it('should handle TransactionEvent request failure gracefully', async () => { sentTransactionEvents = [] - const failingChargingStation = createChargingStation({ + const { station: failingChargingStation } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME + '-FAIL', connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts index ac87da96..d16fc942 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts @@ -24,9 +24,9 @@ import { ResetStatusEnumType, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' await describe('B11 & B12 - Reset', async () => { let mockChargingStation: ChargingStation @@ -34,10 +34,6 @@ await describe('B11 & B12 - Reset', async () => { getNumberOfRunningTransactions: () => number reset: () => Promise } - let mockStation: ReturnType & { - getNumberOfRunningTransactions: () => number - reset: () => Promise - } let incomingRequestService: OCPP20IncomingRequestService let testableService: ReturnType @@ -344,7 +340,7 @@ await describe('B11 & B12 - Reset', async () => { } const createTestStation = (): TestStation => { - const station = createChargingStation({ + const { station } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts index cec05d4d..04dc8acc 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts @@ -8,6 +8,7 @@ import { millisecondsToSeconds } from 'date-fns' import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js' import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js' import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js' @@ -27,11 +28,11 @@ import { } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js' -import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { TEST_CHARGING_STATION_BASE_NAME, TEST_CONNECTOR_ID_VALID_INSTANCE, } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { resetLimits, resetValueSizeLimits, diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts index 72755974..749406b9 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts @@ -5,6 +5,8 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js' import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js' import { @@ -13,10 +15,8 @@ import { OCPP20RequestCommand, OCPPVersion, } from '../../../../src/types/index.js' -import type { ChargingStation } from '../../../../src/charging-station/index.js' import { type ChargingStationType } from '../../../../src/types/ocpp/2.0/Common.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../../ChargingStationTestUtils.js' import { TEST_CHARGE_POINT_MODEL, TEST_CHARGE_POINT_SERIAL_NUMBER, @@ -24,6 +24,7 @@ import { TEST_CHARGING_STATION_BASE_NAME, TEST_FIRMWARE_VERSION, } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createTestableOCPP20RequestService, type TestableOCPP20RequestService, @@ -173,7 +174,7 @@ await describe('B01 - Cold Boot Charging Station', async () => { } const payload = testableRequestService.buildRequestPayload( - station, + station, OCPP20RequestCommand.BOOT_NOTIFICATION, requestParams ) as OCPP20BootNotificationRequest diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts index aaebbd32..3bcf5192 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts @@ -5,6 +5,8 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js' import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js' import { @@ -13,8 +15,6 @@ import { OCPPVersion, } from '../../../../src/types/index.js' import { Constants, has } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../../ChargingStationTestUtils.js' -import type { ChargingStation } from '../../../../src/charging-station/index.js' import { TEST_CHARGE_POINT_MODEL, TEST_CHARGE_POINT_SERIAL_NUMBER, @@ -22,6 +22,7 @@ import { TEST_CHARGING_STATION_BASE_NAME, TEST_FIRMWARE_VERSION, } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createTestableOCPP20RequestService, type TestableOCPP20RequestService, @@ -137,7 +138,7 @@ await describe('G02 - Heartbeat', async () => { // FR: G02.FR.05 await it('should handle HeartBeat request with different charging station configurations', () => { - const alternativeChargingStation = createChargingStation({ + const { station: alternativeChargingStation } = createMockChargingStation({ baseName: 'CS-ALTERNATIVE-002', connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts index 589d3393..f4bad7ba 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts @@ -210,10 +210,10 @@ await describe('M02 - Get15118EVCertificate Request', async () => { }) await describe('M03 - GetCertificateStatus Request', async () => { - let station: TestChargingStation + let station: ReturnType['station'] beforeEach(() => { - station = createChargingStation({ + const result = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, @@ -224,6 +224,7 @@ await describe('M03 - GetCertificateStatus Request', async () => { }, websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL, }) + station = result.station }) afterEach(() => { @@ -327,10 +328,10 @@ await describe('M03 - GetCertificateStatus Request', async () => { }) await describe('Request Command Names', async () => { - let station: TestChargingStation + let station: ReturnType['station'] beforeEach(() => { - station = createChargingStation({ + const result = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, @@ -341,6 +342,7 @@ await describe('Request Command Names', async () => { }, websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL, }) + station = result.station }) afterEach(() => { diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts index d0692193..bfb9e02c 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts @@ -6,6 +6,8 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { createTestableRequestService, type TestableOCPP20RequestService, @@ -22,8 +24,6 @@ import { type ReportDataType, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../../ChargingStationTestUtils.js' -import type { ChargingStation } from '../../../../src/charging-station/index.js' import { TEST_CHARGE_POINT_MODEL, TEST_CHARGE_POINT_SERIAL_NUMBER, @@ -31,6 +31,7 @@ import { TEST_CHARGING_STATION_BASE_NAME, TEST_FIRMWARE_VERSION, } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' await describe('B07/B08 - NotifyReport', async () => { let testableService: TestableOCPP20RequestService diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts index b896f1af..7ac34e19 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts @@ -6,6 +6,8 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { createTestableRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js' import { CertificateSigningUseEnumType, @@ -16,9 +18,8 @@ import { OCPPVersion, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../../ChargingStationTestUtils.js' -import type { ChargingStation } from '../../../../src/charging-station/index.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' const MOCK_ORGANIZATION_NAME = 'Test Organization Inc.' @@ -131,10 +132,7 @@ await describe('I02 - SignCertificate Request', async () => { }, }) - await service.requestSignCertificate( - station, - CertificateSigningUseEnumType.V2GCertificate - ) + await service.requestSignCertificate(station, CertificateSigningUseEnumType.V2GCertificate) const sentPayload = sendMessageMock.mock.calls[0].arguments[2] as OCPP20SignCertificateRequest @@ -247,7 +245,7 @@ await describe('I02 - SignCertificate Request', async () => { await describe('Error Handling', async () => { await it('should generate CSR without certificate manager dependency', async () => { - const stationWithoutCertManager = createChargingStation({ + const { station: stationWithoutCertManager } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts index 8b8878ff..3b31c6ca 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts @@ -5,6 +5,8 @@ import { expect } from '@std/expect' import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/index.js' + import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js' import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js' import { @@ -14,8 +16,6 @@ import { OCPPVersion, } from '../../../../src/types/index.js' import { Constants } from '../../../../src/utils/index.js' -import { createMockChargingStation } from '../../../ChargingStationTestUtils.js' -import type { ChargingStation } from '../../../../src/charging-station/index.js' import { TEST_FIRMWARE_VERSION, TEST_STATUS_CHARGE_POINT_MODEL, @@ -23,6 +23,7 @@ import { TEST_STATUS_CHARGE_POINT_VENDOR, TEST_STATUS_CHARGING_STATION_BASE_NAME, } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' import { createTestableOCPP20RequestService, type TestableOCPP20RequestService, diff --git a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts index 2bed59d4..930c2b9d 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts @@ -7,11 +7,12 @@ import { expect } from '@std/expect' import { millisecondsToSeconds } from 'date-fns' import { afterEach, beforeEach, describe, it } from 'node:test' +import type { ChargingStation } from '../../../../src/charging-station/ChargingStation.js' + 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' diff --git a/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts b/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts index 5347d944..8fb6c63f 100644 --- a/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts +++ b/tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts @@ -10,8 +10,8 @@ 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 { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' +import { createMockChargingStation } from '../../../ChargingStationTestUtils.js' await describe('AuthComponentFactory', async () => { afterEach(() => {