mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-10 17:53:36 +02:00
fix: add tests for impressionData
This commit is contained in:
parent
165d2eae80
commit
d7a082d477
@ -512,13 +512,19 @@ test('Should patch feature toggle', async () => {
|
|||||||
const name = 'new.toggle.patch';
|
const name = 'new.toggle.patch';
|
||||||
await app.request
|
await app.request
|
||||||
.post(url)
|
.post(url)
|
||||||
.send({ name, description: 'some', type: 'release' })
|
.send({
|
||||||
|
name,
|
||||||
|
description: 'some',
|
||||||
|
type: 'release',
|
||||||
|
impressionData: true,
|
||||||
|
})
|
||||||
.expect(201);
|
.expect(201);
|
||||||
await app.request
|
await app.request
|
||||||
.patch(`${url}/${name}`)
|
.patch(`${url}/${name}`)
|
||||||
.send([
|
.send([
|
||||||
{ op: 'replace', path: '/description', value: 'New desc' },
|
{ op: 'replace', path: '/description', value: 'New desc' },
|
||||||
{ op: 'replace', path: '/type', value: 'kill-switch' },
|
{ op: 'replace', path: '/type', value: 'kill-switch' },
|
||||||
|
{ op: 'replace', path: '/impressionData', value: false },
|
||||||
])
|
])
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
@ -527,6 +533,7 @@ test('Should patch feature toggle', async () => {
|
|||||||
expect(toggle.name).toBe(name);
|
expect(toggle.name).toBe(name);
|
||||||
expect(toggle.description).toBe('New desc');
|
expect(toggle.description).toBe('New desc');
|
||||||
expect(toggle.type).toBe('kill-switch');
|
expect(toggle.type).toBe('kill-switch');
|
||||||
|
expect(toggle.impressionData).toBe(false);
|
||||||
expect(toggle.archived).toBeFalsy();
|
expect(toggle.archived).toBeFalsy();
|
||||||
const events = await db.stores.eventStore.getAll({
|
const events = await db.stores.eventStore.getAll({
|
||||||
type: FEATURE_METADATA_UPDATED,
|
type: FEATURE_METADATA_UPDATED,
|
||||||
@ -1983,3 +1990,50 @@ test('should not update project with PATCH', async () => {
|
|||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Can create a feature with impression data', async () => {
|
||||||
|
await app.request
|
||||||
|
.post('/api/admin/projects/default/features')
|
||||||
|
.send({
|
||||||
|
name: 'new.toggle.with.impressionData',
|
||||||
|
impressionData: true,
|
||||||
|
})
|
||||||
|
.expect(201)
|
||||||
|
.expect((res) => {
|
||||||
|
expect(res.body.impressionData).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can create a feature without impression data', async () => {
|
||||||
|
await app.request
|
||||||
|
.post('/api/admin/projects/default/features')
|
||||||
|
.send({
|
||||||
|
name: 'new.toggle.without.impressionData',
|
||||||
|
})
|
||||||
|
.expect(201)
|
||||||
|
.expect((res) => {
|
||||||
|
expect(res.body.impressionData).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can update impression data with PUT', async () => {
|
||||||
|
const toggle = {
|
||||||
|
name: 'update.toggle.with.impressionData',
|
||||||
|
impressionData: true,
|
||||||
|
};
|
||||||
|
await app.request
|
||||||
|
.post('/api/admin/projects/default/features')
|
||||||
|
.send(toggle)
|
||||||
|
.expect(201)
|
||||||
|
.expect((res) => {
|
||||||
|
expect(res.body.impressionData).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
await app.request
|
||||||
|
.put(`/api/admin/projects/default/features/${toggle.name}`)
|
||||||
|
.send({ ...toggle, impressionData: false })
|
||||||
|
.expect(200)
|
||||||
|
.expect((res) => {
|
||||||
|
expect(res.body.impressionData).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -14,6 +14,7 @@ beforeAll(async () => {
|
|||||||
{
|
{
|
||||||
name: 'featureX',
|
name: 'featureX',
|
||||||
description: 'the #1 feature',
|
description: 'the #1 feature',
|
||||||
|
impressionData: true,
|
||||||
},
|
},
|
||||||
'test',
|
'test',
|
||||||
);
|
);
|
||||||
@ -134,6 +135,24 @@ test('gets a feature by name', async () => {
|
|||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('returns a feature toggles impression data', async () => {
|
||||||
|
return app.request
|
||||||
|
.get('/api/client/features/featureX')
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect((res) => {
|
||||||
|
expect(res.body.impressionData).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns a false for impression data when not specified', async () => {
|
||||||
|
return app.request
|
||||||
|
.get('/api/client/features/featureZ')
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect((res) => {
|
||||||
|
expect(res.body.impressionData).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('cant get feature that does not exist', async () => {
|
test('cant get feature that does not exist', async () => {
|
||||||
return app.request
|
return app.request
|
||||||
.get('/api/client/features/myfeature')
|
.get('/api/client/features/myfeature')
|
||||||
|
Loading…
Reference in New Issue
Block a user