mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
fix: variant tests more stable
This commit is contained in:
parent
8c12ead2ae
commit
24ca56e041
@ -238,3 +238,37 @@ test('invalid feature names should have error msg', t => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('should not allow variants with same name when creating feature flag', t => {
|
||||
t.plan(0);
|
||||
const { request, base } = getSetup();
|
||||
|
||||
return request
|
||||
.post(`${base}/api/admin/features`)
|
||||
.send({
|
||||
name: 'ts',
|
||||
strategies: [{ name: 'default' }],
|
||||
variants: [{ name: 'variant1' }, { name: 'variant1' }],
|
||||
})
|
||||
.set('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
|
||||
test('should not allow variants with same name when updating feature flag', t => {
|
||||
t.plan(0);
|
||||
const { request, featureToggleStore, base } = getSetup();
|
||||
featureToggleStore.addFeature({
|
||||
name: 'ts',
|
||||
strategies: [{ name: 'default' }],
|
||||
});
|
||||
|
||||
return request
|
||||
.put(`${base}/api/admin/features/ts`)
|
||||
.send({
|
||||
name: 'ts',
|
||||
strategies: [{ name: 'default' }],
|
||||
variants: [{ name: 'variant1' }, { name: 'variant1' }],
|
||||
})
|
||||
.set('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
|
@ -3,14 +3,14 @@
|
||||
const test = require('ava');
|
||||
const { setupApp } = require('./../../helpers/test-helper');
|
||||
|
||||
test.serial('returns three feature toggles', async t => {
|
||||
test.serial('returns list of feature toggles', async t => {
|
||||
const { request, destroy } = await setupApp('feature_api_serial');
|
||||
return request
|
||||
.get('/api/admin/features')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.expect(res => {
|
||||
t.true(res.body.features.length === 3);
|
||||
t.true(res.body.features.length === 4);
|
||||
})
|
||||
.then(destroy);
|
||||
});
|
||||
@ -51,9 +51,9 @@ test.serial('creates new feature toggle', async t => {
|
||||
});
|
||||
|
||||
test.serial('creates new feature toggle with variants', async t => {
|
||||
t.plan(1);
|
||||
t.plan(0);
|
||||
const { request, destroy } = await setupApp('feature_api_serial');
|
||||
await request
|
||||
return request
|
||||
.post('/api/admin/features')
|
||||
.send({
|
||||
name: 'com.test.variants',
|
||||
@ -61,9 +61,16 @@ test.serial('creates new feature toggle with variants', async t => {
|
||||
strategies: [{ name: 'default' }],
|
||||
variants: [{ name: 'variant1' }, { name: 'variant2' }],
|
||||
})
|
||||
.set('Content-Type', 'application/json');
|
||||
await request
|
||||
.get('/api/admin/features/com.test.variants')
|
||||
.set('Content-Type', 'application/json')
|
||||
.expect(201)
|
||||
.then(destroy);
|
||||
});
|
||||
|
||||
test.serial('fetch feature toggle with variants', async t => {
|
||||
t.plan(1);
|
||||
const { request, destroy } = await setupApp('feature_api_serial');
|
||||
return request
|
||||
.get('/api/admin/features/feature.with.variants')
|
||||
.expect(res => {
|
||||
t.true(res.body.variants.length === 2);
|
||||
})
|
||||
|
@ -3,14 +3,14 @@
|
||||
const test = require('ava');
|
||||
const { setupApp } = require('./../../helpers/test-helper');
|
||||
|
||||
test.serial('returns three feature toggles', async t => {
|
||||
test.serial('returns four feature toggles', async t => {
|
||||
const { request, destroy } = await setupApp('feature_api_client');
|
||||
return request
|
||||
.get('/api/client/features')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.expect(res => {
|
||||
t.true(res.body.features.length === 3);
|
||||
t.true(res.body.features.length === 4);
|
||||
})
|
||||
.then(destroy);
|
||||
});
|
||||
|
@ -120,6 +120,14 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "feature.with.variants",
|
||||
"description": "A feature toggle with watiants",
|
||||
"enabled": true,
|
||||
"archived": false,
|
||||
"strategies": [{ "name": "default" }],
|
||||
"variants": [{ "name": "control" }, { "name": "new" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user