Skip to content

Commit 97a8fc5

Browse files
Test localhost mode updates
1 parent 8da3e94 commit 97a8fc5

6 files changed

Lines changed: 57 additions & 39 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build
4848

4949
- name: Store assets
50-
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/main') }}
50+
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/update_js_commons' || github.ref == 'refs/heads/main') }}
5151
uses: actions/upload-artifact@v3
5252
with:
5353
name: assets
@@ -58,7 +58,7 @@ jobs:
5858
name: Upload assets
5959
runs-on: ubuntu-20.04
6060
needs: build
61-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
61+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/update_js_commons' }}
6262
strategy:
6363
matrix:
6464
environment:

CHANGES.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
0.14.1 (June XX, 2024)
2-
- Updated @splitsoftware/splitio-commons package to version 1.15.1 that includes updates on input validation logs.
1+
0.14.1 (June 14, 2024)
2+
- Updated @splitsoftware/splitio-commons package to version 1.16.0 that includes some vulnerability and bug fixes.
3+
- Bugfixing - Restored some input validation error logs that were removed in version 10.24.0. The logs inform the user when the `getTreatment(s)` methods are called with an invalid value as feature flag name or flag set name.
4+
- Bugfixing - Fixed localhost mode to emit SDK_UPDATE when mocked feature flags are updated in the `features` object map of the config object (Related to issue https://github.com/splitio/javascript-browser-client/issues/119).
35

46
0.14.0 (May 6, 2024)
57
- Updated @splitsoftware/splitio-commons package to version 1.14.0 that includes minor updates:

package-lock.json

Lines changed: 23 additions & 23 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
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-browserjs",
3-
"version": "0.14.0",
3+
"version": "0.14.1-rc.0",
44
"description": "Split SDK for JavaScript on Browser",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",
@@ -64,7 +64,7 @@
6464
"bugs": "https://github.com/splitio/javascript-browser-client/issues",
6565
"homepage": "https://github.com/splitio/javascript-browser-client#readme",
6666
"dependencies": {
67-
"@splitsoftware/splitio-commons": "1.15.1-rc.0",
67+
"@splitsoftware/splitio-commons": "1.16.0",
6868
"@types/google.analytics": "0.0.40",
6969
"tslib": "^2.3.1",
7070
"unfetch": "^4.2.0"

src/__tests__/offline/browser.spec.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ tape('Browser offline mode', function (assert) {
9292
SplitFactory({ ...config, storage: InLocalStorage() }),
9393
SplitFactorySlim({ ...config, storage: InLocalStorage(), sync: { localhostMode: LocalhostFromObject() } }) // slim factory requires localhostFromObject module
9494
];
95-
const factoriesReady = [ // Multiple factories must handle their own `features` mock, even if instantiated with the same config.
96-
SplitFactory(config),
97-
SplitFactory({ ...config }),
98-
SplitFactory({ ...config, features: { ...config.features }, storage: InLocalStorage /* invalid */, sync: { localhostMode: LocalhostFromObject /* invalid */ } }),
95+
const configs = [
96+
{ ...config, features: { ...config.features }, storage: InLocalStorage /* invalid */, sync: { localhostMode: LocalhostFromObject /* invalid */ } },
97+
{ ...config },
98+
config,
99+
];
100+
const factoriesReady = [
101+
...configs.map(config => SplitFactory(config)),
99102
...factoriesReadyFromCache
100103
];
101104
const factoriesTimeout = [ // slim factory without a valid localhostFromObject module will timeout
@@ -115,7 +118,7 @@ tape('Browser offline mode', function (assert) {
115118
readyCount++;
116119
});
117120
client.on(client.Event.SDK_UPDATE, () => {
118-
assert.deepEqual(manager.names(), ['testing_split', 'testing_split_2', 'testing_split_3', 'testing_split_with_config']);
121+
assert.deepEqual(manager.names().sort(), ['testing_split', 'testing_split_2', 'testing_split_3', 'testing_split_with_config']);
119122
assert.equal(client.getTreatment('testing_split_with_config'), 'nope');
120123
updateCount++;
121124
});
@@ -225,7 +228,7 @@ tape('Browser offline mode', function (assert) {
225228
});
226229

227230
setTimeout(() => {
228-
// Update the features
231+
// Update features reference in settings
229232
factory.settings.features = {
230233
testing_split: 'on',
231234
testing_split_2: 'off',
@@ -235,10 +238,23 @@ tape('Browser offline mode', function (assert) {
235238
config: null
236239
}
237240
};
238-
// Update the features in all factories except one
239-
for (let i = 1; i < factories.length; i++) {
240-
factories[i].settings.features = factory.settings.features;
241+
242+
// Update features properties in config
243+
configs[0].features['testing_split'] = 'on';
244+
configs[0].features['testing_split_2'] = 'off';
245+
configs[0].features['testing_split_3'] = 'custom_treatment';
246+
configs[0].features['testing_split_with_config'] = {
247+
treatment: 'nope',
248+
config: null
249+
};
250+
251+
// Update the features in all remaining factories except the last one
252+
for (let i = 1; i < factoriesReady.length - 1; i++) {
253+
factoriesReady[i].settings.features = factory.settings.features;
241254
}
255+
256+
// Assigning a new object to the features property in the config object doesn't trigger an update
257+
configs[configs.length - 1].features = { ...factory.settings.features };
242258
}, 1000);
243259

244260
setTimeout(() => { factory.settings.features = originalFeaturesMap; }, 200);

src/settings/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/
22
import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types';
33
import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants';
44

5-
const packageVersion = '0.14.0';
5+
const packageVersion = '0.14.1-rc.0';
66

77
/**
88
* In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.

0 commit comments

Comments
 (0)