Merge pull request #5154 from overleaf/hb-trial-onboarding-ab
Trial onboarding email GitOrigin-RevId: a9e3ba5a5e333c625b4f983012f81f6fde21b8dc
This commit is contained in:
@@ -26,6 +26,14 @@ describe('RecurlyEventHandler', function () {
|
||||
|
||||
this.RecurlyEventHandler = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'./SubscriptionEmailHandler': (this.SubscriptionEmailHandler = {
|
||||
sendTrialOnboardingEmail: sinon.stub(),
|
||||
}),
|
||||
'../SplitTests/SplitTestV2Handler': (this.SplitTestV2Handler = {
|
||||
promises: {
|
||||
getAssignment: sinon.stub().resolves({ active: false }),
|
||||
},
|
||||
}),
|
||||
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
|
||||
recordEventForUser: sinon.stub(),
|
||||
setUserPropertyForUser: sinon.stub(),
|
||||
@@ -67,6 +75,30 @@ describe('RecurlyEventHandler', function () {
|
||||
'subscription-is-trial',
|
||||
true
|
||||
)
|
||||
sinon.assert.calledWith(
|
||||
this.SplitTestV2Handler.promises.getAssignment,
|
||||
this.userId,
|
||||
'trial-onboarding-email'
|
||||
)
|
||||
})
|
||||
|
||||
it('sends free trial onboarding email if user in ab group', async function () {
|
||||
this.SplitTestV2Handler.promises.getAssignment = sinon
|
||||
.stub()
|
||||
.resolves({ active: true, variant: 'send-email' })
|
||||
this.userId = '123456789trial'
|
||||
this.eventData.account.account_code = this.userId
|
||||
|
||||
// testing directly on the send subscription started event to ensure the split handler
|
||||
// promise is resolved before checking calls
|
||||
await this.RecurlyEventHandler.sendSubscriptionStartedEvent(this.eventData)
|
||||
|
||||
sinon.assert.calledWith(
|
||||
this.SplitTestV2Handler.promises.getAssignment,
|
||||
this.userId,
|
||||
'trial-onboarding-email'
|
||||
)
|
||||
sinon.assert.called(this.SubscriptionEmailHandler.sendTrialOnboardingEmail)
|
||||
})
|
||||
|
||||
it('with new_subscription_notification - no free trial', function () {
|
||||
|
||||
@@ -150,6 +150,7 @@ describe('SubscriptionController', function () {
|
||||
'./RecurlyWrapper': (this.RecurlyWrapper = {
|
||||
updateAccountEmailAddress: sinon.stub().yields(),
|
||||
}),
|
||||
'./RecurlyEventHandler': { sendRecurlyAnalyticsEvent: sinon.stub() },
|
||||
'./FeaturesUpdater': (this.FeaturesUpdater = {}),
|
||||
'./GroupPlansData': (this.GroupPlansData = {}),
|
||||
'./V1SubscriptionManager': (this.V1SubscriptionManager = {}),
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath =
|
||||
'../../../../app/src/Features/Subscription/SubscriptionEmailHandler'
|
||||
|
||||
describe('SubscriptionEmailHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.userId = '123456789abcde'
|
||||
this.email = 'test@test.com'
|
||||
|
||||
this.SubscriptionEmailHandler = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'../Email/EmailHandler': (this.EmailHandler = {
|
||||
promises: {
|
||||
sendEmail: sinon.stub().resolves({}),
|
||||
},
|
||||
}),
|
||||
'../User/UserGetter': (this.UserGetter = {
|
||||
promises: {
|
||||
getUser: sinon
|
||||
.stub()
|
||||
.resolves({ _id: this.userId, email: 'test@test.com' }),
|
||||
},
|
||||
}),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('sends trail onboarding email', async function () {
|
||||
await this.SubscriptionEmailHandler.sendTrialOnboardingEmail(this.userId)
|
||||
expect(this.EmailHandler.promises.sendEmail.lastCall.args).to.deep.equal([
|
||||
'trialOnboarding',
|
||||
{
|
||||
to: this.email,
|
||||
sendingUser_id: this.userId,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user