Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5cdfc25
removed modules provided by js-commons (except utils because some of …
EmilianoSanchez Nov 17, 2020
80d70b6
integration with js-commons: updated index and implemented getModules…
EmilianoSanchez Nov 17, 2020
48188ca
updated offline E2E tests
EmilianoSanchez Nov 17, 2020
5dd7a24
validation of Node E2E tests. polishing some tests. Commented metrics…
EmilianoSanchez Nov 20, 2020
3e36244
Merge branch 'js_commons_integration_baseline' into js_commons_integr…
EmilianoSanchez Nov 20, 2020
1f5091b
added default for key in LOCALHOST mode. removed unused overrideKeyAn…
EmilianoSanchez Nov 20, 2020
645f79c
Merge pull request #2 from NicoZelaya/js_commons_integration_updated_…
EmilianoSanchez Nov 20, 2020
4cdaca5
updated SplitToGa test
EmilianoSanchez Nov 25, 2020
8256339
minor changes
EmilianoSanchez Nov 25, 2020
1e7e8b2
removed testNoBase64Support
EmilianoSanchez Nov 25, 2020
76b1047
updated readiness E2E test
EmilianoSanchez Nov 25, 2020
0e0e67c
updates and config fix for TSC CommonJS build
EmilianoSanchez Nov 27, 2020
2b4d038
updates due to renames in JS-commons
EmilianoSanchez Dec 4, 2020
009fc92
deleted unused utils and their tests
EmilianoSanchez Dec 9, 2020
2e4c2c0
updated imports in E2E tests
EmilianoSanchez Dec 9, 2020
59b1716
Merge pull request #3 from NicoZelaya/js_commons_integration_updated_…
EmilianoSanchez Dec 9, 2020
9384569
Merge pull request #4 from NicoZelaya/js_commons_integration_utils_mi…
EmilianoSanchez Dec 9, 2020
1a5d195
updated UTs
EmilianoSanchez Dec 9, 2020
c2507a6
implementation of node and browser settings validation using js-commo…
EmilianoSanchez Dec 9, 2020
d5d0c3a
removed @TODO comment
EmilianoSanchez Dec 9, 2020
5c8fc13
updated E2E tests
EmilianoSanchez Dec 16, 2020
2c0e6bc
migrated UT
EmilianoSanchez Dec 16, 2020
37f05e9
migrated UT
EmilianoSanchez Dec 16, 2020
2b1db35
removed filterQueryString from getModules
EmilianoSanchez Dec 16, 2020
496d273
Merge pull request #5 from NicoZelaya/js_commons_integration_settings…
EmilianoSanchez Dec 16, 2020
90b5b8e
updated imports
EmilianoSanchez Dec 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
## transpiled code
/lib
/es
/umd
/umd*

## TS tests compilated files
/ts-tests/*.js
Expand Down
9 changes: 8 additions & 1 deletion karma/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ module.exports = {

webpack: {
mode: 'production',

/** Uncomment to debug with source files */
// mode: 'development',
// devtool: 'inline-source-map',

module: {
rules: [
{
Expand All @@ -65,7 +70,9 @@ module.exports = {
'targets': {
'ie': '10',
'node': '6'
}
},
// Required for CJS build with TSC: https://babeljs.io/docs/en/babel-preset-env/#modules
'modules': 'commonjs'
}]],
plugins: [['@babel/plugin-transform-runtime', {
// default values
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"dependencies": {
"@babel/runtime": "^7.10.2",
"@splitsoftware/js-commons": "file:../js-commons",
"@types/google.analytics": "0.0.40",
"@types/node": "^13.9.1",
"events": "3.1.0",
Expand Down Expand Up @@ -111,6 +112,8 @@
"posttest-ts-decls": "npm unlink && npm install",
"browser-test-suite": "npm run test-browser-ci && npm run test-browser-e2e-ci && npm run test-browser-offline && npm run test-browser-destroy && npm run test-browser-errors && npm run test-browser-gaintegration",
"node-test-suite": "npm run test-node && npm run test-node-e2e && npm run test-node-destroy && npm run test-node-offline && npm run test-node-redis && npm run test-node-errors",
"browser-e2e-test-suite": "npm run test-browser-e2e-ci && npm run test-browser-offline && npm run test-browser-destroy && npm run test-browser-errors && npm run test-browser-push && npm run test-browser-gaintegration",
"node-e2e-test-suite": "npm run test-node-e2e && npm run test-node-offline && npm run test-node-destroy && npm run test-node-errors && npm run test-node-push && npm run test-node-redis",
"test": "npm run browser-test-suite && npm run node-test-suite",
"canary": "npm run rebuild && npm publish --tag canary",
"stable": "npm run rebuild && npm publish"
Expand Down
20 changes: 11 additions & 9 deletions src/__tests__/browser.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import tape from 'tape-catch';
import fetchMock from './testUtils/fetchMock';
import { url } from './testUtils';
import evaluationsSuite from './browserSuites/evaluations.spec';
import impressionsSuite from './browserSuites/impressions.spec';
import impressionsSuiteDebug from './browserSuites/impressions.debug.spec';
import metricsSuite from './browserSuites/metrics.spec';
// import metricsSuite from './browserSuites/metrics.spec';
import impressionsListenerSuite from './browserSuites/impressions-listener.spec';
import readinessSuite from './browserSuites/readiness.spec';
import readyFromCache from './browserSuites/ready-from-cache.spec';
Expand Down Expand Up @@ -87,13 +88,13 @@ tape('## E2E CI Tests ##', function(assert) {
//If we change the mocks, we need to clear localstorage. Cleaning up after testing ensures "fresh data".
localStorage.clear();

fetchMock.get(settings.url('/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(settings.url('/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(settings.url('/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });
fetchMock.get(settings.url('/mySegments/nicolas%40split.io'), { status: 200, body: mySegmentsNicolas });
fetchMock.get(settings.url('/mySegments/marcio%40split.io'), { status: 200, body: mySegmentsMarcio });
fetchMock.post(settings.url('/testImpressions/bulk'), 200);
fetchMock.post(settings.url('/testImpressions/count'), 200);
fetchMock.get(url(settings, '/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(url(settings, '/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });
fetchMock.get(url(settings, '/mySegments/nicolas%40split.io'), { status: 200, body: mySegmentsNicolas });
fetchMock.get(url(settings, '/mySegments/marcio%40split.io'), { status: 200, body: mySegmentsMarcio });
fetchMock.post(url(settings, '/testImpressions/bulk'), 200);
fetchMock.post(url(settings, '/testImpressions/count'), 200);

/* Check client evaluations. */
assert.test('E2E / In Memory', evaluationsSuite.bind(null, configInMemory, fetchMock));
Expand All @@ -105,7 +106,8 @@ tape('## E2E CI Tests ##', function(assert) {
/* Check impression listener */
assert.test('E2E / Impression listener', impressionsListenerSuite);
/* Check metrics */
assert.test('E2E / Metrics', metricsSuite.bind(null, fetchMock));
// @TODO uncomment when telemetry is implemented
// assert.test('E2E / Metrics', metricsSuite.bind(null, fetchMock));
/* Check events */
assert.test('E2E / Events', withoutBindingTT.bind(null, fetchMock));
assert.test('E2E / Events with TT binded', bindingTT.bind(null, fetchMock));
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/browserSuites/events.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SplitFactory } from '../../';
import SettingsFactory from '../../utils/settings';
import { url } from '../testUtils';

const settings = SettingsFactory({
core: {
Expand Down Expand Up @@ -32,7 +33,7 @@ export function withoutBindingTT(fetchMock, assert) {

let tsStart, tsEnd;

fetchMock.postOnce(settings.url('/events/bulk'), (url, opts) => {
fetchMock.postOnce(url(settings, '/events/bulk'), (url, opts) => {
const resp = JSON.parse(opts.body);

// We will test the first and last item in detail.
Expand Down Expand Up @@ -101,7 +102,7 @@ export function bindingTT(fetchMock, assert) {

let tsStart, tsEnd;

fetchMock.postOnce(settings.url('/events/bulk'), (url, opts) => {
fetchMock.postOnce(url(settings, '/events/bulk'), (url, opts) => {
const resp = JSON.parse(opts.body);

// We will test the first and last item in detail.
Expand Down
16 changes: 9 additions & 7 deletions src/__tests__/browserSuites/ignore-ip-addresses-setting.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SplitFactory } from '../..';
import SettingsFactory from '../../utils/settings';
import splitChangesMock1 from '../mocks/splitchanges.since.-1.json';
import { DEBUG } from '../../utils/constants';
import { DEBUG } from '@splitsoftware/js-commons/src/utils/constants';
import { url } from '../testUtils';

// Header keys and expected values. Expected values are obtained with the runtime function evaluated with IPAddressesEnabled in true.
const HEADER_SPLITSDKMACHINEIP = 'SplitSDKMachineIP';
Expand Down Expand Up @@ -70,8 +71,9 @@ const configSamples = [
const postEndpoints = [
'/events/bulk',
'/testImpressions/bulk',
'/metrics/times',
'/metrics/counters'
// @TODO uncomment when telemetry is implemented
// '/metrics/times',
// '/metrics/counters'
];

export default function (fetchMock, assert) {
Expand Down Expand Up @@ -103,9 +105,9 @@ export default function (fetchMock, assert) {

// Mock GET endpoints before creating the client
const settings = SettingsFactory(config);
fetchMock.getOnce(settings.url('/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(settings.url('/splitChanges?since=1457552620999'), { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(settings.url(`/mySegments/${encodeURIComponent(config.core.key)}`), { status: 200, body: { mySegments: [] } });
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, `/mySegments/${encodeURIComponent(config.core.key)}`), { status: 200, body: { mySegments: [] } });

// Init Split client
const splitio = SplitFactory(config);
Expand All @@ -123,7 +125,7 @@ export default function (fetchMock, assert) {

// Mock and assert POST endpoints
postEndpoints.forEach(postEndpoint => {
fetchMock.postOnce(settings.url(postEndpoint), (url, opts) => {
fetchMock.postOnce(url(settings, postEndpoint), (url, opts) => {
assertHeaders(settings.core.IPAddressesEnabled, opts);
finishConfig.next();
return 200;
Expand Down
13 changes: 7 additions & 6 deletions src/__tests__/browserSuites/impressions.debug.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import SettingsFactory from '../../utils/settings';
import splitChangesMock1 from '../mocks/splitchanges.since.-1.json';
import splitChangesMock2 from '../mocks/splitchanges.since.1457552620999.json';
import mySegmentsFacundo from '../mocks/mysegments.facundo@split.io.json';
import { DEBUG } from '../../utils/constants';
import { DEBUG } from '@splitsoftware/js-commons/src/utils/constants';
import { url } from '../testUtils';

const baseUrls = {
sdk: 'https://sdk.baseurl/impressionsSuite',
Expand All @@ -20,9 +21,9 @@ 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(settings.url('/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(settings.url('/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(settings.url('/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });
fetchMock.getOnce(url(settings, '/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(url(settings, '/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });

const splitio = SplitFactory({
core: {
Expand Down Expand Up @@ -78,7 +79,7 @@ export default function (fetchMock, assert) {
});
};

fetchMock.postOnce(settings.url('/testImpressions/bulk'), (url, req) => {
fetchMock.postOnce(url(settings, '/testImpressions/bulk'), (url, req) => {
assert.equal(req.headers.SplitSDKImpressionsMode, DEBUG);
assertPayload(req);

Expand All @@ -87,7 +88,7 @@ export default function (fetchMock, assert) {

return 200;
});
fetchMock.postOnce(settings.url('/testImpressions/bulk'), 200);
fetchMock.postOnce(url(settings, '/testImpressions/bulk'), 200);

client.ready().then(() => {
client.getTreatment('split_with_config');
Expand Down
21 changes: 11 additions & 10 deletions src/__tests__/browserSuites/impressions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import SettingsFactory from '../../utils/settings';
import splitChangesMock1 from '../mocks/splitchanges.since.-1.json';
import splitChangesMock2 from '../mocks/splitchanges.since.1457552620999.json';
import mySegmentsFacundo from '../mocks/mysegments.facundo@split.io.json';
import { OPTIMIZED } from '../../utils/constants';
import { truncateTimeFrame } from '../../utils/time';
import { OPTIMIZED } from '@splitsoftware/js-commons/src/utils/constants';
import { truncateTimeFrame } from '@splitsoftware/js-commons/src/utils/time';
import { url } from '../testUtils';

const baseUrls = {
sdk: 'https://sdk.baseurl/impressionsSuite',
Expand All @@ -23,9 +24,9 @@ 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(settings.url('/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(settings.url('/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(settings.url('/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });
fetchMock.getOnce(url(settings, '/splitChanges?since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.get(url(settings, '/mySegments/facundo%40split.io'), { status: 200, body: mySegmentsFacundo });

const splitio = SplitFactory({
core: {
Expand Down Expand Up @@ -73,13 +74,13 @@ export default function (fetchMock, assert) {
assert.equal(t, 'on', 'Present impression should have the correct treatment.');
};

fetchMock.postOnce(settings.url('/testImpressions/bulk'), (url, req) => {
fetchMock.postOnce(url(settings, '/testImpressions/bulk'), (url, req) => {
assertPayload(req);
assert.comment('After a failure, Impressions will keep the data for the next call.');
return 400;
});
// Attach again to catch the retry.
fetchMock.postOnce(settings.url('/testImpressions/bulk'), (url, req) => {
fetchMock.postOnce(url(settings, '/testImpressions/bulk'), (url, req) => {
assert.equal(req.headers.SplitSDKImpressionsMode, OPTIMIZED);
assert.comment('We do one retry, so after a failed impressions post we will try once more.');
assertPayload(req);
Expand All @@ -89,9 +90,9 @@ export default function (fetchMock, assert) {

return 200;
});
fetchMock.postOnce(settings.url('/testImpressions/bulk'), 200);
fetchMock.postOnce(url(settings, '/testImpressions/bulk'), 200);

fetchMock.postOnce(settings.url('/testImpressions/count'), (url, opts) => {
fetchMock.postOnce(url(settings, '/testImpressions/count'), (url, opts) => {
const data = JSON.parse(opts.body);

assert.equal(data.pf.length, 2, 'We should generated 2 impressions count.');
Expand All @@ -109,7 +110,7 @@ export default function (fetchMock, assert) {

return 200;
});
fetchMock.postOnce(settings.url('/testImpressions/count'), 200);
fetchMock.postOnce(url(settings, '/testImpressions/count'), 200);

client.ready().then(() => {
truncatedTimeFrame = truncateTimeFrame(Date.now());
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/browserSuites/manager.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { SplitFactory } from '../../';
import splitChangesMockReal from '../mocks/splitchanges.real.json';
import map from 'lodash/map';
import { url } from '../testUtils';

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

const mockSplits = splitChangesMockReal;

Expand Down
Loading