diff --git a/src/lib/services/segment-service.ts b/src/lib/services/segment-service.ts index 8cc41a3dcd..753381b5f9 100644 --- a/src/lib/services/segment-service.ts +++ b/src/lib/services/segment-service.ts @@ -119,15 +119,10 @@ export class SegmentService implements ISegmentService { const strategies = await this.featureStrategiesStore.getStrategiesBySegment(id); - const strategyIds = new Set(strategies.map((s) => s.id)); - - const changeRequestStrategies = ( + const changeRequestStrategies = await this.changeRequestSegmentUsageReadModel.getStrategiesUsedInActiveChangeRequests( id, - ) - ).filter( - (strategy) => !('id' in strategy && strategyIds.has(strategy.id)), - ); + ); return { strategies, changeRequestStrategies }; } diff --git a/src/test/e2e/api/admin/segment.e2e.test.ts b/src/test/e2e/api/admin/segment.e2e.test.ts index 1824561f6c..cad9c0670d 100644 --- a/src/test/e2e/api/admin/segment.e2e.test.ts +++ b/src/test/e2e/api/admin/segment.e2e.test.ts @@ -583,7 +583,7 @@ describe('detect strategy usage in change requests', () => { expect(strategies).toStrictEqual([]); }); - test('If a segment is used in an existing strategy and in a CR for the same strategy, the strategy should only be listed once', async () => { + test('If a segment is used in an existing strategy and in a CR for the same strategy, the strategy should be listed both places', async () => { await createSegment({ name: 'a', constraints: [] }); const toggle = mockFeatureToggle(); await createFeatureToggle(app, toggle); @@ -628,6 +628,6 @@ describe('detect strategy usage in change requests', () => { expect(strategies).toMatchObject([{ id: strategyId }]); - expect(changeRequestStrategies).toStrictEqual([]); + expect(changeRequestStrategies).toMatchObject([{ id: strategyId }]); }); });