mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #33345 from overleaf/rh-split-group-role
Update group_role in customer.io when changed GitOrigin-RevId: d21866a9fe324a0468de74a45b6932dda27de8a1
This commit is contained in:
@@ -839,6 +839,76 @@ describe('FeaturesUpdater', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('group_role property', function () {
|
||||
it("should set group_role to '' when the user is not in any group", async function (ctx) {
|
||||
ctx.SubscriptionViewModelBuilder.promises.getUsersSubscriptionDetails.resolves(
|
||||
{
|
||||
bestSubscription: { type: 'free' },
|
||||
individualSubscription: null,
|
||||
memberGroupSubscriptions: [],
|
||||
managedGroupSubscriptions: [],
|
||||
}
|
||||
)
|
||||
await ctx.FeaturesUpdater.promises.refreshFeatures(ctx.user._id, 'test')
|
||||
expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
||||
'setUserProperties',
|
||||
ctx.user._id,
|
||||
sinon.match({ group_role: '' })
|
||||
)
|
||||
})
|
||||
|
||||
it("should set group_role to 'member' when the user only belongs to a group as a member", async function (ctx) {
|
||||
ctx.SubscriptionViewModelBuilder.promises.getUsersSubscriptionDetails.resolves(
|
||||
{
|
||||
bestSubscription: { type: 'free' },
|
||||
individualSubscription: null,
|
||||
memberGroupSubscriptions: [{ _id: new ObjectId() }],
|
||||
managedGroupSubscriptions: [],
|
||||
}
|
||||
)
|
||||
await ctx.FeaturesUpdater.promises.refreshFeatures(ctx.user._id, 'test')
|
||||
expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
||||
'setUserProperties',
|
||||
ctx.user._id,
|
||||
sinon.match({ group_role: 'member' })
|
||||
)
|
||||
})
|
||||
|
||||
it("should set group_role to 'manager' when the user manages a group they don't own", async function (ctx) {
|
||||
ctx.SubscriptionViewModelBuilder.promises.getUsersSubscriptionDetails.resolves(
|
||||
{
|
||||
bestSubscription: { type: 'free' },
|
||||
individualSubscription: null,
|
||||
memberGroupSubscriptions: [],
|
||||
managedGroupSubscriptions: [{ admin_id: { _id: new ObjectId() } }],
|
||||
}
|
||||
)
|
||||
await ctx.FeaturesUpdater.promises.refreshFeatures(ctx.user._id, 'test')
|
||||
expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
||||
'setUserProperties',
|
||||
ctx.user._id,
|
||||
sinon.match({ group_role: 'manager' })
|
||||
)
|
||||
})
|
||||
|
||||
it("should set group_role to 'admin' when the user owns a group", async function (ctx) {
|
||||
ctx.SubscriptionViewModelBuilder.promises.getUsersSubscriptionDetails.resolves(
|
||||
{
|
||||
bestSubscription: { type: 'free' },
|
||||
individualSubscription: null,
|
||||
memberGroupSubscriptions: [],
|
||||
managedGroupSubscriptions: [{ admin_id: { _id: ctx.user._id } }],
|
||||
}
|
||||
)
|
||||
await ctx.FeaturesUpdater.promises.refreshFeatures(ctx.user._id, 'test')
|
||||
expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
||||
'setUserProperties',
|
||||
ctx.user._id,
|
||||
sinon.match({ group_role: 'admin' })
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a non-standard feature set', async function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.SubscriptionLocator.promises.getGroupSubscriptionsMemberOf
|
||||
|
||||
Reference in New Issue
Block a user