Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions client/__tests__/allTreatments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ describe('get-all-treatments', () => {
'other-experiment-2': {
treatment: 'on',
},
'other-experiment-4': {
treatment: 'on',
},
},
};
const response = await request(app)
Expand All @@ -242,6 +245,9 @@ describe('get-all-treatments', () => {
'my-experiment': {
treatment: 'on',
},
'other-experiment-4': {
treatment: 'on',
},
'other-experiment-3': {
treatment: 'off',
},
Expand Down Expand Up @@ -277,6 +283,42 @@ describe('get-all-treatments', () => {
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is valid (GET)', async () => {
const response = await request(app)
.get('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}&impressions-disabled=true')
.set('Authorization', 'test');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is valid (POST)', async () => {
const response = await request(app)
.post('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
.send({
properties: { package: 'premium', admin: true, discount: 50 },
impressionsDisabled: true,
})
.set('Authorization', 'test');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}&impressions-disabled={"a":1}')
.set('Authorization', 'test');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is invalid (POST)', async () => {
const response = await request(app)
.post('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
.send({
properties: { package: 'premium', admin: true, discount: 50 },
impressionsDisabled: { a: 1 },
})
.set('Authorization', 'test');
expect(response.status).toBe(200);
});

test('should be 200 if properties is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}')
Expand Down
45 changes: 45 additions & 0 deletions client/__tests__/allTreatmentsWithConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ describe('get-all-treatments-with-config', () => {
treatment: 'on',
config: null,
},
'other-experiment-4': {
treatment: 'on',
config: null,
},
},
};
const response = await request(app)
Expand Down Expand Up @@ -259,6 +263,10 @@ describe('get-all-treatments-with-config', () => {
treatment: 'on',
config: null,
},
'other-experiment-4': {
treatment: 'on',
config: null,
},
},
account: {},
};
Expand All @@ -285,6 +293,43 @@ describe('get-all-treatments-with-config', () => {
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is valid (GET)', async () => {
const response = await request(app)
.get('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}&impressions-disabled=true')
.set('Authorization', 'test');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is valid (POST)', async () => {
const response = await request(app)
.post('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
.send({
properties: { foo: { bar: 1 } },
impressionsDisabled: true,
})
.set('Authorization', 'test');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}&impressions-disabled={"a":1}')
.set('Authorization', 'test');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled parameter is invalid (POST)', async () => {
const response = await request(app)
.post('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
.send({
properties: { foo: { bar: 1 } },
impressionsDisabled: { a: 1 },
})
.set('Authorization', 'test');
expect(response.status).toBe(200);
});


test('should be 200 if properties is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}')
Expand Down
36 changes: 36 additions & 0 deletions client/__tests__/treatment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,40 @@ describe('get-treatment', () => {
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment');
});

test('should be 200 if impressionsDisabled is valid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatment?key=test&split-name=my-experiment&properties={"package":"premium","admin":true,"discount":50}&impressions-disabled=true')
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment');
});

test('should be 200 if impressionsDisabled is valid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatment?key=test&split-name=my-experiment&impressions-disabled=true')
.send({
properties: { package: 'premium', admin: true, discount: 50 },
impressionsDisabled: true,
})
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment');
});

test('should be 200 if impressionsDisabled is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatment?key=test&split-name=my-experiment&properties={"foo": {"bar": 1}}&impressions-disabled=lalala')
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment');
});

test('should be 200 if impressionsDisabled is invalid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatment?key=test&split-name=my-experiment')
.send({
properties: { foo: { bar: 1 } },
impressionsDisabled: 'lalala',
})
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment');
});
});
36 changes: 36 additions & 0 deletions client/__tests__/treatmentWithConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,40 @@ describe('get-treatment-with-config', () => {
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');
});

test('should be 200 if impressionsDisabled is valid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatment-with-config?key=test&split-name=my-experiment&properties={"package":"premium","admin":true,"discount":50}&impressions-disabled=true')
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');
});

test('should be 200 if impressionsDisabled is valid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatment-with-config?key=test&split-name=my-experiment')
.send({
properties: { package: 'premium', admin: true, discount: 50 },
impressionsDisabled: true,
})
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');
});

test('should be 200 if impressionsDisabled is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatment-with-config?key=test&split-name=my-experiment&properties={"foo": {"bar": 1}}&impressions-disabled=lalala')
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');
});

test('should be 200 if impressionsDisabled is invalid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatment-with-config?key=test&split-name=my-experiment')
.send({
properties: { foo: { bar: 1 } },
impressionsDisabled: 'lalala',
})
.set('Authorization', 'test');
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');
});
});
53 changes: 53 additions & 0 deletions client/__tests__/treatments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,57 @@ describe('get-treatments', () => {
},
}, 1);
});


test('should be 200 if impressionsDisabled is valid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatments?key=test&split-names=my-experiment&properties={"package":"premium","admin":true,"discount":50}&impressions-disabled=true')
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
},
}, 1);
});

test('should be 200 if impressionsDisabled is valid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatments?key=test&split-names=my-experiment')
.send({
properties: { package: 'premium', admin: true, discount: 50 },
impressionsDisabled: true,
})
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
},
}, 1);
});

test('should be 200 if impressionsDisabled is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatments?key=test&split-names=my-experiment&properties={"foo": {"bar": 1}}&impressions-disabled=lalala')
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
},
}, 1);
});

test('should be 200 if impressionsDisabled is invalid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatments?key=test&split-names=my-experiment')
.send({
properties: { foo: { bar: 1 } },
impressionsDisabled: 'lalala',
})
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
},
}, 1);
});
});
36 changes: 36 additions & 0 deletions client/__tests__/treatmentsByFlagSets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,40 @@ describe('get-treatments-by-sets', () => {
.set('Authorization', 'key_green');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled is valid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatments-by-sets?key=test&flag-sets=set_green&properties={"package":"premium","admin":true,"discount":50}&impressions-disabled=true')
.set('Authorization', 'key_green');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled is valid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatments-by-sets?key=test&flag-sets=set_green')
.send({
properties: { package: 'premium', admin: true, discount: 50 },
impressionsDisabled: true,
})
.set('Authorization', 'key_green');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatments-by-sets?key=test&flag-sets=set_green&properties={"foo": {"bar": 1}}&impressions-disabled=lalala')
.set('Authorization', 'key_green');
expect(response.status).toBe(200);
});

test('should be 200 if impressionsDisabled is invalid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatments-by-sets?key=test&flag-sets=set_green')
.send({
properties: { foo: { bar: 1 } },
impressionsDisabled: 'lalala',
})
.set('Authorization', 'key_green');
expect(response.status).toBe(200);
});
});
56 changes: 56 additions & 0 deletions client/__tests__/treatmentsWithConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,60 @@ describe('get-treatments-with-config', () => {
},
}, 1);
});

test('should be 200 if impressionsDisabled is valid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatments-with-config?key=test&split-names=my-experiment&properties={"package":"premium","admin":true,"discount":50}&impressions-disabled=true')
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
config: '{"desc" : "this applies only to ON treatment"}',
},
}, 1);
});

test('should be 200 if impressionsDisabled is valid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatments-with-config?key=test&split-names=my-experiment')
.send({
properties: { package: 'premium', admin: true, discount: 50 },
impressionsDisabled: true,
})
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
config: '{"desc" : "this applies only to ON treatment"}',
},
}, 1);
});

test('should be 200 if impressionsDisabled is invalid (GET)', async () => {
const response = await request(app)
.get('/client/get-treatments-with-config?key=test&split-names=my-experiment&properties={"foo": {"bar": 1}}&impressions-disabled=lalala')
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
config: '{"desc" : "this applies only to ON treatment"}',
},
}, 1);
});

test('should be 200 if impressionsDisabled is invalid (POST)', async () => {
const response = await request(app)
.post('/client/get-treatments-with-config?key=test&split-names=my-experiment')
.send({
properties: { foo: { bar: 1 } },
impressionsDisabled: 'lalala',
})
.set('Authorization', 'test');
expectOkMultipleResults(response, 200, {
'my-experiment': {
treatment: 'on',
config: '{"desc" : "this applies only to ON treatment"}',
},
}, 1);
});
});
Loading