]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): restore ping() method and cleanup wsPingSetInterval
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 23:59:52 +0000 (00:59 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 23:59:52 +0000 (00:59 +0100)
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
tests/charging-station/mocks/MockWebSocket.ts

index d3b6de4c7f31f05c476ddfcded6549ed589a80e7..d88939cb326af3a3d6bdbdc928e13865f79b753f 100644 (file)
@@ -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 {
index 2420023bd6677b72cc61bc5c631b52c5b31d1175..04e75bc74317a673eec2b8f7768f8c41f2e3720e 100644 (file)
@@ -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