Skip to content

chore: prepare release 4.9.2 #767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/optimizely-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

- Nothing yet!

## [4.9.2] - June 27, 2022

### Changed
- Add package.json script for running Karma tests locally using Chrome ([#651](https://github.com/optimizely/javascript-sdk/pull/651)).
- Replaced explicit typescript typings with auto generated ones ([#745](https://github.com/optimizely/javascript-sdk/pull/745)).
Expand Down
80 changes: 40 additions & 40 deletions packages/optimizely-sdk/lib/core/bucketer/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ import { getTestProjectConfig } from '../../tests/test_data';
var buildLogMessageFromArgs = args => sprintf(args[1], ...args.splice(2));
var testData = getTestProjectConfig();

describe('lib/core/bucketer', function() {
describe('APIs', function() {
describe('bucket', function() {
describe('lib/core/bucketer', function () {
describe('APIs', function () {
describe('bucket', function () {
var configObj;
var createdLogger = createLogger({ logLevel: LOG_LEVEL.INFO });
var bucketerParams;

beforeEach(function() {
beforeEach(function () {
sinon.stub(createdLogger, 'log');
});

afterEach(function() {
afterEach(function () {
createdLogger.log.restore();
});

describe('return values for bucketing (excluding groups)', function() {
beforeEach(function() {
describe('return values for bucketing (excluding groups)', function () {
beforeEach(function () {
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
bucketerParams = {
experimentId: configObj.experiments[0].id,
Expand All @@ -66,11 +66,11 @@ describe('lib/core/bucketer', function() {
.returns(50000);
});

afterEach(function() {
afterEach(function () {
bucketer._generateBucketValue.restore();
});

it('should return decision response with correct variation ID when provided bucket value', function() {
it('should return decision response with correct variation ID when provided bucket value', function () {
var bucketerParamsTest1 = cloneDeep(bucketerParams);
bucketerParamsTest1.userId = 'ppid1';
var decisionResponse = bucketer.bucket(bucketerParamsTest1);
Expand All @@ -93,9 +93,9 @@ describe('lib/core/bucketer', function() {
});
});

describe('return values for bucketing (including groups)', function() {
describe('return values for bucketing (including groups)', function () {
var bucketerStub;
beforeEach(function() {
beforeEach(function () {
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
bucketerParams = {
experimentId: configObj.experiments[0].id,
Expand All @@ -109,13 +109,13 @@ describe('lib/core/bucketer', function() {
bucketerStub = sinon.stub(bucketer, '_generateBucketValue');
});

afterEach(function() {
afterEach(function () {
bucketer._generateBucketValue.restore();
});

describe('random groups', function() {
describe('random groups', function () {
bucketerParams = {};
beforeEach(function() {
beforeEach(function () {
bucketerParams = {
experimentId: configObj.experiments[4].id,
experimentKey: configObj.experiments[4].key,
Expand All @@ -128,7 +128,7 @@ describe('lib/core/bucketer', function() {
};
});

it('should return decision response with the proper variation for a user in a grouped experiment', function() {
it('should return decision response with the proper variation for a user in a grouped experiment', function () {
bucketerStub.onFirstCall().returns(50);
bucketerStub.onSecondCall().returns(50);

Expand Down Expand Up @@ -160,7 +160,7 @@ describe('lib/core/bucketer', function() {
);
});

it('should return decision response with variation null when a user is bucketed into a different grouped experiment than the one speicfied', function() {
it('should return decision response with variation null when a user is bucketed into a different grouped experiment than the one speicfied', function () {
bucketerStub.returns(5000);

var decisionResponse = bucketer.bucket(bucketerParams);
Expand All @@ -185,7 +185,7 @@ describe('lib/core/bucketer', function() {
);
});

it('should return decision response with variation null when a user is not bucketed into any experiments in the random group', function() {
it('should return decision response with variation null when a user is not bucketed into any experiments in the random group', function () {
bucketerStub.returns(50000);

var decisionResponse = bucketer.bucket(bucketerParams);
Expand All @@ -202,7 +202,7 @@ describe('lib/core/bucketer', function() {
expect(log2).to.equal(sprintf(LOG_MESSAGES.USER_NOT_IN_ANY_EXPERIMENT, 'BUCKETER', 'testUser', '666'));
});

it('should return decision response with variation null when a user is bucketed into traffic space of deleted experiment within a random group', function() {
it('should return decision response with variation null when a user is bucketed into traffic space of deleted experiment within a random group', function () {
bucketerStub.returns(9000);

var decisionResponse = bucketer.bucket(bucketerParams);
Expand All @@ -219,19 +219,19 @@ describe('lib/core/bucketer', function() {
expect(log2).to.equal(sprintf(LOG_MESSAGES.USER_NOT_IN_ANY_EXPERIMENT, 'BUCKETER', 'testUser', '666'));
});

it('should throw an error if group ID is not in the datafile', function() {
it('should throw an error if group ID is not in the datafile', function () {
var bucketerParamsWithInvalidGroupId = cloneDeep(bucketerParams);
bucketerParamsWithInvalidGroupId.experimentIdMap[configObj.experiments[4].id].groupId = '6969';

assert.throws(function() {
assert.throws(function () {
bucketer.bucket(bucketerParamsWithInvalidGroupId);
}, sprintf(ERROR_MESSAGES.INVALID_GROUP_ID, 'BUCKETER', '6969'));
});
});

describe('overlapping groups', function() {
describe('overlapping groups', function () {
bucketerParams = {};
beforeEach(function() {
beforeEach(function () {
bucketerParams = {
experimentId: configObj.experiments[6].id,
experimentKey: configObj.experiments[6].key,
Expand All @@ -244,7 +244,7 @@ describe('lib/core/bucketer', function() {
};
});

it('should return decision response with variation when a user falls into an experiment within an overlapping group', function() {
it('should return decision response with variation when a user falls into an experiment within an overlapping group', function () {
bucketerStub.returns(0);

var decisionResponse = bucketer.bucket(bucketerParams);
Expand All @@ -257,7 +257,7 @@ describe('lib/core/bucketer', function() {
expect(log1).to.equal(sprintf(LOG_MESSAGES.USER_ASSIGNED_TO_EXPERIMENT_BUCKET, 'BUCKETER', '0', 'testUser'));
});

it('should return decision response with variation null when a user does not fall into an experiment within an overlapping group', function() {
it('should return decision response with variation null when a user does not fall into an experiment within an overlapping group', function () {
bucketerStub.returns(3000);

var decisionResponse = bucketer.bucket(bucketerParams);
Expand All @@ -266,8 +266,8 @@ describe('lib/core/bucketer', function() {
});
});

describe('when the bucket value falls into empty traffic allocation ranges', function() {
beforeEach(function() {
describe('when the bucket value falls into empty traffic allocation ranges', function () {
beforeEach(function () {
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
bucketerParams = {
experimentId: configObj.experiments[0].id,
Expand All @@ -289,14 +289,14 @@ describe('lib/core/bucketer', function() {
};
});

it('should return decision response with variation null', function() {
it('should return decision response with variation null', function () {
var bucketerParamsTest1 = cloneDeep(bucketerParams);
bucketerParamsTest1.userId = 'ppid1';
var decisionResponse = bucketer.bucket(bucketerParamsTest1);
expect(decisionResponse.result).to.equal(null);
});

it('should not log an invalid variation ID warning', function() {
it('should not log an invalid variation ID warning', function () {
bucketer.bucket(bucketerParams)
const foundInvalidVariationWarning = createdLogger.log.getCalls().some((call) => {
const message = call.args[1];
Expand All @@ -306,8 +306,8 @@ describe('lib/core/bucketer', function() {
});
});

describe('when the traffic allocation has invalid variation ids', function() {
beforeEach(function() {
describe('when the traffic allocation has invalid variation ids', function () {
beforeEach(function () {
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
bucketerParams = {
experimentId: configObj.experiments[0].id,
Expand All @@ -329,7 +329,7 @@ describe('lib/core/bucketer', function() {
};
});

it('should return decision response with variation null', function() {
it('should return decision response with variation null', function () {
var bucketerParamsTest1 = cloneDeep(bucketerParams);
bucketerParamsTest1.userId = 'ppid1';
var decisionResponse = bucketer.bucket(bucketerParamsTest1);
Expand All @@ -338,8 +338,8 @@ describe('lib/core/bucketer', function() {
});
});

describe('_generateBucketValue', function() {
it('should return a bucket value for different inputs', function() {
describe('_generateBucketValue', function () {
it('should return a bucket value for different inputs', function () {
var experimentId = 1886780721;
var bucketingKey1 = sprintf('%s%s', 'ppid1', experimentId);
var bucketingKey2 = sprintf('%s%s', 'ppid2', experimentId);
Expand All @@ -352,21 +352,21 @@ describe('lib/core/bucketer', function() {
expect(bucketer._generateBucketValue(bucketingKey4)).to.equal(5439);
});

it('should return an error if it cannot generate the hash value', function() {
assert.throws(function() {
it('should return an error if it cannot generate the hash value', function () {
assert.throws(function () {
bucketer._generateBucketValue(null);
}, sprintf(ERROR_MESSAGES.INVALID_BUCKETING_ID, 'BUCKETER', null, "Cannot read property 'length' of null"));
});
});

describe('testBucketWithBucketingId', function() {
describe('testBucketWithBucketingId', function () {
var bucketerParams;
var createdLogger = createLogger({
logLevel: LOG_LEVEL.INFO,
logToConsole: false,
});

beforeEach(function() {
beforeEach(function () {
var configObj = projectConfig.createProjectConfig(cloneDeep(testData));
bucketerParams = {
trafficAllocationConfig: configObj.experiments[0].trafficAllocation,
Expand All @@ -377,7 +377,7 @@ describe('lib/core/bucketer', function() {
};
});

it('check that a non null bucketingId buckets a variation different than the one expected with userId', function() {
it('check that a non null bucketingId buckets a variation different than the one expected with userId', function () {
var bucketerParams1 = cloneDeep(bucketerParams);
bucketerParams1['userId'] = 'testBucketingIdControl';
bucketerParams1['bucketingId'] = '123456789';
Expand All @@ -386,7 +386,7 @@ describe('lib/core/bucketer', function() {
expect(bucketer.bucket(bucketerParams1).result).to.equal('111129');
});

it('check that a null bucketing ID defaults to bucketing with the userId', function() {
it('check that a null bucketing ID defaults to bucketing with the userId', function () {
var bucketerParams2 = cloneDeep(bucketerParams);
bucketerParams2['userId'] = 'testBucketingIdControl';
bucketerParams2['bucketingId'] = null;
Expand All @@ -395,7 +395,7 @@ describe('lib/core/bucketer', function() {
expect(bucketer.bucket(bucketerParams2).result).to.equal('111128');
});

it('check that bucketing works with an experiment in group', function() {
it('check that bucketing works with an experiment in group', function () {
var bucketerParams4 = cloneDeep(bucketerParams);
bucketerParams4['userId'] = 'testBucketingIdControl';
bucketerParams4['bucketingId'] = '123456789';
Expand Down
Loading