From f8db9098fca92e7a7bc165adeadc01e61d71788f Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Tue, 21 Nov 2023 12:54:45 +0100 Subject: [PATCH] Revert "Fix: add the right change" This reverts commit 9dc64659b769320387ff73b7f4bee97d68abf768. Wasn't intended to push to main. --- ...e-request-segment-usage-read-model.test.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/lib/features/change-request-segment-usage-service/change-request-segment-usage-read-model.test.ts b/src/lib/features/change-request-segment-usage-service/change-request-segment-usage-read-model.test.ts index 489900b128..f2581c2208 100644 --- a/src/lib/features/change-request-segment-usage-service/change-request-segment-usage-read-model.test.ts +++ b/src/lib/features/change-request-segment-usage-service/change-request-segment-usage-read-model.test.ts @@ -100,6 +100,40 @@ const updateStrategyInCr = async ( }); }; +describe.each([ + [ + 'updateStrategy', + (segmentId: number) => + updateStrategyInCr(randomId(), segmentId, FLAG_NAME), + ], + [ + 'addStrategy', + (segmentId: number) => addStrategyToCr(segmentId, FLAG_NAME), + ], +])('Should handle %s changes correctly', (_, addOrUpdateStrategy) => { + test.each([ + ['Draft', true], + ['In review', true], + ['Scheduled', true], + ['Approved', true], + ['Rejected', false], + ['Cancelled', false], + ['Applied', false], + ])( + 'Changes in %s CRs should make it %s', + async (state, expectedOutcome) => { + await createCR(state); + + const segmentId = 3; + await addOrUpdateStrategy(segmentId); + + expect( + await readModel.isSegmentUsedInActiveChangeRequests(segmentId), + ).toBe(expectedOutcome); + }, + ); +}); + test.each([ ['Draft', true], ['In review', true],