]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): remove stale optional chaining on now-required variableAttribute
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 20:29:21 +0000 (21:29 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 20:29:21 +0000 (21:29 +0100)
ReportDataType.variableAttribute was made required in 429cdbe3 but
test files still used ?. and ?? [] on the field. The stale eslint
cache masked these errors locally; CI (no cache) correctly rejected.

tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts

index 3bb000bfad275a53dc1df6f151b51d8ec22822ef..cd25ca4d787e534fea513461abd19adf27e2ba23 100644 (file)
@@ -123,9 +123,9 @@ await describe('B07 - Get Base Report', async () => {
     )
     assert.notStrictEqual(heartbeatEntry, undefined)
     if (heartbeatEntry) {
-      const types =
-        heartbeatEntry.variableAttribute?.map((a: { type?: string; value?: string }) => a.type) ??
-        []
+      const types = heartbeatEntry.variableAttribute.map(
+        (a: { type?: string; value?: string }) => a.type
+      )
       assert.deepStrictEqual(types, [AttributeEnumType.Actual])
     }
     // Boolean variable (AuthorizeRemoteStart) should only include Actual
@@ -136,10 +136,9 @@ await describe('B07 - Get Base Report', async () => {
     )
     assert.notStrictEqual(authorizeRemoteStartEntry, undefined)
     if (authorizeRemoteStartEntry) {
-      const types =
-        authorizeRemoteStartEntry.variableAttribute?.map(
-          (a: { type?: string; value?: string }) => a.type
-        ) ?? []
+      const types = authorizeRemoteStartEntry.variableAttribute.map(
+        (a: { type?: string; value?: string }) => a.type
+      )
       assert.deepStrictEqual(types, [AttributeEnumType.Actual])
     }
   })
@@ -235,7 +234,7 @@ await describe('B07 - Get Base Report', async () => {
     )
     assert.notStrictEqual(modelVariable, undefined)
     if (modelVariable) {
-      assert.strictEqual(modelVariable.variableAttribute?.[0]?.value, TEST_CHARGE_POINT_MODEL)
+      assert.strictEqual(modelVariable.variableAttribute[0]?.value, TEST_CHARGE_POINT_MODEL)
     }
 
     const vendorVariable = reportData.find(
@@ -245,7 +244,7 @@ await describe('B07 - Get Base Report', async () => {
     )
     assert.notStrictEqual(vendorVariable, undefined)
     if (vendorVariable) {
-      assert.strictEqual(vendorVariable.variableAttribute?.[0]?.value, TEST_CHARGE_POINT_VENDOR)
+      assert.strictEqual(vendorVariable.variableAttribute[0]?.value, TEST_CHARGE_POINT_VENDOR)
     }
   })
 
@@ -302,7 +301,7 @@ await describe('B07 - Get Base Report', async () => {
     )
     assert.notStrictEqual(timeSourceEntry, undefined)
     if (timeSourceEntry) {
-      const reportedAttr = timeSourceEntry.variableAttribute?.find(
+      const reportedAttr = timeSourceEntry.variableAttribute.find(
         (a: { type?: string; value?: string }) => a.type === AttributeEnumType.Actual
       )
       assert.notStrictEqual(reportedAttr, undefined)
index 3a3638138173c6de3e3641f3bfe65b413b64f540..22a2857fce096a2ec8c79092cabeca08c96de011 100644 (file)
@@ -327,7 +327,6 @@ await describe('B07/B08 - NotifyReport', async () => {
       assert.notStrictEqual(payload, undefined)
       assert(payload.reportData != null)
       const firstReport = payload.reportData[0]
-      assert(firstReport.variableAttribute != null)
       assert.strictEqual(firstReport.variableAttribute[0].type, attributeType)
       assert.strictEqual(firstReport.variableAttribute[0].value, `Test Value ${index.toString()}`)
     })
@@ -382,7 +381,6 @@ await describe('B07/B08 - NotifyReport', async () => {
       assert(payload.reportData != null)
       const firstReport = payload.reportData[0]
       assert(firstReport.variableCharacteristics != null)
-      assert(firstReport.variableAttribute != null)
       assert.strictEqual(firstReport.variableCharacteristics.dataType, testCase.dataType)
       assert.strictEqual(firstReport.variableAttribute[0].value, testCase.value)
     })
@@ -492,7 +490,6 @@ await describe('B07/B08 - NotifyReport', async () => {
     assert.notStrictEqual(payload, undefined)
     assert(payload.reportData != null)
     const firstReport = payload.reportData[0]
-    assert(firstReport.variableAttribute != null)
     assert.strictEqual(firstReport.variableAttribute.length, 1)
     assert.strictEqual(firstReport.variableAttribute[0].type, AttributeEnumType.Actual)
   })