|
@@ -14,7 +14,7 @@ const MODULE_PATH = Path.join(
|
|
|
describe('SplitTestHandler', function () {
|
|
describe('SplitTestHandler', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.splitTests = [
|
|
this.splitTests = [
|
|
|
- makeSplitTest('active-test'),
|
|
|
|
|
|
|
+ makeSplitTest('active-test', { versionNumber: 2 }),
|
|
|
makeSplitTest('not-active-test', { active: false }),
|
|
makeSplitTest('not-active-test', { active: false }),
|
|
|
makeSplitTest('legacy-test'),
|
|
makeSplitTest('legacy-test'),
|
|
|
makeSplitTest('no-analytics-test-1', { analyticsEnabled: false }),
|
|
makeSplitTest('no-analytics-test-1', { analyticsEnabled: false }),
|
|
@@ -109,6 +109,27 @@ describe('SplitTestHandler', function () {
|
|
|
await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
|
await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
|
|
this.user._id
|
|
this.user._id
|
|
|
)
|
|
)
|
|
|
|
|
+ this.explicitAssignments =
|
|
|
|
|
+ await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
|
|
|
|
+ this.user._id,
|
|
|
|
|
+ false,
|
|
|
|
|
+ true
|
|
|
|
|
+ )
|
|
|
|
|
+ this.assignedToActiveTest =
|
|
|
|
|
+ await this.SplitTestHandler.promises.hasUserBeenAssignedToVariant(
|
|
|
|
|
+ this.req,
|
|
|
|
|
+ this.user._id,
|
|
|
|
|
+ 'active-test',
|
|
|
|
|
+ 'variant-1'
|
|
|
|
|
+ )
|
|
|
|
|
+ this.assignedToActiveTestAnyVersion =
|
|
|
|
|
+ await this.SplitTestHandler.promises.hasUserBeenAssignedToVariant(
|
|
|
|
|
+ this.req,
|
|
|
|
|
+ this.user._id,
|
|
|
|
|
+ 'active-test',
|
|
|
|
|
+ 'variant-1',
|
|
|
|
|
+ true
|
|
|
|
|
+ )
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('handles the legacy assignment format', function () {
|
|
it('handles the legacy assignment format', function () {
|
|
@@ -123,7 +144,15 @@ describe('SplitTestHandler', function () {
|
|
|
expect(this.assignments['active-test']).to.deep.equal({
|
|
expect(this.assignments['active-test']).to.deep.equal({
|
|
|
variantName: 'variant-1',
|
|
variantName: 'variant-1',
|
|
|
phase: 'release',
|
|
phase: 'release',
|
|
|
- versionNumber: 1,
|
|
|
|
|
|
|
+ versionNumber: 2,
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('returns the explicit assignment for each active test', function () {
|
|
|
|
|
+ expect(this.explicitAssignments['active-test']).to.deep.equal({
|
|
|
|
|
+ variantName: 'variant-1',
|
|
|
|
|
+ phase: 'release',
|
|
|
|
|
+ versionNumber: 2,
|
|
|
assignedAt: 'active-test-assigned-at',
|
|
assignedAt: 'active-test-assigned-at',
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -144,6 +173,14 @@ describe('SplitTestHandler', function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('shows user has been assigned to previous version of variant', function () {
|
|
|
|
|
+ expect(this.assignedToActiveTestAnyVersion).to.be.true
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('shows user has not been explicitly assigned to current version of variant', function () {
|
|
|
|
|
+ expect(this.assignedToActiveTest).to.be.false
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('does not return assignments for unknown tests', function () {
|
|
it('does not return assignments for unknown tests', function () {
|
|
|
expect(this.assignments).not.to.have.property('unknown-test')
|
|
expect(this.assignments).not.to.have.property('unknown-test')
|
|
|
})
|
|
})
|
|
@@ -171,6 +208,19 @@ describe('SplitTestHandler', function () {
|
|
|
await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
|
await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
|
|
this.user._id
|
|
this.user._id
|
|
|
)
|
|
)
|
|
|
|
|
+ this.explicitAssignments =
|
|
|
|
|
+ await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
|
|
|
|
+ this.user._id,
|
|
|
|
|
+ false,
|
|
|
|
|
+ true
|
|
|
|
|
+ )
|
|
|
|
|
+ this.assignedToActiveTest =
|
|
|
|
|
+ await this.SplitTestHandler.promises.hasUserBeenAssignedToVariant(
|
|
|
|
|
+ this.req,
|
|
|
|
|
+ this.user._id,
|
|
|
|
|
+ 'active-test',
|
|
|
|
|
+ 'variant-1'
|
|
|
|
|
+ )
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('returns current assignments', function () {
|
|
it('returns current assignments', function () {
|
|
@@ -178,7 +228,7 @@ describe('SplitTestHandler', function () {
|
|
|
'active-test': {
|
|
'active-test': {
|
|
|
phase: 'release',
|
|
phase: 'release',
|
|
|
variantName: 'variant-1',
|
|
variantName: 'variant-1',
|
|
|
- versionNumber: 1,
|
|
|
|
|
|
|
+ versionNumber: 2,
|
|
|
},
|
|
},
|
|
|
'legacy-test': {
|
|
'legacy-test': {
|
|
|
phase: 'release',
|
|
phase: 'release',
|
|
@@ -202,6 +252,10 @@ describe('SplitTestHandler', function () {
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ it('shows user not assigned to variant', function () {
|
|
|
|
|
+ expect(this.assignedToActiveTest).to.be.false
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with settings overrides', function () {
|
|
describe('with settings overrides', function () {
|