Skip to content

Commit

Permalink
Merge pull request #798 from splitio/unsupported_matcher_type
Browse files Browse the repository at this point in the history
[Semver] Add flags spec query param
  • Loading branch information
NicoZelaya committed Apr 30, 2024
2 parents 8e8b8b0 + 3965467 commit 6f130c9
Show file tree
Hide file tree
Showing 54 changed files with 319 additions and 318 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
@@ -1,6 +1,7 @@
10.26.0 (April XX, 2024)
- Updated @splitsoftware/splitio-commons package to version 1.14.0 that includes minor updates:
- Added support for Semver matchers.
- Updated Split API client to include the flags spec version query parameter for the `splitChanges` and `auth` endpoints.

10.25.2 (March 26, 2024)
- Updated some transitive dependencies for vulnerability fixes.
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio",
"version": "10.25.3-rc.1",
"version": "10.25.3-rc.2",
"description": "Split SDK",
"files": [
"README.md",
Expand Down Expand Up @@ -40,7 +40,7 @@
"node": ">=6"
},
"dependencies": {
"@splitsoftware/splitio-commons": "1.13.2-rc.6",
"@splitsoftware/splitio-commons": "1.13.2-rc.7",
"@types/google.analytics": "0.0.40",
"@types/ioredis": "^4.28.0",
"bloom-filters": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/browserSuites/evaluations-semver.spec.js
Expand Up @@ -25,8 +25,8 @@ const config = {

export default async function (fetchMock, assert) {

fetchMock.getOnce(config.urls.sdk + '/splitChanges?since=-1', { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(config.urls.sdk + '/splitChanges?since=1675259356568', { status: 200, body: { splits: [], since: 1675259356568, till: 1675259356568 } });
fetchMock.getOnce(config.urls.sdk + '/splitChanges?s=1.1&since=-1', { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(config.urls.sdk + '/splitChanges?s=1.1&since=1675259356568', { status: 200, body: { splits: [], since: 1675259356568, till: 1675259356568 } });
fetchMock.getOnce(config.urls.sdk + '/mySegments/emi%40split.io', { status: 200, body: { mySegments: [] } });
fetchMock.getOnce(config.urls.sdk + '/mySegments/2nd', { status: 200, body: { mySegments: [] } });

Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/browserSuites/fetch-specific-splits.spec.js
Expand Up @@ -25,9 +25,9 @@ export function fetchSpecificSplits(fetchMock, assert) {
const queryString = queryStrings[i] || '';
let factory;

fetchMock.getOnce(urls.sdk + '/splitChanges?since=-1' + queryString, { status: 200, body: { splits: [], since: -1, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?since=1457552620999' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?since=1457552620999' + queryString, function () {
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.1&since=-1' + queryString, { status: 200, body: { splits: [], since: -1, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.1&since=1457552620999' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.1&since=1457552620999' + queryString, function () {
factory.client().destroy().then(() => {
assert.pass(`splitFilters #${i}`);
});
Expand Down Expand Up @@ -70,8 +70,8 @@ export function fetchSpecificSplitsForFlagSets(fetchMock, assert) {
const queryString = '&sets=4_valid,set_2,set_3,set_ww,set_x';
fetchMock.get(baseUrls.sdk + '/mySegments/nicolas%40split.io', { status: 200, body: { 'mySegments': [] } });

fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=-1' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 }});
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1457552620999' + queryString, async function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=-1' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 }});
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1457552620999' + queryString, async function () {
t.pass('flag set query correctly formed');
t.true(logSpy.calledWithExactly('[WARN] splitio => settings: bySet filter value "set_x " has extra whitespace, trimming.'));
t.true(logSpy.calledWithExactly('[WARN] splitio => settings: you passed invalid+, flag set must adhere to the regular expressions /^[a-z0-9][_a-z0-9]{0,49}$/. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. invalid+ was discarded.'));
Expand Down
24 changes: 12 additions & 12 deletions src/__tests__/browserSuites/flag-sets.spec.js
Expand Up @@ -24,12 +24,12 @@ export default function flagSets(fetchMock, t) {
let manager;

// Receive split change with 1 split belonging to set_1 & set_2 and one belonging to set_3
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=-1&sets=set_1,set_2', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=-1&sets=set_1,set_2', function () {
return { status: 200, body: splitChange2};
});

// Receive split change with 1 split belonging to set_1 only
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602796638344&sets=set_1,set_2', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602796638344&sets=set_1,set_2', function () {
// stored feature flags before update
const storedFlags = manager.splits();
assert.true(storedFlags.length === 1, 'only one feature flag should be added');
Expand All @@ -41,7 +41,7 @@ export default function flagSets(fetchMock, t) {
});

// Receive split change with 1 split belonging to set_3 only
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602797638344&sets=set_1,set_2', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602797638344&sets=set_1,set_2', function () {
// stored feature flags before update
const storedFlags = manager.splits();
assert.true(storedFlags.length === 1);
Expand All @@ -52,7 +52,7 @@ export default function flagSets(fetchMock, t) {
return { status: 200, body: splitChange0};
});

fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602798638344&sets=set_1,set_2', async function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602798638344&sets=set_1,set_2', async function () {
// stored feature flags before update
const storedFlags = manager.splits();
assert.true(storedFlags.length === 0, 'the feature flag should be removed');
Expand All @@ -75,12 +75,12 @@ export default function flagSets(fetchMock, t) {
let manager;

// Receive split change with 1 split belonging to set_1 & set_2 and one belonging to set_3
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=-1', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=-1', function () {
return { status: 200, body: splitChange2};
});

// Receive split change with 1 split belonging to set_1 only
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602796638344', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602796638344', function () {
// stored feature flags before update
const storedFlags = manager.splits();
assert.true(storedFlags.length === 2, 'every feature flag should be added');
Expand All @@ -94,7 +94,7 @@ export default function flagSets(fetchMock, t) {
});

// Receive split change with 1 split belonging to set_3 only
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602797638344', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602797638344', function () {
// stored feature flags before update
const storedFlags = manager.splits();
assert.true(storedFlags.length === 2);
Expand All @@ -107,7 +107,7 @@ export default function flagSets(fetchMock, t) {
return { status: 200, body: splitChange0};
});

fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602798638344', async function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602798638344', async function () {
// stored feature flags before update
const storedFlags = manager.splits();
assert.true(storedFlags.length === 2);
Expand Down Expand Up @@ -137,11 +137,11 @@ export default function flagSets(fetchMock, t) {

fetchMock.get(baseUrls.sdk + '/mySegments/nicolas%40split.io', { status: 200, body: { 'mySegments': [] } });
// Receive split change with 1 split belonging to set_1 & set_2 and one belonging to set_3
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=-1&sets=set_1', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=-1&sets=set_1', function () {
return { status: 200, body: splitChange2};
});

fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602796638344&sets=set_1', async function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602796638344&sets=set_1', async function () {
// stored feature flags before update
assert.deepEqual(client.getTreatmentsByFlagSet('set_1'), {workm: 'on'}, 'only the flag in set_1 can be evaluated');
assert.deepEqual(client.getTreatmentsByFlagSet('set_2'), {}, 'only the flag in set_1 can be evaluated');
Expand Down Expand Up @@ -174,11 +174,11 @@ export default function flagSets(fetchMock, t) {

fetchMock.get(baseUrls.sdk + '/mySegments/nicolas%40split.io', { status: 200, body: { 'mySegments': [] } });
// Receive split change with 1 split belonging to set_1 & set_2 and one belonging to set_3
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=-1', function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=-1', function () {
return { status: 200, body: splitChange2};
});

fetchMock.getOnce(baseUrls.sdk + '/splitChanges?since=1602796638344', async function () {
fetchMock.getOnce(baseUrls.sdk + '/splitChanges?s=1.1&since=1602796638344', async function () {
// stored feature flags before update
assert.deepEqual(client.getTreatmentsByFlagSet('set_1'), {workm: 'on'}, 'all flags can be evaluated');
assert.deepEqual(client.getTreatmentsByFlagSet('set_2'), {workm: 'on'}, 'all flags can be evaluated');
Expand Down
Expand Up @@ -101,8 +101,8 @@ export default function (fetchMock, assert) {

// Mock GET endpoints before creating the client
const settings = settingsFactory(config);
fetchMock.getOnce(url(settings, '/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(url(settings, '/splitChanges?since=1457552620999'), { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.1&since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.1&since=1457552620999'), { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(url(settings, `/mySegments/${encodeURIComponent(config.core.key)}`), { status: 200, body: { mySegments: [] } });

// Init Split client
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/browserSuites/impressions.debug.spec.js
Expand Up @@ -21,8 +21,8 @@ const settings = settingsFactory({

export default function (fetchMock, assert) {
// Mocking this specific route to make sure we only get the items we want to test from the handlers.
fetchMock.getOnce(url(settings, '/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.1&since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?s=1.1&since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(url(settings, '/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });

const splitio = SplitFactory({
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/browserSuites/impressions.none.spec.js
Expand Up @@ -41,8 +41,8 @@ const config = {

export default async function (fetchMock, assert) {
// Mocking this specific route to make sure we only get the items we want to test from the handlers.
fetchMock.getOnce(url(settings, '/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.1&since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?s=1.1&since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(url(settings, '/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });
fetchMock.get(url(settings, '/mySegments/emma%40split.io'), { status: 200, body: mySegmentsFacundo });

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/browserSuites/impressions.spec.js
Expand Up @@ -24,8 +24,8 @@ let truncatedTimeFrame;

export default function (fetchMock, assert) {
// Mocking this specific route to make sure we only get the items we want to test from the handlers.
fetchMock.getOnce(url(settings, '/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.1&since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?s=1.1&since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(url(settings, '/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });

const splitio = SplitFactory({
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/browserSuites/manager.spec.js
Expand Up @@ -4,7 +4,7 @@ import map from 'lodash/map';
import { url } from '../testUtils';

export default async function (settings, fetchMock, assert) {
fetchMock.getOnce({ url: url(settings, '/splitChanges?since=-1'), overwriteRoutes: true }, { status: 200, body: splitChangesMockReal });
fetchMock.getOnce({ url: url(settings, '/splitChanges?s=1.1&since=-1'), overwriteRoutes: true }, { status: 200, body: splitChangesMockReal });

const mockSplits = splitChangesMockReal;

Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/browserSuites/push-corner-cases.spec.js
Expand Up @@ -71,13 +71,13 @@ export function testSplitKillOnReadyFromCache(fetchMock, assert) {
});

// 1 auth request
fetchMock.getOnce(url(settings, `/v2/auth?users=${encodeURIComponent(userKey)}`), { status: 200, body: authPushEnabledNicolas });
fetchMock.getOnce(url(settings, `/v2/auth?s=1.1&users=${encodeURIComponent(userKey)}`), { status: 200, body: authPushEnabledNicolas });
// 2 mySegments requests: initial sync and after SSE opened
fetchMock.get({ url: url(settings, '/mySegments/nicolas%40split.io'), repeat: 2 }, { status: 200, body: { mySegments: [] } });

// 2 splitChanges request: initial sync and after SSE opened. Sync after SPLIT_KILL is not performed because SplitsSyncTask is "executing"
fetchMock.getOnce(url(settings, '/splitChanges?since=25'), { status: 200, body: splitChangesMock1 }, { delay: MILLIS_SPLIT_CHANGES_RESPONSE, /* delay response */ });
fetchMock.getOnce(url(settings, `/splitChanges?since=${splitChangesMock1.till}`), { status: 200, body: { splits: [], since: splitChangesMock1.till, till: splitChangesMock1.till } }, { delay: MILLIS_SPLIT_CHANGES_RESPONSE - 100, /* delay response */ });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.1&since=25'), { status: 200, body: splitChangesMock1 }, { delay: MILLIS_SPLIT_CHANGES_RESPONSE, /* delay response */ });
fetchMock.getOnce(url(settings, `/splitChanges?s=1.1&since=${splitChangesMock1.till}`), { status: 200, body: { splits: [], since: splitChangesMock1.till, till: splitChangesMock1.till } }, { delay: MILLIS_SPLIT_CHANGES_RESPONSE - 100, /* delay response */ });

fetchMock.get(new RegExp('.*'), function (url) {
assert.fail('unexpected GET request with url: ' + url);
Expand Down

0 comments on commit 6f130c9

Please sign in to comment.