Skip to content

Commit

Permalink
Merge pull request #44 from splitio/sdks-7830
Browse files Browse the repository at this point in the history
[SDKS-7830] flag sets
  • Loading branch information
emmaz90 authored Dec 18, 2023
2 parents 794f731 + e3199ce commit 682f485
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 46 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
2.0.0 (Dec XX, 2023)
- Updated @splitsoftware/splitio-browserjs package to version 0.13.0
- Updated the minimum Angular version to match Angular's support up to date. Breaking change version is regarding the Angular minimum version update, there are no breaking changes to Split's plugin API or functionality itself.
- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
- Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
- getTreatmentsByFlagSet and getTreatmentsByFlagSets
- getTreatmentsWithConfigByFlagSets and getTreatmentsWithConfigByFlagSets
- Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
- Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
- Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225).

1.0.2 (May 16, 2023)
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and JSDocs tags.
Expand Down
34 changes: 17 additions & 17 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-angular",
"version": "2.0.0",
"version": "1.0.3-rc.0",
"description": "Split Angular utilities to simplify Split SDK browser client usage",
"scripts": {
"ng": "ng",
Expand Down Expand Up @@ -53,7 +53,7 @@
"@angular-eslint/eslint-plugin-template": "15.2.1",
"@angular-eslint/schematics": "15.2.1",
"@angular-eslint/template-parser": "15.2.1",
"@splitsoftware/splitio-browserjs": "0.9.5",
"@splitsoftware/splitio-browserjs": "0.13.0",
"@types/jest": "^29.0.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
Expand Down
4 changes: 2 additions & 2 deletions projects/splitio/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-angular",
"version": "2.0.0",
"version": "1.0.3-rc.0",
"description": "Split Angular utilities to simplify Split SDK browser client usage",
"repository": {
"type": "git",
Expand All @@ -21,7 +21,7 @@
"bugs": "https://github.com/splitio/angular-sdk-plugin/issues",
"homepage": "https://github.com/splitio/angular-sdk-plugin#readme",
"dependencies": {
"@splitsoftware/splitio-browserjs": "0.9.5"
"@splitsoftware/splitio-browserjs": "0.13.0"
},
"peerDependencies": {
"@angular/core": ">=15.2.1",
Expand Down
14 changes: 8 additions & 6 deletions projects/splitio/src/lib/__tests__/mocks/SplitView.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ export const mockedFeatureFlagView = [
'changeNumber': 0,
'configs': {},
'killed': false,
'name':
'test_split',
'name': 'test_split',
'trafficType': 'localhost',
'treatments': ['on']
'treatments': ['on'],
'defaultTreatment': 'control',
'sets': []
},
{
'changeNumber': 0,
'configs': {
'off': '{"bannerText":"Click here."}'
},
'killed': false,
'name':
'test_split2',
'name': 'test_split2',
'trafficType': 'localhost',
'treatments': ['off']
'treatments': ['off'],
'defaultTreatment': 'control',
'sets': []
}
];
44 changes: 44 additions & 0 deletions projects/splitio/src/lib/__tests__/splitio.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,50 @@ describe('SplitService', () => {
});
});

test('Flag sets', (done) => {
expect(service.isSDKReady).toEqual(false);

expect(service.getTreatmentsByFlagSet('set_a')).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

expect(service.getTreatmentsWithConfigByFlagSet('set_a')).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

expect(service.getTreatmentsByFlagSets(['set_a','set_b'])).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

expect(service.getTreatmentsWithConfigByFlagSets(['set_a','set_b'])).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

service.init(localhostConfig).subscribe(() => {

const mainClient = service.getSDKClient();
expect(service.isSDKReady).toEqual(true);

const clientSpy = {
getTreatmentsByFlagSet: jest.spyOn(mainClient, 'getTreatmentsByFlagSet'),
getTreatmentsWithConfigByFlagSet: jest.spyOn(mainClient, 'getTreatmentsWithConfigByFlagSet'),
getTreatmentsByFlagSets: jest.spyOn(mainClient, 'getTreatmentsByFlagSets'),
getTreatmentsWithConfigByFlagSets: jest.spyOn(mainClient, 'getTreatmentsWithConfigByFlagSets'),
};

service.getTreatmentsByFlagSet('set_a');
expect(clientSpy.getTreatmentsByFlagSet.mock.calls[0]).toEqual(['set_a', undefined]);
service.getTreatmentsWithConfigByFlagSet('set_a', {attr: true});
expect(clientSpy.getTreatmentsWithConfigByFlagSet.mock.calls[0]).toEqual(['set_a', {attr: true}]);
service.getTreatmentsByFlagSets(['set_a','set_b'], {attr: true});
expect(clientSpy.getTreatmentsByFlagSets.mock.calls[0]).toEqual([['set_a','set_b'], {attr: true}]);
service.getTreatmentsWithConfigByFlagSets(['set_a','set_b']);
expect(clientSpy.getTreatmentsWithConfigByFlagSets.mock.calls[0]).toEqual([['set_a','set_b'], undefined]);

done();
});
});

test('SDK Manager', (done) => {
expect(service.getSplitNames()).toEqual([]);
service.init(localhostConfig);
Expand Down
Loading

0 comments on commit 682f485

Please sign in to comment.