mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: add test coverage (#5046)
Adds test coverage for different feature flag paths temporarily
This commit is contained in:
parent
8561ba8df7
commit
1a46ab7b12
@ -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);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user