Skip to content

Commit

Permalink
refactor: add test coverage (#5046)
Browse files Browse the repository at this point in the history
Adds test coverage for different feature flag paths temporarily
  • Loading branch information
FredrikOseberg authored Oct 16, 2023
1 parent 8561ba8 commit 1a46ab7
Showing 1 changed file with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 1a46ab7

Please sign in to comment.