|
|
@@ -553,6 +553,107 @@ describe('ProjectListController', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+ it('should send enterprise_commons=true when user has commons from an enterprise_commons institution', async function (ctx) {
|
|
|
+ ctx.Features.hasFeature.withArgs('saas').returns(true)
|
|
|
+ ctx.UserGetter.promises.getUserFullEmails.resolves([
|
|
|
+ {
|
|
|
+ email: 'test@overleaf.com',
|
|
|
+ emailHasInstitutionLicence: true,
|
|
|
+ affiliation: {
|
|
|
+ institution: {
|
|
|
+ id: 1,
|
|
|
+ name: 'Overleaf',
|
|
|
+ commonsAccount: true,
|
|
|
+ enterpriseCommons: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ])
|
|
|
+ ctx.res.render = () => {}
|
|
|
+
|
|
|
+ await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
|
|
+
|
|
|
+ expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
+ 'setUserProperties',
|
|
|
+ ctx.user._id,
|
|
|
+ sinon.match({ enterprise_commons: true })
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should send enterprise_commons=false when affiliated with an enterprise_commons institution but without active commons access', async function (ctx) {
|
|
|
+ ctx.Features.hasFeature.withArgs('saas').returns(true)
|
|
|
+ ctx.UserGetter.promises.getUserFullEmails.resolves([
|
|
|
+ {
|
|
|
+ email: 'test@overleaf.com',
|
|
|
+ emailHasInstitutionLicence: false,
|
|
|
+ affiliation: {
|
|
|
+ institution: {
|
|
|
+ id: 1,
|
|
|
+ name: 'Overleaf',
|
|
|
+ commonsAccount: true,
|
|
|
+ enterpriseCommons: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ])
|
|
|
+ ctx.res.render = () => {}
|
|
|
+
|
|
|
+ await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
|
|
+
|
|
|
+ expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
+ 'setUserProperties',
|
|
|
+ ctx.user._id,
|
|
|
+ sinon.match({ enterprise_commons: false })
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should send domain_capture=true when user has an affiliation with domain capture enabled', async function (ctx) {
|
|
|
+ ctx.Features.hasFeature.withArgs('saas').returns(true)
|
|
|
+ ctx.UserGetter.promises.getUserFullEmails.resolves([
|
|
|
+ {
|
|
|
+ email: 'test@overleaf.com',
|
|
|
+ affiliation: {
|
|
|
+ institution: { id: 1, name: 'Overleaf' },
|
|
|
+ group: {
|
|
|
+ _id: 'g1',
|
|
|
+ domainCaptureEnabled: true,
|
|
|
+ managedUsersEnabled: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ])
|
|
|
+ ctx.res.render = () => {}
|
|
|
+
|
|
|
+ await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
|
|
+
|
|
|
+ expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
+ 'setUserProperties',
|
|
|
+ ctx.user._id,
|
|
|
+ sinon.match({ domain_capture: true })
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should send domain_capture=false when no affiliation has domain capture enabled', async function (ctx) {
|
|
|
+ ctx.Features.hasFeature.withArgs('saas').returns(true)
|
|
|
+ ctx.UserGetter.promises.getUserFullEmails.resolves([
|
|
|
+ {
|
|
|
+ email: 'test@overleaf.com',
|
|
|
+ affiliation: {
|
|
|
+ institution: { id: 1, name: 'Overleaf' },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ])
|
|
|
+ ctx.res.render = () => {}
|
|
|
+
|
|
|
+ await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
|
|
+
|
|
|
+ expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
+ 'setUserProperties',
|
|
|
+ ctx.user._id,
|
|
|
+ sinon.match({ domain_capture: false })
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
it('should show INR Banner for Indian users with free account', async function (ctx) {
|
|
|
// usersBestSubscription is only available when saas feature is present
|
|
|
ctx.Features.hasFeature.withArgs('saas').returns(true)
|