You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.txt
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
- Added two new configuration options for the SDK's `InLocalStorage` module to control the behavior of the persisted rollout plan cache in the browser:
3
3
- `expirationDays` to specify the validity period of the rollout plan cache in days.
4
4
- `clearOnInit` to clear the rollout plan cache on SDK initialization.
5
-
- Updated SDK_READY_FROM_CACHE event when using the `LOCALSTORAGE` storage type to be emitted alongside the SDK_READY event if it has not already been emitted.
5
+
- Updated SDK_READY_FROM_CACHE event when using `InLocalStorage` to be emitted alongside the SDK_READY event if it has not already been emitted.
6
6
- Updated @splitsoftware/splitio-commons package to version 2.2.0.
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: { ...splitChangesMock1,since: 25},headers: {}}),200);});// 400ms is how long it'll take to reply with Splits, no SDK_READY should be emitted before that.
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: membershipsNicolas,headers: {}}),400);});// First client gets segments before splits. No segment cache loading (yet)
t.equal(localStorage.getItem('readyFromCache_3.SPLITIO.split.always_on'),alwaysOnSplitInverted,'feature flags must not be cleaned from cache');
257
256
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: { ...splitChangesMock1,since: 25},headers: {}}),200);});// 400ms is how long it'll take to reply with Splits, no SDK_READY should be emitted before that.
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: membershipsNicolas,headers: {}}),400);});// First client gets segments before splits. No segment cache loading (yet)
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: membershipsNicolas,headers: {}}),400);});// First client gets segments before splits. No segment cache loading (yet)
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: membershipsNicolas,headers: {}}),CLIENT_READY_MS);});// First client gets segments before splits. No segment cache loading (yet)
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: {'ms': {}},headers: {}}),CLIENT3_READY_MS);});// Third client memberships will come after 1s
t.fail('It should not emit SDK_READY_FROM_CACHE if there is expired cache.');
430
-
t.end();
428
+
t.true(nearlyEqual(Date.now()-startTime,CLIENT3_READY_MS),'It should emit SDK_READY_FROM_CACHE alongside SDK_READY');
431
429
});
432
430
433
431
client.on(client.Event.SDK_READY,()=>{
434
-
t.true(Date.now()-startTime>=400,'It should emit SDK_READY after syncing with the cloud.');
432
+
t.true(nearlyEqual(Date.now()-startTime,CLIENT_READY_MS),'It should emit SDK_READY after syncing with the cloud.');
435
433
t.equal(client.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
436
434
});
437
435
client.ready().then(()=>{
438
-
t.true(Date.now()-startTime>=400,'It should resolve ready promise after syncing with the cloud.');
436
+
t.true(nearlyEqual(Date.now()-startTime,CLIENT_READY_MS),'It should resolve ready promise after syncing with the cloud.');
439
437
t.equal(client.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
440
438
});
441
439
client2.on(client2.Event.SDK_READY,()=>{
442
-
t.true(Date.now()-startTime>=700,'It should emit SDK_READY after syncing with the cloud.');
440
+
t.true(nearlyEqual(Date.now()-startTime,CLIENT2_READY_MS),'It should emit SDK_READY after syncing with the cloud.');
443
441
t.equal(client2.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
444
442
});
445
443
client2.ready().then(()=>{
446
-
t.true(Date.now()-startTime>=700,'It should resolve ready promise after syncing with the cloud.');
444
+
t.true(nearlyEqual(Date.now()-startTime,CLIENT2_READY_MS),'It should resolve ready promise after syncing with the cloud.');
447
445
t.equal(client2.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
448
446
});
449
447
client3.on(client3.Event.SDK_READY,()=>{
450
448
client3.ready().then(()=>{
451
-
t.true(Date.now()-startTime>=1000,'It should resolve ready promise after syncing with the cloud.');
449
+
t.true(nearlyEqual(Date.now()-startTime,CLIENT3_READY_MS),'It should resolve ready promise after syncing with the cloud.');
452
450
t.equal(client3.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
453
451
454
452
// Last cb: destroy clients and check that localstorage has the expected items
@@ -481,7 +479,7 @@ export default function (fetchMock, assert) {
481
479
events: 'https://events.baseurl/readyFromCache_5'
482
480
};
483
481
localStorage.clear();
484
-
t.plan(7);
482
+
t.plan(8);
485
483
486
484
fetchMock.getOnce(testUrls.sdk+'/splitChanges?s=1.2&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?s=1.2&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
t.fail('It should not emit SDK_READY_FROM_CACHE if cache is empty.');
554
-
t.end();
550
+
t.true(client.__getStatus().isReady,'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
555
551
});
556
552
557
553
client.once(client.Event.SDK_READY,()=>{
@@ -622,7 +618,7 @@ export default function (fetchMock, assert) {
622
618
events: 'https://events.baseurl/readyFromCache_7'
623
619
};
624
620
localStorage.clear();
625
-
t.plan(6);
621
+
t.plan(7);
626
622
627
623
fetchMock.getOnce(testUrls.sdk+'/splitChanges?s=1.2&since=-1&prefixes=p1,p2',{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
t.fail('It should not emit SDK_READY_FROM_CACHE if cache has expired.');
654
-
t.end();
649
+
t.true(client.__getStatus().isReady,'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
655
650
});
656
651
657
652
client.once(client.Event.SDK_READY,()=>{
@@ -687,7 +682,7 @@ export default function (fetchMock, assert) {
687
682
events: 'https://events.baseurl/readyFromCache_8'
688
683
};
689
684
localStorage.clear();
690
-
t.plan(7);
685
+
t.plan(8);
691
686
692
687
fetchMock.getOnce(testUrls.sdk+'/splitChanges?s=1.2&since=-1',{status: 200,body: {splits: [splitDeclarations.p1__split,splitDeclarations.p2__split,splitDeclarations.p3__split],since: -1,till: 1457552620999}},{delay: 10});// short delay to let emit SDK_READY_FROM_CACHE
t.fail('It should not emit SDK_READY_FROM_CACHE because all feature flags were removed from cache since the filter query changed.');
715
-
t.end();
709
+
t.true(client.__getStatus().isReady,'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
716
710
});
717
711
718
712
client.once(client.Event.SDK_READY,()=>{
@@ -739,7 +733,7 @@ export default function (fetchMock, assert) {
739
733
events: 'https://events.baseurl/readyFromCache_9'
740
734
};
741
735
localStorage.clear();
742
-
t.plan(6);
736
+
t.plan(7);
743
737
744
738
fetchMock.getOnce(testUrls.sdk+'/splitChanges?s=1.2&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
t.fail('It should not emit SDK_READY_FROM_CACHE because all feature flags were removed from cache since the filter query changed.');
768
-
t.end();
761
+
t.true(client.__getStatus().isReady,'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
769
762
});
770
763
771
764
client.once(client.Event.SDK_READY,()=>{
@@ -817,10 +810,12 @@ export default function (fetchMock, assert) {
817
810
818
811
t.true(console.log.calledWithMatch('clearOnInit was set and cache was not cleared in the last 24 hours. Cleaning up cache'),'It should log a message about cleaning up cache');
819
812
820
-
client.once(client.Event.SDK_READY_FROM_CACHE,()=>t.fail('It should not emit SDK_READY_FROM_CACHE because clearOnInit is true.'));
t.true(client.__getStatus().isReady,'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
815
+
});
821
816
822
817
awaitclient.ready();
823
-
t.equal(manager.names().sort().length,32,'active splits should be present for evaluation');
818
+
t.equal(manager.names().sort().length,33,'active splits should be present for evaluation');
824
819
825
820
awaitsplitio.destroy();
826
821
t.equal(localStorage.getItem('readyFromCache_10.SPLITIO.splits.till'),'1457552620999','splits.till must correspond to the till of the last successfully fetched Splits');
@@ -837,7 +832,7 @@ export default function (fetchMock, assert) {
t.equal(manager.names().sort().length,32,'active splits should be present for evaluation');
835
+
t.equal(manager.names().sort().length,33,'active splits should be present for evaluation');
841
836
t.false(console.log.calledWithMatch('clearOnInit was set and cache was not cleared in the last 24 hours. Cleaning up cache'),'It should log a message about cleaning up cache');
842
837
843
838
awaitsplitio.destroy();
@@ -852,11 +847,13 @@ export default function (fetchMock, assert) {
852
847
client=splitio.client();
853
848
manager=splitio.manager();
854
849
855
-
client.once(client.Event.SDK_READY_FROM_CACHE,()=>t.fail('It should not emit SDK_READY_FROM_CACHE because clearOnInit is true.'));
t.equal(manager.names().sort().length,32,'active splits should be present for evaluation');
856
+
t.equal(manager.names().sort().length,33,'active splits should be present for evaluation');
860
857
t.true(console.log.calledWithMatch('clearOnInit was set and cache was not cleared in the last 24 hours. Cleaning up cache'),'It should log a message about cleaning up cache');
0 commit comments