Replace hardcoded literals in recent tests with the shared constants/enums they duplicate (single source of truth, no behavior change; values are byte-equivalent):
- OCPP20 PostStopResurrection: GenericStatus.Accepted / ReportBaseEnumType.FullInventory instead of raw 'Accepted' / 'FullInventory'
- OCPP20 RequestStartTransaction: OCPP20ChargingRateUnitEnumType.A instead of 'A' as OCPP20ChargingRateUnitEnumType casts
- OCPP16 SmartCharging: TEST_ONE_HOUR_SECONDS instead of the 3600 duration literal
- UIHttpServer: ProcedureName.* instead of raw procedure-name strings
- Remove the now-unused TEST_PROCEDURES test constant (ProcedureName is the canonical source)
OCPP16StandardParametersKey,
} from '../../../../src/types/index.js'
import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js'
+import { TEST_ONE_HOUR_SECONDS } from '../../ChargingStationTestConstants.js'
import {
ChargingProfileFixtures,
createOCPP16IncomingRequestTestContext,
profile: OCPP16ChargingProfile
): void => {
profile.chargingSchedule.startSchedule = new Date()
- profile.chargingSchedule.duration = 3600
+ profile.chargingSchedule.duration = TEST_ONE_HOUR_SECONDS
const connectorStatus = station.getConnectorStatus(connectorId)
if (connectorStatus != null) {
connectorStatus.chargingProfiles = [profile]
)
const profile = ChargingProfileFixtures.createTxDefaultProfile()
profile.chargingSchedule.startSchedule = new Date()
- profile.chargingSchedule.duration = 3600
+ profile.chargingSchedule.duration = TEST_ONE_HOUR_SECONDS
const connectorStatus = station.getConnectorStatus(1)
if (connectorStatus != null) {
connectorStatus.chargingProfiles = [profile]
}
const request: OCPP16GetCompositeScheduleRequest = {
connectorId: 1,
- duration: 3600,
+ duration: TEST_ONE_HOUR_SECONDS,
}
// Act
)
const request: OCPP16GetCompositeScheduleRequest = {
connectorId: 99,
- duration: 3600,
+ duration: TEST_ONE_HOUR_SECONDS,
}
// Act
)
const request: OCPP16GetCompositeScheduleRequest = {
connectorId: 0,
- duration: 3600,
+ duration: TEST_ONE_HOUR_SECONDS,
}
// Act
}
const request: OCPP16GetCompositeScheduleRequest = {
connectorId: 1,
- duration: 3600,
+ duration: TEST_ONE_HOUR_SECONDS,
}
// Act
upsertConfigurationKey(station, OCPP16StandardParametersKey.SupportedFeatureProfiles, 'Core')
const request: OCPP16GetCompositeScheduleRequest = {
connectorId: 1,
- duration: 3600,
+ duration: TEST_ONE_HOUR_SECONDS,
}
// Act
'Core,SmartCharging'
)
attachComposableProfile(station, 3, ChargingProfileFixtures.createTxDefaultProfile())
- const request: OCPP16GetCompositeScheduleRequest = { connectorId: 0, duration: 3600 }
+ const request: OCPP16GetCompositeScheduleRequest = {
+ connectorId: 0,
+ duration: TEST_ONE_HOUR_SECONDS,
+ }
// Act
const response = testableService.handleRequestGetCompositeSchedule(station, request)
}
}
attachComposableProfile(station, 0, ChargingProfileFixtures.createChargePointMaxProfile())
- const request: OCPP16GetCompositeScheduleRequest = { connectorId: 0, duration: 3600 }
+ const request: OCPP16GetCompositeScheduleRequest = {
+ connectorId: 0,
+ duration: TEST_ONE_HOUR_SECONDS,
+ }
// Act
const response = testableService.handleRequestGetCompositeSchedule(station, request)
import type { ChargingStation } from '../../../../src/charging-station/index.js'
import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
-import { OCPPVersion } from '../../../../src/types/index.js'
+import { GenericStatus, OCPPVersion, ReportBaseEnumType } from '../../../../src/types/index.js'
import { Constants } from '../../../../src/utils/index.js'
import {
flushMicrotasks,
await plumbing.sendNotifyReportRequest(
station,
- { reportBase: 'FullInventory', requestId: 1 },
- { status: 'Accepted' }
+ { reportBase: ReportBaseEnumType.FullInventory, requestId: 1 },
+ { status: GenericStatus.Accepted }
)
assert.strictEqual(requestHandlerMock.mock.callCount(), 0)
await plumbing.sendNotifyReportRequest(
station,
- { reportBase: 'FullInventory', requestId: 42 },
- { status: 'Accepted' }
+ { reportBase: ReportBaseEnumType.FullInventory, requestId: 42 },
+ { status: GenericStatus.Accepted }
)
assert.strictEqual(requestHandlerMock.mock.callCount(), 0)
import type {
EvseStatus,
OCPP20ChargingProfileType,
- OCPP20ChargingRateUnitEnumType,
OCPP20RequestStartTransactionRequest,
OCPP20RequestStartTransactionResponse,
OCPP20TransactionEventOptions,
AttributeEnumType,
OCPP20ChargingProfileKindEnumType,
OCPP20ChargingProfilePurposeEnumType,
+ OCPP20ChargingRateUnitEnumType,
OCPP20ComponentName,
OCPP20IdTokenEnumType,
OCPP20IncomingRequestCommand,
chargingProfilePurpose: OCPP20ChargingProfilePurposeEnumType.TxProfile,
chargingSchedule: [
{
- chargingRateUnit: 'A' as OCPP20ChargingRateUnitEnumType,
+ chargingRateUnit: OCPP20ChargingRateUnitEnumType.A,
chargingSchedulePeriod: [
{
limit: 30,
chargingProfilePurpose: OCPP20ChargingProfilePurposeEnumType.TxDefaultProfile,
chargingSchedule: [
{
- chargingRateUnit: 'A' as OCPP20ChargingRateUnitEnumType,
+ chargingRateUnit: OCPP20ChargingRateUnitEnumType.A,
chargingSchedulePeriod: [
{
limit: 25,
chargingProfilePurpose: OCPP20ChargingProfilePurposeEnumType.TxProfile,
chargingSchedule: [
{
- chargingRateUnit: 'A' as OCPP20ChargingRateUnitEnumType,
+ chargingRateUnit: OCPP20ChargingRateUnitEnumType.A,
chargingSchedulePeriod: [
{
limit: 32,
chargingProfilePurpose: OCPP20ChargingProfilePurposeEnumType.TxProfile,
chargingSchedule: [
{
- chargingRateUnit: 'A' as OCPP20ChargingRateUnitEnumType,
+ chargingRateUnit: OCPP20ChargingRateUnitEnumType.A,
chargingSchedulePeriod: [
{
limit: 30,
import { UIHttpServer } from '../../../src/charging-station/ui-server/UIHttpServer.js'
import { DEFAULT_COMPRESSION_THRESHOLD_BYTES } from '../../../src/charging-station/ui-server/UIServerSecurity.js'
-import { ApplicationProtocol, ProtocolVersion, ResponseStatus } from '../../../src/types/index.js'
+import {
+ ApplicationProtocol,
+ ProcedureName,
+ ProtocolVersion,
+ ResponseStatus,
+} from '../../../src/types/index.js'
import { Constants, logger } from '../../../src/utils/index.js'
import {
createLoggerMocks,
const res = new MockServerResponse()
broadcastServer.emitRequest(
- buildProcedureRequest('stopChargingStation', {
+ buildProcedureRequest(ProcedureName.STOP_CHARGING_STATION, {
hashIds: [TEST_HASH_ID, TEST_HASH_ID_2],
}),
res
const res = new MockServerResponse()
broadcastServer.emitRequest(
- buildProcedureRequest('stopChargingStation', {
+ buildProcedureRequest(ProcedureName.STOP_CHARGING_STATION, {
hashIds: [TEST_HASH_ID, TEST_HASH_ID_2],
}),
res
broadcastServer.emitRequest(
buildProcedureRequest(
- 'stopChargingStation',
+ ProcedureName.STOP_CHARGING_STATION,
{ hashIds: [TEST_HASH_ID] },
{ 'accept-encoding': 'gzip' }
),
const res = new MockServerResponse()
broadcastServer.emitRequest(
- buildProcedureRequest('stopChargingStation', { hashIds: [TEST_HASH_ID] }),
+ buildProcedureRequest(ProcedureName.STOP_CHARGING_STATION, { hashIds: [TEST_HASH_ID] }),
res
)
try {
const res = new MockServerResponse()
- broadcastServer.emitRequest(buildProcedureRequest('listChargingStations', {}), res)
+ broadcastServer.emitRequest(
+ buildProcedureRequest(ProcedureName.LIST_CHARGING_STATIONS, {}),
+ res
+ )
await awaitFinish(res)
assert.strictEqual(res.statusCode, 200)
const res = new MockServerResponse()
broadcastServer.emitRequest(
- buildProcedureRequest('stopChargingStation', { hashIds: [TEST_HASH_ID] }),
+ buildProcedureRequest(ProcedureName.STOP_CHARGING_STATION, { hashIds: [TEST_HASH_ID] }),
res
)
export const TEST_UUID = '550e8400-e29b-41d4-a716-446655440000' as UUIDv4
export const TEST_UUID_2 = '6ba7b810-9dad-41d1-80b4-00c04fd430c8' as UUIDv4
-export const TEST_PROCEDURES = {
- AUTHORIZE: 'Authorize',
- DELETE_CHARGING_STATIONS: 'deleteChargingStations',
- LIST_CHARGING_STATIONS: 'listChargingStations',
- START_CHARGING_STATION: 'startChargingStation',
- STOP_CHARGING_STATION: 'stopChargingStation',
-} as const
-
export const TEST_HASH_ID = 'test-station-001' as const
export const TEST_HASH_ID_2 = 'test-station-002' as const