Merge pull request #29881 from overleaf/jel-domain-capture-email-invite-cta
[web] Update CTA for domain capture group invites GitOrigin-RevId: addaa81c443da63124b7841f087e34145fe3bfe6
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { expect, vi } from 'vitest'
|
||||
import sinon from 'sinon'
|
||||
import MockResponse from '../helpers/MockResponse.js'
|
||||
|
||||
const modulePath =
|
||||
'../../../../app/src/Features/Subscription/TeamInvitesController'
|
||||
@@ -74,7 +75,9 @@ describe('TeamInvitesController', function () {
|
||||
}
|
||||
|
||||
ctx.RateLimiter = {
|
||||
RateLimiter: class {},
|
||||
RateLimiter: class {
|
||||
consume = sinon.stub().resolves()
|
||||
},
|
||||
}
|
||||
|
||||
vi.doMock(
|
||||
@@ -274,4 +277,58 @@ describe('TeamInvitesController', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('resendInvite', function () {
|
||||
const email = 'user@example.com'
|
||||
const initPath = '/saml/ukamf/init?group_id=12345'
|
||||
beforeEach(function (ctx) {
|
||||
ctx.subscription = { teamInvites: [{ email }], populate: sinon.stub() }
|
||||
ctx.req = {
|
||||
entity: ctx.subscription,
|
||||
body: {
|
||||
email,
|
||||
},
|
||||
}
|
||||
ctx.res = new MockResponse()
|
||||
ctx.next = sinon.stub()
|
||||
})
|
||||
|
||||
it('sends the invite email again', async function (ctx) {
|
||||
await new Promise(resolve => {
|
||||
const res = new MockResponse()
|
||||
res.callback = () => {
|
||||
res.statusCode.should.equal(200)
|
||||
resolve()
|
||||
}
|
||||
|
||||
ctx.Controller.resendInvite(ctx.req, res, ctx.next)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when domain capture is enabled', function () {
|
||||
beforeEach(function (ctx) {
|
||||
ctx.req.entity.domainCaptureEnabled = true
|
||||
|
||||
ctx.Modules.promises.hooks.fire.resolves([initPath])
|
||||
})
|
||||
|
||||
it('sends the invite again', async function (ctx) {
|
||||
await new Promise(resolve => {
|
||||
const res = new MockResponse()
|
||||
res.callback = () => {
|
||||
sinon.assert.calledWith(
|
||||
ctx.Modules.promises.hooks.fire,
|
||||
'getGroupSSOInitPath',
|
||||
ctx.subscription,
|
||||
email
|
||||
)
|
||||
res.statusCode.should.equal(200)
|
||||
resolve()
|
||||
}
|
||||
|
||||
ctx.Controller.resendInvite(ctx.req, res, ctx.next)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -131,7 +131,7 @@ describe('TeamInvitesHandler', function () {
|
||||
}))
|
||||
|
||||
vi.doMock('@overleaf/settings', () => ({
|
||||
default: { siteUrl: 'http://example.com' },
|
||||
default: { siteUrl: 'http://example.com', appName: 'Overleaf' },
|
||||
}))
|
||||
|
||||
vi.doMock('../../../../app/src/models/TeamInvite', () => ({
|
||||
@@ -414,6 +414,90 @@ describe('TeamInvitesHandler', function () {
|
||||
'addGroupAuditLogEntry'
|
||||
)
|
||||
})
|
||||
|
||||
describe('when domain capture is enabled', function () {
|
||||
it('creates a domain capture invite', async function (ctx) {
|
||||
const initPath = '/saml/ukamf/init?group_id=12345'
|
||||
ctx.Modules.promises.hooks.fire.resolves([initPath])
|
||||
ctx.UserGetter.promises.getUser.resolves(ctx.manager)
|
||||
|
||||
ctx.subscription.domainCaptureEnabled = true
|
||||
const invite = await ctx.TeamInvitesHandler.promises.createInvite(
|
||||
ctx.manager._id,
|
||||
ctx.subscription,
|
||||
'user@example.com',
|
||||
{ domainCapture: true }
|
||||
)
|
||||
expect(invite.token).to.be.undefined
|
||||
expect(invite.domainCapture).to.be.true
|
||||
expect(invite.email).to.eq('user@example.com')
|
||||
|
||||
sinon.assert.calledWith(
|
||||
ctx.Modules.promises.hooks.fire,
|
||||
'getGroupSSOInitPath',
|
||||
ctx.subscription,
|
||||
invite.email
|
||||
)
|
||||
|
||||
ctx.EmailHandler.promises.sendEmail
|
||||
.calledWith(
|
||||
'verifyEmailToJoinTeam',
|
||||
sinon.match({
|
||||
to: 'user@example.com',
|
||||
inviter: ctx.manager,
|
||||
acceptInviteUrl: `http://example.com${initPath}`,
|
||||
appName: 'Overleaf',
|
||||
})
|
||||
)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
describe('when managed users is also enabled', function () {
|
||||
it('creates a domain capture invite', async function (ctx) {
|
||||
ctx.SubscriptionLocator.promises.getAdminEmailAndName = sinon
|
||||
.stub()
|
||||
.resolves(ctx.manager)
|
||||
|
||||
ctx.UserGetter.promises.getUserByAnyEmail
|
||||
.withArgs('user@example.com')
|
||||
.resolves(ctx.user)
|
||||
const initPath = '/saml/ukamf/init?group_id=12345'
|
||||
ctx.Modules.promises.hooks.fire.resolves([initPath])
|
||||
ctx.UserGetter.promises.getUser.resolves(ctx.manager)
|
||||
ctx.subscription.managedUsersEnabled = true
|
||||
ctx.subscription.domainCaptureEnabled = true
|
||||
const invite = await ctx.TeamInvitesHandler.promises.createInvite(
|
||||
ctx.manager._id,
|
||||
ctx.subscription,
|
||||
'user@example.com',
|
||||
{ domainCapture: true }
|
||||
)
|
||||
expect(invite.token).to.be.undefined
|
||||
expect(invite.domainCapture).to.be.true
|
||||
expect(invite.email).to.eq('user@example.com')
|
||||
|
||||
sinon.assert.calledWith(
|
||||
ctx.Modules.promises.hooks.fire,
|
||||
'getGroupSSOInitPath',
|
||||
ctx.subscription,
|
||||
invite.email
|
||||
)
|
||||
|
||||
ctx.EmailHandler.promises.sendEmail
|
||||
.calledWith(
|
||||
'inviteNewUserToJoinManagedUsers',
|
||||
sinon.match({
|
||||
to: 'user@example.com',
|
||||
inviter: ctx.manager,
|
||||
acceptInviteUrl: `http://example.com${initPath}`,
|
||||
appName: 'Overleaf',
|
||||
admin: ctx.manager,
|
||||
})
|
||||
)
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('importInvite', function () {
|
||||
|
||||
Reference in New Issue
Block a user