mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +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';
|
||||
await app.request
|
||||
.post(url)
|
||||
.send({ name, description: 'some', type: 'release' })
|
||||
.send({
|
||||
name,
|
||||
description: 'some',
|
||||
type: 'release',
|
||||
impressionData: true,
|
||||
})
|
||||
.expect(201);
|
||||
await app.request
|
||||
.patch(`${url}/${name}`)
|
||||
.send([
|
||||
{ op: 'replace', path: '/description', value: 'New desc' },
|
||||
{ op: 'replace', path: '/type', value: 'kill-switch' },
|
||||
{ op: 'replace', path: '/impressionData', value: false },
|
||||
])
|
||||
.expect(200);
|
||||
|
||||
@ -527,6 +533,7 @@ test('Should patch feature toggle', async () => {
|
||||
expect(toggle.name).toBe(name);
|
||||
expect(toggle.description).toBe('New desc');
|
||||
expect(toggle.type).toBe('kill-switch');
|
||||
expect(toggle.impressionData).toBe(false);
|
||||
expect(toggle.archived).toBeFalsy();
|
||||
const events = await db.stores.eventStore.getAll({
|
||||
type: FEATURE_METADATA_UPDATED,
|
||||
@ -1983,3 +1990,50 @@ test('should not update project with PATCH', async () => {
|
||||
})
|
||||
.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',
|
||||
description: 'the #1 feature',
|
||||
impressionData: true,
|
||||
},
|
||||
'test',
|
||||
);
|
||||
@ -134,6 +135,24 @@ test('gets a feature by name', async () => {
|
||||
.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 () => {
|
||||
return app.request
|
||||
.get('/api/client/features/myfeature')
|
||||
|
Loading…
Reference in New Issue
Block a user