Skip to content

Commit ebafc6a

Browse files
Merge pull request #208 from splitio/fme-4363
[FME-4363] Use properties param instead of options
2 parents c1ef592 + 47dc1b7 commit ebafc6a

18 files changed

+367
-197
lines changed

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- Updated base image to node:24.3.0-alpine3.21
1111

1212
2.7.1 (Jun 25, 2025)
13-
- Fixed OpenAPI spec fot /manager/splits
13+
- Fixed OpenAPI spec for /manager/splits
1414
- Updated base image to node:24.2.0-alpine3.22
1515

1616
2.7.0 (Dec 20, 2024)

client/__tests__/allTreatments.test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,35 @@ describe('get-all-treatments', () => {
260260
expectOkAllTreatments(response, 200, expected, 2);
261261
});
262262

263-
test('should be 200 if options.properties is valid (GET)', async () => {
263+
test('should be 200 if properties is valid (GET)', async () => {
264264
const response = await request(app)
265-
.get('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]&options={"properties":{"package":"premium","admin":true,"discount":50}}')
265+
.get('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"package":"premium","admin":true,"discount":50}')
266266
.set('Authorization', 'test');
267267
expect(response.status).toBe(200);
268268
});
269269

270-
test('should be 200 if options.properties is valid (POST)', async () => {
270+
test('should be 200 if properties is valid (POST)', async () => {
271271
const response = await request(app)
272272
.post('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
273273
.send({
274-
options: { properties: { package: 'premium', admin: true, discount: 50 } },
274+
properties: { package: 'premium', admin: true, discount: 50 },
275+
})
276+
.set('Authorization', 'test');
277+
expect(response.status).toBe(200);
278+
});
279+
280+
test('should be 200 if properties is invalid (GET)', async () => {
281+
const response = await request(app)
282+
.get('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}')
283+
.set('Authorization', 'test');
284+
expect(response.status).toBe(200);
285+
});
286+
287+
test('should be 200 if properties is invalid (POST)', async () => {
288+
const response = await request(app)
289+
.post('/client/get-all-treatments?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
290+
.send({
291+
properties: { foo: { bar: 1 } },
275292
})
276293
.set('Authorization', 'test');
277294
expect(response.status).toBe(200);

client/__tests__/allTreatmentsWithConfig.test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,35 @@ describe('get-all-treatments-with-config', () => {
268268
expectOkAllTreatments(response, 200, expected, 2);
269269
});
270270

271-
test('should be 200 if options.properties is valid (GET)', async () => {
271+
test('should be 200 if properties is valid (GET)', async () => {
272272
const response = await request(app)
273-
.get('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]&options={"properties":{"package":"premium","admin":true,"discount":50}}')
273+
.get('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"package":"premium","admin":true,"discount":50}')
274274
.set('Authorization', 'test');
275275
expect(response.status).toBe(200);
276276
});
277277

278-
test('should be 200 if options.properties is valid (POST)', async () => {
278+
test('should be 200 if properties is valid (POST)', async () => {
279279
const response = await request(app)
280280
.post('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
281281
.send({
282-
options: { properties: { package: 'premium', admin: true, discount: 50 } },
282+
properties: { package: 'premium', admin: true, discount: 50 },
283+
})
284+
.set('Authorization', 'test');
285+
expect(response.status).toBe(200);
286+
});
287+
288+
test('should be 200 if properties is invalid (GET)', async () => {
289+
const response = await request(app)
290+
.get('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]&properties={"foo": {"bar": 1}}')
291+
.set('Authorization', 'test');
292+
expect(response.status).toBe(200);
293+
});
294+
295+
test('should be 200 if properties is invalid (POST)', async () => {
296+
const response = await request(app)
297+
.post('/client/get-all-treatments-with-config?keys=[{"matchingKey":"test","trafficType":"localhost"}]')
298+
.send({
299+
properties: { foo: { bar: 1 } },
283300
})
284301
.set('Authorization', 'test');
285302
expect(response.status).toBe(200);

client/__tests__/track.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ process.env.SPLIT_EVALUATOR_API_KEY = 'localhost';
44
const request = require('supertest');
55
const app = require('../../app');
66
const { expectError, expectErrorContaining, getLongKey } = require('../../utils/testWrapper');
7+
const { PROPERTIES_WARNING } = require('../../utils/constants');
78

89
describe('track', () => {
910
// Testing authorization
@@ -143,22 +144,21 @@ describe('track', () => {
143144
expectErrorContaining(response, 400, expected);
144145
});
145146

146-
test('should be 400 if properties is invalid', async () => {
147-
const expected = [
148-
'properties must be a plain object with only boolean, string, number or null values.'
149-
];
147+
test('should be 200 if properties is invalid', async () => {
148+
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
150149
const response = await request(app)
151150
.get('/client/track?key=my-key&event-type=my-event&traffic-type=my-traffic&value=1&properties=lalala')
152151
.set('Authorization', 'test');
153-
expectErrorContaining(response, 400, expected);
152+
expect(response.statusCode).toBe(200);
153+
expect(logSpy).toHaveBeenCalledWith(PROPERTIES_WARNING);
154+
logSpy.mockRestore();
154155
});
155156

156157
test('should be 400 if there are multiple errors in every input', async () => {
157158
const expected = [
158159
'key too long, key must be 250 characters or less.',
159160
'you passed "@!test", event-type must adhere to the regular expression /^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/g. This means an event_type must be alphanumeric, cannot be more than 80 characters long, and can only include a dash, underscore, period, or colon as separators of alphanumeric characters.',
160161
'you passed an empty traffic-type, traffic-type must be a non-empty string.',
161-
'properties must be a plain object with only boolean, string, number or null values.',
162162
'value must be null or number.'
163163
];
164164
const key = getLongKey();

client/__tests__/treatment.test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,35 @@ describe('get-treatment', () => {
248248
expectOk(response, 200, 'control', 'nonexistant-experiment');
249249
});
250250

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

258-
test('should be 200 if options.properties is valid (POST)', async () => {
258+
test('should be 200 if properties is valid (POST)', async () => {
259259
const response = await request(app)
260260
.post('/client/get-treatment?key=test&split-name=my-experiment')
261261
.send({
262-
options: { properties: { package: 'premium', admin: true, discount: 50 } },
262+
properties: { package: 'premium', admin: true, discount: 50 },
263+
})
264+
.set('Authorization', 'test');
265+
expectOk(response, 200, 'on', 'my-experiment');
266+
});
267+
268+
test('should be 200 if properties is invalid (GET)', async () => {
269+
const response = await request(app)
270+
.get('/client/get-treatment?key=test&split-name=my-experiment&properties={"foo": {"bar": 1}}')
271+
.set('Authorization', 'test');
272+
expectOk(response, 200, 'on', 'my-experiment');
273+
});
274+
275+
test('should be 200 if properties is invalid (POST)', async () => {
276+
const response = await request(app)
277+
.post('/client/get-treatment?key=test&split-name=my-experiment')
278+
.send({
279+
properties: { foo: { bar: 1 } },
263280
})
264281
.set('Authorization', 'test');
265282
expectOk(response, 200, 'on', 'my-experiment');

client/__tests__/treatmentWithConfig.test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,35 @@ describe('get-treatment-with-config', () => {
230230
expectOk(response, 200, 'control', 'nonexistant-experiment', null);
231231
});
232232

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

240-
test('should be 200 if options.properties is valid (POST)', async () => {
240+
test('should be 200 if properties is valid (POST)', async () => {
241241
const response = await request(app)
242242
.post('/client/get-treatment-with-config?key=test&split-name=my-experiment')
243243
.send({
244-
options: { properties: { package: 'premium', admin: true, discount: 50 } },
244+
properties: { package: 'premium', admin: true, discount: 50 },
245+
})
246+
.set('Authorization', 'test');
247+
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');
248+
});
249+
250+
test('should be 200 if properties is invalid (GET)', async () => {
251+
const response = await request(app)
252+
.get('/client/get-treatment-with-config?key=test&split-name=my-experiment&properties={"foo": {"bar": 1}}')
253+
.set('Authorization', 'test');
254+
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');
255+
});
256+
257+
test('should be 200 if properties is invalid (POST)', async () => {
258+
const response = await request(app)
259+
.post('/client/get-treatment-with-config?key=test&split-name=my-experiment')
260+
.send({
261+
properties: { foo: { bar: 1 } },
245262
})
246263
.set('Authorization', 'test');
247264
expectOk(response, 200, 'on', 'my-experiment', '{"desc" : "this applies only to ON treatment"}');

client/__tests__/treatments.test.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ describe('get-treatments', () => {
268268
}, 3);
269269
});
270270

271-
test('should be 200 if options.properties is valid (GET)', async () => {
271+
test('should be 200 if properties is valid (GET)', async () => {
272272
const response = await request(app)
273-
.get('/client/get-treatments?key=test&split-names=my-experiment&options={"properties":{"package":"premium","admin":true,"discount":50}}')
273+
.get('/client/get-treatments?key=test&split-names=my-experiment&properties={"package":"premium","admin":true,"discount":50}')
274274
.set('Authorization', 'test');
275275
expectOkMultipleResults(response, 200, {
276276
'my-experiment': {
@@ -279,11 +279,36 @@ describe('get-treatments', () => {
279279
}, 1);
280280
});
281281

282-
test('should be 200 if options.properties is valid (POST)', async () => {
282+
test('should be 200 if properties is valid (POST)', async () => {
283283
const response = await request(app)
284284
.post('/client/get-treatments?key=test&split-names=my-experiment')
285285
.send({
286-
options: { properties: { package: 'premium', admin: true, discount: 50 } },
286+
properties: { package: 'premium', admin: true, discount: 50 },
287+
})
288+
.set('Authorization', 'test');
289+
expectOkMultipleResults(response, 200, {
290+
'my-experiment': {
291+
treatment: 'on',
292+
},
293+
}, 1);
294+
});
295+
296+
test('should be 200 if properties is invalid (GET)', async () => {
297+
const response = await request(app)
298+
.get('/client/get-treatments?key=test&split-names=my-experiment&properties={"foo": {"bar": 1}}')
299+
.set('Authorization', 'test');
300+
expectOkMultipleResults(response, 200, {
301+
'my-experiment': {
302+
treatment: 'on',
303+
},
304+
}, 1);
305+
});
306+
307+
test('should be 200 if properties is invalid (POST)', async () => {
308+
const response = await request(app)
309+
.post('/client/get-treatments?key=test&split-names=my-experiment')
310+
.send({
311+
properties: { foo: { bar: 1 } },
287312
})
288313
.set('Authorization', 'test');
289314
expectOkMultipleResults(response, 200, {

client/__tests__/treatmentsByFlagSets.test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,35 @@ describe('get-treatments-by-sets', () => {
274274
expectOkMultipleResults(response, 200, expectedPinkResults, 5);
275275
});
276276

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

284-
test('should be 200 if options.properties is valid (POST)', async () => {
284+
test('should be 200 if properties is valid (POST)', async () => {
285285
const response = await request(app)
286286
.post('/client/get-treatments-by-sets?key=test&flag-sets=set_green')
287287
.send({
288-
options: { properties: { package: 'premium', admin: true, discount: 50 } },
288+
properties: { package: 'premium', admin: true, discount: 50 },
289+
})
290+
.set('Authorization', 'key_green');
291+
expect(response.status).toBe(200);
292+
});
293+
294+
test('should be 200 if properties is invalid (GET)', async () => {
295+
const response = await request(app)
296+
.get('/client/get-treatments-by-sets?key=test&flag-sets=set_green&properties={"foo": {"bar": 1}}')
297+
.set('Authorization', 'key_green');
298+
expect(response.status).toBe(200);
299+
});
300+
301+
test('should be 200 if properties is invalid (POST)', async () => {
302+
const response = await request(app)
303+
.post('/client/get-treatments-by-sets?key=test&flag-sets=set_green')
304+
.send({
305+
properties: { foo: { bar: 1 } },
289306
})
290307
.set('Authorization', 'key_green');
291308
expect(response.status).toBe(200);

client/__tests__/treatmentsWithConfig.test.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ describe('get-treatments-with-config', () => {
253253
}, 3);
254254
});
255255

256-
test('should be 200 if options.properties is valid (GET)', async () => {
256+
test('should be 200 if properties is valid (GET)', async () => {
257257
const response = await request(app)
258-
.get('/client/get-treatments-with-config?key=test&split-names=my-experiment&options={"properties":{"package":"premium","admin":true,"discount":50}}')
258+
.get('/client/get-treatments-with-config?key=test&split-names=my-experiment&properties={"package":"premium","admin":true,"discount":50}')
259259
.set('Authorization', 'test');
260260
expectOkMultipleResults(response, 200, {
261261
'my-experiment': {
@@ -265,11 +265,38 @@ describe('get-treatments-with-config', () => {
265265
}, 1);
266266
});
267267

268-
test('should be 200 if options.properties is valid (POST)', async () => {
268+
test('should be 200 if properties is valid (POST)', async () => {
269269
const response = await request(app)
270270
.post('/client/get-treatments-with-config?key=test&split-names=my-experiment')
271271
.send({
272-
options: { properties: { package: 'premium', admin: true, discount: 50 } },
272+
properties: { package: 'premium', admin: true, discount: 50 },
273+
})
274+
.set('Authorization', 'test');
275+
expectOkMultipleResults(response, 200, {
276+
'my-experiment': {
277+
treatment: 'on',
278+
config: '{"desc" : "this applies only to ON treatment"}',
279+
},
280+
}, 1);
281+
});
282+
283+
test('should be 200 if properties is invalid (GET)', async () => {
284+
const response = await request(app)
285+
.get('/client/get-treatments-with-config?key=test&split-names=my-experiment&properties={"foo": {"bar": 1}}')
286+
.set('Authorization', 'test');
287+
expectOkMultipleResults(response, 200, {
288+
'my-experiment': {
289+
treatment: 'on',
290+
config: '{"desc" : "this applies only to ON treatment"}',
291+
},
292+
}, 1);
293+
});
294+
295+
test('should be 200 if properties is invalid (POST)', async () => {
296+
const response = await request(app)
297+
.post('/client/get-treatments-with-config?key=test&split-names=my-experiment')
298+
.send({
299+
properties: { foo: { bar: 1 } },
273300
})
274301
.set('Authorization', 'test');
275302
expectOkMultipleResults(response, 200, {

client/__tests__/treatmentsWithConfigByFlagSets.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,38 @@ describe('get-treatments-with-config-by-sets', () => {
249249
.set('Authorization', 'key_pink');
250250
expectOkMultipleResults(response, 200, expectedPinkResultsWithConfig, 5);
251251
});
252+
253+
test('should be 200 if properties is valid (GET)', async () => {
254+
const response = await request(app)
255+
.get('/client/get-treatments-with-config-by-sets?key=test&flag-sets=set_green&properties={"package":"premium","admin":true,"discount":50}')
256+
.set('Authorization', 'key_green');
257+
expect(response.status).toBe(200);
258+
});
259+
260+
test('should be 200 if properties is valid (POST)', async () => {
261+
const response = await request(app)
262+
.post('/client/get-treatments-with-config-by-sets?key=test&flag-sets=set_green')
263+
.send({
264+
properties: { package: 'premium', admin: true, discount: 50 },
265+
})
266+
.set('Authorization', 'key_green');
267+
expect(response.status).toBe(200);
268+
});
269+
270+
test('should be 200 if properties is invalid (GET)', async () => {
271+
const response = await request(app)
272+
.get('/client/get-treatments-with-config-by-sets?key=test&flag-sets=set_green&properties={"foo": {"bar": 1}}')
273+
.set('Authorization', 'key_green');
274+
expect(response.status).toBe(200);
275+
});
276+
277+
test('should be 200 if properties is invalid (POST)', async () => {
278+
const response = await request(app)
279+
.post('/client/get-treatments-with-config-by-sets?key=test&flag-sets=set_green')
280+
.send({
281+
properties: { foo: { bar: 1 } },
282+
})
283+
.set('Authorization', 'key_green');
284+
expect(response.status).toBe(200);
285+
});
252286
});

0 commit comments

Comments
 (0)