Skip to content

Commit bc94b6b

Browse files
authored
Merge pull request #769 from splitio/add_default_treatment_to_split_view
Add defaultTreatment to SplitView
2 parents be2c8c7 + 31501b3 commit bc94b6b

File tree

12 files changed

+48
-28
lines changed

12 files changed

+48
-28
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
10.24.0 (October XX, 2023)
2+
- Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225).
3+
- Updated @splitsoftware/splitio-commons package to version 1.10.0 that includes vulnerability fixes, and adds the `defaultTreatment` property to the `SplitView` object.
4+
15
10.23.1 (September 22, 2023)
26
- Updated @splitsoftware/splitio-commons package to version 1.9.1. This update removes the handler for 'unload' DOM events, that can prevent browsers from being able to put pages in the back/forward cache for faster back and forward loads (Related to issue https://github.com/splitio/javascript-client/issues/759).
37

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"node": ">=6"
4141
},
4242
"dependencies": {
43-
"@splitsoftware/splitio-commons": "1.9.1",
43+
"@splitsoftware/splitio-commons": "1.10.0",
4444
"@types/google.analytics": "0.0.40",
4545
"@types/ioredis": "^4.28.0",
4646
"bloom-filters": "^3.0.0",
@@ -100,7 +100,7 @@
100100
"check:version": "cross-env NODE_ENV=test tape -r ./ts-node.register src/settings/__tests__/defaults.spec.js",
101101
"test-browser": "npm run test-browser-unit && npm run test-browser-e2e",
102102
"test-browser-unit": "cross-env NODE_ENV=test karma start karma/unit.karma.conf.js",
103-
"test-browser-e2e": "npm run test-browser-e2e-online && npm run test-browser-e2e-offline && npm run test-browser-e2e-destroy && npm run test-browser-e2e-errorCatching && npm run test-browser-e2e-push && npm run test-browser-e2e-gaIntegration",
103+
"test-browser-e2e": "npm run test-browser-e2e-online && npm run test-browser-e2e-offline && npm run test-browser-e2e-destroy && npm run test-browser-e2e-errorCatching && npm run test-browser-e2e-push",
104104
"test-browser-e2e-online": "cross-env NODE_ENV=test karma start karma/e2e.online.karma.conf.js",
105105
"test-browser-e2e-offline": "cross-env NODE_ENV=test karma start karma/e2e.offline.karma.conf.js",
106106
"test-browser-e2e-destroy": "cross-env NODE_ENV=test karma start karma/e2e.destroy.karma.conf.js",

src/__tests__/browserSuites/manager.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export default async function (settings, fetchMock, assert) {
3939
'killed': mockSplits.splits[index].killed,
4040
'changeNumber': mockSplits.splits[index].changeNumber,
4141
'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment),
42-
'configs': mockSplits.splits[index].configurations || {}
42+
'configs': mockSplits.splits[index].configurations || {},
43+
'defaultTreatment': mockSplits.splits[index].defaultTreatment
4344
});
4445

4546
assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.');

src/__tests__/browserSuites/ready-promise.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function assertGetTreatmentWhenReady(assert, client) {
3131
function assertGetTreatmentControlNotReady(assert, client) {
3232
consoleSpy.log.resetHistory();
3333
assert.equal(client.getTreatment('hierarchical_splits_test'), 'control', 'We should get control if client is not ready.');
34-
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
34+
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready, results may be incorrect for feature flag hierarchical_splits_test. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
3535
}
3636

3737
function assertGetTreatmentControlNotReadyOnDestroy(assert, client) {

src/__tests__/nodeSuites/manager.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export default async function (settings, fetchMock, assert) {
3838
'killed': mockSplits.splits[index].killed,
3939
'changeNumber': mockSplits.splits[index].changeNumber,
4040
'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment),
41-
'configs': mockSplits.splits[index].configurations || {}
41+
'configs': mockSplits.splits[index].configurations || {},
42+
'defaultTreatment': mockSplits.splits[index].defaultTreatment
4243
});
4344

4445
assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.');

src/__tests__/nodeSuites/ready-promise.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function assertGetTreatmentWhenReady(assert, client, key) {
2828
function assertGetTreatmentControlNotReady(assert, client, key) {
2929
consoleSpy.log.resetHistory();
3030
assert.equal(client.getTreatment(key, 'hierarchical_splits_test'), 'control', 'We should get control if client is not ready.');
31-
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
31+
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready, results may be incorrect for feature flag hierarchical_splits_test. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
3232
}
3333

3434
function assertGetTreatmentControlNotReadyOnDestroy(assert, client, key) {

src/__tests__/offline/browser.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ tape('Browser offline mode', function (assert) {
166166

167167
// Manager tests
168168
const expectedSplitView1 = {
169-
name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {}
169+
name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {}, defaultTreatment: 'control'
170170
};
171171
const expectedSplitView2 = {
172-
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }
172+
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }, defaultTreatment: 'control'
173173
};
174174
assert.deepEqual(manager.names(), ['testing_split', 'testing_split_with_config']);
175175
assert.deepEqual(manager.split('testing_split'), expectedSplitView1);
@@ -267,7 +267,7 @@ tape('Browser offline mode', function (assert) {
267267

268268
// Manager tests
269269
const expectedSplitView3 = {
270-
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {}
270+
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {}, defaultTreatment: 'control'
271271
};
272272
assert.deepEqual(manager.names(), ['testing_split', 'testing_split_2', 'testing_split_3', 'testing_split_with_config']);
273273
assert.deepEqual(manager.split('testing_split'), expectedSplitView1);

src/__tests__/offline/node.spec.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,15 @@ function ManagerDotSplitTests(assert) {
249249

250250
const expectedView1 = {
251251
name: 'testing_split', changeNumber: 0, killed: false, trafficType: 'localhost',
252-
treatments: ['on'], configs: {}
252+
treatments: ['on'], configs: {}, defaultTreatment: 'control'
253253
};
254254
const expectedView2 = {
255255
name: 'testing_split2', changeNumber: 0, killed: false, trafficType: 'localhost',
256-
treatments: ['off'], configs: {}
256+
treatments: ['off'], configs: {}, defaultTreatment: 'control'
257257
};
258258
const expectedView3 = {
259259
name: 'testing_split3', changeNumber: 0, killed: false, trafficType: 'localhost',
260-
treatments: ['custom_treatment'], configs: {}
260+
treatments: ['custom_treatment'], configs: {}, defaultTreatment: 'control'
261261
};
262262

263263
assert.deepEqual(manager.split('testing_split'), expectedView1);
@@ -289,15 +289,17 @@ function ManagerDotYamlTests(mockFileName, assert) {
289289
killed: false,
290290
trafficType: 'localhost',
291291
treatments: ['on'],
292-
configs: {}
292+
configs: {},
293+
defaultTreatment: 'control'
293294
};
294295
const expectedView2 = {
295296
name: 'testing_split_only_wl',
296297
changeNumber: 0,
297298
killed: false,
298299
trafficType: 'localhost',
299300
treatments: ['whitelisted'],
300-
configs: {}
301+
configs: {},
302+
defaultTreatment: 'control'
301303
};
302304
const expectedView3 = {
303305
name: 'testing_split_with_wl',
@@ -308,13 +310,19 @@ function ManagerDotYamlTests(mockFileName, assert) {
308310
configs: {
309311
not_in_whitelist: '{"color": "green"}',
310312
multi_key_wl: '{"color": "brown"}'
311-
}
313+
},
314+
defaultTreatment: 'control'
312315
};
313316
const expectedView4 = {
314-
name: 'testing_split_off_with_config', changeNumber: 0, killed: false, trafficType: 'localhost',
315-
treatments: ['off'], configs: {
317+
name: 'testing_split_off_with_config',
318+
changeNumber: 0,
319+
killed: false,
320+
trafficType: 'localhost',
321+
treatments: ['off'],
322+
configs: {
316323
off: '{"color": "green"}'
317-
}
324+
},
325+
defaultTreatment: 'control'
318326
};
319327

320328
assert.deepEqual(manager.split('testing_split_on'), expectedView1);

ts-tests/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ splitView = {
123123
changeNumber: 18294,
124124
configs: {
125125
off: '{"dimensions":"{\"height\":20,\"width\":40}"}'
126-
}
126+
},
127+
defaultTreatment: 'off'
127128
};
128129
splitViews = [splitView];
129130

0 commit comments

Comments
 (0)