1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-23 13:46:45 +02:00

wip: start updating tests in read model

This commit is contained in:
Thomas Heartman 2023-11-20 10:11:10 +01:00
parent 33a57bc3f3
commit 6efd78c403
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78
3 changed files with 41 additions and 2 deletions

View File

@ -133,3 +133,43 @@ describe.each([
},
);
});
describe.each([
[
'updateStrategy',
(segmentId: number) =>
updateStrategyInCr(randomId(), segmentId, FLAG_NAME),
],
[
'addStrategy',
(segmentId: number) => addStrategyToCr(segmentId, FLAG_NAME),
],
])(
'%s events should show up in used strategies 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(readModel).get;
expect(
await readModel.isSegmentUsedInActiveChangeRequests(
segmentId,
),
).toBe(expectedOutcome);
},
);
},
);

View File

@ -1,3 +1,4 @@
export interface IChangeRequestSegmentUsageReadModel {
isSegmentUsedInActiveChangeRequests(segmentId: number): Promise<boolean>;
getSegmentsUsedInActiveChangeRequests(): Promise<{}[]>;
}

View File

@ -523,7 +523,6 @@ describe('detect strategy usage in change requests', () => {
});
// for addStrategy, add strategy to feature with segment
// for updateStrategy, add existing strategy, then add segment in CR
// check that getStrategies for segments contains the CR strategies
const segmentStrategies = await fetchSegmentStrategies(segment.id);
@ -577,7 +576,6 @@ describe('detect strategy usage in change requests', () => {
created_by: user.id,
});
// for addStrategy, add strategy to feature with segment
// for updateStrategy, add existing strategy, then add segment in CR
// check that getStrategies for segments contains the CR strategies