mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
test: added tests for has strategies and enabled strategies (#5112)
This commit is contained in:
parent
667aed828b
commit
ba758e13c1
@ -8,6 +8,7 @@ import {
|
|||||||
import getLogger from '../../../../fixtures/no-logger';
|
import getLogger from '../../../../fixtures/no-logger';
|
||||||
|
|
||||||
import { IProjectStore } from 'lib/types';
|
import { IProjectStore } from 'lib/types';
|
||||||
|
import { DEFAULT_ENV } from '../../../../../lib/util';
|
||||||
|
|
||||||
let app: IUnleashTest;
|
let app: IUnleashTest;
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
@ -22,6 +23,7 @@ beforeAll(async () => {
|
|||||||
experimental: {
|
experimental: {
|
||||||
flags: {
|
flags: {
|
||||||
strictSchemaValidation: true,
|
strictSchemaValidation: true,
|
||||||
|
featureSwitchRefactor: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -30,11 +32,87 @@ beforeAll(async () => {
|
|||||||
projectStore = db.stores.projectStore;
|
projectStore = db.stores.projectStore;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await db.stores.featureToggleStore.deleteAll();
|
||||||
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await app.destroy();
|
await app.destroy();
|
||||||
await db.destroy();
|
await db.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should report has strategies and enabled strategies', async () => {
|
||||||
|
const app = await setupAppWithCustomConfig(
|
||||||
|
db.stores,
|
||||||
|
{
|
||||||
|
experimental: {
|
||||||
|
flags: {
|
||||||
|
featureSwitchRefactor: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
db.rawDatabase,
|
||||||
|
);
|
||||||
|
await app.createFeature('featureWithStrategies');
|
||||||
|
await app.createFeature('featureWithoutStrategies');
|
||||||
|
await app.createFeature('featureWithDisabledStrategies');
|
||||||
|
await app.addStrategyToFeatureEnv(
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
},
|
||||||
|
DEFAULT_ENV,
|
||||||
|
'featureWithStrategies',
|
||||||
|
);
|
||||||
|
await app.addStrategyToFeatureEnv(
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
DEFAULT_ENV,
|
||||||
|
'featureWithDisabledStrategies',
|
||||||
|
);
|
||||||
|
|
||||||
|
const { body } = await app.request
|
||||||
|
.get('/api/admin/projects/default')
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
expect(body).toMatchObject({
|
||||||
|
features: [
|
||||||
|
{
|
||||||
|
name: 'featureWithStrategies',
|
||||||
|
environments: [
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
hasStrategies: true,
|
||||||
|
hasEnabledStrategies: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'featureWithoutStrategies',
|
||||||
|
environments: [
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
hasStrategies: false,
|
||||||
|
hasEnabledStrategies: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'featureWithDisabledStrategies',
|
||||||
|
environments: [
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
hasStrategies: true,
|
||||||
|
hasEnabledStrategies: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('Should ONLY return default project', async () => {
|
test('Should ONLY return default project', async () => {
|
||||||
projectStore.create({
|
projectStore.create({
|
||||||
id: 'test2',
|
id: 'test2',
|
||||||
@ -121,6 +199,7 @@ test('response should include last seen at per environment for multiple environm
|
|||||||
},
|
},
|
||||||
db.rawDatabase,
|
db.rawDatabase,
|
||||||
);
|
);
|
||||||
|
await app.createFeature('my-new-feature-toggle');
|
||||||
|
|
||||||
await db.stores.environmentStore.create({
|
await db.stores.environmentStore.create({
|
||||||
name: 'development',
|
name: 'development',
|
||||||
|
Loading…
Reference in New Issue
Block a user