From df60b612e9fb861597445d13886b88bac674b966 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 1 Mar 2026 00:59:52 +0100 Subject: [PATCH] fix(tests): restore ping() method and cleanup wsPingSetInterval Fixes Windows CI hang caused by: - Missing wsPingSetInterval cleanup in cleanupChargingStation() - Removed ping()/pong() methods that ChargingStation.ts still calls The WebSocket ping interval was never cleared during test cleanup, keeping the Node.js event loop alive indefinitely on Windows. --- tests/charging-station/helpers/StationHelpers.ts | 6 ++++++ tests/charging-station/mocks/MockWebSocket.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/charging-station/helpers/StationHelpers.ts b/tests/charging-station/helpers/StationHelpers.ts index d3b6de4c..d88939cb 100644 --- a/tests/charging-station/helpers/StationHelpers.ts +++ b/tests/charging-station/helpers/StationHelpers.ts @@ -175,6 +175,12 @@ export function cleanupChargingStation (station: ChargingStation): void { station.heartbeatSetInterval = undefined } + // Stop WebSocket ping timer + if (station.wsPingSetInterval != null) { + clearInterval(station.wsPingSetInterval) + station.wsPingSetInterval = undefined + } + // Close WebSocket connection if (station.wsConnection != null) { try { diff --git a/tests/charging-station/mocks/MockWebSocket.ts b/tests/charging-station/mocks/MockWebSocket.ts index 2420023b..04e75bc7 100644 --- a/tests/charging-station/mocks/MockWebSocket.ts +++ b/tests/charging-station/mocks/MockWebSocket.ts @@ -98,6 +98,20 @@ export class MockWebSocket extends EventEmitter { return this.sentMessages.map(msg => JSON.parse(msg) as unknown) } + /** + * Ping the server (no-op in mock) + */ + public ping (): void { + // No-op for tests + } + + /** + * Pong response (no-op in mock) + */ + public pong (): void { + // No-op for tests + } + /** * Send a message through the WebSocket * @param data - Message to send -- 2.53.0