]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(ui): use EMPTY_VALUE_PLACEHOLDER in Utils.ts and test assertions
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 3 Apr 2026 23:15:41 +0000 (01:15 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 3 Apr 2026 23:15:41 +0000 (01:15 +0200)
Replace remaining hardcoded 'Ø' in getWebSocketStateName() and 4 test
assertions with the centralized EMPTY_VALUE_PLACEHOLDER constant.
Consolidate duplicate Constants import in Utils.ts.

ui/web/src/composables/Utils.ts
ui/web/tests/unit/CSConnector.test.ts
ui/web/tests/unit/CSData.test.ts

index 99a4ee51100a7fa10c5955dc2e19d10a2a240433..11d6f7de6c91650810eddde968d06736d740e639 100644 (file)
@@ -5,7 +5,11 @@ import { useToast } from 'vue-toast-notification'
 
 import type { ChargingStationData, ConfigurationData, UUIDv4 } from '@/types'
 
-import { SHARED_TOGGLE_BUTTON_KEY_PREFIX, TOGGLE_BUTTON_KEY_PREFIX } from './Constants'
+import {
+  EMPTY_VALUE_PLACEHOLDER,
+  SHARED_TOGGLE_BUTTON_KEY_PREFIX,
+  TOGGLE_BUTTON_KEY_PREFIX,
+} from './Constants'
 import { UIClient } from './UIClient'
 
 export const configurationKey: InjectionKey<Ref<ConfigurationData>> = Symbol('configuration')
@@ -88,7 +92,7 @@ export const deleteLocalStorageByKeyPattern = (pattern: string): void => {
 /**
  * Returns a human-readable name for a WebSocket ready state.
  * @param state - The WebSocket readyState value
- * @returns The state name or 'Ø' for unknown/undefined states
+ * @returns The state name or EMPTY_VALUE_PLACEHOLDER for unknown/undefined states
  */
 export const getWebSocketStateName = (state: number | undefined): string => {
   switch (state) {
@@ -101,7 +105,7 @@ export const getWebSocketStateName = (state: number | undefined): string => {
     case WebSocket.OPEN:
       return 'Open'
     default:
-      return 'Ø'
+      return EMPTY_VALUE_PLACEHOLDER
   }
 }
 
index 14e70ee3afd9a8f876e00435b69d1fb0d4b8fbfa..a24f7969a3920529343a7adc80255a0b1f1bc627 100644 (file)
@@ -9,6 +9,7 @@ import type { UIClient } from '@/composables'
 
 import CSConnector from '@/components/charging-stations/CSConnector.vue'
 import { useUIClient } from '@/composables'
+import { EMPTY_VALUE_PLACEHOLDER } from '@/composables/Constants'
 import { OCPP16ChargePointStatus } from '@/types'
 
 import { toastMock } from '../setup'
@@ -78,7 +79,7 @@ describe('CSConnector', () => {
         connector: createConnectorStatus({ status: undefined }),
       })
       const cells = wrapper.findAll('td')
-      expect(cells[1].text()).toBe('Ø')
+      expect(cells[1].text()).toBe(EMPTY_VALUE_PLACEHOLDER)
     })
 
     it('should display No when transaction not started', () => {
index 303c1cd1ece078c35bd4cc12da35a1631517459a..900d472bf76bc0237dc1828b0fa57ea46f71bcdf 100644 (file)
@@ -11,6 +11,7 @@ import type { ChargingStationData } from '@/types'
 import CSConnector from '@/components/charging-stations/CSConnector.vue'
 import CSData from '@/components/charging-stations/CSData.vue'
 import { useUIClient } from '@/composables'
+import { EMPTY_VALUE_PLACEHOLDER } from '@/composables/Constants'
 import { OCPPVersion } from '@/types'
 
 import { toastMock } from '../setup'
@@ -94,7 +95,7 @@ describe('CSData', () => {
       })
       const wrapper = mountCSData(station)
       const cells = wrapper.findAll('td')
-      expect(cells[9].text()).toBe('Ø')
+      expect(cells[9].text()).toBe(EMPTY_VALUE_PLACEHOLDER)
     })
 
     it('should display WebSocket state as Open when OPEN', () => {
@@ -112,7 +113,7 @@ describe('CSData', () => {
     it('should display WebSocket state as Ø for undefined state', () => {
       const wrapper = mountCSData(createChargingStationData({ wsState: undefined }))
       const cells = wrapper.findAll('td')
-      expect(cells[3].text()).toBe('Ø')
+      expect(cells[3].text()).toBe(EMPTY_VALUE_PLACEHOLDER)
     })
 
     it('should display registration status', () => {
@@ -124,7 +125,7 @@ describe('CSData', () => {
       const station = createChargingStationData({ bootNotificationResponse: undefined })
       const wrapper = mountCSData(station)
       const cells = wrapper.findAll('td')
-      expect(cells[4].text()).toBe('Ø')
+      expect(cells[4].text()).toBe(EMPTY_VALUE_PLACEHOLDER)
     })
 
     it('should display WebSocket state as Connecting when CONNECTING', () => {