From 4bf5a0a9920ed67dabd354e75bab508cf3554e2e Mon Sep 17 00:00:00 2001 From: michal-skraburski Date: Mon, 17 Aug 2026 10:16:46 +0100 Subject: [PATCH] feat: added a new test scenario: boot-outside-repeat-window --- .changeset/happy-turkeys-cough.md | 5 + .../boot-outside-repeat-window.ts | 100 ++++++++++++++++++ packages/toolkit/src/scenarios/index.test.ts | 5 +- packages/toolkit/src/scenarios/index.ts | 5 + 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 .changeset/happy-turkeys-cough.md create mode 100644 packages/toolkit/src/scenarios/__scenarios__/boot-outside-repeat-window.ts diff --git a/.changeset/happy-turkeys-cough.md b/.changeset/happy-turkeys-cough.md new file mode 100644 index 0000000..c88ce6b --- /dev/null +++ b/.changeset/happy-turkeys-cough.md @@ -0,0 +1,5 @@ +--- +'@ocpp-debugkit/toolkit': patch +--- + +added a new scenario: boot-outside-repeat-window diff --git a/packages/toolkit/src/scenarios/__scenarios__/boot-outside-repeat-window.ts b/packages/toolkit/src/scenarios/__scenarios__/boot-outside-repeat-window.ts new file mode 100644 index 0000000..23e2f4b --- /dev/null +++ b/packages/toolkit/src/scenarios/__scenarios__/boot-outside-repeat-window.ts @@ -0,0 +1,100 @@ +export default { + name: 'boot-outside-repeat-window', + description: + 'Two BootNotifications triggered outside the configured repeat window, expecting no failures.', + trace: { + traceId: 'scenario-boot-outside-repeat-window', + metadata: { + stationId: 'CS-SYNTHETIC-023', + ocppVersion: '1.6', + source: 'synthetic-scenario', + description: + '2 BootNotifications 300+ seconds apart should not trigger failure', + }, + events: [ + { + timestamp: '2026-02-01T11:00:00.000Z', + direction: 'CS_TO_CSMS', + message: [ + 2, + 'msg-001', + 'BootNotification', + { + chargePointVendor: 'SyntheticVendor', + chargePointModel: 'SM-100', + chargePointSerialNumber: 'CS-SYNTHETIC-023', + firmwareVersion: '1.0.0', + }, + ], + }, + { + timestamp: '2026-02-01T11:00:00.500Z', + direction: 'CSMS_TO_CS', + message: [ + 3, + 'msg-001', + { + currentTime: '2026-02-01T11:00:00.500Z', + interval: 300, + status: 'Accepted', + }, + ], + }, + { + timestamp: '2026-02-01T11:03:00.000Z', + direction: 'CS_TO_CSMS', + message: [2, 'msg-hb-1', 'Heartbeat', {}], + }, + { + timestamp: '2026-02-01T11:03:00.500Z', + direction: 'CSMS_TO_CS', + message: [3, 'msg-hb-1', { currentTime: '2026-02-01T11:03:00.500Z' }], + }, + { + timestamp: '2026-02-01T11:06:30.000Z', + direction: 'CS_TO_CSMS', + message: [ + 2, + 'msg-002', + 'BootNotification', + { + chargePointVendor: 'SyntheticVendor', + chargePointModel: 'SM-100', + chargePointSerialNumber: 'CS-SYNTHETIC-023', + firmwareVersion: '1.0.0', + }, + ], + }, + { + timestamp: '2026-02-01T11:06:30.500Z', + direction: 'CSMS_TO_CS', + message: [ + 3, + 'msg-002', + { + currentTime: '2026-02-01T11:06:30.500Z', + interval: 300, + status: 'Accepted', + }, + ], + }, + { + timestamp: '2026-02-01T11:09:00.000Z', + direction: 'CS_TO_CSMS', + message: [2, 'msg-hb-2', 'Heartbeat', {}], + }, + { + timestamp: '2026-02-01T11:09:00.500Z', + direction: 'CSMS_TO_CS', + message: [3, 'msg-hb-2', { currentTime: '2026-02-01T11:09:00.500Z' }], + }, + ], + }, + expectedFailures: [], + assertions: [ + { + type: 'no_failures', + params: {}, + }, + ], +}; diff --git a/packages/toolkit/src/scenarios/index.test.ts b/packages/toolkit/src/scenarios/index.test.ts index 7773903..aaa7261 100644 --- a/packages/toolkit/src/scenarios/index.test.ts +++ b/packages/toolkit/src/scenarios/index.test.ts @@ -32,8 +32,8 @@ import { parseTrace, buildSessionTimeline, detectFailures } from '../core/index. // --------------------------------------------------------------------------- describe('scenario registry', () => { - it('exports exactly 21 scenarios', () => { - expect(scenarios).toHaveLength(21); + it('exports exactly 22 scenarios', () => { + expect(scenarios).toHaveLength(22); }); it('exports scenario names in order', () => { @@ -59,6 +59,7 @@ describe('scenario registry', () => { 'heartbeat-timeout', 'repeated-boot-notification', 'meter-value-zero', + 'boot-outside-repeat-window' ]); }); diff --git a/packages/toolkit/src/scenarios/index.ts b/packages/toolkit/src/scenarios/index.ts index fa601d5..eec358b 100644 --- a/packages/toolkit/src/scenarios/index.ts +++ b/packages/toolkit/src/scenarios/index.ts @@ -26,6 +26,7 @@ import refusedAuthorization from './__scenarios__/refused-authorization.js'; import heartbeatTimeout from './__scenarios__/heartbeat-timeout.js'; import repeatedBootNotification from './__scenarios__/repeated-boot-notification.js'; import meterValueZero from './__scenarios__/meter-value-zero.js'; +import bootOutsideRepeatWindow from './__scenarios__/boot-outside-repeat-window.js'; // --------------------------------------------------------------------------- // Scenarios derived from core fixtures @@ -78,6 +79,7 @@ const refusedAuthorizationScenario: Scenario = refusedAuthorization as unknown a const heartbeatTimeoutScenario: Scenario = heartbeatTimeout as unknown as Scenario; const repeatedBootNotificationScenario: Scenario = repeatedBootNotification as unknown as Scenario; const meterValueZeroScenario: Scenario = meterValueZero as unknown as Scenario; +const bootOutsideRepeatWindowScenario: Scenario = bootOutsideRepeatWindow as unknown as Scenario; // --------------------------------------------------------------------------- // Registry @@ -105,6 +107,7 @@ export const scenarios = [ heartbeatTimeoutScenario, repeatedBootNotificationScenario, meterValueZeroScenario, + bootOutsideRepeatWindowScenario, ] as const; export const scenarioNames = [ @@ -129,6 +132,7 @@ export const scenarioNames = [ 'heartbeat-timeout', 'repeated-boot-notification', 'meter-value-zero', + 'boot-outside-repeat-window', ] as const; export { @@ -153,6 +157,7 @@ export { heartbeatTimeoutScenario, repeatedBootNotificationScenario, meterValueZeroScenario, + bootOutsideRepeatWindowScenario, }; export { compareScenarioReports } from './compare.js';