2019-05-29 05:21:06 -04:00
|
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
|
const path = require('path')
|
|
|
|
const sinon = require('sinon')
|
2019-09-30 10:46:15 -04:00
|
|
|
const { expect } = require('chai')
|
|
|
|
const { ObjectId } = require('mongodb')
|
2021-02-18 06:46:08 -05:00
|
|
|
const Errors = require('../../../../app/src/Features/Errors/Errors')
|
2019-09-30 10:46:15 -04:00
|
|
|
|
|
|
|
const MODULE_PATH = path.join(
|
2019-05-29 05:21:06 -04:00
|
|
|
__dirname,
|
|
|
|
'../../../../app/src/Features/Project/ProjectController'
|
|
|
|
)
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('ProjectController', function () {
|
|
|
|
beforeEach(function () {
|
2019-09-30 10:46:15 -04:00
|
|
|
this.project_id = ObjectId('abcdefabcdefabcdefabcdef')
|
2019-05-29 05:21:06 -04:00
|
|
|
|
|
|
|
this.user = {
|
2019-09-30 10:46:15 -04:00
|
|
|
_id: ObjectId('123456123456123456123456'),
|
2019-10-21 12:02:01 -04:00
|
|
|
email: 'test@overleaf.com',
|
2019-05-29 05:21:06 -04:00
|
|
|
first_name: 'bjkdsjfk',
|
2019-10-21 12:02:01 -04:00
|
|
|
features: {},
|
2021-04-27 03:52:58 -04:00
|
|
|
emails: [{ email: 'test@overleaf.com' }],
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.settings = {
|
|
|
|
apis: {
|
|
|
|
chat: {
|
2021-04-27 03:52:58 -04:00
|
|
|
url: 'chat.com',
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
2021-10-20 06:17:59 -04:00
|
|
|
siteUrl: 'https://overleaf.com',
|
2021-04-27 03:52:58 -04:00
|
|
|
algolia: {},
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.brandVariationDetails = {
|
|
|
|
id: '12',
|
|
|
|
active: true,
|
|
|
|
brand_name: 'The journal',
|
|
|
|
home_url: 'http://www.thejournal.com/',
|
2021-04-27 03:52:58 -04:00
|
|
|
publish_menu_link_html: 'Submit your paper to the <em>The Journal</em>',
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.token = 'some-token'
|
|
|
|
this.ProjectDeleter = {
|
|
|
|
deleteProject: sinon.stub().callsArg(2),
|
|
|
|
restoreProject: sinon.stub().callsArg(1),
|
2021-04-27 03:52:58 -04:00
|
|
|
findArchivedProjects: sinon.stub(),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.ProjectDuplicator = {
|
2021-04-27 03:52:58 -04:00
|
|
|
duplicate: sinon.stub().callsArgWith(3, null, { _id: this.project_id }),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.ProjectCreationHandler = {
|
|
|
|
createExampleProject: sinon
|
|
|
|
.stub()
|
|
|
|
.callsArgWith(2, null, { _id: this.project_id }),
|
|
|
|
createBasicProject: sinon
|
|
|
|
.stub()
|
2021-04-27 03:52:58 -04:00
|
|
|
.callsArgWith(2, null, { _id: this.project_id }),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.SubscriptionLocator = { getUsersSubscription: sinon.stub() }
|
|
|
|
this.LimitationsManager = { hasPaidSubscription: sinon.stub() }
|
|
|
|
this.TagsHandler = { getAllTags: sinon.stub() }
|
|
|
|
this.NotificationsHandler = { getUserNotifications: sinon.stub() }
|
|
|
|
this.UserModel = { findById: sinon.stub() }
|
2019-10-18 05:32:19 -04:00
|
|
|
this.AuthorizationManager = {
|
|
|
|
getPrivilegeLevelForProject: sinon.stub(),
|
2021-04-27 03:52:58 -04:00
|
|
|
isRestrictedUser: sinon.stub().returns(false),
|
2019-10-18 05:32:19 -04:00
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController = { renameProject: sinon.stub() }
|
|
|
|
this.InactiveProjectManager = { reactivateProjectIfRequired: sinon.stub() }
|
|
|
|
this.ProjectUpdateHandler = { markAsOpened: sinon.stub() }
|
|
|
|
this.ProjectGetter = {
|
|
|
|
findAllUsersProjects: sinon.stub(),
|
2021-04-27 03:52:58 -04:00
|
|
|
getProject: sinon.stub(),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-08-09 05:40:11 -04:00
|
|
|
this.ProjectHelper = {
|
2019-08-27 06:38:17 -04:00
|
|
|
isArchived: sinon.stub(),
|
|
|
|
isTrashed: sinon.stub(),
|
2020-06-30 08:04:59 -04:00
|
|
|
isArchivedOrTrashed: sinon.stub(),
|
2021-04-27 03:52:58 -04:00
|
|
|
getAllowedImagesForUser: sinon.stub().returns([]),
|
2019-08-09 05:40:11 -04:00
|
|
|
}
|
2021-07-28 04:51:20 -04:00
|
|
|
this.SessionManager = {
|
2019-05-29 05:21:06 -04:00
|
|
|
getLoggedInUser: sinon.stub().callsArgWith(1, null, this.user),
|
|
|
|
getLoggedInUserId: sinon.stub().returns(this.user._id),
|
|
|
|
getSessionUser: sinon.stub().returns(this.user),
|
2021-04-27 03:52:58 -04:00
|
|
|
isUserLoggedIn: sinon.stub().returns(true),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-12-10 03:10:05 -05:00
|
|
|
this.UserController = {
|
2021-04-27 03:52:58 -04:00
|
|
|
logout: sinon.stub(),
|
2019-12-10 03:10:05 -05:00
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
this.TokenAccessHandler = {
|
|
|
|
getRequestToken: sinon.stub().returns(this.token),
|
2021-04-27 03:52:58 -04:00
|
|
|
protectTokens: sinon.stub(),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-10-07 04:30:51 -04:00
|
|
|
this.CollaboratorsGetter = {
|
2021-04-27 03:52:58 -04:00
|
|
|
userIsTokenMember: sinon.stub().callsArgWith(2, null, false),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.ProjectEntityHandler = {}
|
|
|
|
this.NotificationBuilder = {
|
2021-04-27 03:52:58 -04:00
|
|
|
ipMatcherAffiliation: sinon.stub().returns({ create: sinon.stub() }),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.UserGetter = {
|
2021-02-02 09:24:42 -05:00
|
|
|
getUserFullEmails: sinon.stub().yields(null, []),
|
2019-05-29 05:21:06 -04:00
|
|
|
getUser: sinon
|
|
|
|
.stub()
|
2021-04-27 03:52:58 -04:00
|
|
|
.callsArgWith(2, null, { lastLoginIp: '192.170.18.2' }),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-10-21 12:02:01 -04:00
|
|
|
this.Features = {
|
2021-04-27 03:52:58 -04:00
|
|
|
hasFeature: sinon.stub(),
|
2019-10-21 12:02:01 -04:00
|
|
|
}
|
2021-10-26 09:31:24 -04:00
|
|
|
this.FeaturesUpdater = {
|
|
|
|
featuresEpochIsCurrent: sinon.stub().returns(true),
|
|
|
|
refreshFeatures: sinon.stub().yields(null, this.user),
|
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
this.BrandVariationsHandler = {
|
|
|
|
getBrandVariationById: sinon
|
|
|
|
.stub()
|
2021-04-27 03:52:58 -04:00
|
|
|
.callsArgWith(1, null, this.brandVariationDetails),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-11-26 08:11:19 -05:00
|
|
|
this.TpdsProjectFlusher = {
|
2021-04-27 03:52:58 -04:00
|
|
|
flushProjectToTpdsIfNeeded: sinon.stub().yields(),
|
2019-11-26 08:11:19 -05:00
|
|
|
}
|
2020-04-02 06:01:41 -04:00
|
|
|
this.Metrics = {
|
|
|
|
Timer: class {
|
|
|
|
done() {}
|
|
|
|
},
|
2021-04-27 03:52:58 -04:00
|
|
|
inc: sinon.stub(),
|
2020-04-02 06:01:41 -04:00
|
|
|
}
|
2021-02-17 08:52:46 -05:00
|
|
|
this.NewLogsUIHelper = {
|
2021-03-23 06:18:28 -04:00
|
|
|
getNewLogsUIVariantForUser: sinon
|
|
|
|
.stub()
|
2021-04-27 03:52:58 -04:00
|
|
|
.returns({ newLogsUI: false, subvariant: null }),
|
2021-02-17 08:52:46 -05:00
|
|
|
}
|
2021-05-21 07:32:07 -04:00
|
|
|
this.SplitTestHandler = {
|
2021-05-27 05:29:55 -04:00
|
|
|
promises: {
|
|
|
|
getTestSegmentation: sinon.stub().resolves({ enabled: false }),
|
|
|
|
},
|
2021-06-01 09:53:27 -04:00
|
|
|
getTestSegmentation: sinon.stub().yields(null, { enabled: false }),
|
2021-05-21 07:32:07 -04:00
|
|
|
}
|
2021-08-19 11:42:49 -04:00
|
|
|
this.SplitTestV2Handler = {
|
|
|
|
promises: {
|
2021-11-22 05:35:10 -05:00
|
|
|
getAssignment: sinon.stub().resolves({ variant: 'default' }),
|
|
|
|
getAssignmentForSession: sinon.stub().resolves({ variant: 'default' }),
|
|
|
|
assignInLocalsContext: sinon.stub().resolves({ variant: 'default' }),
|
|
|
|
assignInLocalsContextForSession: sinon
|
|
|
|
.stub()
|
|
|
|
.resolves({ variant: 'default' }),
|
2021-08-19 11:42:49 -04:00
|
|
|
},
|
2021-11-22 05:35:10 -05:00
|
|
|
getAssignment: sinon.stub().yields(null, { variant: 'default' }),
|
2021-11-11 06:20:06 -05:00
|
|
|
getAssignmentForSession: sinon
|
|
|
|
.stub()
|
2021-11-22 05:35:10 -05:00
|
|
|
.yields(null, { variant: 'default' }),
|
|
|
|
assignInLocalsContext: sinon.stub().yields(null, { variant: 'default' }),
|
|
|
|
assignInLocalsContextForSession: sinon
|
|
|
|
.stub()
|
|
|
|
.yields(null, { variant: 'default' }),
|
2021-08-19 11:42:49 -04:00
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController = SandboxedModule.require(MODULE_PATH, {
|
2019-05-29 05:21:06 -04:00
|
|
|
requires: {
|
2020-10-05 04:23:21 -04:00
|
|
|
mongodb: { ObjectId },
|
2021-07-07 05:38:56 -04:00
|
|
|
'@overleaf/settings': this.settings,
|
2020-10-30 04:10:50 -04:00
|
|
|
'@overleaf/metrics': this.Metrics,
|
2021-05-21 07:32:07 -04:00
|
|
|
'../SplitTests/SplitTestHandler': this.SplitTestHandler,
|
2021-08-19 11:42:49 -04:00
|
|
|
'../SplitTests/SplitTestV2Handler': this.SplitTestV2Handler,
|
2019-05-29 05:21:06 -04:00
|
|
|
'./ProjectDeleter': this.ProjectDeleter,
|
|
|
|
'./ProjectDuplicator': this.ProjectDuplicator,
|
|
|
|
'./ProjectCreationHandler': this.ProjectCreationHandler,
|
|
|
|
'../Editor/EditorController': this.EditorController,
|
2019-12-10 03:10:05 -05:00
|
|
|
'../User/UserController': this.UserController,
|
2019-08-09 05:40:11 -04:00
|
|
|
'./ProjectHelper': this.ProjectHelper,
|
2019-05-29 05:21:06 -04:00
|
|
|
'../Subscription/SubscriptionLocator': this.SubscriptionLocator,
|
|
|
|
'../Subscription/LimitationsManager': this.LimitationsManager,
|
|
|
|
'../Tags/TagsHandler': this.TagsHandler,
|
|
|
|
'../Notifications/NotificationsHandler': this.NotificationsHandler,
|
2019-11-26 08:11:19 -05:00
|
|
|
'../../models/User': { User: this.UserModel },
|
2019-05-29 05:21:06 -04:00
|
|
|
'../Authorization/AuthorizationManager': this.AuthorizationManager,
|
|
|
|
'../InactiveData/InactiveProjectManager': this.InactiveProjectManager,
|
|
|
|
'./ProjectUpdateHandler': this.ProjectUpdateHandler,
|
|
|
|
'./ProjectGetter': this.ProjectGetter,
|
2019-09-30 10:46:15 -04:00
|
|
|
'./ProjectDetailsHandler': this.ProjectDetailsHandler,
|
2021-07-28 04:51:20 -04:00
|
|
|
'../Authentication/SessionManager': this.SessionManager,
|
2019-05-29 05:21:06 -04:00
|
|
|
'../TokenAccess/TokenAccessHandler': this.TokenAccessHandler,
|
2019-10-07 04:30:51 -04:00
|
|
|
'../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter,
|
2019-05-29 05:21:06 -04:00
|
|
|
'./ProjectEntityHandler': this.ProjectEntityHandler,
|
|
|
|
'../../infrastructure/Features': this.Features,
|
2021-10-26 09:31:24 -04:00
|
|
|
'../Subscription/FeaturesUpdater': this.FeaturesUpdater,
|
2019-05-29 05:21:06 -04:00
|
|
|
'../Notifications/NotificationsBuilder': this.NotificationBuilder,
|
|
|
|
'../User/UserGetter': this.UserGetter,
|
|
|
|
'../BrandVariations/BrandVariationsHandler': this
|
|
|
|
.BrandVariationsHandler,
|
2019-11-26 08:11:19 -05:00
|
|
|
'../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher,
|
2020-07-20 09:23:20 -04:00
|
|
|
'../../models/Project': {},
|
2021-09-10 04:30:01 -04:00
|
|
|
'../Analytics/AnalyticsManager': { recordEventForUser: () => {} },
|
2021-02-02 09:24:42 -05:00
|
|
|
'../../infrastructure/Modules': {
|
2021-04-27 03:52:58 -04:00
|
|
|
hooks: { fire: sinon.stub().yields(null, []) },
|
2021-02-17 08:52:46 -05:00
|
|
|
},
|
2021-04-27 03:52:58 -04:00
|
|
|
'../Helpers/NewLogsUI': this.NewLogsUIHelper,
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
this.projectName = '£12321jkj9ujkljds'
|
|
|
|
this.req = {
|
2021-05-27 05:29:55 -04:00
|
|
|
query: {},
|
2019-05-29 05:21:06 -04:00
|
|
|
params: {
|
2021-04-27 03:52:58 -04:00
|
|
|
Project_id: this.project_id,
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
headers: {},
|
|
|
|
connection: {
|
2021-04-27 03:52:58 -04:00
|
|
|
remoteAddress: '192.170.18.1',
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
session: {
|
2021-04-27 03:52:58 -04:00
|
|
|
user: this.user,
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
body: {
|
2021-04-27 03:52:58 -04:00
|
|
|
projectName: this.projectName,
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
i18n: {
|
2021-04-27 03:52:58 -04:00
|
|
|
translate() {},
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
2021-04-27 03:52:58 -04:00
|
|
|
ip: '192.170.18.1',
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.res = {
|
2019-05-29 05:21:06 -04:00
|
|
|
locals: {
|
2021-04-27 03:52:58 -04:00
|
|
|
jsPath: 'js path here',
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
2021-04-27 03:52:58 -04:00
|
|
|
setTimeout: sinon.stub(),
|
2019-09-30 10:46:15 -04:00
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('updateProjectSettings', function () {
|
|
|
|
it('should update the name', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController.renameProject = sinon.stub().callsArg(2)
|
|
|
|
this.req.body = { name: (this.name = 'New name') }
|
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.EditorController.renameProject
|
|
|
|
.calledWith(this.project_id, this.name)
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(204)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.updateProjectSettings(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should update the compiler', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController.setCompiler = sinon.stub().callsArg(2)
|
|
|
|
this.req.body = { compiler: (this.compiler = 'pdflatex') }
|
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.EditorController.setCompiler
|
|
|
|
.calledWith(this.project_id, this.compiler)
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(204)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.updateProjectSettings(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should update the imageName', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController.setImageName = sinon.stub().callsArg(2)
|
|
|
|
this.req.body = { imageName: (this.imageName = 'texlive-1234.5') }
|
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.EditorController.setImageName
|
|
|
|
.calledWith(this.project_id, this.imageName)
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(204)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.updateProjectSettings(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should update the spell check language', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController.setSpellCheckLanguage = sinon.stub().callsArg(2)
|
|
|
|
this.req.body = { spellCheckLanguage: (this.languageCode = 'fr') }
|
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.EditorController.setSpellCheckLanguage
|
|
|
|
.calledWith(this.project_id, this.languageCode)
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(204)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.updateProjectSettings(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should update the root doc', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController.setRootDoc = sinon.stub().callsArg(2)
|
|
|
|
this.req.body = { rootDocId: (this.rootDocId = 'root-doc-id') }
|
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.EditorController.setRootDoc
|
|
|
|
.calledWith(this.project_id, this.rootDocId)
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(204)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.updateProjectSettings(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('updateProjectAdminSettings', function () {
|
|
|
|
it('should update the public access level', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController.setPublicAccessLevel = sinon.stub().callsArg(2)
|
|
|
|
this.req.body = {
|
2021-04-27 03:52:58 -04:00
|
|
|
publicAccessLevel: (this.publicAccessLevel = 'readonly'),
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.EditorController.setPublicAccessLevel
|
|
|
|
.calledWith(this.project_id, this.publicAccessLevel)
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(204)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.updateProjectAdminSettings(this.req, this.res)
|
2019-08-07 10:04:04 -04:00
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('deleteProject', function () {
|
|
|
|
it('should call the project deleter', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.ProjectDeleter.deleteProject
|
|
|
|
.calledWith(this.project_id, {
|
|
|
|
deleterUser: this.user,
|
2021-04-27 03:52:58 -04:00
|
|
|
ipAddress: this.req.ip,
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(200)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.deleteProject(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('restoreProject', function () {
|
|
|
|
it('should tell the project deleter', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.sendStatus = code => {
|
|
|
|
this.ProjectDeleter.restoreProject
|
|
|
|
.calledWith(this.project_id)
|
|
|
|
.should.equal(true)
|
|
|
|
code.should.equal(200)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.restoreProject(this.req, this.res)
|
2019-08-07 10:04:04 -04:00
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('cloneProject', function () {
|
|
|
|
it('should call the project duplicator', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.send = json => {
|
|
|
|
this.ProjectDuplicator.duplicate
|
|
|
|
.calledWith(this.user, this.project_id, this.projectName)
|
|
|
|
.should.equal(true)
|
|
|
|
json.project_id.should.equal(this.project_id)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.cloneProject(this.req, this.res)
|
2019-08-07 10:04:04 -04:00
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('newProject', function () {
|
|
|
|
it('should call the projectCreationHandler with createExampleProject', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.req.body.template = 'example'
|
|
|
|
this.res.send = json => {
|
|
|
|
this.ProjectCreationHandler.createExampleProject
|
|
|
|
.calledWith(this.user._id, this.projectName)
|
|
|
|
.should.equal(true)
|
|
|
|
this.ProjectCreationHandler.createBasicProject.called.should.equal(
|
|
|
|
false
|
|
|
|
)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.newProject(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should call the projectCreationHandler with createBasicProject', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.req.body.template = 'basic'
|
|
|
|
this.res.send = json => {
|
|
|
|
this.ProjectCreationHandler.createExampleProject.called.should.equal(
|
|
|
|
false
|
|
|
|
)
|
|
|
|
this.ProjectCreationHandler.createBasicProject
|
|
|
|
.calledWith(this.user._id, this.projectName)
|
|
|
|
.should.equal(true)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.newProject(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('projectListPage', function () {
|
|
|
|
beforeEach(function () {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.tags = [
|
|
|
|
{ name: 1, project_ids: ['1', '2', '3'] },
|
|
|
|
{ name: 2, project_ids: ['a', '1'] },
|
2021-04-27 03:52:58 -04:00
|
|
|
{ name: 3, project_ids: ['a', 'b', 'c', 'd'] },
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.notifications = [
|
2021-04-27 03:52:58 -04:00
|
|
|
{
|
|
|
|
_id: '1',
|
|
|
|
user_id: '2',
|
|
|
|
templateKey: '3',
|
|
|
|
messageOpts: '4',
|
|
|
|
key: '5',
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.projects = [
|
|
|
|
{ _id: 1, lastUpdated: 1, owner_ref: 'user-1' },
|
2021-04-27 03:52:58 -04:00
|
|
|
{
|
|
|
|
_id: 2,
|
|
|
|
lastUpdated: 2,
|
|
|
|
owner_ref: 'user-2',
|
|
|
|
lastUpdatedBy: 'user-1',
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.collabertions = [{ _id: 5, lastUpdated: 5, owner_ref: 'user-1' }]
|
|
|
|
this.readOnly = [{ _id: 3, lastUpdated: 3, owner_ref: 'user-1' }]
|
|
|
|
this.tokenReadAndWrite = [{ _id: 6, lastUpdated: 5, owner_ref: 'user-4' }]
|
|
|
|
this.tokenReadOnly = [{ _id: 7, lastUpdated: 4, owner_ref: 'user-5' }]
|
|
|
|
this.allProjects = {
|
|
|
|
owned: this.projects,
|
|
|
|
readAndWrite: this.collabertions,
|
|
|
|
readOnly: this.readOnly,
|
|
|
|
tokenReadAndWrite: this.tokenReadAndWrite,
|
2021-04-27 03:52:58 -04:00
|
|
|
tokenReadOnly: this.tokenReadOnly,
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this.users = {
|
|
|
|
'user-1': {
|
2021-04-27 03:52:58 -04:00
|
|
|
first_name: 'James',
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
'user-2': {
|
2021-04-27 03:52:58 -04:00
|
|
|
first_name: 'Henry',
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.users[this.user._id] = this.user // Owner
|
|
|
|
this.UserModel.findById = (id, fields, callback) => {
|
2019-09-30 10:46:15 -04:00
|
|
|
callback(null, this.users[id])
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-10-01 07:27:15 -04:00
|
|
|
this.UserGetter.getUser = (id, fields, callback) => {
|
2019-09-30 10:46:15 -04:00
|
|
|
callback(null, this.users[id])
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this.LimitationsManager.hasPaidSubscription.callsArgWith(1, null, false)
|
2019-06-27 06:13:59 -04:00
|
|
|
this.TagsHandler.getAllTags.callsArgWith(1, null, this.tags)
|
2019-05-29 05:21:06 -04:00
|
|
|
this.NotificationsHandler.getUserNotifications = sinon
|
|
|
|
.stub()
|
|
|
|
.callsArgWith(1, null, this.notifications, {})
|
|
|
|
this.ProjectGetter.findAllUsersProjects.callsArgWith(
|
|
|
|
2,
|
|
|
|
null,
|
|
|
|
this.allProjects
|
|
|
|
)
|
2020-05-19 15:05:36 -04:00
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should render the project/list page', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
pageName.should.equal('project/list')
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should send the tags', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.tags.length.should.equal(this.tags.length)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should create trigger ip matcher notifications', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.settings.overleaf = true
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
this.NotificationBuilder.ipMatcherAffiliation.called.should.equal(true)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should send the projects', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.projects.length.should.equal(
|
|
|
|
this.projects.length +
|
|
|
|
this.collabertions.length +
|
|
|
|
this.readOnly.length +
|
|
|
|
this.tokenReadAndWrite.length +
|
|
|
|
this.tokenReadOnly.length
|
|
|
|
)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should send the user', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.user.should.deep.equal(this.user)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should inject the users', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.projects[0].owner.should.equal(
|
|
|
|
this.users[this.projects[0].owner_ref]
|
|
|
|
)
|
|
|
|
opts.projects[1].owner.should.equal(
|
|
|
|
this.users[this.projects[1].owner_ref]
|
|
|
|
)
|
|
|
|
opts.projects[1].lastUpdatedBy.should.equal(
|
|
|
|
this.users[this.projects[1].lastUpdatedBy]
|
|
|
|
)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should send hasSubscription == false when no subscription', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.hasSubscription.should.equal(false)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should send hasSubscription == true when there is a subscription', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.LimitationsManager.hasPaidSubscription = sinon
|
|
|
|
.stub()
|
|
|
|
.callsArgWith(1, null, true)
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.hasSubscription.should.equal(true)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('front widget', function (done) {
|
|
|
|
beforeEach(function () {
|
2019-09-30 10:46:15 -04:00
|
|
|
this.settings.overleaf = {
|
2021-04-27 03:52:58 -04:00
|
|
|
front_chat_widget_room_id: 'chat-room-id',
|
2019-09-30 10:46:15 -04:00
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show for paid users', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.user.features.github = true
|
|
|
|
this.user.features.dropbox = true
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.frontChatWidgetRoomId.should.equal(
|
|
|
|
this.settings.overleaf.front_chat_widget_room_id
|
|
|
|
)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show for sample users', function (done) {
|
2019-09-30 10:46:15 -04:00
|
|
|
this.user._id = ObjectId('588f3ddae8ebc1bac07c9f00') // last two digits
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.frontChatWidgetRoomId.should.equal(
|
|
|
|
this.settings.overleaf.front_chat_widget_room_id
|
|
|
|
)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should not show for non sample users', function (done) {
|
2019-09-30 10:46:15 -04:00
|
|
|
this.user._id = ObjectId('588f3ddae8ebc1bac07c9fff') // last two digits
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.frontChatWidgetRoomId).to.equal(undefined)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('With Institution SSO feature', function () {
|
|
|
|
beforeEach(function (done) {
|
2019-10-21 12:02:01 -04:00
|
|
|
this.institutionEmail = 'test@overleaf.com'
|
|
|
|
this.institutionName = 'Overleaf'
|
|
|
|
this.Features.hasFeature.withArgs('saml').returns(true)
|
2020-01-02 14:22:06 -05:00
|
|
|
this.Features.hasFeature.withArgs('affiliations').returns(true)
|
|
|
|
this.Features.hasFeature.withArgs('overleaf-integration').returns(true)
|
2019-10-21 12:02:01 -04:00
|
|
|
done()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show institution SSO available notification for confirmed domains', function () {
|
2021-02-02 09:26:10 -05:00
|
|
|
this.UserGetter.getUserFullEmails.yields(null, [
|
|
|
|
{
|
|
|
|
email: 'test@overleaf.com',
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
id: 1,
|
|
|
|
confirmed: true,
|
|
|
|
name: 'Overleaf',
|
|
|
|
ssoBeta: false,
|
2021-04-27 03:52:58 -04:00
|
|
|
ssoEnabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-02 09:26:10 -05:00
|
|
|
])
|
2019-10-21 12:02:01 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
2019-10-29 11:41:13 -04:00
|
|
|
expect(opts.notificationsInstitution).to.deep.include({
|
2020-04-22 10:12:40 -04:00
|
|
|
email: this.institutionEmail,
|
2019-10-21 12:02:01 -04:00
|
|
|
institutionId: 1,
|
2020-04-22 10:12:40 -04:00
|
|
|
institutionName: this.institutionName,
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_available',
|
2019-10-21 12:02:01 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show a linked notification', function () {
|
2019-10-21 12:02:01 -04:00
|
|
|
this.req.session.saml = {
|
|
|
|
institutionEmail: this.institutionEmail,
|
|
|
|
linked: {
|
|
|
|
hasEntitlement: false,
|
2021-04-27 03:52:58 -04:00
|
|
|
universityName: this.institutionName,
|
|
|
|
},
|
2019-10-21 12:02:01 -04:00
|
|
|
}
|
|
|
|
this.res.render = (pageName, opts) => {
|
2019-10-29 11:41:13 -04:00
|
|
|
expect(opts.notificationsInstitution).to.deep.include({
|
2019-10-21 12:02:01 -04:00
|
|
|
email: this.institutionEmail,
|
|
|
|
institutionName: this.institutionName,
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_linked',
|
2019-10-21 12:02:01 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show a linked another email notification', function () {
|
2019-10-21 12:02:01 -04:00
|
|
|
// when they request to link an email but the institution returns
|
|
|
|
// a different email
|
|
|
|
this.res.render = (pageName, opts) => {
|
2019-10-29 11:41:13 -04:00
|
|
|
expect(opts.notificationsInstitution).to.deep.include({
|
2019-10-21 12:02:01 -04:00
|
|
|
institutionEmail: this.institutionEmail,
|
|
|
|
requestedEmail: 'requested@overleaf.com',
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_non_canonical',
|
2019-10-21 12:02:01 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.req.session.saml = {
|
|
|
|
emailNonCanonical: this.institutionEmail,
|
|
|
|
institutionEmail: this.institutionEmail,
|
|
|
|
requestedEmail: 'requested@overleaf.com',
|
|
|
|
linked: {
|
|
|
|
hasEntitlement: false,
|
2021-04-27 03:52:58 -04:00
|
|
|
universityName: this.institutionName,
|
|
|
|
},
|
2019-10-21 12:02:01 -04:00
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
2021-02-18 06:46:08 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show a notification when intent was to register via SSO but account existed', function () {
|
2019-10-21 12:02:01 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
2019-10-29 11:41:13 -04:00
|
|
|
expect(opts.notificationsInstitution).to.deep.include({
|
2019-10-21 12:02:01 -04:00
|
|
|
email: this.institutionEmail,
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_already_registered',
|
2019-10-21 12:02:01 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.req.session.saml = {
|
|
|
|
institutionEmail: this.institutionEmail,
|
|
|
|
linked: {
|
|
|
|
hasEntitlement: false,
|
2021-04-27 03:52:58 -04:00
|
|
|
universityName: 'Overleaf',
|
2019-10-21 12:02:01 -04:00
|
|
|
},
|
2019-11-06 08:41:08 -05:00
|
|
|
registerIntercept: {
|
|
|
|
id: 1,
|
2021-04-27 03:52:58 -04:00
|
|
|
name: 'Example University',
|
|
|
|
},
|
2019-11-06 08:41:08 -05:00
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
2021-02-18 06:46:08 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should not show a register notification if the flow was abandoned', function () {
|
2019-11-06 08:41:08 -05:00
|
|
|
// could initially start to register with an SSO email and then
|
|
|
|
// abandon flow and login with an existing non-institution SSO email
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.notificationsInstitution).to.deep.not.include({
|
|
|
|
email: 'test@overleaf.com',
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_already_registered',
|
2019-11-06 08:41:08 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.req.session.saml = {
|
|
|
|
registerIntercept: {
|
|
|
|
id: 1,
|
2021-04-27 03:52:58 -04:00
|
|
|
name: 'Example University',
|
|
|
|
},
|
2019-10-21 12:02:01 -04:00
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
2021-02-18 06:46:08 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show error notification', function () {
|
2019-11-12 08:59:04 -05:00
|
|
|
this.res.render = (pageName, opts) => {
|
2021-02-18 06:46:08 -05:00
|
|
|
expect(opts.notificationsInstitution.length).to.equal(1)
|
|
|
|
expect(opts.notificationsInstitution[0].templateKey).to.equal(
|
|
|
|
'notification_institution_sso_error'
|
|
|
|
)
|
|
|
|
expect(opts.notificationsInstitution[0].error).to.be.instanceof(
|
|
|
|
Errors.SAMLAlreadyLinkedError
|
|
|
|
)
|
2019-11-12 08:59:04 -05:00
|
|
|
}
|
|
|
|
this.req.session.saml = {
|
|
|
|
institutionEmail: this.institutionEmail,
|
2021-04-27 03:52:58 -04:00
|
|
|
error: new Errors.SAMLAlreadyLinkedError(),
|
2019-11-12 08:59:04 -05:00
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
2021-02-18 06:46:08 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('for an unconfirmed domain for an SSO institution', function () {
|
|
|
|
beforeEach(function (done) {
|
2021-02-02 09:26:10 -05:00
|
|
|
this.UserGetter.getUserFullEmails.yields(null, [
|
2020-04-22 10:12:40 -04:00
|
|
|
{
|
|
|
|
email: 'test@overleaf-uncofirmed.com',
|
2021-02-02 09:26:10 -05:00
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
id: 1,
|
|
|
|
confirmed: false,
|
|
|
|
name: 'Overleaf',
|
|
|
|
ssoBeta: false,
|
2021-04-27 03:52:58 -04:00
|
|
|
ssoEnabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-04-22 10:12:40 -04:00
|
|
|
])
|
|
|
|
done()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should not show institution SSO available notification', function () {
|
2020-04-22 10:12:40 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.notificationsInstitution.length).to.equal(0)
|
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when linking/logging in initiated on institution side', function () {
|
|
|
|
it('should not show a linked another email notification', function () {
|
2019-11-13 09:22:54 -05:00
|
|
|
// this is only used when initated on Overleaf,
|
|
|
|
// because we keep track of the requested email they tried to link
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.notificationsInstitution).to.not.deep.include({
|
|
|
|
institutionEmail: this.institutionEmail,
|
|
|
|
requestedEmail: undefined,
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_non_canonical',
|
2019-11-13 09:22:54 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.req.session.saml = {
|
|
|
|
emailNonCanonical: this.institutionEmail,
|
|
|
|
institutionEmail: this.institutionEmail,
|
|
|
|
linked: {
|
|
|
|
hasEntitlement: false,
|
2021-04-27 03:52:58 -04:00
|
|
|
universityName: this.institutionName,
|
|
|
|
},
|
2019-11-13 09:22:54 -05:00
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('Institution with SSO beta testable', function () {
|
|
|
|
beforeEach(function (done) {
|
2021-02-02 09:26:10 -05:00
|
|
|
this.UserGetter.getUserFullEmails.yields(null, [
|
2020-01-02 14:22:06 -05:00
|
|
|
{
|
|
|
|
email: 'beta@beta.com',
|
2021-02-02 09:26:10 -05:00
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
id: 2,
|
|
|
|
confirmed: true,
|
|
|
|
name: 'Beta University',
|
|
|
|
ssoBeta: true,
|
2021-04-27 03:52:58 -04:00
|
|
|
ssoEnabled: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-01-02 14:22:06 -05:00
|
|
|
])
|
|
|
|
done()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should show institution SSO available notification when on a beta testing session', function () {
|
2020-01-02 14:22:06 -05:00
|
|
|
this.req.session.samlBeta = true
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.notificationsInstitution).to.deep.include({
|
|
|
|
email: 'beta@beta.com',
|
|
|
|
institutionId: 2,
|
|
|
|
institutionName: 'Beta University',
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_available',
|
2020-01-02 14:22:06 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should not show institution SSO available notification when not on a beta testing session', function () {
|
2020-01-02 14:22:06 -05:00
|
|
|
this.req.session.samlBeta = false
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.notificationsInstitution).to.deep.not.include({
|
|
|
|
email: 'test@overleaf.com',
|
|
|
|
institutionId: 1,
|
|
|
|
institutionName: 'Overleaf',
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_available',
|
2020-01-02 14:22:06 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
|
|
|
})
|
2019-10-21 12:02:01 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('Without Institution SSO feature', function () {
|
|
|
|
beforeEach(function (done) {
|
2019-10-21 12:02:01 -04:00
|
|
|
this.Features.hasFeature.withArgs('saml').returns(false)
|
|
|
|
done()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should not show institution sso available notification', function () {
|
2019-10-21 12:02:01 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
2019-10-29 11:41:13 -04:00
|
|
|
expect(opts.notificationsInstitution).to.deep.not.include({
|
2019-10-21 12:02:01 -04:00
|
|
|
email: 'test@overleaf.com',
|
|
|
|
institutionId: 1,
|
|
|
|
institutionName: 'Overleaf',
|
2021-04-27 03:52:58 -04:00
|
|
|
templateKey: 'notification_institution_sso_available',
|
2019-10-21 12:02:01 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('projectListPage with duplicate projects', function () {
|
|
|
|
beforeEach(function () {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.tags = [
|
|
|
|
{ name: 1, project_ids: ['1', '2', '3'] },
|
|
|
|
{ name: 2, project_ids: ['a', '1'] },
|
2021-04-27 03:52:58 -04:00
|
|
|
{ name: 3, project_ids: ['a', 'b', 'c', 'd'] },
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.notifications = [
|
2021-04-27 03:52:58 -04:00
|
|
|
{
|
|
|
|
_id: '1',
|
|
|
|
user_id: '2',
|
|
|
|
templateKey: '3',
|
|
|
|
messageOpts: '4',
|
|
|
|
key: '5',
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.projects = [
|
|
|
|
{ _id: 1, lastUpdated: 1, owner_ref: 'user-1' },
|
2021-04-27 03:52:58 -04:00
|
|
|
{ _id: 2, lastUpdated: 2, owner_ref: 'user-2' },
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.collabertions = [{ _id: 5, lastUpdated: 5, owner_ref: 'user-1' }]
|
|
|
|
this.readOnly = [{ _id: 3, lastUpdated: 3, owner_ref: 'user-1' }]
|
|
|
|
this.tokenReadAndWrite = [{ _id: 6, lastUpdated: 5, owner_ref: 'user-4' }]
|
|
|
|
this.tokenReadOnly = [
|
|
|
|
{ _id: 6, lastUpdated: 5, owner_ref: 'user-4' }, // Also in tokenReadAndWrite
|
2021-04-27 03:52:58 -04:00
|
|
|
{ _id: 7, lastUpdated: 4, owner_ref: 'user-5' },
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.allProjects = {
|
|
|
|
owned: this.projects,
|
|
|
|
readAndWrite: this.collabertions,
|
|
|
|
readOnly: this.readOnly,
|
|
|
|
tokenReadAndWrite: this.tokenReadAndWrite,
|
2021-04-27 03:52:58 -04:00
|
|
|
tokenReadOnly: this.tokenReadOnly,
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this.users = {
|
|
|
|
'user-1': {
|
2021-04-27 03:52:58 -04:00
|
|
|
first_name: 'James',
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
'user-2': {
|
2021-04-27 03:52:58 -04:00
|
|
|
first_name: 'Henry',
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.users[this.user._id] = this.user // Owner
|
|
|
|
this.UserModel.findById = (id, fields, callback) => {
|
2019-09-30 10:46:15 -04:00
|
|
|
callback(null, this.users[id])
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this.LimitationsManager.hasPaidSubscription.callsArgWith(1, null, false)
|
2019-06-27 06:13:59 -04:00
|
|
|
this.TagsHandler.getAllTags.callsArgWith(1, null, this.tags)
|
2019-05-29 05:21:06 -04:00
|
|
|
this.NotificationsHandler.getUserNotifications = sinon
|
|
|
|
.stub()
|
|
|
|
.callsArgWith(1, null, this.notifications, {})
|
|
|
|
this.ProjectGetter.findAllUsersProjects.callsArgWith(
|
|
|
|
2,
|
|
|
|
null,
|
|
|
|
this.allProjects
|
|
|
|
)
|
2020-05-19 15:05:36 -04:00
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should render the project/list page', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
pageName.should.equal('project/list')
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should omit one of the projects', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.projects.length.should.equal(
|
|
|
|
this.projects.length +
|
|
|
|
this.collabertions.length +
|
|
|
|
this.readOnly.length +
|
|
|
|
this.tokenReadAndWrite.length +
|
|
|
|
this.tokenReadOnly.length -
|
|
|
|
1
|
|
|
|
)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectListPage(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('renameProject', function () {
|
|
|
|
beforeEach(function () {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.newProjectName = 'my supper great new project'
|
2019-09-30 10:46:15 -04:00
|
|
|
this.req.body.newProjectName = this.newProjectName
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should call the editor controller', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.EditorController.renameProject.callsArgWith(2)
|
|
|
|
this.res.sendStatus = code => {
|
|
|
|
code.should.equal(200)
|
|
|
|
this.EditorController.renameProject
|
|
|
|
.calledWith(this.project_id, this.newProjectName)
|
|
|
|
.should.equal(true)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.renameProject(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should send an error to next() if there is a problem', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
let error
|
|
|
|
this.EditorController.renameProject.callsArgWith(
|
|
|
|
2,
|
|
|
|
(error = new Error('problem'))
|
|
|
|
)
|
|
|
|
const next = e => {
|
|
|
|
e.should.equal(error)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.renameProject(this.req, this.res, next)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('loadEditor', function () {
|
|
|
|
beforeEach(function () {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.settings.editorIsOpen = true
|
|
|
|
this.project = {
|
|
|
|
name: 'my proj',
|
|
|
|
_id: '213123kjlkj',
|
2021-04-27 03:52:58 -04:00
|
|
|
owner_ref: '59fc84d5fbea77482d436e1b',
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.brandedProject = {
|
|
|
|
name: 'my branded proj',
|
|
|
|
_id: '3252332',
|
|
|
|
owner_ref: '59fc84d5fbea77482d436e1b',
|
2021-04-27 03:52:58 -04:00
|
|
|
brandVariationId: '12',
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.user = {
|
|
|
|
_id: '588f3ddae8ebc1bac07c9fa4',
|
|
|
|
ace: {
|
|
|
|
fontSize: 'massive',
|
2021-04-27 03:52:58 -04:00
|
|
|
theme: 'sexy',
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
2021-04-21 04:23:46 -04:00
|
|
|
email: 'bob@bob.com',
|
|
|
|
refProviders: {
|
|
|
|
mendeley: { encrypted: 'aaaa' },
|
2021-04-27 03:52:58 -04:00
|
|
|
zotero: { encrypted: 'bbbb' },
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
this.ProjectGetter.getProject.callsArgWith(2, null, this.project)
|
2020-07-16 02:48:02 -04:00
|
|
|
this.UserModel.findById.callsArgWith(2, null, this.user)
|
2019-05-29 05:21:06 -04:00
|
|
|
this.SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {})
|
|
|
|
this.AuthorizationManager.getPrivilegeLevelForProject.callsArgWith(
|
|
|
|
3,
|
|
|
|
null,
|
|
|
|
'owner'
|
|
|
|
)
|
|
|
|
this.ProjectDeleter.unmarkAsDeletedByExternalSource = sinon.stub()
|
|
|
|
this.InactiveProjectManager.reactivateProjectIfRequired.callsArgWith(1)
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectUpdateHandler.markAsOpened.callsArgWith(1)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should render the project/editor page', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
pageName.should.equal('project/editor')
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should add user', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.user.email.should.equal(this.user.email)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-21 04:23:46 -04:00
|
|
|
it('should sanitize refProviders', function (done) {
|
|
|
|
this.res.render = (_pageName, opts) => {
|
|
|
|
expect(opts.user.refProviders).to.deep.equal({
|
|
|
|
mendeley: true,
|
2021-04-27 03:52:58 -04:00
|
|
|
zotero: true,
|
2021-04-21 04:23:46 -04:00
|
|
|
})
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should add on userSettings', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.userSettings.fontSize.should.equal(this.user.ace.fontSize)
|
|
|
|
opts.userSettings.editorTheme.should.equal(this.user.ace.theme)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should add isRestrictedTokenMember', function (done) {
|
2019-09-18 06:01:13 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.isRestrictedTokenMember.should.exist
|
|
|
|
opts.isRestrictedTokenMember.should.equal(false)
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
return this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should set isRestrictedTokenMember when appropriate', function (done) {
|
2019-10-18 05:32:19 -04:00
|
|
|
this.AuthorizationManager.isRestrictedUser.returns(true)
|
2019-09-18 06:01:13 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.isRestrictedTokenMember.should.exist
|
|
|
|
opts.isRestrictedTokenMember.should.equal(true)
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
return this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should render the closed page if the editor is closed', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.settings.editorIsOpen = false
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
pageName.should.equal('general/closed')
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should not render the page if the project can not be accessed', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.AuthorizationManager.getPrivilegeLevelForProject = sinon
|
|
|
|
.stub()
|
|
|
|
.callsArgWith(3, null, null)
|
|
|
|
this.res.sendStatus = (resCode, opts) => {
|
|
|
|
resCode.should.equal(401)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should reactivateProjectIfRequired', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
this.InactiveProjectManager.reactivateProjectIfRequired
|
|
|
|
.calledWith(this.project_id)
|
|
|
|
.should.equal(true)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should mark project as opened', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
this.ProjectUpdateHandler.markAsOpened
|
|
|
|
.calledWith(this.project_id)
|
|
|
|
.should.equal(true)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should call the brand variations handler for branded projects', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.ProjectGetter.getProject.callsArgWith(2, null, this.brandedProject)
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
this.BrandVariationsHandler.getBrandVariationById
|
|
|
|
.calledWith()
|
|
|
|
.should.equal(true)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should not call the brand variations handler for unbranded projects', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
this.BrandVariationsHandler.getBrandVariationById.called.should.equal(
|
|
|
|
false
|
|
|
|
)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should expose the brand variation details as locals for branded projects', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.ProjectGetter.getProject.callsArgWith(2, null, this.brandedProject)
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.brandVariation.should.deep.equal(this.brandVariationDetails)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
2019-11-26 08:11:19 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('flushes the project to TPDS if a flush is pending', function (done) {
|
2019-11-26 08:11:19 -05:00
|
|
|
this.res.render = () => {
|
|
|
|
this.TpdsProjectFlusher.flushProjectToTpdsIfNeeded.should.have.been.calledWith(
|
|
|
|
this.project_id
|
|
|
|
)
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
2020-04-02 06:01:41 -04:00
|
|
|
|
2021-10-26 09:31:24 -04:00
|
|
|
it('should refresh the user features if the epoch is outdated', function (done) {
|
|
|
|
this.FeaturesUpdater.featuresEpochIsCurrent = sinon.stub().returns(false)
|
|
|
|
this.res.render = () => {
|
|
|
|
this.FeaturesUpdater.refreshFeatures.should.have.been.calledWith(
|
|
|
|
this.user._id,
|
|
|
|
'load-editor'
|
|
|
|
)
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
|
2021-05-27 05:29:55 -04:00
|
|
|
describe('pdf caching feature flags', function () {
|
2021-06-01 09:53:27 -04:00
|
|
|
/* eslint-disable mocha/no-identical-title */
|
|
|
|
function showNoVariant() {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.SplitTestHandler.getTestSegmentation = sinon
|
|
|
|
.stub()
|
|
|
|
.yields(null, { enabled: false })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
function showVariant(variant) {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.SplitTestHandler.getTestSegmentation = sinon
|
|
|
|
.stub()
|
|
|
|
.yields(null, { enabled: true, variant })
|
|
|
|
})
|
|
|
|
}
|
2021-05-27 05:29:55 -04:00
|
|
|
function expectBandwidthTrackingEnabled() {
|
|
|
|
it('should track pdf bandwidth', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.trackPdfDownload).to.equal(true)
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
function expectPDFCachingEnabled() {
|
|
|
|
it('should enable pdf caching', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.enablePdfCaching).to.equal(true)
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
function expectBandwidthTrackingDisabled() {
|
|
|
|
it('should not track pdf bandwidth', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.trackPdfDownload).to.equal(false)
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
function expectPDFCachingDisabled() {
|
|
|
|
it('should disable pdf caching', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.enablePdfCaching).to.equal(false)
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
}
|
2021-06-01 09:53:27 -04:00
|
|
|
function expectToCollectMetricsAndCachePDF() {
|
2021-05-27 05:29:55 -04:00
|
|
|
describe('with no query', function () {
|
2021-06-01 09:53:27 -04:00
|
|
|
expectBandwidthTrackingEnabled()
|
|
|
|
expectPDFCachingEnabled()
|
2021-05-27 05:29:55 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=false', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'false'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingDisabled()
|
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=true', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
|
})
|
2021-06-01 09:53:27 -04:00
|
|
|
expectBandwidthTrackingEnabled()
|
2021-05-27 05:29:55 -04:00
|
|
|
expectPDFCachingEnabled()
|
|
|
|
})
|
2021-06-01 09:53:27 -04:00
|
|
|
}
|
|
|
|
function expectToCollectMetricsOnly() {
|
2021-05-27 05:29:55 -04:00
|
|
|
describe('with no query', function () {
|
|
|
|
expectBandwidthTrackingEnabled()
|
2021-06-01 09:53:27 -04:00
|
|
|
expectPDFCachingDisabled()
|
2021-05-27 05:29:55 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=false', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'false'
|
|
|
|
})
|
2021-06-01 09:53:27 -04:00
|
|
|
expectBandwidthTrackingDisabled()
|
2021-05-27 05:29:55 -04:00
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=true', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingEnabled()
|
2021-06-01 09:53:27 -04:00
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function expectToCachePDFOnly() {
|
|
|
|
describe('with no query', function () {
|
|
|
|
expectBandwidthTrackingDisabled()
|
2021-05-27 05:29:55 -04:00
|
|
|
expectPDFCachingEnabled()
|
|
|
|
})
|
|
|
|
|
2021-06-01 09:53:27 -04:00
|
|
|
describe('with enable_pdf_caching=false', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'false'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingDisabled()
|
|
|
|
expectPDFCachingDisabled()
|
2021-05-27 05:29:55 -04:00
|
|
|
})
|
|
|
|
|
2021-06-01 09:53:27 -04:00
|
|
|
describe('with enable_pdf_caching=true', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingDisabled()
|
|
|
|
expectPDFCachingEnabled()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function expectToNotBeEnrolledAtAll() {
|
2021-05-27 05:29:55 -04:00
|
|
|
describe('with no query', function () {
|
|
|
|
expectBandwidthTrackingDisabled()
|
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=false', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'false'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingDisabled()
|
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=true', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingDisabled()
|
2021-06-01 09:53:27 -04:00
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function tagAnonymous() {
|
|
|
|
beforeEach(function () {
|
2021-07-28 04:51:20 -04:00
|
|
|
this.SessionManager.isUserLoggedIn = sinon.stub().returns(false)
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
this.settings.enablePdfCaching = true
|
|
|
|
})
|
|
|
|
|
2021-06-16 04:15:09 -04:00
|
|
|
describe('during regular roll-out', function () {
|
2021-08-24 05:52:38 -04:00
|
|
|
before(function () {
|
|
|
|
this.skip()
|
|
|
|
})
|
2021-06-01 09:53:27 -04:00
|
|
|
describe('disabled', function () {
|
|
|
|
showNoVariant()
|
|
|
|
|
|
|
|
describe('regular user', function () {
|
|
|
|
expectToNotBeEnrolledAtAll()
|
|
|
|
})
|
|
|
|
describe('anonymous user', function () {
|
|
|
|
tagAnonymous()
|
2021-06-22 04:14:45 -04:00
|
|
|
expectToCachePDFOnly()
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('variant=collect-metrics', function () {
|
|
|
|
showVariant('collect-metrics')
|
|
|
|
|
|
|
|
describe('regular user', function () {
|
2021-06-16 04:15:09 -04:00
|
|
|
expectToCollectMetricsOnly()
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
|
|
|
describe('anonymous user', function () {
|
|
|
|
tagAnonymous()
|
2021-06-22 04:14:45 -04:00
|
|
|
expectToCachePDFOnly()
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('variant=collect-metrics-and-enable-caching', function () {
|
|
|
|
showVariant('collect-metrics-and-enable-caching')
|
|
|
|
|
|
|
|
describe('regular user', function () {
|
2021-06-16 04:15:09 -04:00
|
|
|
expectToCollectMetricsAndCachePDF()
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
|
|
|
describe('anonymous user', function () {
|
|
|
|
tagAnonymous()
|
2021-06-22 04:14:45 -04:00
|
|
|
expectToCachePDFOnly()
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('variant=enable-caching-only', function () {
|
|
|
|
showVariant('enable-caching-only')
|
|
|
|
|
|
|
|
describe('regular user', function () {
|
2021-06-16 04:15:09 -04:00
|
|
|
expectToCachePDFOnly()
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
|
|
|
describe('anonymous user', function () {
|
|
|
|
tagAnonymous()
|
2021-06-22 04:14:45 -04:00
|
|
|
expectToCachePDFOnly()
|
2021-06-01 09:53:27 -04:00
|
|
|
})
|
2021-05-27 05:29:55 -04:00
|
|
|
})
|
|
|
|
})
|
2021-08-24 05:52:38 -04:00
|
|
|
|
|
|
|
describe('during opt-in only', function () {
|
|
|
|
describe('with no query', function () {
|
|
|
|
expectBandwidthTrackingDisabled()
|
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=false', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'false'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingDisabled()
|
|
|
|
expectPDFCachingDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=true', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
|
})
|
|
|
|
expectBandwidthTrackingEnabled()
|
|
|
|
expectPDFCachingEnabled()
|
|
|
|
})
|
|
|
|
})
|
2021-05-27 05:29:55 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('wsUrl', function () {
|
2020-04-02 06:01:41 -04:00
|
|
|
function checkLoadEditorWsMetric(metric) {
|
2021-04-14 09:17:21 -04:00
|
|
|
it(`should inc metric ${metric}`, function (done) {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.res.render = () => {
|
|
|
|
this.Metrics.inc.calledWith(metric).should.equal(true)
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
}
|
2020-05-26 06:32:05 -04:00
|
|
|
function checkWsFallback(isBeta, isV2) {
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('with ws=fallback', function () {
|
|
|
|
beforeEach(function () {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.req.query = {}
|
|
|
|
this.req.query.ws = 'fallback'
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should unset the wsUrl', function (done) {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
;(opts.wsUrl || '/socket.io').should.equal('/socket.io')
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
checkLoadEditorWsMetric(
|
2020-05-26 06:32:05 -04:00
|
|
|
`load-editor-ws${isBeta ? '-beta' : ''}${
|
|
|
|
isV2 ? '-v2' : ''
|
|
|
|
}-fallback`
|
2020-04-02 06:01:41 -04:00
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
beforeEach(function () {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.settings.wsUrl = '/other.socket.io'
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should set the custom wsUrl', function (done) {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.wsUrl.should.equal('/other.socket.io')
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
checkLoadEditorWsMetric('load-editor-ws')
|
|
|
|
checkWsFallback(false)
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('beta program', function () {
|
|
|
|
beforeEach(function () {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.settings.wsUrlBeta = '/beta.socket.io'
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('for a normal user', function () {
|
|
|
|
it('should set the normal custom wsUrl', function (done) {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.wsUrl.should.equal('/other.socket.io')
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
checkLoadEditorWsMetric('load-editor-ws')
|
|
|
|
checkWsFallback(false)
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('for a beta user', function () {
|
|
|
|
beforeEach(function () {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.user.betaProgram = true
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should set the beta wsUrl', function (done) {
|
2020-04-02 06:01:41 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.wsUrl.should.equal('/beta.socket.io')
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
checkLoadEditorWsMetric('load-editor-ws-beta')
|
|
|
|
checkWsFallback(true)
|
|
|
|
})
|
|
|
|
})
|
2020-05-26 06:32:05 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('v2-rollout', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.settings.wsUrlBeta = '/beta.socket.io'
|
|
|
|
this.settings.wsUrlV2 = '/socket.io.v2'
|
|
|
|
})
|
|
|
|
|
|
|
|
function checkNonMatch() {
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should set the normal custom wsUrl', function (done) {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.wsUrl.should.equal('/other.socket.io')
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
checkLoadEditorWsMetric('load-editor-ws')
|
|
|
|
checkWsFallback(false)
|
|
|
|
}
|
|
|
|
function checkMatch() {
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should set the v2 wsUrl', function (done) {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.wsUrl.should.equal('/socket.io.v2')
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
checkLoadEditorWsMetric('load-editor-ws-v2')
|
|
|
|
checkWsFallback(false, true)
|
|
|
|
}
|
|
|
|
function checkForBetaUser() {
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('for a beta user', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.user.betaProgram = true
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should set the beta wsUrl', function (done) {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
opts.wsUrl.should.equal('/beta.socket.io')
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
checkLoadEditorWsMetric('load-editor-ws-beta')
|
|
|
|
checkWsFallback(true)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the roll out percentage is 0', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.settings.wsUrlV2Percentage = 0
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId does not match (0)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(0)
|
|
|
|
})
|
|
|
|
checkNonMatch()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId does not match (42)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(42)
|
|
|
|
})
|
|
|
|
checkNonMatch()
|
|
|
|
})
|
|
|
|
checkForBetaUser()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the roll out percentage is 1', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.settings.wsUrlV2Percentage = 1
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId matches (0)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(0)
|
|
|
|
})
|
|
|
|
checkMatch()
|
|
|
|
checkForBetaUser()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId does not match (1)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(1)
|
|
|
|
})
|
|
|
|
checkNonMatch()
|
|
|
|
checkForBetaUser()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId does not match (42)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(42)
|
|
|
|
})
|
|
|
|
checkNonMatch()
|
|
|
|
})
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the roll out percentage is 10', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.settings.wsUrlV2Percentage = 10
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId matches (0)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(0)
|
|
|
|
})
|
|
|
|
checkMatch()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId matches (9)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(9)
|
|
|
|
})
|
|
|
|
checkMatch()
|
|
|
|
checkForBetaUser()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId does not match (10)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(10)
|
|
|
|
})
|
|
|
|
checkNonMatch()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId does not match (42)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(42)
|
|
|
|
})
|
|
|
|
checkNonMatch()
|
|
|
|
checkForBetaUser()
|
|
|
|
})
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the roll out percentage is 100', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.settings.wsUrlV2Percentage = 100
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId matches (0)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(0)
|
|
|
|
})
|
|
|
|
checkMatch()
|
|
|
|
checkForBetaUser()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId matches (10)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(10)
|
|
|
|
})
|
|
|
|
checkMatch()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId matches (42)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(42)
|
|
|
|
})
|
|
|
|
checkMatch()
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when the projectId matches (99)', function () {
|
|
|
|
beforeEach(function () {
|
2020-05-26 06:32:05 -04:00
|
|
|
this.req.params.Project_id = ObjectId.createFromTime(99)
|
|
|
|
})
|
|
|
|
checkMatch()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2020-04-02 06:01:41 -04:00
|
|
|
})
|
2021-11-03 09:21:24 -04:00
|
|
|
|
|
|
|
describe('feature flags', function () {
|
|
|
|
describe('showNewPdfPreview', function () {
|
|
|
|
it('should be false by default', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showNewPdfPreview).to.be.false
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
it('should be true when ?new_pdf_preview=true ', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showNewPdfPreview).to.be.true
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.req.query.new_pdf_preview = 'true'
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
it('should be true for alpha group', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showNewPdfPreview).to.be.true
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.user.alphaProgram = true
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
it('should be false when when ?new_pdf_preview=true and alpha group', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showNewPdfPreview).to.be.true
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.user.alphaProgram = true
|
|
|
|
this.req.query.new_pdf_preview = 'false'
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
describe('showPdfDetach', function () {
|
|
|
|
describe('showPdfDetach=false', function () {
|
|
|
|
it('should be false by default', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showPdfDetach).to.be.false
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
it('should be false by default, even when ?new_pdf_preview=true', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showPdfDetach).to.be.false
|
|
|
|
expect(opts.showNewPdfPreview).to.be.true
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.req.query.new_pdf_preview = 'true'
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
it('should be false when when ?pdf_detach=true and alpha group', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.user.alphaProgram = true
|
|
|
|
this.req.query.pdf_detach = 'false'
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('showPdfDetach=true', function () {
|
|
|
|
it('should be true when ?pdf_detach=true, and set showNewPdfPreview as true ', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showPdfDetach).to.be.true
|
|
|
|
expect(opts.showNewPdfPreview).to.be.true
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.req.query.pdf_detach = 'true'
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
it('should be true for alpha group, and set showNewPdfPreview as true', function (done) {
|
|
|
|
this.res.render = (pageName, opts) => {
|
|
|
|
expect(opts.showPdfDetach).to.be.true
|
|
|
|
expect(opts.showNewPdfPreview).to.be.true
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
this.user.alphaProgram = true
|
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('userProjectsJson', function () {
|
|
|
|
beforeEach(function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
const projects = [
|
|
|
|
{
|
|
|
|
archived: true,
|
2019-08-27 06:38:17 -04:00
|
|
|
trashed: true,
|
2019-05-29 05:21:06 -04:00
|
|
|
id: 'a',
|
|
|
|
name: 'A',
|
|
|
|
accessLevel: 'a',
|
2021-04-27 03:52:58 -04:00
|
|
|
somethingElse: 1,
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
archived: false,
|
|
|
|
id: 'b',
|
|
|
|
name: 'B',
|
|
|
|
accessLevel: 'b',
|
2021-04-27 03:52:58 -04:00
|
|
|
somethingElse: 1,
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
archived: false,
|
2019-08-27 06:38:17 -04:00
|
|
|
trashed: true,
|
2019-05-29 05:21:06 -04:00
|
|
|
id: 'c',
|
|
|
|
name: 'C',
|
|
|
|
accessLevel: 'c',
|
2021-04-27 03:52:58 -04:00
|
|
|
somethingElse: 1,
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
archived: false,
|
2019-08-27 06:38:17 -04:00
|
|
|
trashed: false,
|
2019-05-29 05:21:06 -04:00
|
|
|
id: 'd',
|
|
|
|
name: 'D',
|
|
|
|
accessLevel: 'd',
|
2021-04-27 03:52:58 -04:00
|
|
|
somethingElse: 1,
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
2019-08-09 05:40:11 -04:00
|
|
|
|
2019-08-27 06:38:17 -04:00
|
|
|
this.ProjectHelper.isArchivedOrTrashed
|
2019-08-09 05:40:11 -04:00
|
|
|
.withArgs(projects[0], this.user._id)
|
|
|
|
.returns(true)
|
2019-08-27 06:38:17 -04:00
|
|
|
this.ProjectHelper.isArchivedOrTrashed
|
2019-08-09 05:40:11 -04:00
|
|
|
.withArgs(projects[1], this.user._id)
|
|
|
|
.returns(false)
|
2019-08-27 06:38:17 -04:00
|
|
|
this.ProjectHelper.isArchivedOrTrashed
|
2019-08-09 05:40:11 -04:00
|
|
|
.withArgs(projects[2], this.user._id)
|
2019-08-27 06:38:17 -04:00
|
|
|
.returns(true)
|
|
|
|
this.ProjectHelper.isArchivedOrTrashed
|
2019-08-09 05:40:11 -04:00
|
|
|
.withArgs(projects[3], this.user._id)
|
|
|
|
.returns(false)
|
|
|
|
|
2019-05-29 05:21:06 -04:00
|
|
|
this.ProjectGetter.findAllUsersProjects = sinon
|
|
|
|
.stub()
|
|
|
|
.callsArgWith(2, null, [])
|
|
|
|
this.ProjectController._buildProjectList = sinon.stub().returns(projects)
|
2021-07-28 04:51:20 -04:00
|
|
|
this.SessionManager.getLoggedInUserId = sinon
|
2019-05-29 05:21:06 -04:00
|
|
|
.stub()
|
2019-08-09 05:40:11 -04:00
|
|
|
.returns(this.user._id)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should produce a list of projects', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.json = data => {
|
|
|
|
expect(data).to.deep.equal({
|
|
|
|
projects: [
|
|
|
|
{ _id: 'b', name: 'B', accessLevel: 'b' },
|
2021-04-27 03:52:58 -04:00
|
|
|
{ _id: 'd', name: 'D', accessLevel: 'd' },
|
|
|
|
],
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.userProjectsJson(this.req, this.res, this.next)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('projectEntitiesJson', function () {
|
|
|
|
beforeEach(function () {
|
2021-07-28 04:51:20 -04:00
|
|
|
this.SessionManager.getLoggedInUserId = sinon.stub().returns('abc')
|
2019-05-29 05:21:06 -04:00
|
|
|
this.req.params = { Project_id: 'abcd' }
|
|
|
|
this.project = { _id: 'abcd' }
|
|
|
|
this.docs = [
|
|
|
|
{ path: '/things/b.txt', doc: true },
|
2021-04-27 03:52:58 -04:00
|
|
|
{ path: '/main.tex', doc: true },
|
2019-05-29 05:21:06 -04:00
|
|
|
]
|
|
|
|
this.files = [{ path: '/things/a.txt' }]
|
|
|
|
this.ProjectGetter.getProject = sinon
|
|
|
|
.stub()
|
|
|
|
.callsArgWith(1, null, this.project)
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectEntityHandler.getAllEntitiesFromProject = sinon
|
2019-05-29 05:21:06 -04:00
|
|
|
.stub()
|
2021-12-06 10:27:12 -05:00
|
|
|
.returns({ docs: this.docs, files: this.files })
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should produce a list of entities', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.res.json = data => {
|
|
|
|
expect(data).to.deep.equal({
|
|
|
|
project_id: 'abcd',
|
|
|
|
entities: [
|
|
|
|
{ path: '/main.tex', type: 'doc' },
|
|
|
|
{ path: '/things/a.txt', type: 'file' },
|
2021-04-27 03:52:58 -04:00
|
|
|
{ path: '/things/b.txt', type: 'doc' },
|
|
|
|
],
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
expect(this.ProjectGetter.getProject.callCount).to.equal(1)
|
|
|
|
expect(
|
|
|
|
this.ProjectEntityHandler.getAllEntitiesFromProject.callCount
|
|
|
|
).to.equal(1)
|
2019-09-30 10:46:15 -04:00
|
|
|
done()
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ProjectController.projectEntitiesJson(this.req, this.res, this.next)
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('_buildProjectViewModel', function () {
|
|
|
|
beforeEach(function () {
|
2019-09-18 06:01:13 -04:00
|
|
|
this.ProjectHelper.isArchived.returns(false)
|
2019-11-25 10:41:12 -05:00
|
|
|
this.ProjectHelper.isTrashed.returns(false)
|
|
|
|
|
2019-09-18 06:01:13 -04:00
|
|
|
this.project = {
|
|
|
|
_id: 'abcd',
|
|
|
|
name: 'netsenits',
|
|
|
|
lastUpdated: 1,
|
|
|
|
lastUpdatedBy: 2,
|
|
|
|
publicAccesLevel: 'private',
|
|
|
|
archived: false,
|
|
|
|
owner_ref: 'defg',
|
|
|
|
tokens: {
|
|
|
|
readAndWrite: '1abcd',
|
|
|
|
readAndWritePrefix: '1',
|
2021-04-27 03:52:58 -04:00
|
|
|
readOnly: 'neiotsranteoia',
|
|
|
|
},
|
2019-09-18 06:01:13 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('project not being archived or trashed', function () {
|
|
|
|
it('should produce a model of the project', function () {
|
2019-11-25 10:41:12 -05:00
|
|
|
const result = this.ProjectController._buildProjectViewModel(
|
|
|
|
this.project,
|
|
|
|
'readAndWrite',
|
|
|
|
'owner',
|
|
|
|
this.user._id
|
|
|
|
)
|
|
|
|
expect(result).to.exist
|
|
|
|
expect(result).to.be.an('object')
|
|
|
|
expect(result).to.deep.equal({
|
|
|
|
id: 'abcd',
|
|
|
|
name: 'netsenits',
|
|
|
|
lastUpdated: 1,
|
|
|
|
lastUpdatedBy: 2,
|
|
|
|
publicAccessLevel: 'private',
|
|
|
|
accessLevel: 'readAndWrite',
|
|
|
|
source: 'owner',
|
|
|
|
archived: false,
|
|
|
|
trashed: false,
|
|
|
|
owner_ref: 'defg',
|
2021-04-27 03:52:58 -04:00
|
|
|
isV1Project: false,
|
2019-11-25 10:41:12 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('project being simultaneously archived and trashed', function () {
|
|
|
|
beforeEach(function () {
|
2019-11-25 10:41:12 -05:00
|
|
|
this.ProjectHelper.isArchived.returns(true)
|
|
|
|
this.ProjectHelper.isTrashed.returns(true)
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should produce a model of the project', function () {
|
2019-11-25 10:41:12 -05:00
|
|
|
const result = this.ProjectController._buildProjectViewModel(
|
|
|
|
this.project,
|
|
|
|
'readAndWrite',
|
|
|
|
'owner',
|
|
|
|
this.user._id
|
|
|
|
)
|
|
|
|
expect(result).to.exist
|
|
|
|
expect(result).to.be.an('object')
|
|
|
|
expect(result).to.deep.equal({
|
|
|
|
id: 'abcd',
|
|
|
|
name: 'netsenits',
|
|
|
|
lastUpdated: 1,
|
|
|
|
lastUpdatedBy: 2,
|
|
|
|
publicAccessLevel: 'private',
|
|
|
|
accessLevel: 'readAndWrite',
|
|
|
|
source: 'owner',
|
|
|
|
archived: true,
|
|
|
|
trashed: false,
|
|
|
|
owner_ref: 'defg',
|
2021-04-27 03:52:58 -04:00
|
|
|
isV1Project: false,
|
2019-11-25 10:41:12 -05:00
|
|
|
})
|
2019-09-18 06:01:13 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('when token-read-only access', function () {
|
|
|
|
it('should redact the owner and last-updated data', function () {
|
2019-09-18 06:01:13 -04:00
|
|
|
const result = this.ProjectController._buildProjectViewModel(
|
|
|
|
this.project,
|
|
|
|
'readOnly',
|
|
|
|
'token',
|
|
|
|
this.user._id
|
|
|
|
)
|
|
|
|
expect(result).to.exist
|
2019-11-18 09:37:05 -05:00
|
|
|
expect(result).to.be.an('object')
|
2019-09-18 06:01:13 -04:00
|
|
|
expect(result).to.deep.equal({
|
|
|
|
id: 'abcd',
|
|
|
|
name: 'netsenits',
|
|
|
|
lastUpdated: 1,
|
|
|
|
lastUpdatedBy: null,
|
|
|
|
publicAccessLevel: 'private',
|
|
|
|
accessLevel: 'readOnly',
|
|
|
|
source: 'token',
|
|
|
|
archived: false,
|
2019-11-25 10:41:12 -05:00
|
|
|
trashed: false,
|
2019-09-18 06:01:13 -04:00
|
|
|
owner_ref: null,
|
2021-04-27 03:52:58 -04:00
|
|
|
isV1Project: false,
|
2019-09-18 06:01:13 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('_isInPercentageRollout', function () {
|
|
|
|
before(function () {
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ids = [
|
2019-05-29 05:21:06 -04:00
|
|
|
'5a05cd7621f9fe22be131740',
|
|
|
|
'5a05cd7821f9fe22be131741',
|
|
|
|
'5a05cd7921f9fe22be131742',
|
|
|
|
'5a05cd7a21f9fe22be131743',
|
|
|
|
'5a05cd7b21f9fe22be131744',
|
|
|
|
'5a05cd7c21f9fe22be131745',
|
|
|
|
'5a05cd7d21f9fe22be131746',
|
|
|
|
'5a05cd7e21f9fe22be131747',
|
|
|
|
'5a05cd7f21f9fe22be131748',
|
|
|
|
'5a05cd8021f9fe22be131749',
|
|
|
|
'5a05cd8021f9fe22be13174a',
|
|
|
|
'5a05cd8121f9fe22be13174b',
|
|
|
|
'5a05cd8221f9fe22be13174c',
|
|
|
|
'5a05cd8221f9fe22be13174d',
|
|
|
|
'5a05cd8321f9fe22be13174e',
|
|
|
|
'5a05cd8321f9fe22be13174f',
|
|
|
|
'5a05cd8421f9fe22be131750',
|
|
|
|
'5a05cd8421f9fe22be131751',
|
|
|
|
'5a05cd8421f9fe22be131752',
|
2021-04-27 03:52:58 -04:00
|
|
|
'5a05cd8521f9fe22be131753',
|
2019-09-30 10:46:15 -04:00
|
|
|
]
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should produce the expected results', function () {
|
2019-05-29 05:21:06 -04:00
|
|
|
expect(
|
2019-09-30 10:46:15 -04:00
|
|
|
this.ids.map(i =>
|
|
|
|
this.ProjectController._isInPercentageRollout('abcd', i, 50)
|
|
|
|
)
|
2019-05-29 05:21:06 -04:00
|
|
|
).to.deep.equal([
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
2021-04-27 03:52:58 -04:00
|
|
|
true,
|
2019-05-29 05:21:06 -04:00
|
|
|
])
|
2019-09-30 10:46:15 -04:00
|
|
|
expect(
|
|
|
|
this.ids.map(i =>
|
|
|
|
this.ProjectController._isInPercentageRollout('efgh', i, 50)
|
|
|
|
)
|
2019-05-29 05:21:06 -04:00
|
|
|
).to.deep.equal([
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
false,
|
2021-04-27 03:52:58 -04:00
|
|
|
false,
|
2019-05-29 05:21:06 -04:00
|
|
|
])
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|