Assignment by id for recurly webhook (#6465)

* Allow split test assignment by ID for recurly webhook

* Small refactoring of assignment logic

* Add tests for getAssignmentForUser

* Cleanup following review comments

* Provide default value for sync option in split test handler

GitOrigin-RevId: 828cad3a1f3a0f3efd25f427d00a3c530ae2f087
This commit is contained in:
Alexandre Bourdin
2022-01-25 09:04:05 +00:00
committed by Copybot
parent b3d4bd397f
commit 4c49edd89b
3 changed files with 74 additions and 45 deletions
@@ -31,7 +31,7 @@ describe('RecurlyEventHandler', function () {
}),
'../SplitTests/SplitTestHandler': (this.SplitTestHandler = {
promises: {
getAssignment: sinon.stub().resolves({ active: false }),
getAssignmentForUser: sinon.stub().resolves({ variant: 'default' }),
},
}),
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
@@ -76,16 +76,16 @@ describe('RecurlyEventHandler', function () {
true
)
sinon.assert.calledWith(
this.SplitTestHandler.promises.getAssignment,
this.SplitTestHandler.promises.getAssignmentForUser,
this.userId,
'trial-onboarding-email'
)
})
it('sends free trial onboarding email if user in ab group', async function () {
this.SplitTestHandler.promises.getAssignment = sinon
this.SplitTestHandler.promises.getAssignmentForUser = sinon
.stub()
.resolves({ active: true, variant: 'send-email' })
.resolves({ variant: 'send-email' })
this.userId = '123456789trial'
this.eventData.account.account_code = this.userId
@@ -94,7 +94,7 @@ describe('RecurlyEventHandler', function () {
await this.RecurlyEventHandler.sendSubscriptionStartedEvent(this.eventData)
sinon.assert.calledWith(
this.SplitTestHandler.promises.getAssignment,
this.SplitTestHandler.promises.getAssignmentForUser,
this.userId,
'trial-onboarding-email'
)