diff --git a/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts index 38576fe8f5..7ca87cd007 100644 --- a/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts @@ -696,3 +696,75 @@ test('Should return last seen at per environment', async () => { new Date(lastSeenAtStoreDate), ); }); + +test('Should return same object for /api/admin/features | separateAdminClientApi', async () => { + const featureName = 'same-object-for-features'; + const projectId = 'default'; + + const userName = 'same-object-user'; + + await service.createFeatureToggle( + projectId, + { + name: featureName, + }, + userName, + ); + + const data = await service.getFeatureToggles(); + + // Test with feature flag on + const config = createTestConfig({ + experimental: { flags: { useLastSeenRefactor: true } }, + }); + + const featureService = await createFeatureToggleService( + db.rawDatabase, + config, + ); + + const toggledData = await featureService.getFeatureToggles(); + + const foundToggleOne = data.find((feature) => feature.name === featureName); + const foundToggleTwo = toggledData.find( + (feature) => feature.name === featureName, + ); + + expect(foundToggleOne).toEqual(foundToggleTwo); +}); + +test('Should return same object for playground | separateAdminClientApi', async () => { + const featureName = 'same-object-for-playground'; + const projectId = 'default'; + + const userName = 'same-object-user-playground'; + + await service.createFeatureToggle( + projectId, + { + name: featureName, + }, + userName, + ); + + const data = await service.getPlaygroundFeatures(); + + // Test with feature flag on + const config = createTestConfig({ + experimental: { flags: { useLastSeenRefactor: true } }, + }); + + const featureService = await createFeatureToggleService( + db.rawDatabase, + config, + ); + + const toggledData = await featureService.getPlaygroundFeatures(); + + const foundToggleOne = data.find((feature) => feature.name === featureName); + const foundToggleTwo = toggledData.find( + (feature) => feature.name === featureName, + ); + + expect(foundToggleOne).toEqual(foundToggleTwo); +});