Skip to content

Commit 30f958c

Browse files
Merge pull request #230 from splitio/integration-tests
Add wiring tests
2 parents 128898a + a7d4336 commit 30f958c

File tree

15 files changed

+2105
-24
lines changed

15 files changed

+2105
-24
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.13.1
1+
v24.12

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.9.0 (Dec 16, 2025)
2+
- Updated base image to node:24.12.0-alpine3.22
3+
- Updated @splitsoftware/splitio library, using @splitsoftware/splitio-commons:2.10.0 instead that includes
4+
- Added property `impressionsDisabled` in getTreatment(s) `evaluationOptions` parameter, to disable impressions per evaluations.
5+
16
2.8.1 (Oct 13, 2025)
27
- Updated base image to node:24.10.0-alpine3.22
38

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Builder stage
2-
FROM node:24.10.0-alpine3.22 AS builder
2+
FROM node:24.12.0-alpine3.22 AS builder
33

44
WORKDIR /usr/src/split-evaluator
55

@@ -8,7 +8,7 @@ COPY package.json package-lock.json ./
88
RUN npm install --only=production
99

1010
# Runner stage
11-
FROM node:24.10.0-alpine3.22 AS runner
11+
FROM node:24.12.0-alpine3.22 AS runner
1212

1313
WORKDIR /usr/src/split-evaluator
1414

client/client.router.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ const fwdPropertiesFromPost = function parsePropertiesMiddleware(req, res, next)
194194
next();
195195
};
196196

197+
const fwdImpressionsDisabledFromPost = function parseImpressionsDisabledMiddleware(req, res, next) {
198+
const impressionsDisabled = req.body.impressionsDisabled;
199+
if (impressionsDisabled !== undefined) req.query['impressions-disabled'] = impressionsDisabled.toString();
200+
next();
201+
};
202+
197203
const handleBodyParserErr = function handleBodyParserErr(error, req, res, next) {
198204
if (error) {
199205
return res
@@ -218,14 +224,14 @@ router.get('/get-all-treatments-with-config', allTreatmentValidation, clientCont
218224

219225
// Getting treatments as POST's for big attribute sets
220226
const JSON_PARSE_OPTS = { limit: '300kb' };
221-
router.post('/get-treatment',express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, treatmentValidation, clientController.getTreatment);
222-
router.post('/get-treatment-with-config', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, treatmentValidation, clientController.getTreatmentWithConfig);
223-
router.post('/get-treatments', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, treatmentsValidation, clientController.getTreatments);
224-
router.post('/get-treatments-with-config', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, treatmentsValidation, clientController.getTreatmentsWithConfig);
225-
router.post('/get-treatments-by-sets', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, flagSetsValidation, clientController.getTreatmentsByFlagSets);
226-
router.post('/get-treatments-with-config-by-sets', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, flagSetsValidation, clientController.getTreatmentsWithConfigByFlagSets);
227-
router.post('/get-all-treatments', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, allTreatmentValidation, clientController.getAllTreatments);
228-
router.post('/get-all-treatments-with-config', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, handleBodyParserErr, allTreatmentValidation, clientController.getAllTreatmentsWithConfig);
227+
router.post('/get-treatment',express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, treatmentValidation, clientController.getTreatment);
228+
router.post('/get-treatment-with-config', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, treatmentValidation, clientController.getTreatmentWithConfig);
229+
router.post('/get-treatments', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, treatmentsValidation, clientController.getTreatments);
230+
router.post('/get-treatments-with-config', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, treatmentsValidation, clientController.getTreatmentsWithConfig);
231+
router.post('/get-treatments-by-sets', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, flagSetsValidation, clientController.getTreatmentsByFlagSets);
232+
router.post('/get-treatments-with-config-by-sets', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, flagSetsValidation, clientController.getTreatmentsWithConfigByFlagSets);
233+
router.post('/get-all-treatments', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, allTreatmentValidation, clientController.getAllTreatments);
234+
router.post('/get-all-treatments-with-config', express.json(JSON_PARSE_OPTS), fwdAttributesFromPost, fwdPropertiesFromPost, fwdImpressionsDisabledFromPost, handleBodyParserErr, allTreatmentValidation, clientController.getAllTreatmentsWithConfig);
229235

230236
// Other methods
231237
router.get('/track', trackValidation, clientController.track);

listener/manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fetch = require('node-fetch');
1+
const fetch = require('../sdk/platform/getFetch').getFetch();
22
const config = require('config');
33
const repeat = require('./repeat');
44
const ImpressionQueue = require('./queue');

package-lock.json

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

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "split-evaluator",
3-
"version": "2.9.1",
3+
"version": "2.9.0",
44
"description": "Split-Evaluator",
55
"repository": "splitio/split-evaluator",
66
"homepage": "https://github.com/splitio/split-evaluator#readme",
@@ -22,7 +22,8 @@
2222
"jest": {
2323
"testPathIgnorePatterns": [
2424
"config",
25-
"environmentManager/__tests__/constants"
25+
"environmentManager/__tests__/constants",
26+
"sdk/__tests__/utils"
2627
],
2728
"setupFiles": [
2829
"<rootDir>/.jest/setEnvVars.js"
@@ -40,7 +41,7 @@
4041
"test": "NODE_ENV=test jest"
4142
},
4243
"dependencies": {
43-
"@splitsoftware/splitio-commons": "2.9.1-rc.2",
44+
"@splitsoftware/splitio-commons": "2.10.0",
4445
"bloom-filters": "^3.0.4",
4546
"config": "^3.3.9",
4647
"js-yaml": "^4.1.0",
@@ -57,6 +58,7 @@
5758
"@babel/preset-env": "^7.15.6",
5859
"babel-jest": "^29.7.0",
5960
"eslint": "^8.9.0",
61+
"fetch-mock": "^11.1.5",
6062
"jest": "^29.7.0",
6163
"nodemon": "^3.1.0",
6264
"superagent": "^8.0.9",
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
const { isConsumerMode } = require('@splitsoftware/splitio-commons/cjs/utils/settingsValidation/mode');
2+
const { getSplitFactory } = require('../../sdk');
3+
4+
describe('SDK Wiring & Glue Code Integration', () => {
5+
const baseConfig = {
6+
core: {
7+
authorizationKey: 'localhost',
8+
},
9+
features: {
10+
'test_feature': 'on',
11+
},
12+
};
13+
14+
test('Should initialize correctly in OPTIMIZED mode - bloomFilter', async () => {
15+
const optimizedConfig = {
16+
...baseConfig,
17+
sync: {
18+
impressionsMode: 'OPTIMIZED',
19+
},
20+
};
21+
22+
const { factory } = getSplitFactory(optimizedConfig);
23+
const client = factory.client();
24+
25+
await client.ready();
26+
27+
const treatment = client.getTreatment('test', 'my-experiment');
28+
expect(treatment).toBe('on');
29+
30+
await expect(client.destroy()).resolves.toBeUndefined();
31+
});
32+
33+
test('SDK_READY event must be emitted and resolved', (done) => {
34+
const { factory } = getSplitFactory(baseConfig);
35+
const client = factory.client();
36+
37+
let readyCalled = false;
38+
39+
client.on(client.Event.SDK_READY, () => {
40+
readyCalled = true;
41+
client.destroy().then(async () => {
42+
expect(readyCalled).toBe(true);
43+
await expect(client.destroy()).resolves.toBeUndefined();
44+
45+
done();
46+
});
47+
});
48+
49+
setTimeout(() => {
50+
if (!readyCalled) {
51+
client.destroy();
52+
done(new Error('SDK_READY event was not emitted within timeout'));
53+
}
54+
}, 2000);
55+
});
56+
57+
test('ExtraProps adds getRolloutPlan to Manager', async () => {
58+
const { factory } = getSplitFactory(baseConfig);
59+
60+
expect(typeof factory.getRolloutPlan).toBe('function');
61+
62+
const plan = factory.getRolloutPlan({ feature: 'my-experiment' });
63+
expect(plan).toBeDefined();
64+
expect(plan.splitChanges).toBeDefined();
65+
66+
await expect(factory.destroy()).resolves.toBeUndefined();
67+
68+
});
69+
70+
test('Destroy must resolve and clean up resources', async () => {
71+
const { factory } = getSplitFactory(baseConfig);
72+
const client = factory.client();
73+
74+
await client.ready();
75+
76+
await expect(client.destroy()).resolves.toBeUndefined();
77+
});
78+
79+
test('Must force STANDALONE mode if it receives CONSUMER mode', async () => {
80+
const consumerConfig = {
81+
...baseConfig,
82+
mode: 'consumer',
83+
storage: {
84+
type: 'REDIS',
85+
prefix: 'test',
86+
},
87+
};
88+
89+
const { factory } = getSplitFactory(consumerConfig);
90+
91+
expect(isConsumerMode(factory.settings)).toBe(false);
92+
93+
const client = factory.client();
94+
expect(client).toBeDefined();
95+
96+
await client.ready();
97+
98+
const treatment = client.getTreatment('test', 'my-experiment');
99+
expect(treatment).toBe('on');
100+
101+
await expect(client.destroy()).resolves.toBeUndefined();
102+
});
103+
});

0 commit comments

Comments
 (0)