From 830f20f8d6623338ca3dfbd3edc6fc151032d427 Mon Sep 17 00:00:00 2001 From: Oleksii Shmalko Date: Wed, 31 Jul 2024 18:40:31 +0300 Subject: [PATCH] fix: preserve allocation evaluation details when ASSIGNMENT_ERROR (#49) ASSIGNMENT_ERROR later in the evaluation process should not revert the previously-done evaluation and definitely should not list unmatched/matched allocations as "unevaluated." --- test-validation/validate-tests.spec.ts | 16 +++---- ufc/tests/test-case-invalid-value-flag.json | 48 ++++++++++----------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/test-validation/validate-tests.spec.ts b/test-validation/validate-tests.spec.ts index 927bb86e..799fc8dd 100644 --- a/test-validation/validate-tests.spec.ts +++ b/test-validation/validate-tests.spec.ts @@ -24,16 +24,14 @@ describe('UFC Test Validation', () => { describe.each(testCase.subjects.map(({subjectKey}) => subjectKey))('with subjectKey %s', (subjectKey) => { const subject = testCase.subjects.find((subject) => subject.subjectKey === subjectKey)!; - if (subject.evaluationDetails.variationValue === null) { - it('should have `assignment` match `defaultValue` when `evaluationDetails.variationValue` is null', () => { - expect(subject.assignment).toEqual(testCase.defaultValue); - }) - } - - if (subject.evaluationDetails.variationValue !== null) { - it('should have `assignment` match `evaluationDetails.variationValue` when `evaluationDetails.variationValue` is not null', () => { + if (subject.evaluationDetails.flagEvaluationCode === "MATCH") { + it('should have `assignment` match `evaluationDetails.variationValue` when `evaluationDetails.flagEvaluationCode` is "MATCH"', () => { expect(subject.assignment).toEqual(subject.evaluationDetails.variationValue); - }) + }); + } else { + it('should have `assignment` match `defaultValue` when `evaluationDetails.flagEvaluationCode` is not "MATCH"', () => { + expect(subject.assignment).toEqual(testCase.defaultValue); + }); } }); }) diff --git a/ufc/tests/test-case-invalid-value-flag.json b/ufc/tests/test-case-invalid-value-flag.json index da00eb4a..d82d8a50 100644 --- a/ufc/tests/test-case-invalid-value-flag.json +++ b/ufc/tests/test-case-invalid-value-flag.json @@ -16,23 +16,22 @@ "flagEvaluationDescription": "Variation (pi) is configured for type INTEGER, but is set to incompatible value (3.1415926)", "banditKey": null, "banditAction": null, - "variationKey": null, - "variationValue": null, + "variationKey": "pi", + "variationValue": 3.1415926, "matchedRule": null, - "matchedAllocation": null, - "unmatchedAllocations": [], - "unevaluatedAllocations": [ + "matchedAllocation": { + "key": "invalid", + "allocationEvaluationCode": "MATCH", + "orderPosition": 2 + }, + "unmatchedAllocations": [ { "key": "valid", - "allocationEvaluationCode": "UNEVALUATED", + "allocationEvaluationCode": "FAILING_RULE", "orderPosition": 1 - }, - { - "key": "invalid", - "allocationEvaluationCode": "UNEVALUATED", - "orderPosition": 2 } - ] + ], + "unevaluatedAllocations": [] } }, { @@ -88,24 +87,23 @@ "flagEvaluationDescription": "Variation (pi) is configured for type INTEGER, but is set to incompatible value (3.1415926)", "banditKey": null, "banditAction": null, - "variationKey": null, - "variationValue": null, + "variationKey": "pi", + "variationValue": 3.1415926, "matchedRule": null, - "matchedAllocation": null, - "unmatchedAllocations": [], - "unevaluatedAllocations": [ + "matchedAllocation": { + "key": "invalid", + "allocationEvaluationCode": "MATCH", + "orderPosition": 2 + }, + "unmatchedAllocations": [ { "key": "valid", - "allocationEvaluationCode": "UNEVALUATED", + "allocationEvaluationCode": "FAILING_RULE", "orderPosition": 1 - }, - { - "key": "invalid", - "allocationEvaluationCode": "UNEVALUATED", - "orderPosition": 2 } - ] + ], + "unevaluatedAllocations": [] } } ] -} \ No newline at end of file +}