From 3d00af1582eb04b27c1e7ace50c1cc895b61d193 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 15 Mar 2026 21:29:21 +0100 Subject: [PATCH] fix(tests): remove stale optional chaining on now-required variableAttribute 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. --- ...comingRequestService-GetBaseReport.test.ts | 19 +++++++++---------- .../OCPP20RequestService-NotifyReport.test.ts | 3 --- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts index 3bb000bf..cd25ca4d 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts @@ -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) diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts index 3a363813..22a2857f 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts @@ -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) }) -- 2.43.0