diff --git a/package-lock.json b/package-lock.json index 976d0a61a..bf1a63fb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@splitsoftware/splitio", - "version": "10.23.1", + "version": "10.23.2-rc.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio", - "version": "10.23.1", + "version": "10.23.2-rc.0", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "1.9.1", + "@splitsoftware/splitio-commons": "1.9.2-rc.0", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", @@ -802,9 +802,9 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.9.1.tgz", - "integrity": "sha512-+1lFUBj+Jgfd8l7nT49+rZodwgZXJ6c20+4PPb0O+iTmUZXHtYvfS2AK8A9j6QREubeccc6UMlfjH3SQVgwEbg==", + "version": "1.9.2-rc.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.9.2-rc.0.tgz", + "integrity": "sha512-sKsaIAELQDwA/LUpZflVkkrtBzaghrz1tqnpLV3iVeiXBWK3Im3pEHoMm4bwa3wtoawbInrFbIdN+oIXrCHkRw==", "dependencies": { "tslib": "^2.3.1" }, @@ -8312,9 +8312,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.9.1.tgz", - "integrity": "sha512-+1lFUBj+Jgfd8l7nT49+rZodwgZXJ6c20+4PPb0O+iTmUZXHtYvfS2AK8A9j6QREubeccc6UMlfjH3SQVgwEbg==", + "version": "1.9.2-rc.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.9.2-rc.0.tgz", + "integrity": "sha512-sKsaIAELQDwA/LUpZflVkkrtBzaghrz1tqnpLV3iVeiXBWK3Im3pEHoMm4bwa3wtoawbInrFbIdN+oIXrCHkRw==", "requires": { "tslib": "^2.3.1" } diff --git a/package.json b/package.json index 10c413c7f..f8780ffa3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio", - "version": "10.23.1", + "version": "10.23.2-rc.0", "description": "Split SDK", "files": [ "README.md", @@ -40,7 +40,7 @@ "node": ">=6" }, "dependencies": { - "@splitsoftware/splitio-commons": "1.9.1", + "@splitsoftware/splitio-commons": "1.9.2-rc.0", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", diff --git a/src/__tests__/browserSuites/manager.spec.js b/src/__tests__/browserSuites/manager.spec.js index 856242a5d..a8f1ecd20 100644 --- a/src/__tests__/browserSuites/manager.spec.js +++ b/src/__tests__/browserSuites/manager.spec.js @@ -39,7 +39,8 @@ export default async function (settings, fetchMock, assert) { 'killed': mockSplits.splits[index].killed, 'changeNumber': mockSplits.splits[index].changeNumber, 'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment), - 'configs': mockSplits.splits[index].configurations || {} + 'configs': mockSplits.splits[index].configurations || {}, + 'sets': mockSplits.splits[index].sets || [] }); assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.'); diff --git a/src/__tests__/browserSuites/ready-from-cache.spec.js b/src/__tests__/browserSuites/ready-from-cache.spec.js index c274c8e04..0ab98eb87 100644 --- a/src/__tests__/browserSuites/ready-from-cache.spec.js +++ b/src/__tests__/browserSuites/ready-from-cache.spec.js @@ -477,7 +477,7 @@ export default function (fetchMock, assert) { events: 'https://events.baseurl/readyFromCache_5' }; localStorage.clear(); - t.plan(7); + t.plan(6); fetchMock.getOnce(testUrls.sdk + '/splitChanges?since=-1&names=p1__split,p2__split', { status: 200, body: { splits: [splitDeclarations.p1__split, splitDeclarations.p2__split], since: -1, till: 1457552620999 } }, { delay: 10 }); // short delay to let emit SDK_READY_FROM_CACHE // fetchMock.getOnce(testUrls.sdk + '/splitChanges?since=1457552620999&names=p1__split', { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } }); @@ -504,7 +504,8 @@ export default function (fetchMock, assert) { const manager = splitio.manager(); client.once(client.Event.SDK_READY_FROM_CACHE, () => { - t.deepEqual(manager.names(), ['p2__split'], 'stored p3__split must be removed because doesn\'t match the filter'); + t.fail('It should not emit SDK_READY_FROM_CACHE because localstorage is cleaned and there isn\'t cached data'); + t.end(); }); client.once(client.Event.SDK_READY, () => { @@ -521,6 +522,46 @@ export default function (fetchMock, assert) { }); }); + assert.test(t => { // Testing when we start with cached data with split filter, and the same split filter is provided in the config + const testUrls = { + sdk: 'https://sdk.baseurl/readyFromCache_5', + events: 'https://events.baseurl/readyFromCache_5' + }; + + localStorage.clear(); + t.plan(1); + + fetchMock.getOnce(testUrls.sdk + '/splitChanges?since=25&names=p2__split,p3__split', { status: 200, body: { splits: [splitDeclarations.p2__split, splitDeclarations.p3__split], since: -1, till: 1457552620999 } }, { delay: 10 }); // short delay to let emit SDK_READY_FROM_CACHE + fetchMock.getOnce(testUrls.sdk + '/mySegments/nicolas%40split.io', { status: 200, body: { mySegments: [] } }); + + localStorage.setItem('some_user_item', 'user_item'); + localStorage.setItem('readyFromCache_5.SPLITIO.splits.till', 25); + localStorage.setItem('readyFromCache_5.SPLITIO.splits.filterQuery', '&names=p2__split,p3__split'); + localStorage.setItem('readyFromCache_5.SPLITIO.split.p2__split', JSON.stringify(splitDeclarations.p2__split)); + localStorage.setItem('readyFromCache_5.SPLITIO.split.p3__split', JSON.stringify(splitDeclarations.p3__split)); + + const splitio = SplitFactory({ + ...baseConfig, + storage: { + type: 'LOCALSTORAGE', + prefix: 'readyFromCache_5' + }, + urls: testUrls, + sync: { + splitFilters: [{ type: 'byName', values: ['p2__split', 'p3__split'] }] + }, + debug: true + }); + const client = splitio.client(); + + client.once(client.Event.SDK_READY_FROM_CACHE, () => { + t.assert('It should emit SDK_READY_FROM_CACHE because there is cached data for the same queryFilter'); + client.destroy().then(() => { + t.end(); + }); + }); + }); + assert.test(t => { // Testing when we start from scratch, and a valid split filter config const testUrls = { sdk: 'https://sdk.baseurl/readyFromCache_5B', @@ -740,7 +781,7 @@ export default function (fetchMock, assert) { events: 'https://events.baseurl/readyFromCache_9' }; localStorage.clear(); - t.plan(7); + t.plan(6); fetchMock.getOnce(testUrls.sdk + '/splitChanges?since=-1&names=no%20exist%20trim,no_exist,p3__split&prefixes=no%20exist%20trim,p2', { status: 200, body: { splits: [splitDeclarations.p2__split, splitDeclarations.p3__split], since: -1, till: 1457552620999 } }, { delay: 10 }); // short delay to let emit SDK_READY_FROM_CACHE fetchMock.getOnce(testUrls.sdk + '/mySegments/nicolas%40split.io', { status: 200, body: { mySegments: [] } }); @@ -766,10 +807,6 @@ export default function (fetchMock, assert) { const client = splitio.client(); const manager = splitio.manager(); - client.once(client.Event.SDK_READY_FROM_CACHE, () => { - t.deepEqual(manager.names(), ['p2__split'], 'stored p1__split must be removed because doesn\'t match the filter'); - }); - client.once(client.Event.SDK_READY, () => { t.deepEqual(manager.names(), ['p3__split', 'p2__split'], 'active splits should be present for evaluation'); diff --git a/src/__tests__/browserSuites/telemetry.spec.js b/src/__tests__/browserSuites/telemetry.spec.js index 03eeb21e9..d58e56923 100644 --- a/src/__tests__/browserSuites/telemetry.spec.js +++ b/src/__tests__/browserSuites/telemetry.spec.js @@ -54,7 +54,7 @@ export default async function telemetryBrowserSuite(fetchMock, assert) { const data = JSON.parse(opts.body); // Validate last successful sync - assert.deepEqual(Object.keys(data.lS), ['sp', 'ms', 'te'], 'Successful splitChanges, mySegments and metrics/config requests'); + assert.deepEqual(Object.keys(data.lS), ['ms', 'sp', 'te'], 'Successful splitChanges, mySegments and metrics/config requests'); lastSync = data.lS; delete data.lS; // Validate http and method latencies @@ -106,7 +106,8 @@ export default async function telemetryBrowserSuite(fetchMock, assert) { oM: 0, st: 'memory', aF: 1, rF: 0, sE: false, rR: { sp: 99999, ms: 60, im: 300, ev: 60, te: 1 } /* override featuresRefreshRate */, uO: { s: true, e: true, a: false, st: false, t: true } /* override sdk, events and telemetry URLs */, - iQ: 30000, eQ: 500, iM: 0, iL: false, hP: false, nR: 1 /* 1 non ready usage */, t: [], i: [], uC: 2 /* Default GRANTED */ + iQ: 30000, eQ: 500, iM: 0, iL: false, hP: false, nR: 1 /* 1 non ready usage */, t: [], i: [], uC: 2 /* Default GRANTED */, + fsT: 0, fsI: 0 }, 'metrics/config JSON payload should be the expected'); finish.next(); diff --git a/src/__tests__/nodeSuites/manager.spec.js b/src/__tests__/nodeSuites/manager.spec.js index 2658d2ebc..4d29bcbb6 100644 --- a/src/__tests__/nodeSuites/manager.spec.js +++ b/src/__tests__/nodeSuites/manager.spec.js @@ -38,7 +38,8 @@ export default async function (settings, fetchMock, assert) { 'killed': mockSplits.splits[index].killed, 'changeNumber': mockSplits.splits[index].changeNumber, 'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment), - 'configs': mockSplits.splits[index].configurations || {} + 'configs': mockSplits.splits[index].configurations || {}, + 'sets': mockSplits.splits[index].sets || [] }); assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.'); diff --git a/src/__tests__/nodeSuites/telemetry.spec.js b/src/__tests__/nodeSuites/telemetry.spec.js index da39b1134..25e096c94 100644 --- a/src/__tests__/nodeSuites/telemetry.spec.js +++ b/src/__tests__/nodeSuites/telemetry.spec.js @@ -100,7 +100,8 @@ export default async function telemetryNodejsSuite(key, fetchMock, assert) { oM: 0, st: 'memory', aF: 1, rF: 0, sE: false, rR: { sp: 99999, se: 60, im: 300, ev: 60, te: 1 } /* override featuresRefreshRate */, uO: { s: true, e: true, a: false, st: false, t: true } /* override sdk, events and telemetry URLs */, - iQ: 30000, eQ: 500, iM: 0, iL: false, hP: false, nR: 1 /* 1 non ready usage */, t: [], uC: 0 /* NA */ + iQ: 30000, eQ: 500, iM: 0, iL: false, hP: false, nR: 1 /* 1 non ready usage */, t: [], uC: 0 /* NA */, + fsT: 0, fsI: 0 }, 'metrics/config JSON payload should be the expected'); finish.next(); diff --git a/src/__tests__/offline/browser.spec.js b/src/__tests__/offline/browser.spec.js index ee3baf2fc..181cf6176 100644 --- a/src/__tests__/offline/browser.spec.js +++ b/src/__tests__/offline/browser.spec.js @@ -40,7 +40,8 @@ tape('Browser offline mode', function (assert) { testing_split: 'on', testing_split_with_config: { treatment: 'off', - config: '{ "color": "blue" }' + config: '{ "color": "blue" }', + sets: [] } }; @@ -166,10 +167,10 @@ tape('Browser offline mode', function (assert) { // Manager tests const expectedSplitView1 = { - name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {} + name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {}, sets: [] }; const expectedSplitView2 = { - name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' } + name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }, sets: [] }; assert.deepEqual(manager.names(), ['testing_split', 'testing_split_with_config']); assert.deepEqual(manager.split('testing_split'), expectedSplitView1); @@ -267,7 +268,7 @@ tape('Browser offline mode', function (assert) { // Manager tests const expectedSplitView3 = { - name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {} + name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {}, sets: [] }; assert.deepEqual(manager.names(), ['testing_split', 'testing_split_2', 'testing_split_3', 'testing_split_with_config']); assert.deepEqual(manager.split('testing_split'), expectedSplitView1); diff --git a/src/__tests__/offline/node.spec.js b/src/__tests__/offline/node.spec.js index 9fb3cb511..dfa74a98e 100644 --- a/src/__tests__/offline/node.spec.js +++ b/src/__tests__/offline/node.spec.js @@ -249,15 +249,18 @@ function ManagerDotSplitTests(assert) { const expectedView1 = { name: 'testing_split', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['on'], configs: {} + treatments: ['on'], configs: {}, + sets: [] }; const expectedView2 = { name: 'testing_split2', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['off'], configs: {} + treatments: ['off'], configs: {}, + sets: [] }; const expectedView3 = { name: 'testing_split3', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['custom_treatment'], configs: {} + treatments: ['custom_treatment'], configs: {}, + sets: [] }; assert.deepEqual(manager.split('testing_split'), expectedView1); @@ -289,7 +292,8 @@ function ManagerDotYamlTests(mockFileName, assert) { killed: false, trafficType: 'localhost', treatments: ['on'], - configs: {} + configs: {}, + sets: [] }; const expectedView2 = { name: 'testing_split_only_wl', @@ -297,7 +301,8 @@ function ManagerDotYamlTests(mockFileName, assert) { killed: false, trafficType: 'localhost', treatments: ['whitelisted'], - configs: {} + configs: {}, + sets: [] }; const expectedView3 = { name: 'testing_split_with_wl', @@ -308,13 +313,15 @@ function ManagerDotYamlTests(mockFileName, assert) { configs: { not_in_whitelist: '{"color": "green"}', multi_key_wl: '{"color": "brown"}' - } + }, + sets: [] }; const expectedView4 = { name: 'testing_split_off_with_config', changeNumber: 0, killed: false, trafficType: 'localhost', treatments: ['off'], configs: { off: '{"color": "green"}' - } + }, + sets: [] }; assert.deepEqual(manager.split('testing_split_on'), expectedView1); @@ -395,15 +402,15 @@ function MultipleInstancesTests(assert) { const expectedView1 = { name: 'testing_split', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['on'], configs: {} + treatments: ['on'], configs: {}, sets: [] }; const expectedView2 = { name: 'testing_split2', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['off'], configs: {} + treatments: ['off'], configs: {}, sets: [] }; const expectedView3 = { name: 'testing_split3', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['custom_treatment'], configs: {} + treatments: ['custom_treatment'], configs: {}, sets: [] }; assert.deepEqual(manager.split('testing_split'), expectedView1); diff --git a/src/settings/defaults/version.js b/src/settings/defaults/version.js index fc16e17c3..99f181e5a 100644 --- a/src/settings/defaults/version.js +++ b/src/settings/defaults/version.js @@ -1 +1 @@ -export const packageVersion = '10.23.1'; +export const packageVersion = '10.23.2-rc.0';