Horizontal
@@ -132,5 +132,5 @@ const horizontalContents = (
)
export default {
- title: 'useExpandCollapse'
+ title: 'useExpandCollapse',
}
diff --git a/services/web/frontend/stories/word-count-modal-content.stories.js b/services/web/frontend/stories/word-count-modal-content.stories.js
index 8c9f953774..bbf78137cf 100644
--- a/services/web/frontend/stories/word-count-modal-content.stories.js
+++ b/services/web/frontend/stories/word-count-modal-content.stories.js
@@ -7,7 +7,7 @@ export const Basic = args => {
headers: 4,
mathDisplay: 40,
mathInline: 400,
- textWords: 4000
+ textWords: 4000,
}
return
@@ -24,7 +24,7 @@ export const LoadingError = args => {
export const Messages = args => {
const messages = [
'Lorem ipsum dolor sit amet.',
- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
].join('\n')
return
@@ -37,9 +37,9 @@ export default {
animation: false,
show: true,
error: false,
- loading: false
+ loading: false,
},
argTypes: {
- handleHide: { action: 'hide' }
- }
+ handleHide: { action: 'hide' },
+ },
}
diff --git a/services/web/frontend/stories/word-count-modal.stories.js b/services/web/frontend/stories/word-count-modal.stories.js
index 429c81ac23..d0e1cc6d24 100644
--- a/services/web/frontend/stories/word-count-modal.stories.js
+++ b/services/web/frontend/stories/word-count-modal.stories.js
@@ -22,8 +22,8 @@ export const Interactive = ({
headers: 4,
mathDisplay: 40,
mathInline: 400,
- textWords: 4000
- }
+ textWords: 4000,
+ },
}
default:
@@ -37,7 +37,7 @@ export const Interactive = ({
}
Interactive.propTypes = {
mockResponse: PropTypes.number,
- mockResponseDelay: PropTypes.number
+ mockResponseDelay: PropTypes.number,
}
export default {
@@ -46,7 +46,7 @@ export default {
args: {
clsiServerId: 'server-id',
projectId: 'project-id',
- show: true
+ show: true,
},
argTypes: {
handleHide: { action: 'handleHide' },
@@ -57,8 +57,8 @@ export default {
defaultValue: 200,
control: {
type: 'radio',
- options: [200, 500, 400]
- }
+ options: [200, 500, 400],
+ },
},
mockResponseDelay: {
name: 'Mock Response Delay',
@@ -69,8 +69,8 @@ export default {
type: 'range',
min: 0,
max: 2500,
- step: 250
- }
- }
- }
+ step: 250,
+ },
+ },
+ },
}
diff --git a/services/web/i18next-scanner.config.js b/services/web/i18next-scanner.config.js
index 7a78a403cc..10e6252230 100644
--- a/services/web/i18next-scanner.config.js
+++ b/services/web/i18next-scanner.config.js
@@ -2,26 +2,26 @@ module.exports = {
input: [
'frontend/js/**/*.{js,jsx}',
'modules/**/*.{js,jsx}',
- '!frontend/js/vendor/**'
+ '!frontend/js/vendor/**',
],
output: './',
options: {
sort: true,
func: {
list: ['t'],
- extensions: ['.js', '.jsx']
+ extensions: ['.js', '.jsx'],
},
trans: {
component: 'Trans',
i18nKey: 'i18nKey',
defaultsKey: 'defaults',
extensions: ['.js', '.jsx'],
- fallbackKey: false
+ fallbackKey: false,
},
resource: {
savePath: 'frontend/extracted-translations.json',
jsonIndent: 2,
- lineEnding: '\n'
- }
- }
+ lineEnding: '\n',
+ },
+ },
}
diff --git a/services/web/karma.conf.js b/services/web/karma.conf.js
index 6c7af4ce25..7f42224f6d 100644
--- a/services/web/karma.conf.js
+++ b/services/web/karma.conf.js
@@ -8,18 +8,18 @@ module.exports = function (config) {
// We must disable the Chrome sandbox when running Chrome inside Docker
// (Chrome's sandbox needs more permissions than Docker allows by
// default)
- flags: ['--no-sandbox']
- }
+ flags: ['--no-sandbox'],
+ },
},
browsers: ['ChromeCustom'],
files: [
// Import all tests (see comment in the file for why this is necessary)
- 'test/karma/import_tests.js'
+ 'test/karma/import_tests.js',
],
middleware: ['fake-img'],
preprocessors: {
// Run files through webpack
- 'test/karma/import_tests.js': ['webpack']
+ 'test/karma/import_tests.js': ['webpack'],
},
frameworks: ['mocha', 'chai-sinon'],
// Configure webpack in the tests
@@ -34,11 +34,11 @@ module.exports = function (config) {
// v seems to be supported, according to
// https://www.npmjs.com/package/webpack-dev-middleware#watchoptions
watchOptions: {
- ignored: [/node_modules/, /frontend/, /test/]
+ ignored: [/node_modules/, /frontend/, /test/],
},
// Disable noisy CLI output
- stats: 'errors-only'
+ stats: 'errors-only',
},
plugins: [
require('karma-chrome-launcher'),
@@ -46,9 +46,9 @@ module.exports = function (config) {
require('karma-chai-sinon'),
require('karma-webpack'),
require('karma-mocha-reporter'),
- { 'middleware:fake-img': ['factory', fakeImgMiddlewareFactory] }
+ { 'middleware:fake-img': ['factory', fakeImgMiddlewareFactory] },
],
- reporters: ['mocha']
+ reporters: ['mocha'],
})
}
diff --git a/services/web/modules/launchpad/app/src/LaunchpadController.js b/services/web/modules/launchpad/app/src/LaunchpadController.js
index ce3f4afecc..fbc469bbcb 100644
--- a/services/web/modules/launchpad/app/src/LaunchpadController.js
+++ b/services/web/modules/launchpad/app/src/LaunchpadController.js
@@ -52,7 +52,7 @@ module.exports = LaunchpadController = {
if (!adminUserExists) {
return res.render(Path.resolve(__dirname, '../views/launchpad'), {
adminUserExists,
- authMethod
+ authMethod,
})
} else {
AuthenticationController.setRedirectInSession(req)
@@ -70,7 +70,7 @@ module.exports = LaunchpadController = {
return res.render(Path.resolve(__dirname, '../views/launchpad'), {
wsUrl: Settings.wsUrl,
adminUserExists,
- authMethod
+ authMethod,
})
} else {
return res.redirect('/restricted')
@@ -108,7 +108,7 @@ module.exports = LaunchpadController = {
return EmailHandler.sendEmail('testEmail', emailOptions, function (err) {
if (err != null) {
OError.tag(err, 'error sending test email', {
- email
+ email,
})
return next(err)
}
@@ -150,7 +150,7 @@ module.exports = LaunchpadController = {
email,
password: 'password_here',
first_name: email,
- last_name: ''
+ last_name: '',
}
logger.log(
{ body, authMethod },
@@ -163,7 +163,7 @@ module.exports = LaunchpadController = {
if (err != null) {
OError.tag(err, 'error with registerNewUser', {
email,
- authMethod
+ authMethod,
})
return next(err)
}
@@ -172,12 +172,12 @@ module.exports = LaunchpadController = {
{ _id: user._id },
{
$set: { isAdmin: true },
- emails: [{ email }]
+ emails: [{ email }],
},
function (err) {
if (err != null) {
OError.tag(err, 'error setting user to admin', {
- user_id: user._id
+ user_id: user._id,
})
return next(err)
}
@@ -233,13 +233,13 @@ module.exports = LaunchpadController = {
{
$set: {
isAdmin: true,
- emails: [{ email }]
- }
+ emails: [{ email }],
+ },
},
function (err) {
if (err != null) {
OError.tag(err, 'error setting user to admin', {
- user_id: user._id
+ user_id: user._id,
})
return next(err)
}
@@ -255,12 +255,12 @@ module.exports = LaunchpadController = {
first_name: user.first_name,
last_name: user.last_name,
email: user.email,
- created: Date.now()
+ created: Date.now(),
})
}
)
}
)
})
- }
+ },
}
diff --git a/services/web/modules/launchpad/app/src/LaunchpadRouter.js b/services/web/modules/launchpad/app/src/LaunchpadRouter.js
index 7965c72db0..a6692f3f24 100644
--- a/services/web/modules/launchpad/app/src/LaunchpadRouter.js
+++ b/services/web/modules/launchpad/app/src/LaunchpadRouter.js
@@ -54,5 +54,5 @@ module.exports = {
'/launchpad/register_saml_admin'
)
}
- }
+ },
}
diff --git a/services/web/modules/launchpad/frontend/js/main/controllers/LaunchpadController.js b/services/web/modules/launchpad/frontend/js/main/controllers/LaunchpadController.js
index ca78bd12ac..c716a4adf3 100644
--- a/services/web/modules/launchpad/frontend/js/main/controllers/LaunchpadController.js
+++ b/services/web/modules/launchpad/frontend/js/main/controllers/LaunchpadController.js
@@ -27,13 +27,13 @@ export default App.controller(
$scope.statusChecks = {
ideJs: { status: 'inflight', error: null },
websocket: { status: 'inflight', error: null },
- healthCheck: { status: 'inflight', error: null }
+ healthCheck: { status: 'inflight', error: null },
}
$scope.testEmail = {
emailAddress: '',
inflight: false,
- status: null // | 'ok' | 'success'
+ status: null, // | 'ok' | 'success'
}
$scope.shouldShowAdminForm = () => !$scope.adminUserExists
@@ -53,7 +53,7 @@ export default App.controller(
return $http
.post('/launchpad/send_test_email', {
email: $scope.testEmail.emailAddress,
- _csrf: window.csrfToken
+ _csrf: window.csrfToken,
})
.then(function (response) {
const { status } = response
@@ -103,7 +103,7 @@ export default App.controller(
const socket = io.connect(null, {
reconnect: false,
'connect timeout': 30 * 1000,
- 'force new connection': true
+ 'force new connection': true,
})
socket.on('connectionAccepted', function () {
diff --git a/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js b/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js
index 654dc0d464..a7ee54dfa4 100644
--- a/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js
+++ b/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js
@@ -25,7 +25,7 @@ describe('LaunchpadController', function () {
_id: '323123',
first_name: 'fn',
last_name: 'ln',
- save: sinon.stub().callsArgWith(0)
+ save: sinon.stub().callsArgWith(0),
}
this.User = {}
@@ -37,8 +37,8 @@ describe('LaunchpadController', function () {
'../../../../app/src/Features/Email/EmailHandler': (this.EmailHandler = {}),
'../../../../app/src/Features/User/UserGetter': (this.UserGetter = {}),
'../../../../app/src/models/User': { User: this.User },
- '../../../../app/src/Features/Authentication/AuthenticationController': (this.AuthenticationController = {})
- }
+ '../../../../app/src/Features/Authentication/AuthenticationController': (this.AuthenticationController = {}),
+ },
})
this.email = 'bob@smith.com'
@@ -46,14 +46,14 @@ describe('LaunchpadController', function () {
this.req = {
query: {},
body: {},
- session: {}
+ session: {},
}
this.res = {
render: sinon.stub(),
redirect: sinon.stub(),
send: sinon.stub(),
- sendStatus: sinon.stub()
+ sendStatus: sinon.stub(),
}
return (this.next = sinon.stub())
@@ -99,7 +99,7 @@ describe('LaunchpadController', function () {
return this.res.render
.calledWith(viewPath, {
adminUserExists: false,
- authMethod: 'local'
+ authMethod: 'local',
})
.should.equal(true)
})
@@ -132,7 +132,7 @@ describe('LaunchpadController', function () {
beforeEach(function () {
this.user = {
_id: 'abcd',
- email: 'abcd@example.com'
+ email: 'abcd@example.com',
}
this.AuthenticationController.getSessionUser = sinon
.stub()
@@ -164,7 +164,7 @@ describe('LaunchpadController', function () {
.calledWith(viewPath, {
wsUrl: undefined,
adminUserExists: true,
- authMethod: 'local'
+ authMethod: 'local',
})
.should.equal(true)
})
@@ -322,7 +322,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon
.stub()
@@ -362,8 +362,8 @@ describe('LaunchpadController', function () {
{
$set: {
isAdmin: true,
- emails: [{ email: this.user.email }]
- }
+ emails: [{ email: this.user.email }],
+ },
}
)
.should.equal(true)
@@ -388,7 +388,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -427,7 +427,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -466,7 +466,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -501,7 +501,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -540,7 +540,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon
.stub()
@@ -586,7 +586,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon
.stub()
@@ -630,7 +630,7 @@ describe('LaunchpadController', function () {
this.req.body.password = this.password
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon
.stub()
@@ -672,8 +672,8 @@ describe('LaunchpadController', function () {
{
$set: {
isAdmin: true,
- emails: [{ email: this.user.email }]
- }
+ emails: [{ email: this.user.email }],
+ },
}
)
.should.equal(true)
@@ -710,7 +710,7 @@ describe('LaunchpadController', function () {
this.req.body.email = this.email
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon
.stub()
@@ -742,7 +742,7 @@ describe('LaunchpadController', function () {
email: this.email,
password: 'password_here',
first_name: this.email,
- last_name: ''
+ last_name: '',
})
.should.equal(true)
})
@@ -754,7 +754,7 @@ describe('LaunchpadController', function () {
{ _id: this.user._id },
{
$set: { isAdmin: true },
- emails: [{ email: this.user.email }]
+ emails: [{ email: this.user.email }],
}
)
.should.equal(true)
@@ -777,7 +777,7 @@ describe('LaunchpadController', function () {
this.req.body.email = this.email
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -812,7 +812,7 @@ describe('LaunchpadController', function () {
this.req.body.email = this.email
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -849,7 +849,7 @@ describe('LaunchpadController', function () {
this.req.body.email = this.email
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -882,7 +882,7 @@ describe('LaunchpadController', function () {
this.req.body.email = this.email
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.updateOne = sinon.stub()
@@ -919,7 +919,7 @@ describe('LaunchpadController', function () {
this.req.body.email = this.email
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon
.stub()
@@ -951,7 +951,7 @@ describe('LaunchpadController', function () {
email: this.email,
password: 'password_here',
first_name: this.email,
- last_name: ''
+ last_name: '',
})
.should.equal(true)
})
@@ -968,7 +968,7 @@ describe('LaunchpadController', function () {
this.req.body.email = this.email
this.user = {
_id: 'abcdef',
- email: this.email
+ email: this.email,
}
this.UserRegistrationHandler.registerNewUser = sinon
.stub()
@@ -1000,7 +1000,7 @@ describe('LaunchpadController', function () {
email: this.email,
password: 'password_here',
first_name: this.email,
- last_name: ''
+ last_name: '',
})
.should.equal(true)
})
diff --git a/services/web/modules/modules-ide.js b/services/web/modules/modules-ide.js
index 537f27829c..fdd9553fae 100644
--- a/services/web/modules/modules-ide.js
+++ b/services/web/modules/modules-ide.js
@@ -20,6 +20,6 @@ if (fs.existsSync(MODULES_PATH)) {
module.exports = function () {
return {
- code: entryPoints.map(entryPoint => `import '${entryPoint}'`).join('\n')
+ code: entryPoints.map(entryPoint => `import '${entryPoint}'`).join('\n'),
}
}
diff --git a/services/web/modules/modules-main.js b/services/web/modules/modules-main.js
index e565f82bc2..54f5c807c0 100644
--- a/services/web/modules/modules-main.js
+++ b/services/web/modules/modules-main.js
@@ -20,6 +20,6 @@ if (fs.existsSync(MODULES_PATH)) {
module.exports = function () {
return {
- code: entryPoints.map(entryPoint => `import '${entryPoint}'`).join('\n')
+ code: entryPoints.map(entryPoint => `import '${entryPoint}'`).join('\n'),
}
}
diff --git a/services/web/modules/user-activate/app/src/UserActivateController.js b/services/web/modules/user-activate/app/src/UserActivateController.js
index db23611a96..1da5304503 100644
--- a/services/web/modules/user-activate/app/src/UserActivateController.js
+++ b/services/web/modules/user-activate/app/src/UserActivateController.js
@@ -34,10 +34,10 @@ module.exports = {
res.render(Path.resolve(__dirname, '../views/user/activate'), {
title: 'activate_account',
email: user.email,
- token: req.query.token
+ token: req.query.token,
})
}
}
)
- }
+ },
}
diff --git a/services/web/modules/user-activate/app/src/UserActivateRouter.js b/services/web/modules/user-activate/app/src/UserActivateRouter.js
index 68e3d7fbeb..cba4811fe5 100644
--- a/services/web/modules/user-activate/app/src/UserActivateRouter.js
+++ b/services/web/modules/user-activate/app/src/UserActivateRouter.js
@@ -13,5 +13,5 @@ module.exports = {
webRouter.get('/user/activate', UserActivateController.activateAccountPage)
AuthenticationController.addEndpointToLoginWhitelist('/user/activate')
- }
+ },
}
diff --git a/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js b/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js
index dc5ba4d322..23d4b9cef5 100644
--- a/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js
+++ b/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js
@@ -13,7 +13,7 @@ describe('UserActivateController', function () {
this.user = {
_id: (this.user_id = 'kwjewkl'),
features: {},
- email: 'joe@example.com'
+ email: 'joe@example.com',
}
this.UserGetter = { getUser: sinon.stub() }
@@ -22,14 +22,14 @@ describe('UserActivateController', function () {
requires: {
'../../../../app/src/Features/User/UserGetter': this.UserGetter,
'../../../../app/src/Features/Errors/ErrorController': this
- .ErrorController
- }
+ .ErrorController,
+ },
})
this.req = {
query: {},
session: {
- user: this.user
- }
+ user: this.user,
+ },
}
this.res = {}
})
diff --git a/services/web/scripts/back_fill_dummy_doc_meta.js b/services/web/scripts/back_fill_dummy_doc_meta.js
index 09df7e8e42..3b389390eb 100644
--- a/services/web/scripts/back_fill_dummy_doc_meta.js
+++ b/services/web/scripts/back_fill_dummy_doc_meta.js
@@ -25,7 +25,7 @@ const DUMMY_TIME = new Date('2021-04-12T00:00:00.000Z')
const LRUCache = require('lru-cache')
const deletedProjectsCache = new LRUCache({
- max: CACHE_SIZE
+ max: CACHE_SIZE,
})
function getSecondsFromObjectId(id) {
@@ -47,12 +47,12 @@ async function main() {
// include edge
$gte: startId,
// exclude edge
- $lt: endId
+ $lt: endId,
},
deleted: true,
name: {
- $exists: false
- }
+ $exists: false,
+ },
}
const docs = await db.docs
.find(query, { readPreference: ReadPreference.SECONDARY })
@@ -86,8 +86,8 @@ async function getDeletedProject(projectId) {
{
projection: {
_id: 1,
- 'project.deletedDocs': 1
- }
+ 'project.deletedDocs': 1,
+ },
}
)
deletedProjectsCache.set(cacheKey, deletedProject)
@@ -135,7 +135,7 @@ async function letUserDoubleCheckInputs() {
FIRST_PROJECT_ID,
INCREMENT_BY_S,
STOP_AT_S,
- LET_USER_DOUBLE_CHECK_INPUTS_FOR
+ LET_USER_DOUBLE_CHECK_INPUTS_FOR,
},
null,
2
diff --git a/services/web/scripts/convert_archived_state.js b/services/web/scripts/convert_archived_state.js
index f8b715eade..1124b3ff79 100644
--- a/services/web/scripts/convert_archived_state.js
+++ b/services/web/scripts/convert_archived_state.js
@@ -14,7 +14,7 @@ async function main() {
'projects',
{ archived: false },
{
- $set: { archived: [] }
+ $set: { archived: [] },
}
)
@@ -28,7 +28,7 @@ async function main() {
collaberator_refs: 1,
readOnly_refs: 1,
tokenAccessReadAndWrite_refs: 1,
- tokenAccessReadOnly_refs: 1
+ tokenAccessReadOnly_refs: 1,
})
console.error('Done, with second part')
@@ -56,7 +56,7 @@ async function setArchived(collection, project) {
return collection.updateOne(
{ _id: project._id },
{
- $set: { archived: archived }
+ $set: { archived: archived },
}
)
}
diff --git a/services/web/scripts/count_files_in_projects.js b/services/web/scripts/count_files_in_projects.js
index a71e032e01..6098368069 100644
--- a/services/web/scripts/count_files_in_projects.js
+++ b/services/web/scripts/count_files_in_projects.js
@@ -8,7 +8,7 @@ const Errors = require('../app/src/Features/Errors/Errors')
async function countFiles() {
const rl = readline.createInterface({
- input: process.stdin
+ input: process.stdin,
})
for await (const projectId of rl) {
@@ -19,7 +19,7 @@ async function countFiles() {
}
const {
files,
- docs
+ docs,
} = await ProjectEntityHandler.promises.getAllEntitiesFromProject(project)
console.error(
projectId,
diff --git a/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.js b/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.js
index aaf85cb66a..dd5d4f90cb 100644
--- a/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.js
+++ b/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.js
@@ -7,7 +7,7 @@ const readline = require('readline')
const {
db,
ObjectId,
- waitForDb
+ waitForDb,
} = require('../../app/src/infrastructure/mongodb')
const DocstoreManager = require('../../app/src/Features/Docstore/DocstoreManager')
.promises
@@ -25,7 +25,7 @@ const input = fs.createReadStream(argv._[0])
const rl = readline.createInterface({
crlfDelay: Infinity,
- input
+ input,
})
const orphanedDocs = {}
@@ -106,7 +106,7 @@ async function projectIdExists(projectId) {
// check both projects and deletedProjects to see if project id exists
const [project, deletedProject] = await Promise.all([
findProject(projectId),
- findDeletedProject(projectId)
+ findDeletedProject(projectId),
])
return project !== null || deletedProject !== null
diff --git a/services/web/scripts/ensure_affiliations.js b/services/web/scripts/ensure_affiliations.js
index b006f67d38..746ae2c438 100644
--- a/services/web/scripts/ensure_affiliations.js
+++ b/services/web/scripts/ensure_affiliations.js
@@ -9,7 +9,7 @@ const success = []
console.log('Starting ensure affiliations')
const query = {
- 'emails.affiliationUnchecked': true
+ 'emails.affiliationUnchecked': true,
}
async function _handleEnsureAffiliation(user) {
diff --git a/services/web/scripts/helpers/batchedUpdate.js b/services/web/scripts/helpers/batchedUpdate.js
index ffb59df564..058cc3908f 100644
--- a/services/web/scripts/helpers/batchedUpdate.js
+++ b/services/web/scripts/helpers/batchedUpdate.js
@@ -74,5 +74,5 @@ function batchedUpdateWithResultHandling(collection, query, update) {
module.exports = {
getNextBatch,
batchedUpdate,
- batchedUpdateWithResultHandling
+ batchedUpdateWithResultHandling,
}
diff --git a/services/web/scripts/invalidate_tokens.js b/services/web/scripts/invalidate_tokens.js
index 52ea6c746b..588e0fff6a 100644
--- a/services/web/scripts/invalidate_tokens.js
+++ b/services/web/scripts/invalidate_tokens.js
@@ -19,8 +19,8 @@ waitForDb().then(async () => {
_id: 1,
owner_ref: 1,
tokenAccessReadOnly_refs: 1,
- tokenAccessReadAndWrite_refs: 1
- }
+ tokenAccessReadAndWrite_refs: 1,
+ },
}
)
.toArray()
@@ -39,8 +39,8 @@ waitForDb().then(async () => {
$set: {
publicAccesLevel: 'private', // note the spelling in the db is publicAccesLevel (with one 's')
tokenAccessReadOnly_refs: [],
- tokenAccessReadAndWrite_refs: []
- }
+ tokenAccessReadAndWrite_refs: [],
+ },
}
)
console.log('result', JSON.stringify(result))
diff --git a/services/web/scripts/recurly/collect_paypal_past_due_invoice.js b/services/web/scripts/recurly/collect_paypal_past_due_invoice.js
index 298c4f4a94..c4a12e32b0 100644
--- a/services/web/scripts/recurly/collect_paypal_past_due_invoice.js
+++ b/services/web/scripts/recurly/collect_paypal_past_due_invoice.js
@@ -89,7 +89,7 @@ attemptInvoicesCollection(error => {
{
INVOICES_COLLECTED,
INVOICES_COLLECTED_SUCCESS,
- USERS_COLLECTED
+ USERS_COLLECTED,
},
{ maxArrayLength: null }
)
diff --git a/services/web/scripts/recurly/get_paypal_accounts_csv.js b/services/web/scripts/recurly/get_paypal_accounts_csv.js
index 2012cc4a08..1ca79c38ad 100644
--- a/services/web/scripts/recurly/get_paypal_accounts_csv.js
+++ b/services/web/scripts/recurly/get_paypal_accounts_csv.js
@@ -62,7 +62,7 @@ const printAccountCSV = (account, callback) => {
}-${endAt.getDate()}`,
current_period_ends_at_segment: parseInt(
((endAt - NOW) / 1000 / 3600 / 24 / 365) * 7
- )
+ ),
}
callback(null, csvData)
})
@@ -93,7 +93,7 @@ const csvFields = [
'billing_info_url',
'account_management_url',
'current_period_ends_at',
- 'current_period_ends_at_segment'
+ 'current_period_ends_at_segment',
]
const csvParser = new CSVParser({ csvFields })
diff --git a/services/web/scripts/recurly/resync_subscriptions.js b/services/web/scripts/recurly/resync_subscriptions.js
index e433315d9a..d1803adf1f 100644
--- a/services/web/scripts/recurly/resync_subscriptions.js
+++ b/services/web/scripts/recurly/resync_subscriptions.js
@@ -35,7 +35,7 @@ const ScriptLogger = {
)
} else {
ScriptLogger.allMismatchReasons[mismatchReasonsString] = [
- subscription._id
+ subscription._id,
]
}
},
@@ -52,7 +52,7 @@ const ScriptLogger = {
'Mismatch Subscriptions Count',
ScriptLogger.mismatchSubscriptionsCount
)
- }
+ },
}
const slowCallback = callback => setTimeout(callback, 80)
@@ -105,7 +105,7 @@ const syncSubscriptions = (subscriptions, callback) => {
const loopForSubscriptions = (skip, callback) => {
Subscription.find({
- recurlySubscription_id: { $exists: true, $ne: '' }
+ recurlySubscription_id: { $exists: true, $ne: '' },
})
.sort('_id')
.skip(skip)
diff --git a/services/web/scripts/refresh_features.js b/services/web/scripts/refresh_features.js
index 8ff2d6e743..73f9f330a7 100644
--- a/services/web/scripts/refresh_features.js
+++ b/services/web/scripts/refresh_features.js
@@ -50,7 +50,7 @@ const ScriptLogger = {
'Recent Logged In (Last 30 Days):',
_.filter(ScriptLogger.allDaysSinceLastLoggedIn, a => a < 30).length
)
- }
+ },
}
const checkAndUpdateUser = (user, callback) =>
diff --git a/services/web/scripts/regenerate_duplicate_referral_ids.js b/services/web/scripts/regenerate_duplicate_referral_ids.js
index feae88b182..46295fd704 100644
--- a/services/web/scripts/regenerate_duplicate_referral_ids.js
+++ b/services/web/scripts/regenerate_duplicate_referral_ids.js
@@ -24,7 +24,7 @@ async function rewriteDuplicates(duplicateReferralIds) {
{ referal_id: referralId },
{
projection: { _id: 1 },
- readPreference: ReadPreference.SECONDARY
+ readPreference: ReadPreference.SECONDARY,
}
)
.toArray()
@@ -44,8 +44,8 @@ async function rewriteDuplicates(duplicateReferralIds) {
{ _id: user._id },
{
$set: {
- referal_id: newReferralId
- }
+ referal_id: newReferralId,
+ },
}
)
}
diff --git a/services/web/scripts/restore_soft_deleted_docs.js b/services/web/scripts/restore_soft_deleted_docs.js
index b8d2c373a1..19b2d54d70 100644
--- a/services/web/scripts/restore_soft_deleted_docs.js
+++ b/services/web/scripts/restore_soft_deleted_docs.js
@@ -11,7 +11,7 @@ const FILE_NAMES_TO_RESTORE = ARGV
async function main() {
const project = await ProjectGetter.promises.getProject(PROJECT_ID, {
- deletedDocs: 1
+ deletedDocs: 1,
})
const docsToRestore = project.deletedDocs.filter(doc =>
FILE_NAMES_TO_RESTORE.includes(doc.name)
@@ -22,7 +22,7 @@ async function main() {
PROJECT_ID,
deletedDoc._id,
{
- include_deleted: true
+ include_deleted: true,
},
(err, lines, rev, version, ranges) => {
if (err) return reject(err)
diff --git a/services/web/scripts/sync-user-entitlements/sync-user-entitlements.js b/services/web/scripts/sync-user-entitlements/sync-user-entitlements.js
index 1e67cf8243..f1acaff9e6 100644
--- a/services/web/scripts/sync-user-entitlements/sync-user-entitlements.js
+++ b/services/web/scripts/sync-user-entitlements/sync-user-entitlements.js
@@ -135,7 +135,7 @@ async function syncUserEntitlement(userId, email, hasEntitlement) {
function loadUserEntitlements(userEntitlementsFilename) {
const userEntitlementsFile = fs.readFileSync(userEntitlementsFilename, {
- encoding: 'utf8'
+ encoding: 'utf8',
})
const userEntitlements = {}
@@ -156,7 +156,7 @@ function loadUserEntitlements(userEntitlementsFilename) {
function loadCachedEntitlements(cachedEntitlementsFilename) {
const cachedEntitlementsFile = fs.readFileSync(cachedEntitlementsFilename, {
- encoding: 'utf8'
+ encoding: 'utf8',
})
const cachedEntitlements = {}
@@ -167,7 +167,7 @@ function loadCachedEntitlements(cachedEntitlementsFilename) {
userId,
email,
hasEntitlement,
- providerId
+ providerId,
] = cachedEntitlementLine.split(',')
let hasEntitlementBoolean
if (ignoreNulls) {
@@ -180,7 +180,7 @@ function loadCachedEntitlements(cachedEntitlementsFilename) {
email,
hasEntitlement: hasEntitlementBoolean,
providerId,
- userId
+ userId,
}
}
diff --git a/services/web/scripts/translations/config.js b/services/web/scripts/translations/config.js
index ac5abfb5ef..8846709377 100644
--- a/services/web/scripts/translations/config.js
+++ b/services/web/scripts/translations/config.js
@@ -18,12 +18,12 @@ function withAuth(options) {
{
apiKey: process.env.ONE_SKY_PUBLIC_KEY,
secret: process.env.ONE_SKY_PRIVATE_KEY,
- projectId: '25049'
+ projectId: '25049',
},
userOptions
)
}
module.exports = {
- withAuth
+ withAuth,
}
diff --git a/services/web/scripts/translations/download.js b/services/web/scripts/translations/download.js
index a1295c8da9..0b5a35c059 100644
--- a/services/web/scripts/translations/download.js
+++ b/services/web/scripts/translations/download.js
@@ -13,7 +13,7 @@ async function run() {
// of the translations
const content = await oneSky.getMultilingualFile(
withAuth({
- fileName: 'en-US.json'
+ fileName: 'en-US.json',
})
)
const json = JSON.parse(content)
@@ -62,13 +62,13 @@ function sanitize(input) {
// number of "replacement" tags.
allowedTags: ['b', 'strong', 'a', 'code', ...range(10)],
allowedAttributes: {
- a: ['href', 'class']
+ a: ['href', 'class'],
},
textFilter(text) {
return text
.replace(/\{\{/, '{{')
.replace(/\}\}/, '}}')
- }
+ },
})
}
diff --git a/services/web/scripts/translations/insertHTMLFragments.js b/services/web/scripts/translations/insertHTMLFragments.js
index f354d012c9..a910ed5a18 100644
--- a/services/web/scripts/translations/insertHTMLFragments.js
+++ b/services/web/scripts/translations/insertHTMLFragments.js
@@ -34,7 +34,7 @@ const MAPPING = {
project_ownership_transfer_confirmation_1: ['user', 'project'],
you_introed_high_number: ['numberOfPeople'],
you_introed_small_number: ['numberOfPeople'],
- click_here_to_view_sl_in_lng: ['lngName']
+ click_here_to_view_sl_in_lng: ['lngName'],
}
const { transformLocales } = require('./transformLocales')
diff --git a/services/web/scripts/translations/replaceLinkFragments.js b/services/web/scripts/translations/replaceLinkFragments.js
index 7d23e38666..b1e03fe39a 100644
--- a/services/web/scripts/translations/replaceLinkFragments.js
+++ b/services/web/scripts/translations/replaceLinkFragments.js
@@ -15,7 +15,7 @@
*/
const MAPPING = {
also_provides_free_plan: ['registerLinkOpen', 'registerLinkClose'],
- faq_pay_by_invoice_answer: ['payByInvoiceLinkOpen', 'payByInvoiceLinkClose']
+ faq_pay_by_invoice_answer: ['payByInvoiceLinkOpen', 'payByInvoiceLinkClose'],
}
const { transformLocales } = require('./transformLocales')
diff --git a/services/web/scripts/translations/transformLocales.js b/services/web/scripts/translations/transformLocales.js
index 601c54c789..467c7e9044 100644
--- a/services/web/scripts/translations/transformLocales.js
+++ b/services/web/scripts/translations/transformLocales.js
@@ -18,7 +18,7 @@ const LANGUAGES = [
'ru',
'sv',
'tr',
- 'zh-CN'
+ 'zh-CN',
]
const LOCALES = {}
LANGUAGES.forEach(loadLocales)
@@ -45,5 +45,5 @@ function transformLocales(mapping, transformLocale) {
}
module.exports = {
- transformLocales
+ transformLocales,
}
diff --git a/services/web/scripts/translations/upload.js b/services/web/scripts/translations/upload.js
index 911a195f11..8ad10f8a38 100644
--- a/services/web/scripts/translations/upload.js
+++ b/services/web/scripts/translations/upload.js
@@ -13,7 +13,7 @@ async function uploadLocales() {
language: 'en-GB',
format: 'HIERARCHICAL_JSON',
content: await fs.readFile(`${__dirname}/../../locales/en.json`),
- keepStrings: false // deprecate locales that no longer exist in en.json
+ keepStrings: false, // deprecate locales that no longer exist in en.json
})
)
return JSON.parse(blob).data.import.id
diff --git a/services/web/scripts/ukamf/check-certs.js b/services/web/scripts/ukamf/check-certs.js
index 3cb78efec7..bb7ae4d8db 100644
--- a/services/web/scripts/ukamf/check-certs.js
+++ b/services/web/scripts/ukamf/check-certs.js
@@ -44,7 +44,7 @@ async function checkCert(ukamfDB, providerId) {
const { body } = await V1Api.request({
json: true,
qs: { university_id: providerId },
- uri: '/api/v1/sharelatex/university_saml'
+ uri: '/api/v1/sharelatex/university_saml',
})
// show notice if sso not currently enabled
if (body.sso_enabled === true) {
@@ -93,6 +93,6 @@ async function checkCert(ukamfDB, providerId) {
async function getActiveProviderIds() {
return db.users.distinct('samlIdentifiers.providerId', {
- 'samlIdentifiers.externalUserId': { $exists: true }
+ 'samlIdentifiers.externalUserId': { $exists: true },
})
}
diff --git a/services/web/scripts/ukamf/ukamf-entity.js b/services/web/scripts/ukamf/ukamf-entity.js
index 346f429a7e..b4ad596cf8 100644
--- a/services/web/scripts/ukamf/ukamf-entity.js
+++ b/services/web/scripts/ukamf/ukamf-entity.js
@@ -22,7 +22,7 @@ class UKAMFEntity {
'ds:X509Data',
0,
'ds:X509Certificate',
- 0
+ 0,
])
if (!cert) {
throw new Error('no cert')
@@ -42,7 +42,7 @@ class UKAMFEntity {
return {
cert,
entityId,
- entryPoint
+ entryPoint,
}
}
}
diff --git a/services/web/test/acceptance/src/AdminEmailTests.js b/services/web/test/acceptance/src/AdminEmailTests.js
index 16838daa97..85c312ba20 100644
--- a/services/web/test/acceptance/src/AdminEmailTests.js
+++ b/services/web/test/acceptance/src/AdminEmailTests.js
@@ -14,7 +14,7 @@ describe('AdminEmails', function () {
async.series(
[
cb => this.badUser.ensureUserExists(cb),
- cb => this.badUser.ensureAdmin(cb)
+ cb => this.badUser.ensureAdmin(cb),
],
done
)
@@ -37,7 +37,7 @@ describe('AdminEmails', function () {
async.series(
[
cb => this.goodUser.ensureUserExists(cb),
- cb => this.goodUser.ensureAdmin(cb)
+ cb => this.goodUser.ensureAdmin(cb),
],
done
)
diff --git a/services/web/test/acceptance/src/ApiClsiTests.js b/services/web/test/acceptance/src/ApiClsiTests.js
index 599c62104a..4003fbfef2 100644
--- a/services/web/test/acceptance/src/ApiClsiTests.js
+++ b/services/web/test/acceptance/src/ApiClsiTests.js
@@ -19,8 +19,8 @@ const Settings = require('settings-sharelatex')
const auth = new Buffer('sharelatex:password').toString('base64')
const authed_request = request.defaults({
headers: {
- Authorization: `Basic ${auth}`
- }
+ Authorization: `Basic ${auth}`,
+ },
})
describe('ApiClsiTests', function () {
@@ -30,22 +30,22 @@ describe('ApiClsiTests', function () {
compile: {
options: {
compiler: 'pdflatex',
- timeout: 60
+ timeout: 60,
},
rootResourcePath: 'main.tex',
resources: [
{
path: 'main/tex',
content:
- '\\documentclass{article}\n\\begin{document}\nHello World\n\\end{document}'
+ '\\documentclass{article}\n\\begin{document}\nHello World\n\\end{document}',
},
{
path: 'image.png',
url: 'www.example.com/image.png',
- modified: 123456789
- }
- ]
- }
+ modified: 123456789,
+ },
+ ],
+ },
}
return done()
})
@@ -55,7 +55,7 @@ describe('ApiClsiTests', function () {
return authed_request.post(
{
uri: '/api/clsi/compile/abcd',
- json: this.compileSpec
+ json: this.compileSpec,
},
(error, response, body) => {
if (error != null) {
@@ -69,15 +69,15 @@ describe('ApiClsiTests', function () {
path: 'project.pdf',
url: '/project/abcd/build/1234/output/project.pdf',
type: 'pdf',
- build: 1234
+ build: 1234,
},
{
path: 'project.log',
url: '/project/abcd/build/1234/output/project.log',
type: 'log',
- build: 1234
- }
- ]
+ build: 1234,
+ },
+ ],
})
return done()
}
@@ -90,7 +90,7 @@ describe('ApiClsiTests', function () {
return request.post(
{
uri: '/api/clsi/compile/abcd',
- json: this.compileSpec
+ json: this.compileSpec,
},
(error, response, body) => {
if (error != null) {
diff --git a/services/web/test/acceptance/src/AuthenticationTests.js b/services/web/test/acceptance/src/AuthenticationTests.js
index 523701561b..90e6b929e1 100644
--- a/services/web/test/acceptance/src/AuthenticationTests.js
+++ b/services/web/test/acceptance/src/AuthenticationTests.js
@@ -27,10 +27,10 @@ describe('Authentication', function () {
user.request.post(
{
headers: {
- 'x-csrf-token': oldToken
+ 'x-csrf-token': oldToken,
},
url: '/project/new',
- json: { projectName: 'test' }
+ json: { projectName: 'test' },
},
(err, response, body) => {
expect(err).to.not.exist
@@ -52,14 +52,14 @@ describe('Authentication', function () {
it('should log the user in', async function () {
const {
- response: { statusCode }
+ response: { statusCode },
} = await user.doRequest('GET', '/project')
expect(statusCode).to.equal(200)
})
it('should emit an user auditLog entry for the login', async function () {
const {
- auditLog: [auditLogEntry]
+ auditLog: [auditLogEntry],
} = await user.get()
expect(auditLogEntry).to.exist
expect(auditLogEntry.timestamp).to.exist
@@ -67,7 +67,7 @@ describe('Authentication', function () {
expect(auditLogEntry).to.deep.equal({
operation: 'login',
ipAddress: '127.0.0.1',
- initiatorId: ObjectId(user.id)
+ initiatorId: ObjectId(user.id),
})
})
})
diff --git a/services/web/test/acceptance/src/AuthorizationTests.js b/services/web/test/acceptance/src/AuthorizationTests.js
index ab7f8ee37d..5ea7d7a285 100644
--- a/services/web/test/acceptance/src/AuthorizationTests.js
+++ b/services/web/test/acceptance/src/AuthorizationTests.js
@@ -27,7 +27,7 @@ function tryReadAccess(user, projectId, test, callback) {
test(response, body)
cb()
}
- )
+ ),
],
callback
)
@@ -41,8 +41,8 @@ function trySettingsWriteAccess(user, projectId, test, callback) {
{
uri: `/project/${projectId}/settings`,
json: {
- compiler: 'latex'
- }
+ compiler: 'latex',
+ },
},
(error, response, body) => {
if (error != null) {
@@ -51,7 +51,7 @@ function trySettingsWriteAccess(user, projectId, test, callback) {
test(response, body)
cb()
}
- )
+ ),
],
callback
)
@@ -65,8 +65,8 @@ function tryAdminAccess(user, projectId, test, callback) {
{
uri: `/project/${projectId}/rename`,
json: {
- newProjectName: 'new-name'
- }
+ newProjectName: 'new-name',
+ },
},
(error, response, body) => {
if (error != null) {
@@ -81,8 +81,8 @@ function tryAdminAccess(user, projectId, test, callback) {
{
uri: `/project/${projectId}/settings/admin`,
json: {
- publicAccessLevel: 'private'
- }
+ publicAccessLevel: 'private',
+ },
},
(error, response, body) => {
if (error != null) {
@@ -91,7 +91,7 @@ function tryAdminAccess(user, projectId, test, callback) {
test(response, body)
cb()
}
- )
+ ),
],
callback
)
@@ -113,10 +113,10 @@ function tryContentAccess(user, projectId, test, callback) {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
+ sendImmediately: true,
},
json: true,
- jar: false
+ jar: false,
},
(error, response, body) => {
if (error != null) {
@@ -147,10 +147,10 @@ function expectReadAccess(user, projectId, callback) {
expect(body.privilegeLevel).to.be.oneOf([
'owner',
'readAndWrite',
- 'readOnly'
+ 'readOnly',
]),
cb
- )
+ ),
],
callback
)
@@ -198,7 +198,7 @@ function expectNoReadAccess(user, projectId, options, callback) {
expect(body).to.equal('Forbidden')
},
cb
- )
+ ),
],
callback
)
@@ -247,7 +247,7 @@ function expectChatAccess(user, projectId, callback) {
user.request.get(
{
url: `/project/${projectId}/messages`,
- json: true
+ json: true,
},
(error, response) => {
if (error != null) {
@@ -263,7 +263,7 @@ function expectNoChatAccess(user, projectId, callback) {
user.request.get(
{
url: `/project/${projectId}/messages`,
- json: true
+ json: true,
},
(error, response) => {
if (error != null) {
@@ -296,7 +296,7 @@ describe('Authorization', function () {
}
return this.site_admin.ensureAdmin(cb)
})
- }
+ },
],
done
)
diff --git a/services/web/test/acceptance/src/BackFillDeletedFilesTests.js b/services/web/test/acceptance/src/BackFillDeletedFilesTests.js
index 21bd950476..13b96299f0 100644
--- a/services/web/test/acceptance/src/BackFillDeletedFilesTests.js
+++ b/services/web/test/acceptance/src/BackFillDeletedFilesTests.js
@@ -47,13 +47,13 @@ describe('BackFillDeletedFiles', function () {
linkedFileData: null,
hash: 'ed19e7d6779b47d8c63f6fa5a21954dcfb6cac00',
deletedAt: new Date(),
- __v: 0
+ __v: 0,
}
let deletedFiles1, deletedFiles2, deletedFiles3
beforeEach('set deletedFiles details', async function () {
deletedFiles1 = [
{ _id: fileId1, ...otherFileDetails },
- { _id: fileId2, ...otherFileDetails }
+ { _id: fileId2, ...otherFileDetails },
]
deletedFiles2 = [{ _id: fileId3, ...otherFileDetails }]
await setDeletedFiles(projectId1, deletedFiles1)
@@ -66,7 +66,7 @@ describe('BackFillDeletedFiles', function () {
// duplicate entry
deletedFiles3 = [
{ _id: fileId4, ...otherFileDetails },
- { _id: fileId4, ...otherFileDetails }
+ { _id: fileId4, ...otherFileDetails },
]
await setDeletedFiles(projectId5, deletedFiles3)
})
@@ -101,7 +101,7 @@ describe('BackFillDeletedFiles', function () {
{ _id: fileId1, projectId: projectId1, ...otherFileDetails },
{ _id: fileId2, projectId: projectId1, ...otherFileDetails },
{ _id: fileId3, projectId: projectId2, ...otherFileDetails },
- { _id: fileId4, projectId: projectId5, ...otherFileDetails }
+ { _id: fileId4, projectId: projectId5, ...otherFileDetails },
])
})
}
diff --git a/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.js b/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.js
index 3fafb3e6a3..036ac9a568 100644
--- a/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.js
+++ b/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.js
@@ -42,7 +42,7 @@ describe('BackFillDocNameForDeletedDocs', function () {
await db.docs.insertMany([
{ _id: docId1, deleted: true },
{ _id: docId2, deleted: true },
- { _id: docId3, deleted: true }
+ { _id: docId3, deleted: true },
])
})
let deletedDocs1, deletedDocs2
@@ -53,7 +53,7 @@ describe('BackFillDocNameForDeletedDocs', function () {
deletedAt3 = new Date()
deletedDocs1 = [
{ _id: docId1, name: 'doc1.tex', deletedAt: deletedAt1 },
- { _id: docId2, name: 'doc2.tex', deletedAt: deletedAt2 }
+ { _id: docId2, name: 'doc2.tex', deletedAt: deletedAt2 },
]
deletedDocs2 = [{ _id: docId3, name: 'doc3.tex', deletedAt: deletedAt3 }]
await setDeletedDocs(projectId1, deletedDocs1)
@@ -87,7 +87,7 @@ describe('BackFillDocNameForDeletedDocs', function () {
expect(docs).to.deep.equal([
{ _id: docId1, deleted: true, name: 'doc1.tex', deletedAt: deletedAt1 },
{ _id: docId2, deleted: true, name: 'doc2.tex', deletedAt: deletedAt2 },
- { _id: docId3, deleted: true, name: 'doc3.tex', deletedAt: deletedAt3 }
+ { _id: docId3, deleted: true, name: 'doc3.tex', deletedAt: deletedAt3 },
])
})
}
diff --git a/services/web/test/acceptance/src/BackFillDummyDocMetaTests.js b/services/web/test/acceptance/src/BackFillDummyDocMetaTests.js
index 2c51743de6..404b054bec 100644
--- a/services/web/test/acceptance/src/BackFillDummyDocMetaTests.js
+++ b/services/web/test/acceptance/src/BackFillDummyDocMetaTests.js
@@ -70,7 +70,7 @@ describe('BackFillDummyDocMeta', function () {
project_id: projectIds[5],
deleted: true,
name: 'foo.tex',
- deletedAt: now
+ deletedAt: now,
},
// not deleted
{ _id: docIds[6], project_id: projectIds[6] },
@@ -80,7 +80,7 @@ describe('BackFillDummyDocMeta', function () {
{ _id: docIds[9], project_id: projectIds[9], deleted: true },
// two docs in one project
{ _id: docIds[10], project_id: projectIds[10], deleted: true },
- { _id: docIds[11], project_id: projectIds[11], deleted: true }
+ { _id: docIds[11], project_id: projectIds[11], deleted: true },
])
})
beforeEach('insert deleted project context', async function () {
@@ -92,7 +92,7 @@ describe('BackFillDummyDocMeta', function () {
// soft-deleted, no entry for doc
{
deleterData: { deletedProjectId: projectIds[3] },
- project: { deletedDocs: [] }
+ project: { deletedDocs: [] },
},
// soft-deleted, has entry for doc
{
@@ -100,10 +100,10 @@ describe('BackFillDummyDocMeta', function () {
project: {
deletedDocs: [
{ _id: docIds[4], name: 'main.tex', deletedAt: now },
- { _id: docIds[11], name: 'main.tex', deletedAt: now }
- ]
- }
- }
+ { _id: docIds[11], name: 'main.tex', deletedAt: now },
+ ],
+ },
+ },
])
})
@@ -117,7 +117,7 @@ describe('BackFillDummyDocMeta', function () {
INCREMENT_BY_S: ONE_DAY_IN_S,
STOP_AT_S: stopAtSeconds,
// start right away
- LET_USER_DOUBLE_CHECK_INPUTS_FOR: 1
+ LET_USER_DOUBLE_CHECK_INPUTS_FOR: 1,
}
let result
try {
@@ -150,19 +150,19 @@ describe('BackFillDummyDocMeta', function () {
overlappingPartStdOut = [
`Back filling dummy meta data for ["${docIds[9]}","${docIds[10]}"]`,
`Orphaned deleted doc ${docIds[9]} (no deletedProjects entry)`,
- `Orphaned deleted doc ${docIds[10]} (no deletedProjects entry)`
+ `Orphaned deleted doc ${docIds[10]} (no deletedProjects entry)`,
]
overlappingPartStdErr = [
- `Processed 11 until ${oneDayFromProjectId9AsObjectId}`
+ `Processed 11 until ${oneDayFromProjectId9AsObjectId}`,
]
} else {
// Outside dry-run, the previous id will not match again as the `name` has been back-filled.
overlappingPartStdOut = [
`Back filling dummy meta data for ["${docIds[10]}"]`,
- `Orphaned deleted doc ${docIds[10]} (no deletedProjects entry)`
+ `Orphaned deleted doc ${docIds[10]} (no deletedProjects entry)`,
]
overlappingPartStdErr = [
- `Processed 10 until ${oneDayFromProjectId9AsObjectId}`
+ `Processed 10 until ${oneDayFromProjectId9AsObjectId}`,
]
}
@@ -186,7 +186,7 @@ describe('BackFillDummyDocMeta', function () {
`Orphaned deleted doc ${docIds[9]} (no deletedProjects entry)`,
// Potential double processing
...overlappingPartStdOut,
- ''
+ '',
])
expect(stdErr).to.deep.equal([
...`Options: ${JSON.stringify(options, null, 2)}`.split('\n'),
@@ -210,7 +210,7 @@ describe('BackFillDummyDocMeta', function () {
`Processed 9 until ${projectIds[9]}`,
...overlappingPartStdErr,
'Done.',
- ''
+ '',
])
}
@@ -232,14 +232,14 @@ describe('BackFillDummyDocMeta', function () {
project_id: projectIds[5],
deleted: true,
name: 'foo.tex',
- deletedAt: now
+ deletedAt: now,
},
{ _id: docIds[6], project_id: projectIds[6] },
{ _id: docIds[7], project_id: projectIds[7], deleted: true },
{ _id: docIds[8], project_id: projectIds[8], deleted: true },
{ _id: docIds[9], project_id: projectIds[9], deleted: true },
{ _id: docIds[10], project_id: projectIds[10], deleted: true },
- { _id: docIds[11], project_id: projectIds[11], deleted: true }
+ { _id: docIds[11], project_id: projectIds[11], deleted: true },
])
})
})
@@ -257,42 +257,42 @@ describe('BackFillDummyDocMeta', function () {
project_id: projectIds[0],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[1],
project_id: projectIds[1],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[2],
project_id: projectIds[2],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[3],
project_id: projectIds[3],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[4],
project_id: projectIds[4],
deleted: true,
name: 'main.tex',
- deletedAt: now
+ deletedAt: now,
},
{
_id: docIds[5],
project_id: projectIds[5],
deleted: true,
name: 'foo.tex',
- deletedAt: now
+ deletedAt: now,
},
{ _id: docIds[6], project_id: projectIds[6] },
{
@@ -300,36 +300,36 @@ describe('BackFillDummyDocMeta', function () {
project_id: projectIds[7],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[8],
project_id: projectIds[8],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[9],
project_id: projectIds[9],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[10],
project_id: projectIds[10],
deleted: true,
name: DUMMY_NAME,
- deletedAt: DUMMY_TIME
+ deletedAt: DUMMY_TIME,
},
{
_id: docIds[11],
project_id: projectIds[11],
deleted: true,
name: 'main.tex',
- deletedAt: now
- }
+ deletedAt: now,
+ },
])
})
})
diff --git a/services/web/test/acceptance/src/BetaProgramTests.js b/services/web/test/acceptance/src/BetaProgramTests.js
index df28a4c23d..0e6bb5a4f8 100644
--- a/services/web/test/acceptance/src/BetaProgramTests.js
+++ b/services/web/test/acceptance/src/BetaProgramTests.js
@@ -9,33 +9,33 @@ describe('BetaProgram', function () {
userHelper = await UserHelper.createUser({ email })
userHelper = await UserHelper.loginUser({
email,
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
})
it('should opt in', async function () {
const response = await userHelper.request.post('/beta/opt-in', {
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(302)
response.statusCode.should.equal(302)
expect(response.headers.location).to.equal('/beta/participate')
const user = (
await UserHelper.getUser({
- email
+ email,
})
).user
expect(user.betaProgram).to.equal(true)
})
it('should opt out', async function () {
const response = await userHelper.request.post('/beta/opt-out', {
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(302)
response.statusCode.should.equal(302)
expect(response.headers.location).to.equal('/beta/participate')
const user = (
await UserHelper.getUser({
- email
+ email,
})
).user
expect(user.betaProgram).to.equal(false)
diff --git a/services/web/test/acceptance/src/BodyParserErrorsTest.js b/services/web/test/acceptance/src/BodyParserErrorsTest.js
index 42aec8a61c..f8355e76d2 100644
--- a/services/web/test/acceptance/src/BodyParserErrorsTest.js
+++ b/services/web/test/acceptance/src/BodyParserErrorsTest.js
@@ -12,7 +12,7 @@ describe('BodyParserErrors', function () {
{
url: '/login',
body: { password: wayTooLongString },
- json: true
+ json: true,
},
(error, response, body) => {
if (error) {
@@ -31,7 +31,7 @@ describe('BodyParserErrors', function () {
request.post(
{
url: '/login',
- form: { password: wayTooLongString }
+ form: { password: wayTooLongString },
},
(error, response, body) => {
if (error) {
@@ -53,7 +53,7 @@ describe('BodyParserErrors', function () {
{
url: '/login',
body: { password: 'foo' },
- json: true
+ json: true,
},
(error, response, body) => {
if (error) {
@@ -71,7 +71,7 @@ describe('BodyParserErrors', function () {
request.post(
{
url: '/login',
- form: { password: 'foo' }
+ form: { password: 'foo' },
},
(error, response, body) => {
if (error) {
diff --git a/services/web/test/acceptance/src/BonusTests.js b/services/web/test/acceptance/src/BonusTests.js
index dd51cadb0e..4dd4382a3c 100644
--- a/services/web/test/acceptance/src/BonusTests.js
+++ b/services/web/test/acceptance/src/BonusTests.js
@@ -10,13 +10,13 @@ describe('Bonus', function () {
userHelper = await UserHelper.createUser({ email })
userHelper = await UserHelper.loginUser({
email,
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
})
it('should use the count rather than refered_users', async function () {
await UserHelper.updateUser(userHelper.user._id, {
- $set: { refered_user_count: 1, refered_users: [] }
+ $set: { refered_user_count: 1, refered_users: [] },
})
const response = await userHelper.request.get('/user/bonus')
diff --git a/services/web/test/acceptance/src/ConvertArchivedState.js b/services/web/test/acceptance/src/ConvertArchivedState.js
index 44e7058d8b..11b5e60353 100644
--- a/services/web/test/acceptance/src/ConvertArchivedState.js
+++ b/services/web/test/acceptance/src/ConvertArchivedState.js
@@ -22,7 +22,7 @@ describe('ConvertArchivedState', function () {
await userFour.login()
projectOneId = await userOne.createProject('old-archived-1', {
- template: 'blank'
+ template: 'blank',
})
projectOne = await userOne.getProject(projectOneId)
@@ -33,7 +33,7 @@ describe('ConvertArchivedState', function () {
await userOne.saveProject(projectOne)
projectTwoId = await userOne.createProject('old-archived-2', {
- template: 'blank'
+ template: 'blank',
})
projectTwo = await userOne.getProject(projectTwoId)
@@ -44,13 +44,13 @@ describe('ConvertArchivedState', function () {
await userOne.saveProject(projectTwo)
projectThreeId = await userOne.createProject('already-new-archived', {
- template: 'blank'
+ template: 'blank',
})
projectThree = await userOne.getProject(projectThreeId)
projectThree.archived = [
ObjectId(userOne._id),
ObjectId(userTwo._id),
- ObjectId(userFour._id)
+ ObjectId(userFour._id),
]
projectThree.collaberator_refs.push(userTwo._id)
projectThree.tokenAccessReadOnly_refs.push(userFour._id)
@@ -58,7 +58,7 @@ describe('ConvertArchivedState', function () {
await userOne.saveProject(projectThree)
projectFourId = await userOne.createProject('not-archived', {
- template: 'blank'
+ template: 'blank',
})
projectFour = await userOne.getProject(projectFourId)
projectFour.archived = false
@@ -87,13 +87,13 @@ describe('ConvertArchivedState', function () {
expect(convertObjectIdsToStrings(projectOne.archived)).to.deep.equal([
userOne._id,
userTwo._id,
- userThree._id
+ userThree._id,
])
expect(convertObjectIdsToStrings(projectTwo.archived)).to.deep.equal([
userOne._id,
userThree._id,
- userFour._id
+ userFour._id,
])
})
@@ -102,7 +102,7 @@ describe('ConvertArchivedState', function () {
expect(convertObjectIdsToStrings(projectThree.archived)).to.deep.equal([
userOne._id,
userTwo._id,
- userFour._id
+ userFour._id,
])
})
diff --git a/services/web/test/acceptance/src/DeletionTests.js b/services/web/test/acceptance/src/DeletionTests.js
index 517bbdfb97..57043e04a8 100644
--- a/services/web/test/acceptance/src/DeletionTests.js
+++ b/services/web/test/acceptance/src/DeletionTests.js
@@ -22,7 +22,7 @@ describe('Deleting a user', function () {
async.series(
[
this.user.ensureUserExists.bind(this.user),
- this.user.login.bind(this.user)
+ this.user.login.bind(this.user),
],
done
)
@@ -80,7 +80,7 @@ describe('Deleting a user', function () {
{
admin_id: this.user._id,
manager_ids: [this.user._id],
- planCode: 'collaborator'
+ planCode: 'collaborator',
},
error => {
expect(error).not.to.exist
@@ -143,8 +143,8 @@ describe('Deleting a user', function () {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
},
(error, res) => {
expect(error).not.to.exist
@@ -293,8 +293,8 @@ describe('Deleting a project', function () {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
},
(error, res) => {
expect(error).not.to.exist
@@ -333,7 +333,7 @@ describe('Deleting a project', function () {
}
)
MockFilestoreApi.files[this.projectId.toString()] = {
- dummyFile: 'wombat'
+ dummyFile: 'wombat',
}
})
})
@@ -359,8 +359,8 @@ describe('Deleting a project', function () {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
},
(error, res) => {
expect(error).not.to.exist
@@ -381,8 +381,8 @@ describe('Deleting a project', function () {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
},
(error, res) => {
expect(error).not.to.exist
@@ -411,8 +411,8 @@ describe('Deleting a project', function () {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
},
(error, res) => {
expect(error).not.to.exist
@@ -452,14 +452,14 @@ describe('Deleting a project', function () {
name: 'universe.jpg',
linkedFileData: null,
hash: 'ed19e7d6779b47d8c63f6fa5a21954dcfb6cac00',
- deletedAt: new Date()
+ deletedAt: new Date(),
}
beforeEach('insert deletedFiles', async function () {
const deletedFiles = [
{ _id: fileId1, ...otherFileDetails },
{ _id: fileId2, ...otherFileDetails },
// duplicate entry
- { _id: fileId1, ...otherFileDetails }
+ { _id: fileId1, ...otherFileDetails },
]
await db.deletedProjects.updateOne(
{ 'deleterData.deletedProjectId': ObjectId(this.projectId) },
@@ -474,7 +474,7 @@ describe('Deleting a project', function () {
[
cb => admin.ensureUserExists(cb),
cb => admin.ensureAdmin(cb),
- cb => admin.login(cb)
+ cb => admin.login(cb),
],
done
)
@@ -499,13 +499,13 @@ describe('Deleting a project', function () {
{
_id: fileId1,
projectId: ObjectId(this.projectId),
- ...otherFileDetails
+ ...otherFileDetails,
},
{
_id: fileId2,
projectId: ObjectId(this.projectId),
- ...otherFileDetails
- }
+ ...otherFileDetails,
+ },
])
})
})
@@ -520,7 +520,7 @@ describe('Deleting a project', function () {
beforeEach('set deletedDocs', function () {
deletedDocs = [
{ _id: ObjectId(), name: 'foo.tex', deletedAt: new Date() },
- { _id: ObjectId(), name: 'bar.tex', deletedAt: new Date() }
+ { _id: ObjectId(), name: 'bar.tex', deletedAt: new Date() },
]
deletedDocs.forEach(doc => {
MockDocstoreApi.createLegacyDeletedDoc(
@@ -555,7 +555,7 @@ describe('Deleting a project', function () {
[
cb => admin.ensureUserExists(cb),
cb => admin.ensureAdmin(cb),
- cb => admin.login(cb)
+ cb => admin.login(cb),
],
done
)
diff --git a/services/web/test/acceptance/src/DocUpdateTests.js b/services/web/test/acceptance/src/DocUpdateTests.js
index e57ec6e2d4..624d963ab9 100644
--- a/services/web/test/acceptance/src/DocUpdateTests.js
+++ b/services/web/test/acceptance/src/DocUpdateTests.js
@@ -43,9 +43,9 @@ describe('DocUpdate', function () {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
+ sendImmediately: true,
},
- json: { lines, version, ranges, lastUpdatedAt, lastUpdatedBy }
+ json: { lines, version, ranges, lastUpdatedAt, lastUpdatedBy },
},
(error, res) => {
if (error) return callback(error)
@@ -85,7 +85,7 @@ describe('DocUpdate', function () {
version: 1,
ranges: {},
lastUpdatedAt: new Date(),
- lastUpdatedBy: this.user.id
+ lastUpdatedBy: this.user.id,
}
})
diff --git a/services/web/test/acceptance/src/EditorHttpControllerTests.js b/services/web/test/acceptance/src/EditorHttpControllerTests.js
index 8a7feeedcd..e2b8424215 100644
--- a/services/web/test/acceptance/src/EditorHttpControllerTests.js
+++ b/services/web/test/acceptance/src/EditorHttpControllerTests.js
@@ -46,7 +46,7 @@ describe('EditorHttpController', function () {
if (error) return done(error)
expect(details.project.deletedDocs).to.deep.equal([
- { _id: this.docId, name: 'potato.tex' }
+ { _id: this.docId, name: 'potato.tex' },
])
done()
})
diff --git a/services/web/test/acceptance/src/ExportsTests.js b/services/web/test/acceptance/src/ExportsTests.js
index bf8e567588..6a85cb6432 100644
--- a/services/web/test/acceptance/src/ExportsTests.js
+++ b/services/web/test/acceptance/src/ExportsTests.js
@@ -67,8 +67,8 @@ describe('Exports', function () {
description: 'description',
author: 'author',
license: 'other',
- showSource: true
- }
+ showSource: true,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -86,7 +86,7 @@ describe('Exports', function () {
project,
user,
destination,
- options
+ options,
} = MockV1Api.getLastExportParams()
// project details should match
expect(project.id).to.equal(this.project_id)
diff --git a/services/web/test/acceptance/src/FeatureUpdaterTests.js b/services/web/test/acceptance/src/FeatureUpdaterTests.js
index 9efe5fff83..21e4201b10 100644
--- a/services/web/test/acceptance/src/FeatureUpdaterTests.js
+++ b/services/web/test/acceptance/src/FeatureUpdaterTests.js
@@ -57,7 +57,7 @@ describe('FeatureUpdater.refreshFeatures', function () {
admin_id: user._id,
manager_ids: [user._id],
planCode: 'collaborator',
- customAccount: true
+ customAccount: true,
})
}) // returns a promise
@@ -84,7 +84,7 @@ describe('FeatureUpdater.refreshFeatures', function () {
member_ids: [user._id],
groupAccount: true,
planCode: 'collaborator',
- customAccount: true
+ customAccount: true,
})
}) // returns a promise
@@ -106,10 +106,10 @@ describe('FeatureUpdater.refreshFeatures', function () {
beforeEach(function () {
return User.updateOne(
{
- _id: user._id
+ _id: user._id,
},
{
- refered_user_count: 10
+ refered_user_count: 10,
}
)
}) // returns a promise
@@ -137,7 +137,7 @@ describe('FeatureUpdater.refreshFeatures', function () {
institutionId = MockV1Api.createInstitution({ commonsAccount: true })
hostname = 'institution.edu'
MockV1Api.addInstitutionDomain(institutionId, hostname, {
- confirmed: true
+ confirmed: true,
})
email2 = `${user._id}@${hostname}`
userHelper = await UserHelper.loginUser(
@@ -171,7 +171,7 @@ describe('FeatureUpdater.refreshFeatures', function () {
describe('when domain is not confirmed as part of institution', function () {
beforeEach(function () {
MockV1Api.updateInstitutionDomain(institutionId, hostname, {
- confirmed: false
+ confirmed: false,
})
})
it('should not set their features', function (done) {
@@ -188,11 +188,11 @@ describe('FeatureUpdater.refreshFeatures', function () {
beforeEach(function () {
return User.updateOne(
{
- _id: user._id
+ _id: user._id,
},
{
refered_user_count: 10,
- 'features.github': true
+ 'features.github': true,
}
)
}) // returns a promise
@@ -219,12 +219,12 @@ describe('FeatureUpdater.refreshFeatures', function () {
MockV1Api.setUser(42, { plan_name: 'free' })
return User.updateOne(
{
- _id: user._id
+ _id: user._id,
},
{
overleaf: {
- id: 42
- }
+ id: 42,
+ },
}
)
}) // returns a promise
@@ -246,13 +246,13 @@ describe('FeatureUpdater.refreshFeatures', function () {
MockV1Api.setUser(42, { plan_name: 'free' })
return User.updateOne(
{
- _id: user._id
+ _id: user._id,
},
{
overleaf: {
- id: 42
+ id: 42,
},
- refered_user_count: 10
+ refered_user_count: 10,
}
)
}) // returns a promise
@@ -283,7 +283,7 @@ describe('FeatureUpdater.refreshFeatures', function () {
admin_id: user._id,
manager_ids: [user._id],
planCode: 'professional',
- customAccount: true
+ customAccount: true,
},
error => {
if (error) {
@@ -296,7 +296,7 @@ describe('FeatureUpdater.refreshFeatures', function () {
member_ids: [user._id],
groupAccount: true,
planCode: 'collaborator',
- customAccount: true
+ customAccount: true,
},
done
)
@@ -322,12 +322,12 @@ describe('FeatureUpdater.refreshFeatures', function () {
beforeEach(function () {
User.updateOne(
{
- _id: user._id
+ _id: user._id,
},
{
overleaf: {
- id: 42
- }
+ id: 42,
+ },
}
)
}) // returns a promise
@@ -339,28 +339,28 @@ describe('FeatureUpdater.refreshFeatures', function () {
futureDate.setDate(futureDate.getDate() + 1)
return User.updateOne(
{
- _id: user._id
+ _id: user._id,
},
{
featuresOverrides: [
{
features: {
- github: true
- }
+ github: true,
+ },
},
{
features: {
- dropbox: true
+ dropbox: true,
},
- expiresAt: new Date(1990, 12, 25)
+ expiresAt: new Date(1990, 12, 25),
},
{
features: {
- trackChanges: true
+ trackChanges: true,
},
- expiresAt: futureDate
- }
- ]
+ expiresAt: futureDate,
+ },
+ ],
}
)
}) // returns a promise
@@ -372,7 +372,7 @@ describe('FeatureUpdater.refreshFeatures', function () {
}
let expectedFeatures = Object.assign(settings.defaultFeatures, {
github: true,
- trackChanges: true
+ trackChanges: true,
})
expect(features).to.deep.equal(expectedFeatures)
done()
diff --git a/services/web/test/acceptance/src/HealthCheckControllerTests.js b/services/web/test/acceptance/src/HealthCheckControllerTests.js
index 7498a93869..25b554f355 100644
--- a/services/web/test/acceptance/src/HealthCheckControllerTests.js
+++ b/services/web/test/acceptance/src/HealthCheckControllerTests.js
@@ -22,7 +22,7 @@ describe('HealthCheckController', function () {
const start = Date.now()
const { response, body } = await user.doRequest('GET', {
url: '/health_check/full',
- json: true
+ json: true,
})
const end = Date.now()
@@ -51,7 +51,7 @@ describe('HealthCheckController', function () {
await user.doRequest('GET', {
timeout: 1,
url: '/health_check/full',
- json: true
+ json: true,
})
} catch (err) {
expect(err.code).to.be.oneOf(['ETIMEDOUT', 'ESOCKETTIMEDOUT'])
diff --git a/services/web/test/acceptance/src/HistoryTests.js b/services/web/test/acceptance/src/HistoryTests.js
index a1ba614286..19474df179 100644
--- a/services/web/test/acceptance/src/HistoryTests.js
+++ b/services/web/test/acceptance/src/HistoryTests.js
@@ -41,12 +41,12 @@ describe('History', function () {
this.v1_history_id = 42
return db.projects.updateOne(
{
- _id: ObjectId(this.project_id)
+ _id: ObjectId(this.project_id),
},
{
$set: {
- 'overleaf.history.id': this.v1_history_id
- }
+ 'overleaf.history.id': this.v1_history_id,
+ },
},
error => {
if (error != null) {
@@ -93,8 +93,8 @@ describe('History', function () {
{ _id: ObjectId(this.project_id) },
{
$set: {
- 'overleaf.history.id': this.v1_history_id
- }
+ 'overleaf.history.id': this.v1_history_id,
+ },
},
done
)
@@ -198,12 +198,12 @@ describe('History', function () {
}
return db.projects.updateOne(
{
- _id: ObjectId(this.project_id)
+ _id: ObjectId(this.project_id),
},
{
$unset: {
- 'overleaf.history.id': true
- }
+ 'overleaf.history.id': true,
+ },
},
error => {
if (error != null) {
diff --git a/services/web/test/acceptance/src/Init.js b/services/web/test/acceptance/src/Init.js
index 7939bebbb4..dad80ea8ed 100644
--- a/services/web/test/acceptance/src/Init.js
+++ b/services/web/test/acceptance/src/Init.js
@@ -14,7 +14,7 @@ const MockV1Api = require('./mocks/MockV1Api')
const MockV1HistoryApi = require('./mocks/MockV1HistoryApi')
const mockOpts = {
- debug: ['1', 'true', 'TRUE'].includes(process.env.DEBUG_MOCKS)
+ debug: ['1', 'true', 'TRUE'].includes(process.env.DEBUG_MOCKS),
}
MockAnalyticsApi.initialize(3050, mockOpts)
diff --git a/services/web/test/acceptance/src/LabelsTests.js b/services/web/test/acceptance/src/LabelsTests.js
index d38cee1219..1a0183f7ca 100644
--- a/services/web/test/acceptance/src/LabelsTests.js
+++ b/services/web/test/acceptance/src/LabelsTests.js
@@ -53,14 +53,14 @@ describe('Labels', function () {
MockProjectHistoryApi.addLabel(this.project_id, {
id: label_id,
comment,
- version
+ version,
})
return this.owner.request(
{
method: 'GET',
url: `/project/${this.project_id}/labels`,
- json: true
+ json: true,
},
(error, response, body) => {
if (error != null) {
@@ -81,7 +81,7 @@ describe('Labels', function () {
{
method: 'POST',
url: `/project/${this.project_id}/labels`,
- json: { comment, version }
+ json: { comment, version },
},
(error, response, body) => {
if (error != null) {
@@ -90,7 +90,7 @@ describe('Labels', function () {
expect(response.statusCode).to.equal(200)
const { label_id } = body
expect(MockProjectHistoryApi.getLabels(this.project_id)).to.deep.equal([
- { id: label_id, comment, version }
+ { id: label_id, comment, version },
])
return done()
}
@@ -104,14 +104,14 @@ describe('Labels', function () {
MockProjectHistoryApi.addLabel(this.project_id, {
id: label_id,
comment,
- version
+ version,
})
return this.owner.request(
{
method: 'DELETE',
url: `/project/${this.project_id}/labels/${label_id}`,
- json: true
+ json: true,
},
(error, response, body) => {
if (error != null) {
diff --git a/services/web/test/acceptance/src/LinkedFilesTests.js b/services/web/test/acceptance/src/LinkedFilesTests.js
index 727352f676..712e7602d5 100644
--- a/services/web/test/acceptance/src/LinkedFilesTests.js
+++ b/services/web/test/acceptance/src/LinkedFilesTests.js
@@ -37,13 +37,13 @@ describe('LinkedFiles', function () {
describe('creating a project linked file', function () {
beforeEach(async function () {
projectOneId = await owner.createProject('plf-test-one', {
- template: 'blank'
+ template: 'blank',
})
projectOne = await owner.getProject(projectOneId)
projectOneRootFolderId = projectOne.rootFolder[0]._id.toString()
projectTwoId = await owner.createProject('plf-test-two', {
- template: 'blank'
+ template: 'blank',
})
projectTwo = await owner.getProject(projectTwoId)
projectTwoRootFolderId = projectTwo.rootFolder[0]._id.toString()
@@ -63,7 +63,7 @@ describe('LinkedFiles', function () {
it('should produce a list of the users projects and their entities', async function () {
let { body } = await owner.doRequest('get', {
url: '/user/projects',
- json: true
+ json: true,
})
expect(body).to.deep.equal({
@@ -71,26 +71,26 @@ describe('LinkedFiles', function () {
{
_id: projectOneId,
name: 'plf-test-one',
- accessLevel: 'owner'
+ accessLevel: 'owner',
},
{
_id: projectTwoId,
name: 'plf-test-two',
- accessLevel: 'owner'
- }
- ]
+ accessLevel: 'owner',
+ },
+ ],
})
;({ body } = await owner.doRequest('get', {
url: `/project/${projectTwoId}/entities`,
- json: true
+ json: true,
}))
expect(body).to.deep.equal({
project_id: projectTwoId,
entities: [
{ path: '/main.tex', type: 'doc' },
{ path: '/some-harmless-doc.txt', type: 'doc' },
- { path: '/test.txt', type: 'doc' }
- ]
+ { path: '/test.txt', type: 'doc' },
+ ],
})
})
@@ -104,9 +104,9 @@ describe('LinkedFiles', function () {
provider: 'project_file',
data: {
source_project_id: projectTwoId,
- source_entity_path: `/${sourceDocName}`
- }
- }
+ source_entity_path: `/${sourceDocName}`,
+ },
+ },
})
expect(response.statusCode).to.equal(200)
const existingFileId = body.new_file_id
@@ -119,14 +119,14 @@ describe('LinkedFiles', function () {
expect(firstFile.linkedFileData).to.deep.equal({
provider: 'project_file',
source_project_id: projectTwoId,
- source_entity_path: `/${sourceDocName}`
+ source_entity_path: `/${sourceDocName}`,
})
expect(firstFile.name).to.equal('test-link.txt')
// refresh the file
;({ response, body } = await owner.doRequest('post', {
url: `/project/${projectOneId}/linked_file/${existingFileId}/refresh`,
- json: true
+ json: true,
}))
expect(response.statusCode).to.equal(200)
const newFileId = body.new_file_id
@@ -147,9 +147,9 @@ describe('LinkedFiles', function () {
provider: 'project_file',
data: {
v1_source_doc_id: 1234,
- source_entity_path: `/${sourceDocName}`
- }
- }
+ source_entity_path: `/${sourceDocName}`,
+ },
+ },
}))
expect(response.statusCode).to.equal(403)
expect(body).to.equal('You do not have access to this project')
@@ -159,7 +159,7 @@ describe('LinkedFiles', function () {
describe('with a linked project_file from a v1 project that has not been imported', function () {
beforeEach(async function () {
projectOneId = await owner.createProject('plf-v1-test-one', {
- template: 'blank'
+ template: 'blank',
})
projectOne = await owner.getProject(projectOneId)
projectOneRootFolderId = projectOne.rootFolder[0]._id.toString()
@@ -167,12 +167,12 @@ describe('LinkedFiles', function () {
linkedFileData: {
provider: 'project_file',
v1_source_doc_id: 9999999, // We won't find this id in the database
- source_entity_path: 'example.jpeg'
+ source_entity_path: 'example.jpeg',
},
_id: 'abcd',
rev: 0,
created: new Date(),
- name: 'example.jpeg'
+ name: 'example.jpeg',
})
await owner.saveProject(projectOne)
})
@@ -180,7 +180,7 @@ describe('LinkedFiles', function () {
it('should refuse to refresh', async function () {
const { response, body } = await owner.doRequest('post', {
url: `/project/${projectOneId}/linked_file/abcd/refresh`,
- json: true
+ json: true,
})
expect(response.statusCode).to.equal(409)
expect(body).to.equal(
@@ -192,7 +192,7 @@ describe('LinkedFiles', function () {
describe('creating a URL based linked file', function () {
beforeEach(async function () {
projectOneId = await owner.createProject('url-linked-files-project', {
- template: 'blank'
+ template: 'blank',
})
projectOne = await owner.getProject(projectOneId)
projectOneRootFolderId = projectOne.rootFolder[0]._id.toString()
@@ -205,11 +205,11 @@ describe('LinkedFiles', function () {
json: {
provider: 'url',
data: {
- url: 'http://example.com/foo'
+ url: 'http://example.com/foo',
},
parent_folder_id: projectOneRootFolderId,
- name: 'url-test-file-1'
- }
+ name: 'url-test-file-1',
+ },
})
expect(response.statusCode).to.equal(200)
@@ -217,7 +217,7 @@ describe('LinkedFiles', function () {
let file = updatedProject.rootFolder[0].fileRefs[0]
expect(file.linkedFileData).to.deep.equal({
provider: 'url',
- url: 'http://example.com/foo'
+ url: 'http://example.com/foo',
})
;({ response, body } = await owner.doRequest(
'get',
@@ -232,11 +232,11 @@ describe('LinkedFiles', function () {
json: {
provider: 'url',
data: {
- url: 'http://example.com/foo'
+ url: 'http://example.com/foo',
},
parent_folder_id: projectOneRootFolderId,
- name: 'url-test-file-2'
- }
+ name: 'url-test-file-2',
+ },
}))
expect(response.statusCode).to.equal(200)
;({ response, body } = await owner.doRequest('post', {
@@ -244,11 +244,11 @@ describe('LinkedFiles', function () {
json: {
provider: 'url',
data: {
- url: 'http://example.com/bar'
+ url: 'http://example.com/bar',
},
parent_folder_id: projectOneRootFolderId,
- name: 'url-test-file-2'
- }
+ name: 'url-test-file-2',
+ },
}))
expect(response.statusCode).to.equal(200)
@@ -256,7 +256,7 @@ describe('LinkedFiles', function () {
file = updatedProject.rootFolder[0].fileRefs[1]
expect(file.linkedFileData).to.deep.equal({
provider: 'url',
- url: 'http://example.com/bar'
+ url: 'http://example.com/bar',
})
;({ response, body } = await owner.doRequest(
'get',
@@ -273,11 +273,11 @@ describe('LinkedFiles', function () {
json: {
provider: 'url',
data: {
- url: 'http://example.com/does-not-exist'
+ url: 'http://example.com/does-not-exist',
},
parent_folder_id: projectOneRootFolderId,
- name: 'url-test-file-3'
- }
+ name: 'url-test-file-3',
+ },
})
expect(response.statusCode).to.equal(422) // unprocessable
expect(body).to.equal(
@@ -290,11 +290,11 @@ describe('LinkedFiles', function () {
json: {
provider: 'url',
data: {
- url: '!^$%'
+ url: '!^$%',
},
parent_folder_id: projectOneRootFolderId,
- name: 'url-test-file-4'
- }
+ name: 'url-test-file-4',
+ },
}))
expect(response.statusCode).to.equal(422) // unprocessable
expect(body).to.equal(
@@ -307,11 +307,11 @@ describe('LinkedFiles', function () {
json: {
provider: 'url',
data: {
- url: 'ftp://localhost'
+ url: 'ftp://localhost',
},
parent_folder_id: projectOneRootFolderId,
- name: 'url-test-file-5'
- }
+ name: 'url-test-file-5',
+ },
}))
expect(response.statusCode).to.equal(422) // unprocessable
expect(body).to.equal(
@@ -325,11 +325,11 @@ describe('LinkedFiles', function () {
json: {
provider: 'url',
data: {
- url: 'example.com/foo'
+ url: 'example.com/foo',
},
parent_folder_id: projectOneRootFolderId,
- name: 'url-test-file-6'
- }
+ name: 'url-test-file-6',
+ },
})
expect(response.statusCode).to.equal(200)
@@ -341,7 +341,7 @@ describe('LinkedFiles', function () {
)
expect(file.linkedFileData).to.deep.equal({
provider: 'url',
- url: 'http://example.com/foo'
+ url: 'http://example.com/foo',
})
;({ response, body } = await owner.doRequest(
'get',
@@ -358,13 +358,13 @@ describe('LinkedFiles', function () {
describe('creating a linked output file', function () {
beforeEach(async function () {
projectOneId = await owner.createProject('output-test-one', {
- template: 'blank'
+ template: 'blank',
})
projectOne = await owner.getProject(projectOneId)
projectOneRootFolderId = projectOne.rootFolder[0]._id.toString()
projectTwoId = await owner.createProject('output-test-two', {
- template: 'blank'
+ template: 'blank',
})
projectTwo = await owner.getProject(projectTwoId)
projectTwoRootFolderId = projectTwo.rootFolder[0]._id.toString()
@@ -381,9 +381,9 @@ describe('LinkedFiles', function () {
data: {
source_project_id: projectTwoId,
source_output_file_path: 'project.pdf',
- build_id: '1234-abcd'
- }
- }
+ build_id: '1234-abcd',
+ },
+ },
})
expect(response.statusCode).to.equal(200)
const existingFileId = body.new_file_id
@@ -396,14 +396,14 @@ describe('LinkedFiles', function () {
provider: 'project_output_file',
source_project_id: projectTwoId,
source_output_file_path: 'project.pdf',
- build_id: '1234-abcd'
+ build_id: '1234-abcd',
})
expect(firstFile.name).to.equal('test.pdf')
// refresh the file
;({ response, body } = await owner.doRequest('post', {
url: `/project/${projectOneId}/linked_file/${existingFileId}/refresh`,
- json: true
+ json: true,
}))
expect(response.statusCode).to.equal(200)
const refreshedFileId = body.new_file_id
@@ -420,7 +420,7 @@ describe('LinkedFiles', function () {
describe('with a linked project_output_file from a v1 project that has not been imported', function () {
beforeEach(async function () {
projectOneId = await owner.createProject('output-v1-test-one', {
- template: 'blank'
+ template: 'blank',
})
projectOne = await owner.getProject(projectOneId)
@@ -429,12 +429,12 @@ describe('LinkedFiles', function () {
linkedFileData: {
provider: 'project_output_file',
v1_source_doc_id: 9999999, // We won't find this id in the database
- source_output_file_path: 'project.pdf'
+ source_output_file_path: 'project.pdf',
},
_id: 'abcdef',
rev: 0,
created: new Date(),
- name: 'whatever.pdf'
+ name: 'whatever.pdf',
})
await owner.saveProject(projectOne)
})
@@ -442,7 +442,7 @@ describe('LinkedFiles', function () {
it('should refuse to refresh', async function () {
const { response, body } = await owner.doRequest('post', {
url: `/project/${projectOneId}/linked_file/abcdef/refresh`,
- json: true
+ json: true,
})
expect(response.statusCode).to.equal(409)
expect(body).to.equal(
diff --git a/services/web/test/acceptance/src/MongoHelper.js b/services/web/test/acceptance/src/MongoHelper.js
index 6eb7acec4c..a8cbd07b8f 100644
--- a/services/web/test/acceptance/src/MongoHelper.js
+++ b/services/web/test/acceptance/src/MongoHelper.js
@@ -7,7 +7,7 @@ const { User: UserModel } = require('../../../app/src/models/User')
const { db } = require('../../../app/src/infrastructure/mongodb')
const {
normalizeQuery,
- normalizeMultiQuery
+ normalizeMultiQuery,
} = require('../../../app/src/Features/Helpers/Mongo')
const User = require('./helpers/User').promises
diff --git a/services/web/test/acceptance/src/PasswordResetTests.js b/services/web/test/acceptance/src/PasswordResetTests.js
index 164eb5db77..911ca46fe0 100644
--- a/services/web/test/acceptance/src/PasswordResetTests.js
+++ b/services/web/test/acceptance/src/PasswordResetTests.js
@@ -22,13 +22,13 @@ describe('PasswordReset', function () {
await userHelper.getCsrfToken()
response = await userHelper.request.post('/user/password/reset', {
form: {
- email
- }
+ email,
+ },
})
token = (
await db.tokens.findOne({
- 'data.user_id': user._id.toString()
+ 'data.user_id': user._id.toString(),
})
).token
})
@@ -37,7 +37,7 @@ describe('PasswordReset', function () {
beforeEach(async function () {
userHelper = await UserHelper.loginUser({
email,
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
response = await userHelper.request.get(
`/user/password/set?passwordResetToken=${token}&email=${email}`,
@@ -51,8 +51,8 @@ describe('PasswordReset', function () {
response = await userHelper.request.post('/user/password/set', {
form: {
passwordResetToken: token,
- password: 'a-password'
- }
+ password: 'a-password',
+ },
})
userHelper = await UserHelper.getUser({ email })
user = userHelper.user
@@ -80,7 +80,7 @@ describe('PasswordReset', function () {
otherUser = userHelper.user
userHelper = await UserHelper.loginUser({
email: otherUserEmail,
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
response = await userHelper.request.get(
`/user/password/set?passwordResetToken=${token}&email=${email}`,
@@ -94,8 +94,8 @@ describe('PasswordReset', function () {
response = await userHelper.request.post('/user/password/set', {
form: {
passwordResetToken: token,
- password: 'a-password'
- }
+ password: 'a-password',
+ },
})
userHelper = await UserHelper.getUser({ email })
user = userHelper.user
@@ -129,8 +129,8 @@ describe('PasswordReset', function () {
response = await userHelper.request.post('/user/password/set', {
form: {
passwordResetToken: token,
- password: 'a-password'
- }
+ password: 'a-password',
+ },
})
userHelper = await UserHelper.getUser({ email })
user = userHelper.user
@@ -164,9 +164,9 @@ describe('PasswordReset', function () {
// send reset request
response = await userHelper.request.post('/user/password/set', {
form: {
- passwordResetToken: token
+ passwordResetToken: token,
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(400)
userHelper = await UserHelper.getUser({ email })
@@ -180,9 +180,9 @@ describe('PasswordReset', function () {
response = await userHelper.request.post('/user/password/set', {
form: {
passwordResetToken: token,
- password: 'short'
+ password: 'short',
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(400)
userHelper = await UserHelper.getUser({ email })
@@ -215,9 +215,9 @@ describe('PasswordReset', function () {
response = await userHelper.request.post('/user/password/set', {
form: {
passwordResetToken: invalidToken,
- password: 'a-password'
+ password: 'a-password',
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(404)
})
@@ -226,8 +226,8 @@ describe('PasswordReset', function () {
it('should return 200 if email field is valid', async function () {
response = await userHelper.request.post(`/user/password/reset`, {
form: {
- email
- }
+ email,
+ },
})
expect(response.statusCode).to.equal(200)
})
@@ -235,9 +235,9 @@ describe('PasswordReset', function () {
it('should return 400 if email field is missing', async function () {
response = await userHelper.request.post(`/user/password/reset`, {
form: {
- mail: email
+ mail: email,
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(400)
})
@@ -247,8 +247,8 @@ describe('PasswordReset', function () {
response = await userHelper.request.post(`/user/password/set`, {
form: {
password: 'new-password',
- passwordResetToken: token
- }
+ passwordResetToken: token,
+ },
})
expect(response.statusCode).to.equal(200)
})
@@ -256,9 +256,9 @@ describe('PasswordReset', function () {
it('should return 400 if password field is missing', async function () {
response = await userHelper.request.post(`/user/password/set`, {
form: {
- passwordResetToken: token
+ passwordResetToken: token,
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(400)
})
@@ -266,9 +266,9 @@ describe('PasswordReset', function () {
it('should return 400 if passwordResetToken field is missing', async function () {
response = await userHelper.request.post(`/user/password/set`, {
form: {
- password: 'new-password'
+ password: 'new-password',
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(400)
})
diff --git a/services/web/test/acceptance/src/PasswordUpdateTests.js b/services/web/test/acceptance/src/PasswordUpdateTests.js
index 137a1f90fe..cdf271caf5 100644
--- a/services/web/test/acceptance/src/PasswordUpdateTests.js
+++ b/services/web/test/acceptance/src/PasswordUpdateTests.js
@@ -17,7 +17,7 @@ describe('PasswordUpdate', function () {
userHelper = await UserHelper.createUser({ email, password })
userHelper = await UserHelper.loginUser({
email,
- password
+ password,
})
await userHelper.getCsrfToken()
})
@@ -27,9 +27,9 @@ describe('PasswordUpdate', function () {
form: {
currentPassword: password,
newPassword1: 'new-password',
- newPassword2: 'new-password'
+ newPassword2: 'new-password',
},
- simple: false
+ simple: false,
})
userHelper = await UserHelper.getUser({ email })
user = userHelper.user
@@ -53,9 +53,9 @@ describe('PasswordUpdate', function () {
response = await userHelper.request.post('/user/password/update', {
form: {
newPassword1: 'new-password',
- newPassword2: 'new-password'
+ newPassword2: 'new-password',
},
- simple: false
+ simple: false,
})
userHelper = await UserHelper.getUser({ email })
})
@@ -73,9 +73,9 @@ describe('PasswordUpdate', function () {
form: {
currentPassword: 'wrong-password',
newPassword1: 'new-password',
- newPassword2: 'new-password'
+ newPassword2: 'new-password',
},
- simple: false
+ simple: false,
})
userHelper = await UserHelper.getUser({ email })
})
@@ -93,10 +93,10 @@ describe('PasswordUpdate', function () {
form: {
currentPassword: password,
newPassword1: 'new-password',
- newPassword2: 'oops-password'
+ newPassword2: 'oops-password',
},
json: true,
- simple: false
+ simple: false,
})
userHelper = await UserHelper.getUser({ email })
})
@@ -117,10 +117,10 @@ describe('PasswordUpdate', function () {
form: {
currentPassword: password,
newPassword1: 'short',
- newPassword2: 'short'
+ newPassword2: 'short',
},
json: true,
- simple: false
+ simple: false,
})
userHelper = await UserHelper.getUser({ email })
})
diff --git a/services/web/test/acceptance/src/ProjectCRUDTests.js b/services/web/test/acceptance/src/ProjectCRUDTests.js
index 80071d6e6f..b07b4542f7 100644
--- a/services/web/test/acceptance/src/ProjectCRUDTests.js
+++ b/services/web/test/acceptance/src/ProjectCRUDTests.js
@@ -17,9 +17,9 @@ describe('Project CRUD', function () {
$set: {
refProviders: {
mendeley: { encrypted: 'aaa' },
- zotero: { encrypted: 'bbb' }
- }
- }
+ zotero: { encrypted: 'bbb' },
+ },
+ },
})
const { response, body } = await this.user.doRequest(
'GET',
diff --git a/services/web/test/acceptance/src/ProjectDuplicateNameTests.js b/services/web/test/acceptance/src/ProjectDuplicateNameTests.js
index d0e0966863..6e026071c1 100644
--- a/services/web/test/acceptance/src/ProjectDuplicateNameTests.js
+++ b/services/web/test/acceptance/src/ProjectDuplicateNameTests.js
@@ -78,8 +78,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/folder`,
json: {
name: 'testfolder',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.testFolderId = body._id
@@ -114,8 +114,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/doc`,
json: {
name: 'main.tex',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -136,8 +136,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/folder`,
json: {
name: 'main.tex',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -158,8 +158,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/folder`,
json: {
name: 'main.tex',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -182,8 +182,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/doc`,
json: {
name: 'universe.jpg',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -204,8 +204,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/folder`,
json: {
name: 'universe.jpg',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -227,7 +227,7 @@ describe('ProjectDuplicateNames', function () {
json: true,
qs: {
folder_id: this.rootFolderId,
- qqfilename: 'universe.jpg'
+ qqfilename: 'universe.jpg',
},
formData: {
qqfile: {
@@ -236,10 +236,10 @@ describe('ProjectDuplicateNames', function () {
),
options: {
filename: 'universe.jpg',
- contentType: 'image/jpeg'
- }
- }
- }
+ contentType: 'image/jpeg',
+ },
+ },
+ },
},
(err, res, body) => {
this.body = body
@@ -265,8 +265,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/doc`,
json: {
name: 'testfolder',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -287,8 +287,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/folder`,
json: {
name: 'testfolder',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -310,7 +310,7 @@ describe('ProjectDuplicateNames', function () {
json: true,
qs: {
folder_id: this.rootFolderId,
- qqfilename: 'universe.jpg'
+ qqfilename: 'universe.jpg',
},
formData: {
qqfile: {
@@ -319,10 +319,10 @@ describe('ProjectDuplicateNames', function () {
),
options: {
filename: 'testfolder',
- contentType: 'image/jpeg'
- }
- }
- }
+ contentType: 'image/jpeg',
+ },
+ },
+ },
},
(err, res, body) => {
this.body = body
@@ -344,8 +344,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/doc/${this.refBibDoc._id}/rename`,
json: {
- name: 'main.tex'
- }
+ name: 'main.tex',
+ },
},
(err, res, body) => {
this.res = res
@@ -365,8 +365,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/folder/${this.testFolderId}/rename`,
json: {
- name: 'main.tex'
- }
+ name: 'main.tex',
+ },
},
(err, res, body) => {
this.res = res
@@ -386,8 +386,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/file/${this.imageFile._id}/rename`,
json: {
- name: 'main.tex'
- }
+ name: 'main.tex',
+ },
},
(err, res, body) => {
this.res = res
@@ -409,8 +409,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/doc/${this.refBibDoc._id}/rename`,
json: {
- name: 'universe.jpg'
- }
+ name: 'universe.jpg',
+ },
},
(err, res, body) => {
this.res = res
@@ -430,8 +430,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/folder/${this.testFolderId}/rename`,
json: {
- name: 'universe.jpg'
- }
+ name: 'universe.jpg',
+ },
},
(err, res, body) => {
this.res = res
@@ -451,8 +451,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/file/${this.imageFile._id}/rename`,
json: {
- name: 'universe.jpg'
- }
+ name: 'universe.jpg',
+ },
},
(err, res, body) => {
this.res = res
@@ -474,8 +474,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/doc/${this.refBibDoc._id}/rename`,
json: {
- name: 'testfolder'
- }
+ name: 'testfolder',
+ },
},
(err, res, body) => {
this.res = res
@@ -495,8 +495,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/folder/${this.testFolderId}/rename`,
json: {
- name: 'testfolder'
- }
+ name: 'testfolder',
+ },
},
(err, res, body) => {
this.res = res
@@ -516,8 +516,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/file/${this.imageFile._id}/rename`,
json: {
- name: 'testfolder'
- }
+ name: 'testfolder',
+ },
},
(err, res, body) => {
this.res = res
@@ -539,8 +539,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/doc`,
json: {
name: 'main.tex',
- parent_folder_id: this.testFolderId
- }
+ parent_folder_id: this.testFolderId,
+ },
},
(err, res, body) => {
return this.owner.request.post(
@@ -548,8 +548,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/doc`,
json: {
name: 'universe.jpg',
- parent_folder_id: this.testFolderId
- }
+ parent_folder_id: this.testFolderId,
+ },
},
(err, res, body) => {
return this.owner.request.post(
@@ -557,8 +557,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/folder`,
json: {
name: 'otherFolder',
- parent_folder_id: this.testFolderId
- }
+ parent_folder_id: this.testFolderId,
+ },
},
(err, res, body) => {
this.subFolderId = body._id
@@ -567,8 +567,8 @@ describe('ProjectDuplicateNames', function () {
uri: `/project/${this.example_project_id}/folder`,
json: {
name: 'otherFolder',
- parent_folder_id: this.rootFolderId
- }
+ parent_folder_id: this.rootFolderId,
+ },
},
(err, res, body) => {
this.otherFolderId = body._id
@@ -589,8 +589,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/doc/${this.mainTexDoc._id}/move`,
json: {
- folder_id: this.testFolderId
- }
+ folder_id: this.testFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -610,8 +610,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/file/${this.imageFile._id}/move`,
json: {
- folder_id: this.testFolderId
- }
+ folder_id: this.testFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -631,8 +631,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/folder/${this.otherFolderId}/move`,
json: {
- folder_id: this.testFolderId
- }
+ folder_id: this.testFolderId,
+ },
},
(err, res, body) => {
this.res = res
@@ -652,8 +652,8 @@ describe('ProjectDuplicateNames', function () {
{
uri: `/project/${this.example_project_id}/folder/${this.testFolderId}/move`,
json: {
- folder_id: this.subFolderId
- }
+ folder_id: this.subFolderId,
+ },
},
(err, res, body) => {
this.res = res
diff --git a/services/web/test/acceptance/src/ProjectFeaturesTests.js b/services/web/test/acceptance/src/ProjectFeaturesTests.js
index 6086e67657..a9820ed2d9 100644
--- a/services/web/test/acceptance/src/ProjectFeaturesTests.js
+++ b/services/web/test/acceptance/src/ProjectFeaturesTests.js
@@ -25,10 +25,10 @@ const joinProject = (user_id, project_id, callback) =>
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
+ sendImmediately: true,
},
json: true,
- jar: false
+ jar: false,
},
callback
)
diff --git a/services/web/test/acceptance/src/ProjectInviteTests.js b/services/web/test/acceptance/src/ProjectInviteTests.js
index d4a90944fe..c4ea9502d3 100644
--- a/services/web/test/acceptance/src/ProjectInviteTests.js
+++ b/services/web/test/acceptance/src/ProjectInviteTests.js
@@ -15,8 +15,8 @@ const createInvite = (sendingUser, projectId, email, callback) => {
uri: `/project/${projectId}/invite`,
json: {
email,
- privileges: 'readAndWrite'
- }
+ privileges: 'readAndWrite',
+ },
},
(err, response, body) => {
if (err) {
@@ -37,7 +37,7 @@ const createProject = (owner, projectName, callback) => {
const fakeProject = {
_id: projectId,
name: projectName,
- owner_ref: owner
+ owner_ref: owner,
}
callback(err, projectId, fakeProject)
})
@@ -65,7 +65,7 @@ const revokeInvite = (sendingUser, projectId, inviteId, callback) => {
}
sendingUser.request.delete(
{
- uri: `/project/${projectId}/invite/${inviteId}`
+ uri: `/project/${projectId}/invite/${inviteId}`,
},
err => {
if (err) {
@@ -82,7 +82,7 @@ const tryFollowInviteLink = (user, link, callback) => {
user.request.get(
{
uri: link,
- baseUrl: null
+ baseUrl: null,
},
callback
)
@@ -97,8 +97,8 @@ const tryAcceptInvite = (user, invite, callback) => {
{
uri: `/project/${invite.projectId}/invite/token/${invite.token}/accept`,
json: {
- token: invite.token
- }
+ token: invite.token,
+ },
},
callback
)
@@ -115,8 +115,8 @@ const tryRegisterUser = (user, email, callback) => {
url: '/register',
json: {
email,
- password: 'some_weird_password'
- }
+ password: 'some_weird_password',
+ },
},
callback
)
@@ -142,8 +142,8 @@ const tryLoginUser = (user, callback) => {
url: '/login',
json: {
email: user.email,
- password: user.password
- }
+ password: user.password,
+ },
},
callback
)
@@ -158,7 +158,7 @@ const tryGetInviteList = (user, projectId, callback) => {
user.request.get(
{
url: `/project/${projectId}/invites`,
- json: true
+ json: true,
},
callback
)
@@ -177,10 +177,10 @@ const tryJoinProject = (user, projectId, callback) => {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
+ sendImmediately: true,
},
json: true,
- jar: false
+ jar: false,
},
callback
)
@@ -310,7 +310,7 @@ describe('ProjectInviteTests', function () {
[
cb => this.user.ensureUserExists(cb),
cb => this.sendingUser.login(cb),
- cb => this.sendingUser.setFeatures({ collaborators: 10 }, cb)
+ cb => this.sendingUser.setFeatures({ collaborators: 10 }, cb),
],
done
)
@@ -408,7 +408,7 @@ describe('ProjectInviteTests', function () {
this.projectId,
0,
cb
- )
+ ),
],
done
)
@@ -480,7 +480,8 @@ describe('ProjectInviteTests', function () {
this.inviteTwo._id,
cb
),
- cb => expectInviteListCount(this.sendingUser, this.projectId, 0, cb)
+ cb =>
+ expectInviteListCount(this.sendingUser, this.projectId, 0, cb),
],
done
)
@@ -516,7 +517,7 @@ describe('ProjectInviteTests', function () {
[
cb => expectInvitePage(this.user, this.link, cb),
cb => expectAcceptInviteAndRedirect(this.user, this.invite, cb),
- cb => expectProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -534,7 +535,7 @@ describe('ProjectInviteTests', function () {
this.invite,
cb
),
- cb => expectProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -577,7 +578,7 @@ describe('ProjectInviteTests', function () {
this.projectId,
this.secondInvite._id,
cb
- )
+ ),
],
done
)
@@ -591,7 +592,7 @@ describe('ProjectInviteTests', function () {
Async.series(
[
cb => expectInvitePage(this.user, this.link, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -608,7 +609,7 @@ describe('ProjectInviteTests', function () {
expectInvalidInvitePage(this.user, link, cb)
},
cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -619,7 +620,7 @@ describe('ProjectInviteTests', function () {
[
cb => expectInvitePage(this.user, this.link, cb),
cb => expectAcceptInviteAndRedirect(this.user, this.invite, cb),
- cb => expectProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -652,7 +653,7 @@ describe('ProjectInviteTests', function () {
),
cb => expectInvitePage(this.user, this.link, cb),
cb => expectAcceptInviteAndRedirect(this.user, this.invite, cb),
- cb => expectProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -670,7 +671,7 @@ describe('ProjectInviteTests', function () {
Async.series(
[
cb => expectInviteRedirectToRegister(this.user, this.link, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -692,7 +693,7 @@ describe('ProjectInviteTests', function () {
cb
),
cb => expectInvalidInvitePage(this.user, badLink, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -704,7 +705,7 @@ describe('ProjectInviteTests', function () {
Async.series(
[
cb => expectInviteRedirectToRegister(this.user, this.link, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -717,7 +718,7 @@ describe('ProjectInviteTests', function () {
cb => expectLoginPage(this.user, cb),
cb => expectLoginRedirectToInvite(this.user, this.link, cb),
cb => expectInvitePage(this.user, this.link, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -731,7 +732,7 @@ describe('ProjectInviteTests', function () {
cb => expectLoginRedirectToInvite(this.user, this.link, cb),
cb => expectInvitePage(this.user, this.link, cb),
cb => expectAcceptInviteAndRedirect(this.user, this.invite, cb),
- cb => expectProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -743,7 +744,7 @@ describe('ProjectInviteTests', function () {
Async.series(
[
cb => expectInviteRedirectToRegister(this.user, this.link, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
@@ -764,7 +765,7 @@ describe('ProjectInviteTests', function () {
},
cb => expectLoginRedirectToInvite(this.user, badLink, cb),
cb => expectInvalidInvitePage(this.user, badLink, cb),
- cb => expectNoProjectAccess(this.user, this.invite.projectId, cb)
+ cb => expectNoProjectAccess(this.user, this.invite.projectId, cb),
],
done
)
diff --git a/services/web/test/acceptance/src/ProjectOwnershipTransferTests.js b/services/web/test/acceptance/src/ProjectOwnershipTransferTests.js
index 739f1f71e1..e238095332 100644
--- a/services/web/test/acceptance/src/ProjectOwnershipTransferTests.js
+++ b/services/web/test/acceptance/src/ProjectOwnershipTransferTests.js
@@ -43,7 +43,7 @@ describe('Project ownership transfer', function () {
it('adds the previous owner as a read/write collaborator', async function () {
const project = await this.collaboratorSession.getProject(this.projectId)
expect(project.collaberator_refs.map(x => x.toString())).to.have.members([
- this.owner._id.toString()
+ this.owner._id.toString(),
])
})
diff --git a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js
index 7e3008b9ae..0a0655a808 100644
--- a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js
+++ b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js
@@ -46,7 +46,7 @@ describe('ProjectStructureMongoLock', function () {
this.lockValue = 'lock-value'
const userDetails = {
holdingAccount: false,
- email: 'test@example.com'
+ email: 'test@example.com',
}
UserCreator.createNewUser(userDetails, {}, (err, user) => {
this.user = user
@@ -87,7 +87,7 @@ describe('ProjectStructureMongoLock', function () {
'mkdirp',
'moveEntity',
'renameEntity',
- 'addFolder'
+ 'addFolder',
]
for (var methodName of Array.from(LOCKING_UPDATE_METHODS)) {
it(`cannot call ProjectEntityMongoUpdateHandler.${methodName}`, function (done) {
diff --git a/services/web/test/acceptance/src/ProjectStructureTests.js b/services/web/test/acceptance/src/ProjectStructureTests.js
index 48def3e9aa..9cfc7f8c21 100644
--- a/services/web/test/acceptance/src/ProjectStructureTests.js
+++ b/services/web/test/acceptance/src/ProjectStructureTests.js
@@ -58,8 +58,8 @@ describe('ProjectStructureChanges', function () {
uri: `project/${projectId}/doc`,
json: {
name: 'new.tex',
- parent_folder_id: project.rootFolder[0]._id
- }
+ parent_folder_id: project.rootFolder[0]._id,
+ },
},
(error, res, body) => {
if (error) {
@@ -79,8 +79,8 @@ describe('ProjectStructureChanges', function () {
{
uri: `project/${projectId}/folder`,
json: {
- name: 'foo'
- }
+ name: 'foo',
+ },
},
(error, res, body) => {
if (error) {
@@ -136,8 +136,8 @@ describe('ProjectStructureChanges', function () {
{
uri: 'project/new/upload',
formData: {
- qqfile: zipFile
- }
+ qqfile: zipFile,
+ },
},
(error, res, body) => {
if (error) {
@@ -229,8 +229,8 @@ describe('ProjectStructureChanges', function () {
{
uri: `/Project/${projectId}/clone`,
json: {
- projectName: 'new.tex'
- }
+ projectName: 'new.tex',
+ },
},
(error, res, body) => {
if (error) {
@@ -292,7 +292,7 @@ describe('ProjectStructureChanges', function () {
it('should version the doc added', function (done) {
const {
updates,
- version: newVersion
+ version: newVersion,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
@@ -602,7 +602,7 @@ describe('ProjectStructureChanges', function () {
() => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(2)
expect(updates[0].type).to.equal('rename-file')
@@ -680,7 +680,7 @@ describe('ProjectStructureChanges', function () {
() => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
@@ -711,7 +711,7 @@ describe('ProjectStructureChanges', function () {
() => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
@@ -746,8 +746,8 @@ describe('ProjectStructureChanges', function () {
{
uri: `project/${exampleProjectId}/folder`,
json: {
- name: 'bar'
- }
+ name: 'bar',
+ },
},
(error, res, body) => {
if (error) {
@@ -764,7 +764,7 @@ describe('ProjectStructureChanges', function () {
() => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(
exampleProjectId
)
@@ -851,7 +851,7 @@ describe('ProjectStructureChanges', function () {
() => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
@@ -881,7 +881,7 @@ describe('ProjectStructureChanges', function () {
() => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
@@ -911,7 +911,7 @@ describe('ProjectStructureChanges', function () {
() => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(2)
expect(updates[0].type).to.equal('rename-doc')
@@ -982,7 +982,7 @@ describe('ProjectStructureChanges', function () {
deleteItem(owner, exampleProjectId, 'folder', exampleFolderId, () => {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(2)
expect(updates[0].type).to.equal('rename-doc')
@@ -1148,8 +1148,8 @@ describe('ProjectStructureChanges', function () {
auth: {
user: _.keys(Settings.httpAuthUsers)[0],
pass: _.values(Settings.httpAuthUsers)[0],
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
})
texFile.on('error', err => {
@@ -1167,7 +1167,7 @@ describe('ProjectStructureChanges', function () {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
@@ -1192,8 +1192,8 @@ describe('ProjectStructureChanges', function () {
auth: {
user: _.keys(Settings.httpAuthUsers)[0],
pass: _.values(Settings.httpAuthUsers)[0],
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
})
imageFile.on('error', err => {
@@ -1211,7 +1211,7 @@ describe('ProjectStructureChanges', function () {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
@@ -1252,8 +1252,8 @@ describe('ProjectStructureChanges', function () {
auth: {
user: _.keys(Settings.httpAuthUsers)[0],
pass: _.values(Settings.httpAuthUsers)[0],
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
})
imageFile.on('error', err => {
@@ -1271,7 +1271,7 @@ describe('ProjectStructureChanges', function () {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(2)
expect(updates[0].type).to.equal('rename-file')
@@ -1302,8 +1302,8 @@ describe('ProjectStructureChanges', function () {
auth: {
user: _.keys(Settings.httpAuthUsers)[0],
pass: _.values(Settings.httpAuthUsers)[0],
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
},
(error, res) => {
if (error) {
@@ -1315,7 +1315,7 @@ describe('ProjectStructureChanges', function () {
const {
updates,
- version
+ version,
} = MockDocUpdaterApi.getProjectStructureUpdates(exampleProjectId)
expect(updates.length).to.equal(1)
const update = updates[0]
diff --git a/services/web/test/acceptance/src/ProxyUrls.js b/services/web/test/acceptance/src/ProxyUrls.js
index 67eed01da6..f51cc7bba0 100644
--- a/services/web/test/acceptance/src/ProxyUrls.js
+++ b/services/web/test/acceptance/src/ProxyUrls.js
@@ -32,7 +32,7 @@ describe('ProxyUrls', function () {
return async.series(
[
cb => assertResponse('/institutions/list', 200, [], cb),
- cb => assertResponse('/institutions/domains', 200, [], cb)
+ cb => assertResponse('/institutions/domains', 200, [], cb),
],
done
)
@@ -54,7 +54,7 @@ describe('ProxyUrls', function () {
200,
{ id: 456, name: 'Institution 456' },
cb
- )
+ ),
],
done
)
diff --git a/services/web/test/acceptance/src/RecurlySubscriptionUpdateTests.js b/services/web/test/acceptance/src/RecurlySubscriptionUpdateTests.js
index c588e5cdd8..c0c44640a2 100644
--- a/services/web/test/acceptance/src/RecurlySubscriptionUpdateTests.js
+++ b/services/web/test/acceptance/src/RecurlySubscriptionUpdateTests.js
@@ -14,12 +14,12 @@ describe('Subscriptions', function () {
this.recurlySubscription = new RecurlySubscription({
adminId: this.recurlyUser._id,
account: {
- email: 'stale-recurly@email.com'
- }
+ email: 'stale-recurly@email.com',
+ },
})
this.recurlySubscription.ensureExists(cb)
},
- cb => this.recurlyUser.login(cb)
+ cb => this.recurlyUser.login(cb),
],
done
)
diff --git a/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js b/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js
index 33d11e46a5..a030928ccd 100644
--- a/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js
+++ b/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js
@@ -15,7 +15,7 @@ function getUserWithReferralId(referralId) {
referal_id: referralId,
// Make the unique indexes happy.
email,
- emails: [{ email }]
+ emails: [{ email }],
}
}
async function getBatch(batchCounter) {
@@ -26,7 +26,7 @@ async function getBatch(batchCounter) {
{
projection: { _id: 1 },
skip: BATCH_SIZE * --batchCounter,
- limit: BATCH_SIZE
+ limit: BATCH_SIZE,
}
)
.toArray()
@@ -95,7 +95,7 @@ describe('RegenerateDuplicateReferralIds', function () {
// actual command
'node',
- 'scripts/regenerate_duplicate_referral_ids'
+ 'scripts/regenerate_duplicate_referral_ids',
].join(' ')
)
} catch (err) {
@@ -119,7 +119,7 @@ describe('RegenerateDuplicateReferralIds', function () {
`Completed batch ending ${thirdBatch[BATCH_SIZE - 1]}`,
`Completed batch ending ${forthBatch[BATCH_SIZE - 1]}`,
'Done.',
- ''
+ '',
])
expect(stdOut).to.deep.equal([
// only duplicates
@@ -139,7 +139,7 @@ describe('RegenerateDuplicateReferralIds', function () {
// no new duplicates
`Running update on batch with ids ${JSON.stringify(forthBatch)}`,
- ''
+ '',
])
})
diff --git a/services/web/test/acceptance/src/RegistrationTests.js b/services/web/test/acceptance/src/RegistrationTests.js
index cf36c3515d..a3e0da86eb 100644
--- a/services/web/test/acceptance/src/RegistrationTests.js
+++ b/services/web/test/acceptance/src/RegistrationTests.js
@@ -54,8 +54,8 @@ const tryLoginThroughRegistrationForm = function (
url: '/register',
json: {
email,
- password
- }
+ password,
+ },
},
callback
)
@@ -84,8 +84,8 @@ describe('Registration', function () {
url: '/login',
json: {
email: this.badEmail,
- password: this.badPassword
- }
+ password: this.badPassword,
+ },
},
(err, response, body) => {
const message = body && body.message && body.message.text
@@ -142,11 +142,11 @@ describe('Registration', function () {
url: '/register',
json: {
email: this.email,
- password: this.password
+ password: this.password,
},
headers: {
- 'x-csrf-token': this.user.csrfToken
- }
+ 'x-csrf-token': this.user.csrfToken,
+ },
},
(error, response, body) => {
expect(err != null).to.equal(false)
@@ -166,11 +166,11 @@ describe('Registration', function () {
url: '/register',
json: {
email: this.email,
- password: this.password
+ password: this.password,
},
headers: {
- 'x-csrf-token': ''
- }
+ 'x-csrf-token': '',
+ },
},
(error, response, body) => {
expect(response.statusCode).to.equal(403)
@@ -191,11 +191,11 @@ describe('Registration', function () {
url: '/register',
json: {
email: this.email,
- password: this.password
+ password: this.password,
},
headers: {
- 'x-csrf-token': oldCsrfToken
- }
+ 'x-csrf-token': oldCsrfToken,
+ },
},
(error, response, body) => {
expect(response.statusCode).to.equal(403)
@@ -249,7 +249,7 @@ describe('Registration', function () {
this.user2.registerWithQuery(
`?r=${this.user1.referal_id}&rm=d&rs=b`,
cb
- )
+ ),
],
done
)
@@ -277,7 +277,7 @@ describe('Registration', function () {
cb => redis.clearUserSessions(this.user1, cb),
cb => this.user2.login(cb),
cb => this.user2.logout(cb),
- cb => redis.clearUserSessions(this.user2, cb)
+ cb => redis.clearUserSessions(this.user2, cb),
],
done
)
@@ -340,7 +340,7 @@ describe('Registration', function () {
)
},
// check user still can't access the project
- cb => expectNoProjectAccess(this.user2, projectId, done)
+ cb => expectNoProjectAccess(this.user2, projectId, done),
],
done
)
diff --git a/services/web/test/acceptance/src/RestoringFilesTest.js b/services/web/test/acceptance/src/RestoringFilesTest.js
index 2b2d6f7f12..560f89ece1 100644
--- a/services/web/test/acceptance/src/RestoringFilesTest.js
+++ b/services/web/test/acceptance/src/RestoringFilesTest.js
@@ -66,7 +66,7 @@ describe('RestoringFiles', function () {
return this.owner.request(
{
method: 'DELETE',
- url: `/project/${this.project_id}/doc/${this.doc._id}`
+ url: `/project/${this.project_id}/doc/${this.doc._id}`,
},
(error, response, body) => {
if (error != null) {
@@ -78,8 +78,8 @@ describe('RestoringFiles', function () {
method: 'POST',
url: `/project/${this.project_id}/doc/${this.doc._id}/restore`,
json: {
- name: 'main.tex'
- }
+ name: 'main.tex',
+ },
},
(error, response, body) => {
if (error != null) {
@@ -132,8 +132,8 @@ describe('RestoringFiles', function () {
url: `/project/${this.project_id}/restore_file`,
json: {
pathname: 'foo.tex',
- version: 42
- }
+ version: 42,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -179,8 +179,8 @@ describe('RestoringFiles', function () {
url: `/project/${this.project_id}/restore_file`,
json: {
pathname: 'image.png',
- version: 42
- }
+ version: 42,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -220,8 +220,8 @@ describe('RestoringFiles', function () {
{
uri: `project/${this.project_id}/folder`,
json: {
- name: 'foldername'
- }
+ name: 'foldername',
+ },
},
(error, response, body) => {
if (error != null) {
@@ -234,8 +234,8 @@ describe('RestoringFiles', function () {
url: `/project/${this.project_id}/restore_file`,
json: {
pathname: 'foldername/foo2.tex',
- version: 42
- }
+ version: 42,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -280,8 +280,8 @@ describe('RestoringFiles', function () {
url: `/project/${this.project_id}/restore_file`,
json: {
pathname: 'nothere/foo3.tex',
- version: 42
- }
+ version: 42,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -325,8 +325,8 @@ describe('RestoringFiles', function () {
url: `/project/${this.project_id}/restore_file`,
json: {
pathname: 'main.tex',
- version: 42
- }
+ version: 42,
+ },
},
(error, response, body) => {
if (error != null) {
diff --git a/services/web/test/acceptance/src/SecurityHeadersTests.js b/services/web/test/acceptance/src/SecurityHeadersTests.js
index 0ad8662774..462d743f4a 100644
--- a/services/web/test/acceptance/src/SecurityHeadersTests.js
+++ b/services/web/test/acceptance/src/SecurityHeadersTests.js
@@ -85,7 +85,7 @@ describe('SecurityHeaders', function () {
[
cb => this.user.login(cb),
cb => this.user.request.get('/', cb),
- cb => this.user.logout(cb)
+ cb => this.user.logout(cb),
],
(err, results) => {
const main_response = results[1][0]
@@ -111,7 +111,7 @@ describe('SecurityHeaders', function () {
}
)
},
- cb => this.user.logout(cb)
+ cb => this.user.logout(cb),
],
(err, results) => {
return request.get(`/project/${this.project_id}`, (err, res, body) => {
@@ -127,7 +127,7 @@ describe('SecurityHeaders', function () {
[
cb => this.user.login(cb),
cb => this.user.request.get('/favicon.ico', cb),
- cb => this.user.logout(cb)
+ cb => this.user.logout(cb),
],
(err, results) => {
const res = results[1][0]
diff --git a/services/web/test/acceptance/src/SessionTests.js b/services/web/test/acceptance/src/SessionTests.js
index d3b227c902..7a9bd22418 100644
--- a/services/web/test/acceptance/src/SessionTests.js
+++ b/services/web/test/acceptance/src/SessionTests.js
@@ -56,7 +56,7 @@ describe('Sessions', function () {
expect(sessions.length).to.equal(0)
next()
})
- }
+ },
],
(err, result) => {
if (err) {
@@ -180,7 +180,7 @@ describe('Sessions', function () {
expect(statusCode).to.equal(302)
next()
})
- }
+ },
],
(err, result) => {
if (err) {
@@ -304,7 +304,7 @@ describe('Sessions', function () {
expect(sessions.length).to.equal(0)
next()
})
- }
+ },
],
(err, result) => {
if (err) {
@@ -383,7 +383,7 @@ describe('Sessions', function () {
next => {
this.user2.request.get(
{
- uri: '/user/sessions'
+ uri: '/user/sessions',
},
(err, response, body) => {
expect(err).to.be.oneOf([null, undefined])
@@ -399,7 +399,7 @@ describe('Sessions', function () {
expect(err).to.be.oneOf([null, undefined])
this.user2.request.post(
{
- uri: '/user/sessions/clear'
+ uri: '/user/sessions/clear',
},
err => next(err)
)
@@ -465,7 +465,7 @@ describe('Sessions', function () {
expect(auditLog[0].info.sessions.length).to.equal(2)
next()
})
- }
+ },
],
(err, result) => {
if (err) {
diff --git a/services/web/test/acceptance/src/SettingsTests.js b/services/web/test/acceptance/src/SettingsTests.js
index 0487da2b08..1ba2cce2e1 100644
--- a/services/web/test/acceptance/src/SettingsTests.js
+++ b/services/web/test/acceptance/src/SettingsTests.js
@@ -29,8 +29,8 @@ describe('SettingsPage', function () {
password: this.user.password,
profile: {
id: this.v1Id,
- email: this.user.email
- }
+ email: this.user.email,
+ },
}
return async.series(
[
@@ -40,7 +40,7 @@ describe('SettingsPage', function () {
cb => {
MockV1Api.setUser(this.v1Id, this.v1User)
return cb()
- }
+ },
],
done
)
diff --git a/services/web/test/acceptance/src/SharingTests.js b/services/web/test/acceptance/src/SharingTests.js
index 875302f4f8..478bcbe828 100644
--- a/services/web/test/acceptance/src/SharingTests.js
+++ b/services/web/test/acceptance/src/SharingTests.js
@@ -32,7 +32,7 @@ describe('Sharing', function () {
)
const project = await this.ownerSession.getProject(this.projectId)
expect(project.collaberator_refs).to.be.unordered.ids([
- this.collaborator._id
+ this.collaborator._id,
])
expect(project.readOnly_refs).to.deep.equal([])
})
diff --git a/services/web/test/acceptance/src/SubscriptionDashboardTests.js b/services/web/test/acceptance/src/SubscriptionDashboardTests.js
index 2426ff8b4a..a9fafcd2ff 100644
--- a/services/web/test/acceptance/src/SubscriptionDashboardTests.js
+++ b/services/web/test/acceptance/src/SubscriptionDashboardTests.js
@@ -81,13 +81,13 @@ describe('Subscriptions', function () {
trial_ends_at: new Date(2018, 6, 7),
account: {
hosted_login_token: 'mock-login-token',
- email: 'mock@email.com'
- }
+ email: 'mock@email.com',
+ },
})
MockRecurlyApi.coupons = this.coupons = {
'test-coupon-1': { description: 'Test Coupon 1' },
'test-coupon-2': { description: 'Test Coupon 2' },
- 'test-coupon-3': { name: 'TestCoupon3' }
+ 'test-coupon-3': { name: 'TestCoupon3' },
}
this.recurlySubscription.ensureExists(error => {
if (error) {
@@ -112,7 +112,7 @@ describe('Subscriptions', function () {
MockRecurlyApi.redemptions = {}
Subscription.deleteOne(
{
- admin_id: this.user._id
+ admin_id: this.user._id,
},
done
)
@@ -140,10 +140,10 @@ describe('Subscriptions', function () {
account: {
account_code: this.user._id.toString(),
email: 'mock@email.com',
- hosted_login_token: 'mock-login-token'
+ hosted_login_token: 'mock-login-token',
},
additionalLicenses: 0,
- totalLicenses: 0
+ totalLicenses: 0,
})
})
@@ -155,7 +155,7 @@ describe('Subscriptions', function () {
MockRecurlyApi.redemptions[this.user._id] = [
{ state: 'active', coupon_code: 'test-coupon-1' },
{ state: 'inactive', coupon_code: 'test-coupon-2' },
- { state: 'active', coupon_code: 'test-coupon-3' }
+ { state: 'active', coupon_code: 'test-coupon-3' },
]
// rebuild the view model with the redemptions
@@ -169,13 +169,13 @@ describe('Subscriptions', function () {
{
coupon_code: 'test-coupon-1',
name: '',
- description: 'Test Coupon 1'
+ description: 'Test Coupon 1',
},
{
coupon_code: 'test-coupon-3',
name: 'TestCoupon3',
- description: ''
- }
+ description: '',
+ },
])
done()
}
@@ -195,7 +195,7 @@ describe('Subscriptions', function () {
{
admin_id: this.user._id,
manager_ids: [this.user._id],
- planCode: 'collaborator'
+ planCode: 'collaborator',
},
error => {
if (error) {
@@ -218,7 +218,7 @@ describe('Subscriptions', function () {
after(function (done) {
Subscription.deleteOne(
{
- admin_id: this.user._id
+ admin_id: this.user._id,
},
done
)
@@ -248,14 +248,14 @@ describe('Subscriptions', function () {
manager_ids: [this.owner1._id],
planCode: 'collaborator',
groupPlan: true,
- member_ids: [this.user._id]
+ member_ids: [this.user._id],
})
await Subscription.create({
admin_id: this.owner2._id,
manager_ids: [this.owner2._id],
planCode: 'collaborator',
groupPlan: true,
- member_ids: [this.user._id]
+ member_ids: [this.user._id],
})
this.data = await buildUsersSubscriptionViewModelPromise(this.user._id)
})
@@ -263,7 +263,7 @@ describe('Subscriptions', function () {
after(function (done) {
Subscription.deleteOne(
{
- admin_id: this.owner1._id
+ admin_id: this.owner1._id,
},
error => {
if (error) {
@@ -271,7 +271,7 @@ describe('Subscriptions', function () {
}
Subscription.deleteOne(
{
- admin_id: this.owner2._id
+ admin_id: this.owner2._id,
},
done
)
@@ -306,7 +306,7 @@ describe('Subscriptions', function () {
admin_id: this.owner1._id,
manager_ids: [this.owner1._id, this.user._id],
planCode: 'collaborator',
- groupPlan: true
+ groupPlan: true,
})
this.data = await buildUsersSubscriptionViewModelPromise(this.user._id)
})
@@ -314,7 +314,7 @@ describe('Subscriptions', function () {
after(function (done) {
Subscription.deleteOne(
{
- admin_id: this.owner1._id
+ admin_id: this.owner1._id,
},
done
)
@@ -344,11 +344,11 @@ describe('Subscriptions', function () {
Institution.create(
{
v1Id: this.v1Id,
- managerIds: [this.user._id]
+ managerIds: [this.user._id],
},
cb
)
- }
+ },
],
error => {
if (error) {
@@ -371,7 +371,7 @@ describe('Subscriptions', function () {
after(function (done) {
Institution.deleteOne(
{
- v1Id: this.v1Id
+ v1Id: this.v1Id,
},
done
)
@@ -390,10 +390,10 @@ describe('Subscriptions', function () {
const v1Id = MockV1Api.nextV1Id()
MockV1Api.setUser(v1Id, {
subscription: {},
- subscription_status: {}
+ subscription_status: {},
})
await UserHelper.updateUser(this.user._id, {
- $set: { overleaf: { id: v1Id } }
+ $set: { overleaf: { id: v1Id } },
})
const harvardDomain = 'harvard.example.edu'
@@ -401,24 +401,24 @@ describe('Subscriptions', function () {
const stanfordDomain = 'stanford.example.edu'
const harvardId = MockV1Api.createInstitution({
name: 'Harvard',
- hostname: harvardDomain
+ hostname: harvardDomain,
})
const mitId = MockV1Api.createInstitution({
name: 'MIT',
- hostname: mitDomain
+ hostname: mitDomain,
})
const stanfordId = MockV1Api.createInstitution({
name: 'Stanford',
- hostname: stanfordDomain
+ hostname: stanfordDomain,
})
MockV1Api.updateInstitutionDomain(harvardId, harvardDomain, {
- confirmed: true
+ confirmed: true,
})
MockV1Api.updateInstitutionDomain(mitId, mitDomain, {
- confirmed: false
+ confirmed: false,
})
MockV1Api.updateInstitutionDomain(stanfordId, stanfordDomain, {
- confirmed: true
+ confirmed: true,
})
this.harvardEmail = `unconfirmed-affiliation-email@${harvardDomain}`
this.stanfordEmail = `confirmed-affiliation-email@${stanfordDomain}`
@@ -450,21 +450,21 @@ describe('Subscriptions', function () {
teams: [
{
id: 56,
- name: 'Test team'
- }
- ]
+ name: 'Test team',
+ },
+ ],
}),
subscription_status: (this.subscription_status = {
product: { mock: 'product' },
- team: null
- })
+ team: null,
+ }),
})
await UserHelper.updateUser(this.user._id, {
$set: {
overleaf: {
- id: v1Id
- }
- }
+ id: v1Id,
+ },
+ },
})
this.data = await buildUsersSubscriptionViewModelPromise(this.user._id)
})
@@ -500,7 +500,7 @@ describe('Subscriptions', function () {
this.response = await userHelper.request.post(
'/user/subscription/v1/cancel',
{
- simple: false
+ simple: false,
}
)
})
diff --git a/services/web/test/acceptance/src/SubscriptionDeletionTests.js b/services/web/test/acceptance/src/SubscriptionDeletionTests.js
index 96e17649e8..48ec5d0e04 100644
--- a/services/web/test/acceptance/src/SubscriptionDeletionTests.js
+++ b/services/web/test/acceptance/src/SubscriptionDeletionTests.js
@@ -22,12 +22,12 @@ describe('Subscriptions', function () {
teamInvites: [{ email: 'foo@baz.com' }],
groupPlan: true,
state: 'expired',
- planCode: 'professional'
+ planCode: 'professional',
})
this.subscription = this.recurlySubscription.subscription
this.recurlySubscription.ensureExists(cb)
},
- cb => this.subscription.refreshUsersFeatures(cb)
+ cb => this.subscription.refreshUsersFeatures(cb),
],
done
)
diff --git a/services/web/test/acceptance/src/SubscriptionFeaturesTests.js b/services/web/test/acceptance/src/SubscriptionFeaturesTests.js
index 8f85989624..351b0889b6 100644
--- a/services/web/test/acceptance/src/SubscriptionFeaturesTests.js
+++ b/services/web/test/acceptance/src/SubscriptionFeaturesTests.js
@@ -15,11 +15,11 @@ describe('Subscriptions', function () {
this.subscription = new Subscription({
adminId: this.adminUser._id,
groupPlan: false,
- planCode: 'professional'
+ planCode: 'professional',
})
this.subscription.ensureExists(cb)
},
- cb => this.subscription.refreshUsersFeatures(cb)
+ cb => this.subscription.refreshUsersFeatures(cb),
],
done
)
@@ -46,11 +46,11 @@ describe('Subscriptions', function () {
adminId: this.adminUser._id,
memberIds: [this.memberUser._id],
groupPlan: true,
- planCode: 'professional'
+ planCode: 'professional',
})
this.subscription.ensureExists(cb)
},
- cb => this.subscription.refreshUsersFeatures(cb)
+ cb => this.subscription.refreshUsersFeatures(cb),
],
done
)
diff --git a/services/web/test/acceptance/src/TagsTests.js b/services/web/test/acceptance/src/TagsTests.js
index 3f7adb1d34..5ef01aee31 100644
--- a/services/web/test/acceptance/src/TagsTests.js
+++ b/services/web/test/acceptance/src/TagsTests.js
@@ -135,8 +135,8 @@ describe('Tags', function () {
const auth = Buffer.from('sharelatex:password').toString('base64')
const authedRequest = request.defaults({
headers: {
- Authorization: `Basic ${auth}`
- }
+ Authorization: `Basic ${auth}`,
+ },
})
it('should disallow without appropriate auth headers', function (done) {
diff --git a/services/web/test/acceptance/src/TokenAccessTests.js b/services/web/test/acceptance/src/TokenAccessTests.js
index 3402465742..c5efaa98c8 100644
--- a/services/web/test/acceptance/src/TokenAccessTests.js
+++ b/services/web/test/acceptance/src/TokenAccessTests.js
@@ -34,7 +34,7 @@ const tryEditorAccess = (user, projectId, test, callback) =>
test(response, body)
cb()
}
- )
+ ),
],
callback
)
@@ -119,10 +119,10 @@ const tryContentAccess = (user, projcetId, test, callback) => {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
+ sendImmediately: true,
},
json: true,
- jar: false
+ jar: false,
},
(error, response, body) => {
if (error != null) {
@@ -150,13 +150,13 @@ const tryAnonContentAccess = (user, projectId, token, test, callback) => {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
+ sendImmediately: true,
},
headers: {
- 'x-sl-anonymous-access-token': token
+ 'x-sl-anonymous-access-token': token,
},
json: true,
- jar: false
+ jar: false,
},
(error, response, body) => {
if (error != null) {
@@ -188,7 +188,7 @@ describe('TokenAccess', function () {
cb => this.owner.login(cb),
cb => this.other1.login(cb),
cb => this.other2.login(cb),
- cb => this.anon.getCsrfToken(cb)
+ cb => this.anon.getCsrfToken(cb),
],
done
)
@@ -231,7 +231,7 @@ describe('TokenAccess', function () {
},
cb
)
- }
+ },
],
done
)
@@ -318,7 +318,7 @@ describe('TokenAccess', function () {
},
cb
)
- }
+ },
],
done
)
@@ -353,7 +353,7 @@ describe('TokenAccess', function () {
},
cb
)
- }
+ },
],
done
)
@@ -405,7 +405,7 @@ describe('TokenAccess', function () {
expect(body).to.equal('Forbidden')
},
cb
- )
+ ),
],
done
)
@@ -487,7 +487,7 @@ describe('TokenAccess', function () {
)
},
cb
- )
+ ),
],
done
)
@@ -540,7 +540,7 @@ describe('TokenAccess', function () {
expect(body).to.equal('Forbidden')
},
cb
- )
+ ),
],
done
)
@@ -624,7 +624,7 @@ describe('TokenAccess', function () {
)
},
cb
- )
+ ),
],
done
)
@@ -753,7 +753,7 @@ describe('TokenAccess', function () {
)
},
cb
- )
+ ),
],
done
)
@@ -807,7 +807,7 @@ describe('TokenAccess', function () {
},
cb
)
- }
+ },
],
done
)
@@ -862,7 +862,7 @@ describe('TokenAccess', function () {
expect(response.statusCode).to.equal(200)
expect(body).to.deep.equal({
redirect: '/restricted',
- anonWriteAccessDenied: true
+ anonWriteAccessDenied: true,
})
},
cb
@@ -884,7 +884,7 @@ describe('TokenAccess', function () {
expect(response.statusCode).to.equal(200)
expect(body.redir).to.equal(`/${this.tokens.readAndWrite}`)
cb()
- })
+ }),
],
done
)
@@ -958,7 +958,7 @@ describe('TokenAccess', function () {
expect(body.privilegeLevel).to.equal('readAndWrite')
},
cb
- )
+ ),
],
done
)
@@ -1008,7 +1008,7 @@ describe('TokenAccess', function () {
expect(body).to.equal('Forbidden')
},
cb
- )
+ ),
],
done
)
@@ -1032,8 +1032,8 @@ describe('TokenAccess', function () {
{ _id: project._id },
{
$set: {
- overleaf: { id: 1234 }
- }
+ overleaf: { id: 1234 },
+ },
},
err => {
expect(err).not.to.exist
@@ -1094,7 +1094,7 @@ describe('TokenAccess', function () {
expect(body).to.equal('Forbidden')
},
cb
- )
+ ),
],
done
)
@@ -1204,7 +1204,7 @@ describe('TokenAccess', function () {
expect(body).to.equal('Forbidden')
},
cb
- )
+ ),
],
done
)
@@ -1291,7 +1291,7 @@ describe('TokenAccess', function () {
exists: true,
exported: false,
has_owner: true,
- name: 'Test Project Import Example'
+ name: 'Test Project Import Example',
}
MockV1Api.setDocInfo(this.tokens.readAndWrite, docInfo)
MockV1Api.setDocInfo(this.tokens.readOnly, docInfo)
@@ -1328,8 +1328,8 @@ describe('TokenAccess', function () {
status: 'canDownloadZip',
projectId: this.tokens.readAndWrite,
hasOwner: true,
- name: 'Test Project Import Example'
- }
+ name: 'Test Project Import Example',
+ },
})
},
cb
@@ -1348,8 +1348,8 @@ describe('TokenAccess', function () {
status: 'canDownloadZip',
projectId: this.tokens.readOnly,
hasOwner: true,
- name: 'Test Project Import Example'
- }
+ name: 'Test Project Import Example',
+ },
})
},
cb
@@ -1371,7 +1371,7 @@ describe('TokenAccess', function () {
expect(response.statusCode).to.equal(404)
},
cb
- )
+ ),
],
done
)
@@ -1429,7 +1429,7 @@ describe('TokenAccess', function () {
expect(response.statusCode).to.equal(404)
},
cb
- )
+ ),
],
done
)
diff --git a/services/web/test/acceptance/src/TpdsUpdateTests.js b/services/web/test/acceptance/src/TpdsUpdateTests.js
index 046e7642fe..29ab490510 100644
--- a/services/web/test/acceptance/src/TpdsUpdateTests.js
+++ b/services/web/test/acceptance/src/TpdsUpdateTests.js
@@ -46,9 +46,9 @@ describe('TpdsUpdateTests', function () {
auth: {
username: 'sharelatex',
password: 'password',
- sendImmediately: true
+ sendImmediately: true,
},
- body: 'test one two'
+ body: 'test one two',
},
(error, response, body) => {
if (error != null) {
@@ -82,8 +82,8 @@ describe('TpdsUpdateTests', function () {
auth: {
username: 'sharelatex',
password: 'password',
- sendImmediately: true
- }
+ sendImmediately: true,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -120,9 +120,9 @@ describe('TpdsUpdateTests', function () {
auth: {
username: 'sharelatex',
password: 'password',
- sendImmediately: true
+ sendImmediately: true,
},
- body: 'test one two'
+ body: 'test one two',
},
(error, response, body) => {
if (error != null) {
@@ -152,7 +152,7 @@ describe('TpdsUpdateTests', function () {
this.owner.request(
{
url: `/Project/${this.project_id}/archive`,
- method: 'post'
+ method: 'post',
},
(err, response, body) => {
expect(err).to.not.exist
@@ -163,9 +163,9 @@ describe('TpdsUpdateTests', function () {
auth: {
username: 'sharelatex',
password: 'password',
- sendImmediately: true
+ sendImmediately: true,
},
- body: 'test one two'
+ body: 'test one two',
},
(error, response, body) => {
if (error != null) {
diff --git a/services/web/test/acceptance/src/UnsupportedBrowserTests.js b/services/web/test/acceptance/src/UnsupportedBrowserTests.js
index 6467b66995..a437a6a064 100644
--- a/services/web/test/acceptance/src/UnsupportedBrowserTests.js
+++ b/services/web/test/acceptance/src/UnsupportedBrowserTests.js
@@ -14,8 +14,8 @@ describe('UnsupportedBrowsers', function () {
headers: {
// Googlebot user agent
'user-agent':
- 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
- }
+ 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
+ },
},
(error, response) => {
expect(error).to.not.exist
@@ -32,8 +32,8 @@ describe('UnsupportedBrowsers', function () {
headers: {
// Chrome 90 user agent
'user-agent':
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36'
- }
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36',
+ },
},
(error, response) => {
expect(error).to.not.exist
@@ -50,8 +50,8 @@ describe('UnsupportedBrowsers', function () {
headers: {
// IE11 user agent
'user-agent':
- 'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko'
- }
+ 'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
+ },
},
(error, response) => {
expect(error).to.not.exist
diff --git a/services/web/test/acceptance/src/UserEmailsTests.js b/services/web/test/acceptance/src/UserEmailsTests.js
index da9a80db53..80056c8319 100644
--- a/services/web/test/acceptance/src/UserEmailsTests.js
+++ b/services/web/test/acceptance/src/UserEmailsTests.js
@@ -33,8 +33,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: 'newly-added-email@example.com'
- }
+ email: 'newly-added-email@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -62,7 +62,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -82,8 +82,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/confirm',
json: {
- token
- }
+ token,
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -112,7 +112,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -120,7 +120,7 @@ describe('UserEmails', function () {
expect(tokens.length).to.equal(0)
cb()
})
- }
+ },
],
done
)
@@ -140,7 +140,7 @@ describe('UserEmails', function () {
{
method: 'POST',
url: '/user/emails',
- json: { email: this.email }
+ json: { email: this.email },
},
cb
)
@@ -150,7 +150,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -168,7 +168,7 @@ describe('UserEmails', function () {
{
method: 'POST',
url: '/user/emails/delete',
- json: { email: this.email }
+ json: { email: this.email },
},
cb
)
@@ -179,7 +179,7 @@ describe('UserEmails', function () {
{
method: 'POST',
url: '/user/emails',
- json: { email: this.email }
+ json: { email: this.email },
},
cb
)
@@ -191,8 +191,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/confirm',
json: {
- token: token1
- }
+ token: token1,
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -206,7 +206,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user2._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -225,8 +225,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/confirm',
json: {
- token: token2
- }
+ token: token2,
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -246,7 +246,7 @@ describe('UserEmails', function () {
cb()
}
)
- }
+ },
],
done
)
@@ -261,7 +261,7 @@ describe('UserEmails', function () {
userHelper = await UserHelper.createUser({ email })
userHelper = await UserHelper.loginUser({
email,
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
// original confirmation
await userHelper.confirmEmail(userHelper.user._id, email)
@@ -295,8 +295,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: (this.email = 'expired-token-email@example.com')
- }
+ email: (this.email = 'expired-token-email@example.com'),
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -310,7 +310,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -325,12 +325,12 @@ describe('UserEmails', function () {
cb => {
db.tokens.update(
{
- token
+ token,
},
{
$set: {
- expiresAt: new Date(Date.now() - 1000000)
- }
+ expiresAt: new Date(Date.now() - 1000000),
+ },
},
cb
)
@@ -341,8 +341,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/confirm',
json: {
- token
- }
+ token,
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -350,7 +350,7 @@ describe('UserEmails', function () {
cb()
}
)
- }
+ },
],
done
)
@@ -367,8 +367,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: 'reconfirmation-email@example.com'
- }
+ email: 'reconfirmation-email@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -382,7 +382,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -401,8 +401,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/resend_confirmation',
json: {
- email: 'reconfirmation-email@example.com'
- }
+ email: 'reconfirmation-email@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -416,7 +416,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -432,7 +432,7 @@ describe('UserEmails', function () {
expect(tokens[1].data.user_id).to.equal(this.user._id)
cb()
})
- }
+ },
],
done
)
@@ -448,7 +448,7 @@ describe('UserEmails', function () {
{
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
},
cb
)
@@ -459,8 +459,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/resend_confirmation',
json: {
- email: this.user.email
- }
+ email: this.user.email,
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -474,7 +474,7 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
@@ -484,7 +484,7 @@ describe('UserEmails', function () {
expect(tokens[0].data.user_id).to.equal(this.user._id)
cb()
})
- }
+ },
],
done
)
@@ -499,8 +499,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/resend_confirmation',
json: {
- email: 'non-matching-email@example.com'
- }
+ email: 'non-matching-email@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -514,14 +514,14 @@ describe('UserEmails', function () {
.find({
use: 'email_confirmation',
'data.user_id': this.user._id,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.toArray((error, tokens) => {
expect(error).to.not.exist
expect(tokens.length).to.equal(0)
cb()
})
- }
+ },
],
done
)
@@ -538,8 +538,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: 'new-confirmed-default@example.com'
- }
+ email: 'new-confirmed-default@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -552,12 +552,12 @@ describe('UserEmails', function () {
// Mark the email as confirmed
db.users.updateOne(
{
- 'emails.email': 'new-confirmed-default@example.com'
+ 'emails.email': 'new-confirmed-default@example.com',
},
{
$set: {
- 'emails.$.confirmedAt': new Date()
- }
+ 'emails.$.confirmedAt': new Date(),
+ },
},
cb
)
@@ -568,8 +568,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/default',
json: {
- email: 'new-confirmed-default@example.com'
- }
+ email: 'new-confirmed-default@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -591,7 +591,7 @@ describe('UserEmails', function () {
cb()
}
)
- }
+ },
],
done
)
@@ -603,12 +603,12 @@ describe('UserEmails', function () {
cb => {
db.users.updateOne(
{
- _id: ObjectId(this.user._id)
+ _id: ObjectId(this.user._id),
},
{
$set: {
- 'overleaf.id': 42
- }
+ 'overleaf.id': 42,
+ },
},
cb
)
@@ -619,8 +619,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: 'new-unconfirmed-default@example.com'
- }
+ email: 'new-unconfirmed-default@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -635,8 +635,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/default',
json: {
- email: 'new-unconfirmed-default@example.com'
- }
+ email: 'new-unconfirmed-default@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -655,7 +655,7 @@ describe('UserEmails', function () {
cb()
}
)
- }
+ },
],
done
)
@@ -667,12 +667,12 @@ describe('UserEmails', function () {
cb => {
db.users.updateOne(
{
- _id: ObjectId(this.user._id)
+ _id: ObjectId(this.user._id),
},
{
$set: {
- 'overleaf.id': 42
- }
+ 'overleaf.id': 42,
+ },
},
cb
)
@@ -683,8 +683,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: 'new-confirmed-default-in-v1@example.com'
- }
+ email: 'new-confirmed-default-in-v1@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -697,12 +697,12 @@ describe('UserEmails', function () {
// Mark the email as confirmed
db.users.updateOne(
{
- 'emails.email': 'new-confirmed-default-in-v1@example.com'
+ 'emails.email': 'new-confirmed-default-in-v1@example.com',
},
{
$set: {
- 'emails.$.confirmedAt': new Date()
- }
+ 'emails.$.confirmedAt': new Date(),
+ },
},
cb
)
@@ -713,8 +713,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/default',
json: {
- email: 'new-confirmed-default-in-v1@example.com'
- }
+ email: 'new-confirmed-default-in-v1@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -722,7 +722,7 @@ describe('UserEmails', function () {
cb()
}
)
- }
+ },
],
error => {
expect(error).to.not.exist
@@ -739,12 +739,12 @@ describe('UserEmails', function () {
cb => {
db.users.updateOne(
{
- _id: ObjectId(this.user._id)
+ _id: ObjectId(this.user._id),
},
{
$set: {
- 'overleaf.id': 42
- }
+ 'overleaf.id': 42,
+ },
},
cb
)
@@ -755,8 +755,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: 'exists-in-v1@example.com'
- }
+ email: 'exists-in-v1@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -769,12 +769,12 @@ describe('UserEmails', function () {
// Mark the email as confirmed
db.users.updateOne(
{
- 'emails.email': 'exists-in-v1@example.com'
+ 'emails.email': 'exists-in-v1@example.com',
},
{
$set: {
- 'emails.$.confirmedAt': new Date()
- }
+ 'emails.$.confirmedAt': new Date(),
+ },
},
cb
)
@@ -785,8 +785,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails/default',
json: {
- email: 'exists-in-v1@example.com'
- }
+ email: 'exists-in-v1@example.com',
+ },
},
(error, response, body) => {
expect(error).to.not.exist
@@ -805,7 +805,7 @@ describe('UserEmails', function () {
cb()
}
)
- }
+ },
],
done
)
@@ -818,39 +818,39 @@ describe('UserEmails', function () {
otherEmail = 'other@overleaf.com'
userHelper = new UserHelper()
userHelper = await UserHelper.createUser({
- email: originalEmail
+ email: originalEmail,
})
userHelper = await UserHelper.loginUser({
email: originalEmail,
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
userId = userHelper.user._id
response = await userHelper.request.post({
form: {
- email: otherEmail
+ email: otherEmail,
},
simple: false,
- uri: '/user/emails'
+ uri: '/user/emails',
})
expect(response.statusCode).to.equal(204)
const token = (
await db.tokens.findOne({
'data.user_id': userId.toString(),
- 'data.email': otherEmail
+ 'data.email': otherEmail,
})
).token
response = await userHelper.request.post(`/user/emails/confirm`, {
form: {
- token
+ token,
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(200)
response = await userHelper.request.post('/user/emails/default', {
form: {
- email: otherEmail
+ email: otherEmail,
},
- simple: false
+ simple: false,
})
expect(response.statusCode).to.equal(200)
userHelper = await UserHelper.getUser(userId)
@@ -864,7 +864,7 @@ describe('UserEmails', function () {
expect(entry.ipAddress).to.equal('127.0.0.1')
expect(entry.info).to.deep.equal({
newPrimaryEmail: otherEmail,
- oldPrimaryEmail: originalEmail
+ oldPrimaryEmail: originalEmail,
})
})
})
@@ -896,7 +896,7 @@ describe('UserEmails', function () {
{
method: 'POST',
url: '/user/emails',
- json: { email: 'new-confirmed-default@example.com' }
+ json: { email: 'new-confirmed-default@example.com' },
},
(error, response) => {
expect(error).to.not.exist
@@ -919,7 +919,7 @@ describe('UserEmails', function () {
{
method: 'POST',
url: '/user/emails/default',
- json: { email: 'new-confirmed-default@example.com' }
+ json: { email: 'new-confirmed-default@example.com' },
},
(error, response) => {
expect(error).to.not.exist
@@ -956,8 +956,8 @@ describe('UserEmails', function () {
method: 'POST',
url: '/user/emails',
json: {
- email: 'newly-added-email@example.com'
- }
+ email: 'newly-added-email@example.com',
+ },
},
(error, response, body) => {
if (error) {
@@ -978,15 +978,15 @@ describe('UserEmails', function () {
userHelper = await UserHelper.createUser()
userHelper = await UserHelper.loginUser({
email: userHelper.getDefaultEmail(),
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
userId = userHelper.user._id
await userHelper.request.post({
form: {
- email: newEmail
+ email: newEmail,
},
simple: false,
- uri: '/user/emails'
+ uri: '/user/emails',
})
userHelper = await UserHelper.getUser(userId)
user = userHelper.user
@@ -1024,12 +1024,12 @@ describe('UserEmails', function () {
userHelper = await UserHelper.createUser({ email: defaultEmail })
userHelper = await UserHelper.loginUser({
email: defaultEmail,
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
const institutionId = MockV1Api.createInstitution({
commonsAccount: true,
ssoEnabled: false,
- maxConfirmationMonths
+ maxConfirmationMonths,
})
const domain = 'example-affiliation.com'
MockV1Api.addInstitutionDomain(institutionId, domain, { confirmed: true })
@@ -1157,10 +1157,10 @@ describe('UserEmails', function () {
const userId = userHelper.user._id
const query = {
_id: userId,
- 'emails.email': email2
+ 'emails.email': email2,
}
const update = {
- $unset: { 'emails.$.reconfirmedAt': true }
+ $unset: { 'emails.$.reconfirmedAt': true },
}
await UserUpdater.promises.updateUser(query, update)
})
diff --git a/services/web/test/acceptance/src/UserHelperTests.js b/services/web/test/acceptance/src/UserHelperTests.js
index 3a2b7c06fb..7dad120090 100644
--- a/services/web/test/acceptance/src/UserHelperTests.js
+++ b/services/web/test/acceptance/src/UserHelperTests.js
@@ -27,7 +27,7 @@ describe('UserHelper', function () {
describe('with email', function () {
it('should create new user with provided email and default password', async function () {
const userHelper = await UserHelper.createUser({
- email: 'foo@test.com'
+ email: 'foo@test.com',
})
userHelper.user.email.should.equal('foo@test.com')
const authedUser = await AuthenticationManager.promises.authenticate(
@@ -41,7 +41,7 @@ describe('UserHelper', function () {
describe('with password', function () {
it('should create new user with provided password and default email', async function () {
const userHelper = await UserHelper.createUser({
- password: 'foofoofoo'
+ password: 'foofoofoo',
})
userHelper.user.email.should.equal(userHelper.getDefaultEmail())
const authedUser = await AuthenticationManager.promises.authenticate(
@@ -86,7 +86,7 @@ describe('UserHelper', function () {
it('should login user', async function () {
const newUserHelper = await UserHelper.loginUser({
email: userHelper.getDefaultEmail(),
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
})
newUserHelper.user.email.should.equal(userHelper.user.email)
})
@@ -95,7 +95,7 @@ describe('UserHelper', function () {
describe('without email', function () {
it('should throw error', async function () {
await UserHelper.loginUser({
- password: userHelper.getDefaultPassword()
+ password: userHelper.getDefaultPassword(),
}).should.be.rejectedWith('email and password required')
})
})
@@ -103,7 +103,7 @@ describe('UserHelper', function () {
describe('without password', function () {
it('should throw error', async function () {
await UserHelper.loginUser({
- email: userHelper.getDefaultEmail()
+ email: userHelper.getDefaultEmail(),
}).should.be.rejectedWith('email and password required')
})
})
@@ -133,7 +133,7 @@ describe('UserHelper', function () {
describe('with email', function () {
it('should create new user with provided email and default password', async function () {
const userHelper = await UserHelper.registerUser({
- email: 'foo2@test.com'
+ email: 'foo2@test.com',
})
userHelper.user.email.should.equal('foo2@test.com')
const authedUser = await AuthenticationManager.promises.authenticate(
@@ -147,7 +147,7 @@ describe('UserHelper', function () {
describe('with password', function () {
it('should create new user with provided password and default email', async function () {
const userHelper = await UserHelper.registerUser({
- password: 'foofoofoo'
+ password: 'foofoofoo',
})
userHelper.user.email.should.equal(userHelper.getDefaultEmail())
const authedUser = await AuthenticationManager.promises.authenticate(
diff --git a/services/web/test/acceptance/src/UserMembershipAuthorizationTests.js b/services/web/test/acceptance/src/UserMembershipAuthorizationTests.js
index 743e3ac884..abefd422e5 100644
--- a/services/web/test/acceptance/src/UserMembershipAuthorizationTests.js
+++ b/services/web/test/acceptance/src/UserMembershipAuthorizationTests.js
@@ -14,12 +14,12 @@ describe('UserMembershipAuthorization', function () {
describe('group', function () {
beforeEach(function (done) {
this.subscription = new Subscription({
- groupPlan: true
+ groupPlan: true,
})
async.series(
[
this.subscription.ensureExists.bind(this.subscription),
- cb => this.user.login(cb)
+ cb => this.user.login(cb),
],
done
)
@@ -32,7 +32,7 @@ describe('UserMembershipAuthorization', function () {
[
expectAccess(this.user, url, 403),
cb => this.subscription.setManagerIds([this.user._id], cb),
- expectAccess(this.user, url, 200)
+ expectAccess(this.user, url, 200),
],
done
)
@@ -46,7 +46,7 @@ describe('UserMembershipAuthorization', function () {
[
expectAccess(this.user, url, 403),
cb => this.subscription.setManagerIds([this.user._id], cb),
- expectAccess(this.user, url, 200)
+ expectAccess(this.user, url, 200),
],
done
)
@@ -68,7 +68,7 @@ describe('UserMembershipAuthorization', function () {
this.user.login.bind(this.user),
expectAccess(this.user, url, 403),
cb => this.institution.setManagerIds([this.user._id], cb),
- expectAccess(this.user, url, 200)
+ expectAccess(this.user, url, 200),
],
done
)
@@ -84,7 +84,7 @@ describe('UserMembershipAuthorization', function () {
expectAccess(this.user, url, 403),
cb => this.user.ensureStaffAccess('institutionManagement', cb),
this.user.login.bind(this.user),
- expectAccess(this.user, url, 200)
+ expectAccess(this.user, url, 200),
],
done
)
@@ -98,7 +98,7 @@ describe('UserMembershipAuthorization', function () {
async.series(
[
this.publisher.ensureExists.bind(this.publisher),
- cb => this.user.login(cb)
+ cb => this.user.login(cb),
],
done
)
@@ -111,7 +111,7 @@ describe('UserMembershipAuthorization', function () {
[
expectAccess(this.user, url, 403),
cb => this.publisher.setManagerIds([this.user._id], cb),
- expectAccess(this.user, url, 200)
+ expectAccess(this.user, url, 200),
],
done
)
@@ -127,7 +127,7 @@ describe('UserMembershipAuthorization', function () {
expectAccess(this.user, url, 404),
cb => this.user.ensureStaffAccess('publisherManagement', cb),
this.user.login.bind(this.user),
- expectAccess(this.user, url, 302, /\/create/)
+ expectAccess(this.user, url, 302, /\/create/),
],
done
)
@@ -140,7 +140,7 @@ describe('UserMembershipAuthorization', function () {
expectAccess(this.user, url, 403),
cb => this.user.ensureStaffAccess('publisherManagement', cb),
this.user.login.bind(this.user),
- expectAccess(this.user, url, 200)
+ expectAccess(this.user, url, 200),
],
done
)
diff --git a/services/web/test/acceptance/src/UserReconfirmTests.js b/services/web/test/acceptance/src/UserReconfirmTests.js
index a58f2ca1c0..620ecfbb0f 100644
--- a/services/web/test/acceptance/src/UserReconfirmTests.js
+++ b/services/web/test/acceptance/src/UserReconfirmTests.js
@@ -21,7 +21,7 @@ describe('User Must Reconfirm', function () {
return async.series(
[
this.user.ensureUserExists.bind(this.user),
- cb => this.user.mongoUpdate({ $set: { must_reconfirm: true } }, cb)
+ cb => this.user.mongoUpdate({ $set: { must_reconfirm: true } }, cb),
],
done
)
diff --git a/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js b/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js
index a99257f813..2732f4c871 100644
--- a/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js
+++ b/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js
@@ -58,7 +58,7 @@ describe('ThirdPartyIdentityManager', function () {
it('should merge external data', function (done) {
this.externalData = {
test: 'different',
- another: 'key'
+ another: 'key',
}
ThirdPartyIdentityManager.login(
this.provider,
diff --git a/services/web/test/acceptance/src/helpers/MongoHelper.js b/services/web/test/acceptance/src/helpers/MongoHelper.js
index c81666f120..0e010e9d41 100644
--- a/services/web/test/acceptance/src/helpers/MongoHelper.js
+++ b/services/web/test/acceptance/src/helpers/MongoHelper.js
@@ -21,5 +21,5 @@ module.exports = {
Object.values(db).map(collection => collection.deleteMany({}))
)
})
- }
+ },
}
diff --git a/services/web/test/acceptance/src/helpers/RecurlySubscription.js b/services/web/test/acceptance/src/helpers/RecurlySubscription.js
index 1cbb1ee3e1..edc1e08c59 100644
--- a/services/web/test/acceptance/src/helpers/RecurlySubscription.js
+++ b/services/web/test/acceptance/src/helpers/RecurlySubscription.js
@@ -25,7 +25,7 @@ class RecurlySubscription {
this.account = {
id: this.subscription.admin_id.toString(),
email: options.account && options.account.email,
- hosted_login_token: options.account && options.account.hosted_login_token
+ hosted_login_token: options.account && options.account.hosted_login_token,
}
}
@@ -42,8 +42,8 @@ class RecurlySubscription {
buildCallbackXml() {
return RecurlyWrapper._buildXml('expired_subscription_notification', {
subscription: {
- uuid: this.uuid
- }
+ uuid: this.uuid,
+ },
})
}
}
diff --git a/services/web/test/acceptance/src/helpers/User.js b/services/web/test/acceptance/src/helpers/User.js
index cef21804a0..95ecd0a315 100644
--- a/services/web/test/acceptance/src/helpers/User.js
+++ b/services/web/test/acceptance/src/helpers/User.js
@@ -18,15 +18,15 @@ class User {
this.emails = [
{
email: options.email || `acceptance-test-${count}@example.com`,
- createdAt: new Date()
- }
+ createdAt: new Date(),
+ },
]
this.email = this.emails[0].email
this.password = `a-terrible-secret-${count}`
count++
this.jar = request.jar()
this.request = request.defaults({
- jar: this.jar
+ jar: this.jar,
})
}
@@ -77,7 +77,7 @@ class User {
this.request.post(
{
url: `/register${query}`,
- json: { email: this.email, password: this.password }
+ json: { email: this.email, password: this.password },
},
(error, response, body) => {
if (error != null) {
@@ -111,7 +111,7 @@ class User {
this.request.post(
{
url: settings.enableLegacyLogin ? '/login/legacy' : '/login',
- json: { email, password: this.password }
+ json: { email, password: this.password },
},
(error, response, body) => {
if (error != null) {
@@ -184,8 +184,8 @@ class User {
url: '/logout',
json: {
email: this.email,
- password: this.password
- }
+ password: this.password,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -248,7 +248,7 @@ class User {
templates: true,
references: true,
trackChanges: true,
- trackChangesVisible: true
+ trackChangesVisible: true,
}
this.mongoUpdate({ $set: { features } }, callback)
}
@@ -263,7 +263,7 @@ class User {
templates: false,
references: false,
trackChanges: false,
- trackChangesVisible: false
+ trackChangesVisible: false,
}
this.mongoUpdate({ $set: { features } }, callback)
}
@@ -307,7 +307,7 @@ class User {
this.request.post(
{
url: '/user/delete',
- json: { password: this.password }
+ json: { password: this.password },
},
(err, res) => {
if (err) {
@@ -342,7 +342,7 @@ class User {
this.request.post(
{
url: '/project/new',
- json: Object.assign({ projectName: name }, options)
+ json: Object.assign({ projectName: name }, options),
},
(error, response, body) => {
if (error != null) {
@@ -356,7 +356,7 @@ class User {
options,
response.statusCode,
response.headers.location,
- body
+ body,
])
)
callback(error)
@@ -370,7 +370,7 @@ class User {
deleteProject(projectId, callback) {
this.request.delete(
{
- url: `/project/${projectId}`
+ url: `/project/${projectId}`,
},
(error, response, body) => {
if (error != null) {
@@ -384,7 +384,7 @@ class User {
undeleteProject(projectId, callback) {
this.request.post(
{
- url: `/admin/project/${projectId}/undelete`
+ url: `/admin/project/${projectId}/undelete`,
},
(error, response) => {
if (error) {
@@ -409,7 +409,7 @@ class User {
openProject(projectId, callback) {
this.request.get(
{
- url: `/project/${projectId}`
+ url: `/project/${projectId}`,
},
(error, response, body) => {
if (error != null) {
@@ -436,8 +436,8 @@ class User {
url: `/project/${projectId}/doc`,
json: {
name,
- parentFolderId
- }
+ parentFolderId,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -458,17 +458,17 @@ class User {
{
uri: `project/${projectId}/upload`,
qs: {
- folder_id: String(folderId)
+ folder_id: String(folderId),
},
formData: {
qqfile: {
value: imageFile,
options: {
filename: name,
- contentType: contentType
- }
- }
- }
+ contentType: contentType,
+ },
+ },
+ },
},
(error, res, body) => {
if (error) {
@@ -499,8 +499,8 @@ class User {
{
uri: `project/${projectId}/${type}/${itemId}/move`,
json: {
- folder_id: folderId
- }
+ folder_id: folderId,
+ },
},
(error, res) => {
if (error) {
@@ -520,8 +520,8 @@ class User {
{
uri: `project/${projectId}/${type}/${itemId}/rename`,
json: {
- name: name
- }
+ name: name,
+ },
},
(error, res) => {
if (error) {
@@ -563,10 +563,10 @@ class User {
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
- sendImmediately: true
+ sendImmediately: true,
},
json: true,
- jar: false
+ jar: false,
},
(error, res, body) => {
if (error) {
@@ -597,8 +597,8 @@ class User {
{
url: `/project/${projectId}/settings/admin`,
json: {
- publicAccessLevel: level
- }
+ publicAccessLevel: level,
+ },
},
(error, response, body) => {
if (error != null) {
@@ -614,8 +614,8 @@ class User {
{
url: `/project/${projectId}/settings/admin`,
json: {
- publicAccessLevel: 'private'
- }
+ publicAccessLevel: 'private',
+ },
},
(error, response, body) => {
if (error != null) {
@@ -631,8 +631,8 @@ class User {
{
url: `/project/${projectId}/settings/admin`,
json: {
- publicAccessLevel: 'tokenBased'
- }
+ publicAccessLevel: 'tokenBased',
+ },
},
(error, response, body) => {
if (error != null) {
@@ -646,7 +646,7 @@ class User {
getCsrfToken(callback) {
this.request.get(
{
- url: '/dev/csrf'
+ url: '/dev/csrf',
},
(err, response, body) => {
if (err != null) {
@@ -655,8 +655,8 @@ class User {
this.csrfToken = body
this.request = this.request.defaults({
headers: {
- 'x-csrf-token': this.csrfToken
- }
+ 'x-csrf-token': this.csrfToken,
+ },
})
callback()
}
@@ -674,8 +674,8 @@ class User {
json: {
currentPassword: this.password,
newPassword1: this.password,
- newPassword2: this.password
- }
+ newPassword2: this.password,
+ },
},
callback
)
@@ -691,8 +691,8 @@ class User {
{
url: '/user/reconfirm',
json: {
- email: userEmail
- }
+ email: userEmail,
+ },
},
(error, response, body) => {
callback(error, response)
@@ -708,7 +708,7 @@ class User {
}
this.request.get(
{
- url: '/user/settings'
+ url: '/user/settings',
},
(error, response, body) => {
if (error != null) {
@@ -728,7 +728,7 @@ class User {
this.request.post(
{
url: '/user/settings',
- json: newSettings
+ json: newSettings,
},
callback
)
@@ -742,7 +742,7 @@ class User {
}
this.request.get(
{
- url: '/project'
+ url: '/project',
},
(error, response, body) => {
if (error != null) {
@@ -782,8 +782,8 @@ class User {
{
url: `/project/${projectId.toString()}/transfer-ownership`,
json: {
- user_id: userId.toString()
- }
+ user_id: userId.toString(),
+ },
},
(err, response) => {
if (err != null) {
@@ -803,12 +803,12 @@ class User {
setV1Id(v1Id, callback) {
UserModel.updateOne(
{
- _id: this._id
+ _id: this._id,
},
{
overleaf: {
- id: v1Id
- }
+ id: v1Id,
+ },
},
callback
)
@@ -822,7 +822,7 @@ class User {
this.request.put(
{
url: `/project/${projectId.toString()}/users/${userId.toString()}`,
- json: info
+ json: info,
},
(err, response) => {
if (err != null) {
diff --git a/services/web/test/acceptance/src/helpers/UserHelper.js b/services/web/test/acceptance/src/helpers/UserHelper.js
index fc025ee116..efc763b200 100644
--- a/services/web/test/acceptance/src/helpers/UserHelper.js
+++ b/services/web/test/acceptance/src/helpers/UserHelper.js
@@ -57,7 +57,7 @@ class UserHelper {
return {
email: this.getDefaultEmail(),
password: this.getDefaultPassword(),
- ...userData
+ ...userData,
}
}
@@ -86,7 +86,7 @@ class UserHelper {
baseUrl: UserHelper.baseUrl(),
followRedirect: false,
jar: this.jar,
- resolveWithFullResponse: true
+ resolveWithFullResponse: true,
})
}
@@ -128,7 +128,7 @@ class UserHelper {
this._csrfToken = response.body
// use csrf token for requests
this.setRequestDefaults({
- headers: { 'x-csrf-token': this._csrfToken }
+ headers: { 'x-csrf-token': this._csrfToken },
})
}
@@ -239,7 +239,7 @@ class UserHelper {
const loginPath = Settings.enableLegacyLogin ? '/login/legacy' : '/login'
await userHelper.getCsrfToken()
const response = await userHelper.request.post(loginPath, {
- json: userData
+ json: userData,
})
if (response.statusCode !== 200 || response.body.redir !== '/project') {
const error = new Error('login failed')
@@ -247,7 +247,7 @@ class UserHelper {
throw error
}
userHelper.user = await UserGetter.promises.getUser({
- email: userData.email
+ email: userData.email,
})
if (!userHelper.user) {
throw new Error(`user not found for email: ${userData.email}`)
@@ -263,7 +263,7 @@ class UserHelper {
*/
async isLoggedIn() {
const response = await this.request.get('/user/sessions', {
- followRedirect: true
+ followRedirect: true,
})
return response.request.path === '/user/sessions'
}
@@ -291,7 +291,7 @@ class UserHelper {
)
}
userHelper.user = await UserGetter.promises.getUser({
- email: userData.email
+ email: userData.email,
})
if (!userHelper.user) {
throw new Error(`user not found for email: ${userData.email}`)
@@ -303,7 +303,7 @@ class UserHelper {
async refreshMongoUser() {
this.user = await UserGetter.promises.getUser({
- _id: this.user._id
+ _id: this.user._id,
})
return this.user
}
@@ -311,10 +311,10 @@ class UserHelper {
async addEmail(email) {
let response = await this.request.post({
form: {
- email
+ email,
},
simple: false,
- uri: '/user/emails'
+ uri: '/user/emails',
})
expect(response.statusCode).to.equal(204)
}
@@ -328,13 +328,13 @@ class UserHelper {
const confirmedDate = moment().subtract(days, 'days').toDate()
const query = {
_id: userId,
- 'emails.email': email
+ 'emails.email': email,
}
const update = {
$set: {
'emails.$.confirmedAt': confirmedDate,
- 'emails.$.reconfirmedAt': confirmedDate
- }
+ 'emails.$.reconfirmedAt': confirmedDate,
+ },
}
await UserUpdater.promises.updateUser(query, update)
}
@@ -344,10 +344,10 @@ class UserHelper {
// UserHelper.createUser does not create a confirmation token
response = await this.request.post({
form: {
- email
+ email,
},
simple: false,
- uri: '/user/emails/resend_confirmation'
+ uri: '/user/emails/resend_confirmation',
})
expect(response.statusCode).to.equal(200)
const tokenData = await db.tokens
@@ -355,15 +355,15 @@ class UserHelper {
use: 'email_confirmation',
'data.user_id': userId.toString(),
'data.email': email,
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
})
.next()
response = await this.request.post({
form: {
- token: tokenData.token
+ token: tokenData.token,
},
simple: false,
- uri: '/user/emails/confirm'
+ uri: '/user/emails/confirm',
})
expect(response.statusCode).to.equal(200)
}
diff --git a/services/web/test/acceptance/src/helpers/expectErrorResponse.js b/services/web/test/acceptance/src/helpers/expectErrorResponse.js
index f669d7d656..87de023e7b 100644
--- a/services/web/test/acceptance/src/helpers/expectErrorResponse.js
+++ b/services/web/test/acceptance/src/helpers/expectErrorResponse.js
@@ -6,7 +6,7 @@ module.exports = {
expect(response.statusCode).to.equal(401)
expect(body).to.equal('Unauthorized')
expect(response.headers['www-authenticate']).to.equal('OverleafLogin')
- }
+ },
},
restricted: {
@@ -17,6 +17,6 @@ module.exports = {
json(response, body) {
expect(response.statusCode).to.equal(403)
expect(body).to.deep.equal({ message: 'restricted' })
- }
- }
+ },
+ },
}
diff --git a/services/web/test/acceptance/src/helpers/redis.js b/services/web/test/acceptance/src/helpers/redis.js
index 1e48d51fb9..966e3b881f 100644
--- a/services/web/test/acceptance/src/helpers/redis.js
+++ b/services/web/test/acceptance/src/helpers/redis.js
@@ -53,5 +53,5 @@ module.exports = {
})
)
})
- }
+ },
}
diff --git a/services/web/test/acceptance/src/helpers/request.js b/services/web/test/acceptance/src/helpers/request.js
index 939cc1f802..337cd59932 100644
--- a/services/web/test/acceptance/src/helpers/request.js
+++ b/services/web/test/acceptance/src/helpers/request.js
@@ -3,7 +3,7 @@
const BASE_URL = `http://${process.env.HTTP_TEST_HOST || 'localhost'}:3000`
const request = require('request').defaults({
baseUrl: BASE_URL,
- followRedirect: false
+ followRedirect: false,
})
module.exports = request
@@ -19,5 +19,5 @@ module.exports.promises = {
}
})
})
- }
+ },
}
diff --git a/services/web/test/acceptance/src/mocks/AbstractMockApi.js b/services/web/test/acceptance/src/mocks/AbstractMockApi.js
index b24b027232..780a49bb5f 100644
--- a/services/web/test/acceptance/src/mocks/AbstractMockApi.js
+++ b/services/web/test/acceptance/src/mocks/AbstractMockApi.js
@@ -37,7 +37,7 @@ class AbstractMockApi {
if (this.constructor._obj) {
throw new OError('mock already initialized', {
className: this.constructor._obj.constructor.name,
- port: this.port
+ port: this.port,
})
}
if (this.constructor === AbstractMockApi) {
@@ -66,7 +66,7 @@ class AbstractMockApi {
path,
query,
params,
- body
+ body,
})
const oldEnd = res.end
const oldJson = res.json
diff --git a/services/web/test/acceptance/src/mocks/MockAnalyticsApi.js b/services/web/test/acceptance/src/mocks/MockAnalyticsApi.js
index 6895e53dc4..b7c830f81c 100644
--- a/services/web/test/acceptance/src/mocks/MockAnalyticsApi.js
+++ b/services/web/test/acceptance/src/mocks/MockAnalyticsApi.js
@@ -15,16 +15,16 @@ class MockAnalyticsApi extends AbstractMockApi {
institutionId: 123,
day: {
projects: 0,
- users: 0
+ users: 0,
},
week: {
projects: 0,
- users: 0
+ users: 0,
},
month: {
projects: 1,
- users: 2
- }
+ users: 2,
+ },
})
})
}
diff --git a/services/web/test/acceptance/src/mocks/MockChatApi.js b/services/web/test/acceptance/src/mocks/MockChatApi.js
index c74ce1a267..ed0b51188e 100644
--- a/services/web/test/acceptance/src/mocks/MockChatApi.js
+++ b/services/web/test/acceptance/src/mocks/MockChatApi.js
@@ -15,7 +15,7 @@ class MockChatApi extends AbstractMockApi {
id: Math.random().toString(),
content: req.body.content,
timestamp: Date.now(),
- user_id: req.body.user_id
+ user_id: req.body.user_id,
}
this.projects[projectId] = this.projects[projectId] || []
this.projects[projectId].push(message)
diff --git a/services/web/test/acceptance/src/mocks/MockClsiApi.js b/services/web/test/acceptance/src/mocks/MockClsiApi.js
index 55186c5458..6bd90f5e9b 100644
--- a/services/web/test/acceptance/src/mocks/MockClsiApi.js
+++ b/services/web/test/acceptance/src/mocks/MockClsiApi.js
@@ -11,16 +11,16 @@ class MockClsiApi extends AbstractMockApi {
url: `/project/${req.params.project_id}/build/1234/output/project.pdf`,
path: 'project.pdf',
type: 'pdf',
- build: 1234
+ build: 1234,
},
{
url: `/project/${req.params.project_id}/build/1234/output/project.log`,
path: 'project.log',
type: 'log',
- build: 1234
- }
- ]
- }
+ build: 1234,
+ },
+ ],
+ },
})
}
diff --git a/services/web/test/acceptance/src/mocks/MockDocstoreApi.js b/services/web/test/acceptance/src/mocks/MockDocstoreApi.js
index 037def7e91..57ce7155e8 100644
--- a/services/web/test/acceptance/src/mocks/MockDocstoreApi.js
+++ b/services/web/test/acceptance/src/mocks/MockDocstoreApi.js
@@ -13,7 +13,7 @@ class MockDocstoreApi extends AbstractMockApi {
lines: [],
version: 1,
ranges: {},
- deleted: true
+ deleted: true,
}
}
@@ -44,7 +44,7 @@ class MockDocstoreApi extends AbstractMockApi {
this.docs[projectId][docId]._id = docId
res.json({
modified: oldVersion !== version,
- rev: this.docs[projectId][docId].rev
+ rev: this.docs[projectId][docId].rev,
})
})
diff --git a/services/web/test/acceptance/src/mocks/MockV1Api.js b/services/web/test/acceptance/src/mocks/MockV1Api.js
index 771f622309..fda0e167d4 100644
--- a/services/web/test/acceptance/src/mocks/MockV1Api.js
+++ b/services/web/test/acceptance/src/mocks/MockV1Api.js
@@ -207,7 +207,8 @@ class MockV1Api extends AbstractMockApi {
isUniversity: !institutionData.institution,
ssoBeta: institutionData.sso_beta || false,
ssoEnabled: institutionData.sso_enabled || false,
- maxConfirmationMonths: institutionData.maxConfirmationMonths || null
+ maxConfirmationMonths:
+ institutionData.maxConfirmationMonths || null,
}
affiliation.institution.confirmed = !!domainData.confirmed
@@ -254,7 +255,7 @@ class MockV1Api extends AbstractMockApi {
this.app.get('/universities/list/:id', (req, res) =>
res.json({
id: parseInt(req.params.id),
- name: `Institution ${req.params.id}`
+ name: `Institution ${req.params.id}`,
})
)
@@ -281,13 +282,13 @@ class MockV1Api extends AbstractMockApi {
return res.json({
email: user.email,
valid: true,
- user_profile: user.profile
+ user_profile: user.profile,
})
}
}
res.status(403).json({
email: req.body.email,
- valid: false
+ valid: false,
})
})
@@ -299,7 +300,7 @@ class MockV1Api extends AbstractMockApi {
if (conversion) {
res.status(200).json({
input_file_uri: conversion,
- brand_variation_id: partner.brand_variation_id
+ brand_variation_id: partner.brand_variation_id,
})
} else {
res.status(404).json({})
@@ -324,7 +325,7 @@ class MockV1Api extends AbstractMockApi {
(req, res) => {
const info = this.getDocInfo(req.params.token) || {
exists: false,
- exported: false
+ exported: false,
}
res.json(info)
}
diff --git a/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js b/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js
index f49e40b2f9..14049d9def 100644
--- a/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js
+++ b/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js
@@ -64,7 +64,7 @@ class MockV1HistoryApi extends AbstractMockApi {
this.requestedZipPacks++
this.events.emit('v1-history-pack-zip')
res.json({
- zipUrl: `http://localhost:3100/fake-zip-download/${req.params.project_id}/version/${req.params.version}`
+ zipUrl: `http://localhost:3100/fake-zip-download/${req.params.project_id}/version/${req.params.version}`,
})
}
)
diff --git a/services/web/test/frontend/bootstrap.js b/services/web/test/frontend/bootstrap.js
index 0568d854b3..d76b43f67c 100644
--- a/services/web/test/frontend/bootstrap.js
+++ b/services/web/test/frontend/bootstrap.js
@@ -21,7 +21,7 @@ chai.use(require('chai-as-promised'))
window.ExposedSettings = {
appName: 'Overleaf',
maxEntitiesPerProject: 10,
- maxUploadSize: 5 * 1024 * 1024
+ maxUploadSize: 5 * 1024 * 1024,
}
window.i18n = { currentLangCode: 'en' }
@@ -35,8 +35,8 @@ moment.updateLocale('en', {
nextDay: '[Tomorrow]',
lastWeek: 'ddd, Do MMM YY',
nextWeek: 'ddd, Do MMM YY',
- sameElse: 'ddd, Do MMM YY'
- }
+ sameElse: 'ddd, Do MMM YY',
+ },
})
let inMemoryLocalStorage = {}
@@ -49,9 +49,9 @@ Object.defineProperty(global, 'localStorage', {
: null,
setItem: (key, value) => (inMemoryLocalStorage[key] = value),
clear: () => (inMemoryLocalStorage = {}),
- removeItem: key => delete inMemoryLocalStorage[key]
+ removeItem: key => delete inMemoryLocalStorage[key],
},
- writable: true
+ writable: true,
})
// node-fetch doesn't accept relative URL's: https://github.com/node-fetch/node-fetch/blob/master/docs/v2-LIMITS.md#known-differences
diff --git a/services/web/test/frontend/features/chat/components/chat-pane.test.js b/services/web/test/frontend/features/chat/components/chat-pane.test.js
index 0a0fe77ce7..3bd491c6ea 100644
--- a/services/web/test/frontend/features/chat/components/chat-pane.test.js
+++ b/services/web/test/frontend/features/chat/components/chat-pane.test.js
@@ -6,7 +6,7 @@ import fetchMock from 'fetch-mock'
import ChatPane from '../../../../../frontend/js/features/chat/components/chat-pane'
import {
renderWithChatContext,
- cleanUpContext
+ cleanUpContext,
} from '../../../helpers/render-with-context'
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
@@ -14,7 +14,7 @@ describe('
', function () {
const user = {
id: 'fake_user',
first_name: 'fake_user_first_name',
- email: 'fake@example.com'
+ email: 'fake@example.com',
}
const testMessages = [
@@ -22,14 +22,14 @@ describe('
', function () {
id: 'msg_1',
content: 'a message',
user,
- timestamp: new Date().getTime()
+ timestamp: new Date().getTime(),
},
{
id: 'msg_2',
content: 'another message',
user,
- timestamp: new Date().getTime()
- }
+ timestamp: new Date().getTime(),
+ },
]
beforeEach(function () {
diff --git a/services/web/test/frontend/features/chat/components/message-list.test.js b/services/web/test/frontend/features/chat/components/message-list.test.js
index e60b8be8a4..a750cdc7a6 100644
--- a/services/web/test/frontend/features/chat/components/message-list.test.js
+++ b/services/web/test/frontend/features/chat/components/message-list.test.js
@@ -10,7 +10,7 @@ describe('
', function () {
const currentUser = {
id: 'fake_user',
first_name: 'fake_user_first_name',
- email: 'fake@example.com'
+ email: 'fake@example.com',
}
function createMessages() {
@@ -19,14 +19,14 @@ describe('
', function () {
id: '1',
contents: ['a message'],
user: currentUser,
- timestamp: new Date().getTime()
+ timestamp: new Date().getTime(),
},
{
id: '2',
contents: ['another message'],
user: currentUser,
- timestamp: new Date().getTime()
- }
+ timestamp: new Date().getTime(),
+ },
]
}
diff --git a/services/web/test/frontend/features/chat/components/message.test.js b/services/web/test/frontend/features/chat/components/message.test.js
index 7c563362b7..5fd143c1f1 100644
--- a/services/web/test/frontend/features/chat/components/message.test.js
+++ b/services/web/test/frontend/features/chat/components/message.test.js
@@ -9,7 +9,7 @@ describe('
', function () {
const currentUser = {
id: 'fake_user',
first_name: 'fake_user_first_name',
- email: 'fake@example.com'
+ email: 'fake@example.com',
}
beforeEach(function () {
@@ -25,7 +25,7 @@ describe('
', function () {
it('renders a basic message', function () {
const message = {
contents: ['a message'],
- user: currentUser
+ user: currentUser,
}
render(
)
@@ -36,7 +36,7 @@ describe('
', function () {
it('renders a message with multiple contents', function () {
const message = {
contents: ['a message', 'another message'],
- user: currentUser
+ user: currentUser,
}
render(
)
@@ -48,9 +48,9 @@ describe('
', function () {
it('renders HTML links within messages', function () {
const message = {
contents: [
- 'a message with a
link to Overleaf'
+ 'a message with a
link to Overleaf',
],
- user: currentUser
+ user: currentUser,
}
render(
)
@@ -61,7 +61,7 @@ describe('
', function () {
describe('when the message is from the user themselves', function () {
const message = {
contents: ['a message'],
- user: currentUser
+ user: currentUser,
}
it('does not render the user name nor the email', function () {
@@ -75,12 +75,12 @@ describe('
', function () {
describe('when the message is from other user', function () {
const otherUser = {
id: 'other_user',
- first_name: 'other_user_first_name'
+ first_name: 'other_user_first_name',
}
const message = {
contents: ['a message'],
- user: otherUser
+ user: otherUser,
}
it('should render the other user name', function () {
@@ -94,8 +94,8 @@ describe('
', function () {
contents: message.contents,
user: {
id: otherUser.id,
- email: 'other@example.com'
- }
+ email: 'other@example.com',
+ },
}
render(
)
diff --git a/services/web/test/frontend/features/chat/components/stubs.js b/services/web/test/frontend/features/chat/components/stubs.js
index 2a52159225..47b93b8b3b 100644
--- a/services/web/test/frontend/features/chat/components/stubs.js
+++ b/services/web/test/frontend/features/chat/components/stubs.js
@@ -4,8 +4,8 @@ export function stubMathJax() {
window.MathJax = {
Hub: {
Queue: sinon.stub(),
- config: { tex2jax: { inlineMath: [['$', '$']] } }
- }
+ config: { tex2jax: { inlineMath: [['$', '$']] } },
+ },
}
}
diff --git a/services/web/test/frontend/features/chat/context/chat-context.test.js b/services/web/test/frontend/features/chat/context/chat-context.test.js
index 497ec28e93..b44f452d59 100644
--- a/services/web/test/frontend/features/chat/context/chat-context.test.js
+++ b/services/web/test/frontend/features/chat/context/chat-context.test.js
@@ -10,7 +10,7 @@ import EventEmitter from 'events'
import { useChatContext } from '../../../../../frontend/js/features/chat/context/chat-context'
import {
ChatProviders,
- cleanUpContext
+ cleanUpContext,
} from '../../../helpers/render-with-context'
import { stubMathJax, tearDownMathJaxStubs } from '../components/stubs'
@@ -18,7 +18,7 @@ describe('ChatContext', function () {
const user = {
id: 'fake_user',
first_name: 'fake_user_first_name',
- email: 'fake@example.com'
+ email: 'fake@example.com',
}
beforeEach(function () {
@@ -64,7 +64,7 @@ describe('ChatContext', function () {
const socket = new EventEmitter()
const { result, waitForNextUpdate } = renderChatContextHook({
user,
- socket
+ socket,
})
// Wait until initial messages have loaded
@@ -82,8 +82,8 @@ describe('ChatContext', function () {
user: {
id: 'another_fake_user',
first_name: 'another_fake_user_first_name',
- email: 'another_fake@example.com'
- }
+ email: 'another_fake@example.com',
+ },
})
const message = result.current.messages[0]
@@ -95,7 +95,7 @@ describe('ChatContext', function () {
const socket = new EventEmitter()
const { result, waitForNextUpdate } = renderChatContextHook({
user,
- socket
+ socket,
})
// Wait until initial messages have loaded
@@ -110,7 +110,7 @@ describe('ChatContext', function () {
id: 'msg_1',
content: 'received message',
timestamp: Date.now(),
- user
+ user,
})
// Expect that the sent message is shown, but the new message is not
@@ -125,7 +125,7 @@ describe('ChatContext', function () {
const socket = new EventEmitter()
const { result, waitForNextUpdate } = renderChatContextHook({
user,
- socket
+ socket,
})
// Wait until initial messages have loaded
@@ -137,7 +137,7 @@ describe('ChatContext', function () {
const [sentMessageFromCurrentUser] = result.current.messages
expect(sentMessageFromCurrentUser.contents).to.deep.equal([
- 'sent message from current user'
+ 'sent message from current user',
])
act(() => {
@@ -149,14 +149,14 @@ describe('ChatContext', function () {
user: {
id: 'another_fake_user',
first_name: 'another_fake_user_first_name',
- email: 'another_fake@example.com'
- }
+ email: 'another_fake@example.com',
+ },
})
})
const [, messageFromOtherUser] = result.current.messages
expect(messageFromOtherUser.contents).to.deep.equal([
- 'new message from other user'
+ 'new message from other user',
])
// Receive a message from the current user
@@ -164,13 +164,13 @@ describe('ChatContext', function () {
id: 'msg_2',
content: 'received message from current user',
timestamp: Date.now(),
- user
+ user,
})
// Since the current user didn't just send a message, it is now shown
const [, , receivedMessageFromCurrentUser] = result.current.messages
expect(receivedMessageFromCurrentUser.contents).to.deep.equal([
- 'received message from current user'
+ 'received message from current user',
])
})
})
@@ -182,8 +182,8 @@ describe('ChatContext', function () {
id: 'msg_1',
content: 'a message',
user,
- timestamp: Date.now()
- }
+ timestamp: Date.now(),
+ },
])
})
@@ -218,8 +218,8 @@ describe('ChatContext', function () {
id: 'msg_1',
content: 'first message',
user,
- timestamp: new Date('2021-03-04T10:00:00').getTime()
- }
+ timestamp: new Date('2021-03-04T10:00:00').getTime(),
+ },
])
const { result, waitForNextUpdate } = renderChatContextHook({ user })
@@ -228,7 +228,7 @@ describe('ChatContext', function () {
await waitForNextUpdate()
expect(result.current.messages[0].contents).to.deep.equal([
- 'first message'
+ 'first message',
])
// The before query param is not set
@@ -250,8 +250,8 @@ describe('ChatContext', function () {
id: 'msg_51',
content: 'message from second page',
user,
- timestamp: new Date('2021-03-04T11:00:00').getTime()
- }
+ timestamp: new Date('2021-03-04T11:00:00').getTime(),
+ },
],
{ overwriteRoutes: false }
)
@@ -312,7 +312,7 @@ describe('ChatContext', function () {
const socket = new EventEmitter()
const { result, waitForNextUpdate } = renderChatContextHook({
user,
- socket
+ socket,
})
// Start loading messages
@@ -327,8 +327,8 @@ describe('ChatContext', function () {
user: {
id: 'another_fake_user',
first_name: 'another_fake_user_first_name',
- email: 'another_fake@example.com'
- }
+ email: 'another_fake@example.com',
+ },
})
// Resolve messages being loaded
@@ -337,8 +337,8 @@ describe('ChatContext', function () {
id: 'fetched_msg',
content: 'loaded message',
user,
- timestamp: Date.now()
- }
+ timestamp: Date.now(),
+ },
])
await waitForNextUpdate()
@@ -349,7 +349,7 @@ describe('ChatContext', function () {
)
expect(messageContents).to.deep.equal([
'loaded message',
- 'socket message'
+ 'socket message',
])
})
})
@@ -369,7 +369,7 @@ describe('ChatContext', function () {
result.current.sendMessage('sent message')
expect(result.current.messages[0].contents).to.deep.equal([
- 'sent message'
+ 'sent message',
])
})
@@ -393,7 +393,7 @@ describe('ChatContext', function () {
expect(result.current.messages).to.be.empty
expect(
fetchMock.called('express:/project/:projectId/messages', {
- method: 'post'
+ method: 'post',
})
).to.be.false
})
@@ -414,7 +414,7 @@ describe('ChatContext', function () {
id: 'msg_1',
content: 'new message',
timestamp: Date.now(),
- user
+ user,
})
expect(result.current.unreadMessageCount).to.equal(1)
@@ -430,7 +430,7 @@ describe('ChatContext', function () {
id: 'msg_1',
content: 'new message',
timestamp: Date.now(),
- user
+ user,
})
result.current.markMessagesAsRead()
@@ -445,7 +445,7 @@ function renderChatContextHook(props) {
// Wrap with ChatContext.Provider (and the other editor context providers)
wrapper: ({ children }) => (
{children}
- )
+ ),
})
}
@@ -454,7 +454,7 @@ function createMessages(number, user, timestamp = Date.now()) {
id: `msg_${idx + 1}`,
content: `message ${idx + 1}`,
user,
- timestamp
+ timestamp,
}))
}
diff --git a/services/web/test/frontend/features/chat/util/message-list-appender.test.js b/services/web/test/frontend/features/chat/util/message-list-appender.test.js
index 31a6a72782..a7eaa20ea5 100644
--- a/services/web/test/frontend/features/chat/util/message-list-appender.test.js
+++ b/services/web/test/frontend/features/chat/util/message-list-appender.test.js
@@ -1,15 +1,15 @@
import { expect } from 'chai'
import {
appendMessage,
- prependMessages
+ prependMessages,
} from '../../../../../frontend/js/features/chat/utils/message-list-appender'
const testUser = {
- id: '123abc'
+ id: '123abc',
}
const otherUser = {
- id: '234other'
+ id: '234other',
}
function createTestMessageList() {
@@ -18,14 +18,14 @@ function createTestMessageList() {
id: 'msg_1',
contents: ['hello', 'world'],
timestamp: new Date().getTime(),
- user: otherUser
+ user: otherUser,
},
{
id: 'msg_2',
contents: ['foo'],
timestamp: new Date().getTime(),
- user: testUser
- }
+ user: testUser,
+ },
]
}
@@ -35,7 +35,7 @@ describe('prependMessages()', function () {
id: 'prepended_message',
content: 'hello',
timestamp: new Date().getTime(),
- user: testUser
+ user: testUser,
}
const message2 = { ...message1, id: 'prepended_message_2' }
return [message1, message2]
@@ -48,8 +48,8 @@ describe('prependMessages()', function () {
id: messages[0].id,
timestamp: messages[0].timestamp,
user: messages[0].user,
- contents: [messages[0].content, messages[1].content]
- }
+ contents: [messages[0].content, messages[1].content],
+ },
])
})
@@ -69,7 +69,7 @@ describe('prependMessages()', function () {
id: messages[0].id,
timestamp: messages[0].timestamp,
user: messages[0].user,
- contents: [messages[0].content, messages[1].content]
+ contents: [messages[0].content, messages[1].content],
})
})
@@ -81,13 +81,13 @@ describe('prependMessages()', function () {
id: messages[0].id,
timestamp: messages[0].timestamp,
user: messages[0].user,
- contents: [messages[0].content]
+ contents: [messages[0].content],
})
expect(result[1]).to.deep.equal({
id: messages[1].id,
timestamp: messages[1].timestamp,
user: messages[1].user,
- contents: [messages[1].content]
+ contents: [messages[1].content],
})
})
})
@@ -108,13 +108,13 @@ describe('prependMessages()', function () {
id: messages[0].id,
timestamp: messages[0].timestamp,
user: messages[0].user,
- contents: [messages[0].content]
+ contents: [messages[0].content],
})
expect(result[1]).to.deep.equal({
id: messages[1].id,
timestamp: messages[1].timestamp,
user: messages[1].user,
- contents: [messages[1].content]
+ contents: [messages[1].content],
})
})
})
@@ -130,7 +130,7 @@ describe('prependMessages()', function () {
id: messages[0].id,
timestamp: messages[0].timestamp,
user: messages[0].user,
- contents: [messages[0].content, messages[1].content, ...list[0].contents]
+ contents: [messages[0].content, messages[1].content, ...list[0].contents],
})
})
})
@@ -141,7 +141,7 @@ describe('appendMessage()', function () {
id: 'appended_message',
content: 'hi!',
timestamp: new Date().getTime(),
- user: testUser
+ user: testUser,
}
}
@@ -152,8 +152,8 @@ describe('appendMessage()', function () {
id: 'appended_message',
timestamp: testMessage.timestamp,
user: testMessage.user,
- contents: [testMessage.content]
- }
+ contents: [testMessage.content],
+ },
])
})
@@ -193,7 +193,7 @@ describe('appendMessage()', function () {
id: 'appended_message',
timestamp: message.timestamp,
user: message.user,
- contents: [message.content]
+ contents: [message.content],
})
})
})
@@ -215,7 +215,7 @@ describe('appendMessage()', function () {
id: 'appended_message',
timestamp: message.timestamp,
user: message.user,
- contents: [message.content]
+ contents: [message.content],
})
})
@@ -228,7 +228,7 @@ describe('appendMessage()', function () {
id: 'appended_message',
timestamp: message.timestamp,
user: message.user,
- contents: [message.content]
+ contents: [message.content],
})
})
})
diff --git a/services/web/test/frontend/features/clone-project-modal/components/clone-project-modal.test.js b/services/web/test/frontend/features/clone-project-modal/components/clone-project-modal.test.js
index fe6325a9b0..a0ca4251fe 100644
--- a/services/web/test/frontend/features/clone-project-modal/components/clone-project-modal.test.js
+++ b/services/web/test/frontend/features/clone-project-modal/components/clone-project-modal.test.js
@@ -15,7 +15,7 @@ describe('
', function () {
projectId: 'project-1',
projectName: 'Test Project',
openProject: sinon.stub(),
- show: true
+ show: true,
}
it('renders the translated modal title', async function () {
@@ -29,7 +29,7 @@ describe('
', function () {
'express:/project/:projectId/clone',
{
status: 200,
- body: { project_id: modalProps.projectId }
+ body: { project_id: modalProps.projectId },
},
{ delay: 10 }
)
@@ -47,12 +47,12 @@ describe('
', function () {
const input = await screen.getByLabelText('New Name')
fireEvent.change(input, {
- target: { value: '' }
+ target: { value: '' },
})
expect(submitButton.disabled).to.be.true
fireEvent.change(input, {
- target: { value: 'A Cloned Project' }
+ target: { value: 'A Cloned Project' },
})
expect(submitButton.disabled).to.be.false
@@ -67,7 +67,7 @@ describe('
', function () {
expect(url).to.equal('/project/project-1/clone')
expect(JSON.parse(options.body)).to.deep.equal({
- projectName: 'A Cloned Project'
+ projectName: 'A Cloned Project',
})
expect(openProject).to.be.calledOnce
@@ -86,7 +86,7 @@ describe('
', function () {
fetchMock.postOnce(matcher, {
status: 500,
- body: 'There was an error!'
+ body: 'There was an error!',
})
const openProject = sinon.stub()
@@ -115,7 +115,7 @@ describe('
', function () {
fetchMock.postOnce(matcher, {
status: 400,
- body: 'There was an error!'
+ body: 'There was an error!',
})
const openProject = sinon.stub()
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-create/context-props.js b/services/web/test/frontend/features/file-tree/components/file-tree-create/context-props.js
index cde817ae14..1ebb180fbf 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-create/context-props.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-create/context-props.js
@@ -18,9 +18,9 @@ export const contextProps = {
{
docs: [{ _id: 'entity-1' }],
fileRefs: [],
- folders: []
- }
+ folders: [],
+ },
],
initialSelectedEntityId: 'entity-1',
- onSelect: sinon.stub()
+ onSelect: sinon.stub(),
}
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-create/file-tree-modal-create-file.test.js b/services/web/test/frontend/features/file-tree/components/file-tree-create/file-tree-modal-create-file.test.js
index 029e224d7b..7bb63221cb 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-create/file-tree-modal-create-file.test.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-create/file-tree-modal-create-file.test.js
@@ -5,7 +5,7 @@ import {
render,
fireEvent,
cleanup,
- waitFor
+ waitFor,
} from '@testing-library/react'
import fetchMock from 'fetch-mock'
import PropTypes from 'prop-types'
@@ -60,11 +60,11 @@ describe('
', function () {
const rootFolder = [
{
docs: Array.from({ length: 10 }, (_, index) => ({
- _id: `entity-${index}`
+ _id: `entity-${index}`,
})),
fileRefs: [],
- folders: []
- }
+ folders: [],
+ },
]
render(
@@ -88,11 +88,11 @@ describe('
', function () {
const rootFolder = [
{
docs: Array.from({ length: 9 }, (_, index) => ({
- _id: `entity-${index}`
+ _id: `entity-${index}`,
})),
fileRefs: [],
- folders: []
- }
+ folders: [],
+ },
]
render(
@@ -126,15 +126,15 @@ describe('
', function () {
{ _id: 'entity-6' },
{ _id: 'entity-7' },
{ _id: 'entity-8' },
- { _id: 'entity-9' }
+ { _id: 'entity-9' },
],
fileRefs: [],
- folders: []
- }
- ]
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
+ ],
+ },
]
render(
@@ -168,7 +168,7 @@ describe('
', function () {
expect(
fetchMock.called('express:/project/:projectId/doc', {
- body: { name: 'test.tex' }
+ body: { name: 'test.tex' },
})
).to.be.true
})
@@ -179,40 +179,40 @@ describe('
', function () {
projects: [
{
_id: 'test-project',
- name: 'This Project'
+ name: 'This Project',
},
{
_id: 'project-1',
- name: 'Project One'
+ name: 'Project One',
},
{
_id: 'project-2',
- name: 'Project Two'
- }
- ]
+ name: 'Project Two',
+ },
+ ],
})
.get('express:/project/:projectId/entities', {
entities: [
{
- path: '/foo.tex'
+ path: '/foo.tex',
},
{
- path: '/bar.tex'
- }
- ]
+ path: '/bar.tex',
+ },
+ ],
})
.post('express:/project/:projectId/compile', {
status: 'success',
outputFiles: [
{
build: 'test',
- path: 'baz.jpg'
+ path: 'baz.jpg',
},
{
build: 'test',
- path: 'ball.jpg'
- }
- ]
+ path: 'ball.jpg',
+ },
+ ],
})
.post('express:/project/:projectId/linked_file', () => 204)
@@ -253,7 +253,7 @@ describe('
', function () {
// click on the button to toggle between source and output files
const sourceTypeButton = screen.getByRole('button', {
- name: 'select from output files'
+ name: 'select from output files',
})
await fireEvent.click(sourceTypeButton)
@@ -282,9 +282,9 @@ describe('
', function () {
data: {
source_project_id: 'project-2',
source_output_file_path: 'ball.jpg',
- build_id: 'test'
- }
- }
+ build_id: 'test',
+ },
+ },
})
).to.be.true
})
@@ -302,14 +302,14 @@ describe('
', function () {
const nameInput = screen.getByLabelText('File Name In This Project')
await fireEvent.change(urlInput, {
- target: { value: 'https://example.com/example.tex' }
+ target: { value: 'https://example.com/example.tex' },
})
// check that the name has updated automatically
expect(nameInput.value).to.equal('example.tex')
await fireEvent.change(nameInput, {
- target: { value: 'test.tex' }
+ target: { value: 'test.tex' },
})
// check that the name can still be edited manually
@@ -324,8 +324,8 @@ describe('
', function () {
body: {
name: 'test.tex',
provider: 'url',
- data: { url: 'https://example.com/example.tex' }
- }
+ data: { url: 'https://example.com/example.tex' },
+ },
})
).to.be.true
})
@@ -350,8 +350,8 @@ describe('
', function () {
// https://github.com/jsdom/jsdom/issues/1568 - no paste
fireEvent.drop(dropzone, {
dataTransfer: {
- files: [new File(['test'], 'test.tex', { type: 'text/plain' })]
- }
+ files: [new File(['test'], 'test.tex', { type: 'text/plain' })],
+ },
})
expect(fetchMock.called('express:/project/:projectId/upload')).to.be.true
@@ -373,5 +373,5 @@ function OpenWithMode({ mode }) {
return
}
OpenWithMode.propTypes = {
- mode: PropTypes.string.isRequired
+ mode: PropTypes.string.isRequired,
}
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-doc.test.js b/services/web/test/frontend/features/file-tree/components/file-tree-doc.test.js
index 9652165bda..8909ac88be 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-doc.test.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-doc.test.js
@@ -24,10 +24,10 @@ describe('
', function () {
{
docs: [{ _id: '123abc' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
}
)
@@ -58,10 +58,10 @@ describe('
', function () {
{
docs: [{ _id: '123abc' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
})
const treeitem = screen.getByRole('treeitem', { selected: false })
@@ -77,10 +77,10 @@ describe('
', function () {
{
docs: [{ _id: '123abc' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
})
const treeitem = screen.getByRole('treeitem')
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-folder-list.test.js b/services/web/test/frontend/features/file-tree/components/file-tree-folder-list.test.js
index e9bcfaf903..220ceb3b19 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-folder-list.test.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-folder-list.test.js
@@ -19,7 +19,7 @@ describe('
', function () {
name: 'A Folder',
folders: [],
docs: [],
- fileRefs: []
+ fileRefs: [],
}
const aDoc = { _id: '789ghi', name: 'doc.tex', linkedFileData: {} }
const aFile = { _id: '987jkl', name: 'file.bib', linkedFileData: {} }
@@ -37,7 +37,7 @@ describe('
', function () {
it('without write permissions', function () {
const docs = [
{ _id: '1', name: '1.tex' },
- { _id: '2', name: '2.tex' }
+ { _id: '2', name: '2.tex' },
]
renderWithContext(
,
@@ -48,10 +48,10 @@ describe('
', function () {
{
docs: [{ _id: '1' }, { _id: '2' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
}
)
@@ -73,7 +73,7 @@ describe('
', function () {
const docs = [
{ _id: '1', name: '1.tex' },
{ _id: '2', name: '2.tex' },
- { _id: '3', name: '3.tex' }
+ { _id: '3', name: '3.tex' },
]
renderWithContext(
,
@@ -83,10 +83,10 @@ describe('
', function () {
{
docs: [{ _id: '1' }, { _id: '2' }, { _id: '3' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
}
)
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-folder.test.js b/services/web/test/frontend/features/file-tree/components/file-tree-folder.test.js
index f6ca725440..416bb4e921 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-folder.test.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-folder.test.js
@@ -40,10 +40,10 @@ describe('
', function () {
{
docs: [{ _id: '123abc' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
}
)
@@ -76,10 +76,10 @@ describe('
', function () {
{
docs: [{ _id: '123abc' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
}
)
@@ -105,10 +105,10 @@ describe('
', function () {
{
docs: [{ _id: '123abc' }],
fileRefs: [],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
}
)
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-inner.test.js b/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-inner.test.js
index 3f042e905f..d4aea62ad1 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-inner.test.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-inner.test.js
@@ -77,10 +77,10 @@ describe('
', function () {
_id: 'root-folder-id',
docs: [{ _id: '123abc', name: 'bar.tex' }],
folders: [],
- fileRefs: []
- }
- ]
- }
+ fileRefs: [],
+ },
+ ],
+ },
}
)
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-name.test.js b/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-name.test.js
index 1610e714f4..9925b9b2aa 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-name.test.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-name.test.js
@@ -76,7 +76,7 @@ describe('
', function () {
setIsDraggable={setIsDraggable}
/>,
{
- contextProps: { hasWritePermissions: false }
+ contextProps: { hasWritePermissions: false },
}
)
diff --git a/services/web/test/frontend/features/file-tree/components/file-tree-root.test.js b/services/web/test/frontend/features/file-tree/components/file-tree-root.test.js
index 70771bb22a..727154e290 100644
--- a/services/web/test/frontend/features/file-tree/components/file-tree-root.test.js
+++ b/services/web/test/frontend/features/file-tree/components/file-tree-root.test.js
@@ -28,8 +28,8 @@ describe('
', function () {
_id: 'root-folder-id',
docs: [{ _id: '456def', name: 'main.tex' }],
folders: [],
- fileRefs: []
- }
+ fileRefs: [],
+ },
]
const { container } = render(
', function () {
_id: 'root-folder-id',
docs: [{ _id: '456def', name: 'main.tex' }],
folders: [],
- fileRefs: []
- }
+ fileRefs: [],
+ },
]
render(
', function () {
_id: 'root-folder-id',
docs: [{ _id: '456def', name: 'main.tex' }],
folders: [],
- fileRefs: []
- }
+ fileRefs: [],
+ },
]
const { container } = render(
@@ -130,11 +130,11 @@ describe('
', function () {
_id: 'root-folder-id',
docs: [
{ _id: '456def', name: 'main.tex' },
- { _id: '789ghi', name: 'other.tex' }
+ { _id: '789ghi', name: 'other.tex' },
],
folders: [],
- fileRefs: []
- }
+ fileRefs: [],
+ },
]
render(
', function () {
sinon.match({
entity: {
_id: '456def',
- name: 'main.tex'
- }
- })
+ name: 'main.tex',
+ },
+ }),
])
onSelect.reset()
@@ -171,9 +171,9 @@ describe('
', function () {
sinon.match({
entity: {
_id: '789ghi',
- name: 'other.tex'
- }
- })
+ name: 'other.tex',
+ },
+ }),
])
})
@@ -183,11 +183,11 @@ describe('
', function () {
_id: 'root-folder-id',
docs: [
{ _id: '456def', name: 'main.tex' },
- { _id: '789ghi', name: 'other.tex' }
+ { _id: '789ghi', name: 'other.tex' },
],
folders: [],
- fileRefs: []
- }
+ fileRefs: [],
+ },
]
render(
', function () {
it('read-only', function () {
renderWithContext(
, {
- contextProps: { hasWritePermissions: false }
+ contextProps: { hasWritePermissions: false },
})
expect(screen.queryByRole('button')).to.not.exist
@@ -37,10 +37,10 @@ describe('
', function () {
_id: 'root-folder-id',
docs: [{ _id: '456def', name: 'main.tex' }],
folders: [],
- fileRefs: []
- }
- ]
- }
+ fileRefs: [],
+ },
+ ],
+ },
})
screen.getByRole('button', { name: 'New File' })
diff --git a/services/web/test/frontend/features/file-tree/flows/context-menu.test.js b/services/web/test/frontend/features/file-tree/flows/context-menu.test.js
index 42c0037194..16d151b567 100644
--- a/services/web/test/frontend/features/file-tree/flows/context-menu.test.js
+++ b/services/web/test/frontend/features/file-tree/flows/context-menu.test.js
@@ -15,8 +15,8 @@ describe('FileTree Context Menu Flow', function () {
_id: 'root-folder-id',
docs: [{ _id: '456def', name: 'main.tex' }],
folders: [],
- fileRefs: []
- }
+ fileRefs: [],
+ },
]
render(
{
{
docs: [],
fileRefs: [],
- folders: []
- }
+ folders: [],
+ },
],
hasWritePermissions: true,
userHasFeature: () => true,
@@ -26,7 +26,7 @@ export default (children, options = {}) => {
console.log('started free trial')
},
onSelect: () => {},
- ...contextProps
+ ...contextProps,
}
return render(
{children},
diff --git a/services/web/test/frontend/features/hotkeys-modal/components/hotkeys-modal.test.js b/services/web/test/frontend/features/hotkeys-modal/components/hotkeys-modal.test.js
index 6b425a4f1f..8565658cea 100644
--- a/services/web/test/frontend/features/hotkeys-modal/components/hotkeys-modal.test.js
+++ b/services/web/test/frontend/features/hotkeys-modal/components/hotkeys-modal.test.js
@@ -7,7 +7,7 @@ import sinon from 'sinon'
const modalProps = {
show: true,
handleHide: sinon.stub(),
- trackChangesVisible: false
+ trackChangesVisible: false,
}
describe('', function () {
diff --git a/services/web/test/frontend/features/outline/components/outline-item.test.js b/services/web/test/frontend/features/outline/components/outline-item.test.js
index bc7fe5be13..cbe9307c1a 100644
--- a/services/web/test/frontend/features/outline/components/outline-item.test.js
+++ b/services/web/test/frontend/features/outline/components/outline-item.test.js
@@ -15,7 +15,7 @@ describe('', function () {
it('renders basic item', function () {
const outlineItem = {
title: 'Test Title',
- line: 1
+ line: 1,
}
render()
@@ -28,7 +28,7 @@ describe('', function () {
const outlineItem = {
title: 'Parent',
line: 1,
- children: [{ title: 'Child', line: 2 }]
+ children: [{ title: 'Child', line: 2 }],
}
render()
@@ -47,7 +47,7 @@ describe('', function () {
it('highlights', function () {
const outlineItem = {
title: 'Parent',
- line: 1
+ line: 1,
}
render(
@@ -65,7 +65,7 @@ describe('', function () {
const outlineItem = {
title: 'Parent',
line: 1,
- children: [{ title: 'Child', line: 2 }]
+ children: [{ title: 'Child', line: 2 }],
}
render(
', function () {
it('click and double-click jump to location', function () {
const outlineItem = {
title: 'Parent',
- line: 1
+ line: 1,
}
render()
diff --git a/services/web/test/frontend/features/outline/components/outline-list.test.js b/services/web/test/frontend/features/outline/components/outline-list.test.js
index d05551a18a..2a61eec3ce 100644
--- a/services/web/test/frontend/features/outline/components/outline-list.test.js
+++ b/services/web/test/frontend/features/outline/components/outline-list.test.js
@@ -11,13 +11,13 @@ describe('', function () {
{
title: 'Section 1',
line: 1,
- level: 10
+ level: 10,
},
{
title: 'Section 2',
line: 2,
- level: 10
- }
+ level: 10,
+ },
]
render()
@@ -30,8 +30,8 @@ describe('', function () {
{
title: 'Section',
line: 1,
- level: 10
- }
+ level: 10,
+ },
]
render()
@@ -43,8 +43,8 @@ describe('', function () {
{
title: 'Section',
line: 1,
- level: 10
- }
+ level: 10,
+ },
]
render()
diff --git a/services/web/test/frontend/features/outline/components/outline-pane.test.js b/services/web/test/frontend/features/outline/components/outline-pane.test.js
index 75c0f3204c..2ebf37ed29 100644
--- a/services/web/test/frontend/features/outline/components/outline-pane.test.js
+++ b/services/web/test/frontend/features/outline/components/outline-pane.test.js
@@ -22,8 +22,8 @@ describe('', function () {
Object.defineProperty(global, 'localStorage', {
value: {
getItem: sinon.stub().returns(null),
- setItem: sinon.stub()
- }
+ setItem: sinon.stub(),
+ },
})
})
@@ -36,7 +36,7 @@ describe('', function () {
after(function () {
Object.defineProperty(global, 'localStorage', {
- value: originalLocalStorage
+ value: originalLocalStorage,
})
})
@@ -45,8 +45,8 @@ describe('', function () {
{
title: 'Section',
line: 1,
- level: 10
- }
+ level: 10,
+ },
]
render(
', function () {
{
title: 'Section',
line: 1,
- level: 10
- }
+ level: 10,
+ },
]
render(
', function () {
expect(screen.queryByRole('tree')).to.be.null
const collapseButton = screen.getByRole('button', {
- name: 'Show File outline'
+ name: 'Show File outline',
})
fireEvent.click(collapseButton)
diff --git a/services/web/test/frontend/features/outline/components/outline-root.test.js b/services/web/test/frontend/features/outline/components/outline-root.test.js
index faed37c8cd..0643b390a7 100644
--- a/services/web/test/frontend/features/outline/components/outline-root.test.js
+++ b/services/web/test/frontend/features/outline/components/outline-root.test.js
@@ -12,8 +12,8 @@ describe('', function () {
{
title: 'Section',
line: 1,
- level: 10
- }
+ level: 10,
+ },
]
render()
diff --git a/services/web/test/frontend/features/outline/outline-parser.test.js b/services/web/test/frontend/features/outline/outline-parser.test.js
index cff041a0a5..c0c3a8b419 100644
--- a/services/web/test/frontend/features/outline/outline-parser.test.js
+++ b/services/web/test/frontend/features/outline/outline-parser.test.js
@@ -2,7 +2,7 @@ import { expect } from 'chai'
import {
matchOutline,
- nestOutline
+ nestOutline,
} from '../../../../frontend/js/features/outline/outline-parser'
describe('OutlineParser', function () {
@@ -37,7 +37,7 @@ describe('OutlineParser', function () {
{ line: 11, title: 'Section 2', level: 40 },
{ line: 12, title: 'Subsubsection without subsection', level: 60 },
{ line: 13, title: 'a paragraph', level: 70 },
- { line: 14, title: 'a subparagraph', level: 80 }
+ { line: 14, title: 'a subparagraph', level: 80 },
])
})
@@ -55,7 +55,7 @@ describe('OutlineParser', function () {
{ line: 3, title: 'Label after ', level: 40 },
{ line: 4, title: 'Label between', level: 40 },
{ line: 5, title: 'TT Bar', level: 40 },
- { line: 6, title: 'plain title', level: 40 }
+ { line: 6, title: 'plain title', level: 40 },
])
})
@@ -67,7 +67,7 @@ describe('OutlineParser', function () {
const outline = matchOutline(content)
expect(outline).to.deep.equal([
{ line: 2, title: 'Plain title', level: 40 },
- { line: 3, title: ' Label before', level: 40 }
+ { line: 3, title: ' Label before', level: 40 },
])
})
@@ -84,7 +84,7 @@ describe('OutlineParser', function () {
it('matches unnumbered sections', function () {
const outline = matchOutline('\\section*{Unnumbered}')
expect(outline).to.deep.equal([
- { line: 1, title: 'Unnumbered', level: 40 }
+ { line: 1, title: 'Unnumbered', level: 40 },
])
})
@@ -93,7 +93,7 @@ describe('OutlineParser', function () {
'\\chapter[Short Title For TOC]{Very Long Title for Text}'
)
expect(outline).to.deep.equal([
- { line: 1, title: 'Short Title For TOC', level: 30 }
+ { line: 1, title: 'Short Title For TOC', level: 30 },
])
})
@@ -107,7 +107,7 @@ describe('OutlineParser', function () {
expect(outline).to.deep.equal([
{ line: 2, title: 'Weird Spacing', level: 40 },
{ line: 3, title: 'Weird Spacing Unnumbered', level: 40 },
- { line: 4, title: 'Weird Spacing for TOC', level: 40 }
+ { line: 4, title: 'Weird Spacing for TOC', level: 40 },
])
})
@@ -142,7 +142,7 @@ describe('OutlineParser', function () {
{ line: 90, title: 'Chapter', level: 30 },
{ line: 100, title: 'Part B', level: 20 },
{ line: 110, title: 'Section 2', level: 40 },
- { line: 120, title: 'Subsubsection without subsection', level: 60 }
+ { line: 120, title: 'Subsubsection without subsection', level: 60 },
]
const nestedOutline = nestOutline(flatOutline)
expect(nestedOutline).to.deep.equal([
@@ -162,18 +162,20 @@ describe('OutlineParser', function () {
level: 40,
children: [
{ line: 40, title: 'Subsection A 1 1', level: 50 },
- { line: 50, title: 'Subsection A 1 2', level: 50 }
- ]
+ { line: 50, title: 'Subsection A 1 2', level: 50 },
+ ],
},
{ line: 60, title: 'Section A 2', level: 40 },
{
line: 70,
title: 'Section A 3',
level: 40,
- children: [{ line: 80, title: 'Subsection A 3 1', level: 50 }]
+ children: [
+ { line: 80, title: 'Subsection A 3 1', level: 50 },
+ ],
},
- { line: 90, title: 'Chapter', level: 30 }
- ]
+ { line: 90, title: 'Chapter', level: 30 },
+ ],
},
{
line: 100,
@@ -188,14 +190,14 @@ describe('OutlineParser', function () {
{
line: 120,
title: 'Subsubsection without subsection',
- level: 60
- }
- ]
- }
- ]
- }
- ]
- }
+ level: 60,
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
])
})
})
diff --git a/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js b/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js
index eaddd6632c..9fd2b9a059 100644
--- a/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js
+++ b/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js
@@ -3,7 +3,7 @@ import { expect } from 'chai'
import { screen, render } from '@testing-library/react'
import PreviewDownloadFileList, {
- topFileTypes
+ topFileTypes,
} from '../../../../../frontend/js/features/preview/components/preview-download-file-list'
describe('', function () {
@@ -14,7 +14,7 @@ describe('', function () {
fileName,
url: `/project/${projectId}/output/${fileName}`,
type: fileName.split('.').pop(),
- main: main || false
+ main: main || false,
}
}
@@ -28,7 +28,7 @@ describe('', function () {
makeFile('output.stdout'),
makeFile('output.aux'),
makeFile('output.bbl'),
- makeFile('output.blg')
+ makeFile('output.blg'),
]
render()
@@ -87,7 +87,7 @@ describe('', function () {
makeFile('output.bbl'),
makeFile('output.ind'),
makeFile('output.gls'),
- makeFile('output.log')
+ makeFile('output.log'),
]
render()
@@ -100,7 +100,7 @@ describe('', function () {
const outputFiles = [
makeFile('output.bbl'),
makeFile('output.ind'),
- makeFile('output.gls')
+ makeFile('output.gls'),
]
render()
diff --git a/services/web/test/frontend/features/preview/components/preview-logs-pane-entry.test.js b/services/web/test/frontend/features/preview/components/preview-logs-pane-entry.test.js
index 03fe1afcf2..0932bdf549 100644
--- a/services/web/test/frontend/features/preview/components/preview-logs-pane-entry.test.js
+++ b/services/web/test/frontend/features/preview/components/preview-logs-pane-entry.test.js
@@ -31,14 +31,14 @@ describe('', function () {
)
screen.getByRole('button', {
- name: `Navigate to log position in source code: ${file}, ${line}`
+ name: `Navigate to log position in source code: ${file}, ${line}`,
})
})
it('renders only file when line information is not available', function () {
render()
screen.getByRole('button', {
- name: `Navigate to log position in source code: ${file}`
+ name: `Navigate to log position in source code: ${file}`,
})
})
@@ -46,7 +46,7 @@ describe('', function () {
render()
expect(
screen.queryByRole('button', {
- name: `Navigate to log position in source code: `
+ name: `Navigate to log position in source code: `,
})
).to.not.exist
})
@@ -60,7 +60,7 @@ describe('', function () {
/>
)
const linkToSourceButton = screen.getByRole('button', {
- name: `Navigate to log position in source code: ${file}, ${line}`
+ name: `Navigate to log position in source code: ${file}, ${line}`,
})
fireEvent.click(linkToSourceButton)
@@ -68,7 +68,7 @@ describe('', function () {
expect(onSourceLocationClick).to.be.calledWith({
file,
line,
- column
+ column,
})
})
})
@@ -91,11 +91,11 @@ describe('', function () {
beforeEach(function () {
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', {
configurable: true,
- value: 500
+ value: 500,
})
Object.defineProperty(HTMLElement.prototype, 'scrollWidth', {
configurable: true,
- value: 500
+ value: 500,
})
})
@@ -116,7 +116,7 @@ describe('', function () {
render()
screen.getByText(rawContent)
screen.getByRole('button', {
- name: 'Expand'
+ name: 'Expand',
})
})
@@ -124,11 +124,11 @@ describe('', function () {
render()
screen.getByText(rawContent)
const expandCollapseBtn = screen.getByRole('button', {
- name: 'Expand'
+ name: 'Expand',
})
fireEvent.click(expandCollapseBtn)
screen.getByRole('button', {
- name: 'Collapse'
+ name: 'Collapse',
})
})
diff --git a/services/web/test/frontend/features/preview/components/preview-logs-pane.test.js b/services/web/test/frontend/features/preview/components/preview-logs-pane.test.js
index 77c833b334..e09c49fdbe 100644
--- a/services/web/test/frontend/features/preview/components/preview-logs-pane.test.js
+++ b/services/web/test/frontend/features/preview/components/preview-logs-pane.test.js
@@ -12,26 +12,26 @@ describe('', function () {
file: 'main.tex',
level: 'error',
line: 17,
- message: 'Misplaced alignment tab character &.'
+ message: 'Misplaced alignment tab character &.',
}
const sampleError2 = {
content: 'error 1 content',
file: 'main.tex',
level: 'error',
line: 22,
- message: 'Extra alignment tab has been changed to cr.'
+ message: 'Extra alignment tab has been changed to cr.',
}
const sampleWarning = {
file: 'main.tex',
level: 'warning',
line: 30,
- message: "Reference `idontexist' on page 1 undefined on input line 30."
+ message: "Reference `idontexist' on page 1 undefined on input line 30.",
}
const sampleTypesettingIssue = {
file: 'main.tex',
level: 'typesetting',
line: 12,
- message: "Reference `idontexist' on page 1 undefined on input line 30."
+ message: "Reference `idontexist' on page 1 undefined on input line 30.",
}
const sampleRawLog = `
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex 2020.9.10) 6 NOV 2020 15:23
@@ -54,7 +54,7 @@ entering extended mode
all: [...errors, ...warnings, ...typesetting],
errors,
warnings,
- typesetting
+ typesetting,
}
const noOp = () => {}
const onLogEntryLocationClick = sinon.stub()
@@ -92,7 +92,7 @@ entering extended mode
it('renders a link to location button for every error and warning log entry', function () {
logEntries.all.forEach((entry, index) => {
const linkToSourceButton = screen.getByRole('button', {
- name: `Navigate to log position in source code: ${entry.file}, ${entry.line}`
+ name: `Navigate to log position in source code: ${entry.file}, ${entry.line}`,
})
fireEvent.click(linkToSourceButton)
expect(onLogEntryLocationClick).to.have.callCount(index + 1)
@@ -101,7 +101,7 @@ entering extended mode
call.calledWith({
file: entry.file,
line: entry.line,
- column: entry.column
+ column: entry.column,
})
).to.be.true
})
@@ -119,10 +119,10 @@ entering extended mode
sizeCheck: {
resources: [
{ path: 'foo/bar', kbSize: 76221 },
- { path: 'bar/baz', kbSize: 2342 }
- ]
+ { path: 'bar/baz', kbSize: 2342 },
+ ],
},
- mainFile: true
+ mainFile: true,
}
it('renders a validation entry for known issues', function () {
@@ -160,7 +160,7 @@ entering extended mode
const sampleErrors = {
clsiMaintenance: true,
tooRecentlyCompiled: true,
- compileTerminated: true
+ compileTerminated: true,
}
it('renders an error entry for known errors', function () {
diff --git a/services/web/test/frontend/features/preview/components/preview-logs-toggle-button.test.js b/services/web/test/frontend/features/preview/components/preview-logs-toggle-button.test.js
index bb67cfbf6b..0db13d2961 100644
--- a/services/web/test/frontend/features/preview/components/preview-logs-toggle-button.test.js
+++ b/services/web/test/frontend/features/preview/components/preview-logs-toggle-button.test.js
@@ -28,7 +28,7 @@ describe('', function () {
describe('basic toggle functionality', function () {
const logsState = {
nErrors: 0,
- nWarnings: 0
+ nWarnings: 0,
}
const onToggleLogs = () => {}
it('should render a view logs button when previewing the PDF', function () {
@@ -48,7 +48,7 @@ describe('', function () {
it('should render a view logs button by default', function () {
const logsState = {
nErrors: 0,
- nWarnings: 0
+ nWarnings: 0,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText('View logs')
@@ -57,7 +57,7 @@ describe('', function () {
it('should render the code check failed notice', function () {
const logsState = {
nErrors: 1,
- nWarnings: 0
+ nWarnings: 0,
}
renderPreviewLogsToggleButton(
logsState,
@@ -72,7 +72,7 @@ describe('', function () {
it('should render an error status message when there are errors', function () {
const logsState = {
nErrors: 1,
- nWarnings: 0
+ nWarnings: 0,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText(`This project has errors (${logsState.nErrors})`)
@@ -81,7 +81,7 @@ describe('', function () {
it('should render an error status message when there are both errors and warnings', function () {
const logsState = {
nErrors: 1,
- nWarnings: 1
+ nWarnings: 1,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText(`This project has errors (${logsState.nErrors})`)
@@ -90,7 +90,7 @@ describe('', function () {
it('should render a warning status message when there are warnings but no errors', function () {
const logsState = {
nErrors: 0,
- nWarnings: 1
+ nWarnings: 1,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText(`View warnings (${logsState.nWarnings})`)
@@ -99,7 +99,7 @@ describe('', function () {
it('should render 99+ errors when there are more than 99 errors', function () {
const logsState = {
nErrors: 100,
- nWarnings: 0
+ nWarnings: 0,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText('This project has errors (99+)')
@@ -107,7 +107,7 @@ describe('', function () {
it('should show the button text when prop showText=true', function () {
const logsState = {
nErrors: 0,
- nWarnings: 0
+ nWarnings: 0,
}
const showText = true
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs, showText)
@@ -116,7 +116,7 @@ describe('', function () {
it('should not show the button text when prop showText=false', function () {
const logsState = {
nErrors: 0,
- nWarnings: 0
+ nWarnings: 0,
}
const showText = false
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs, showText)
diff --git a/services/web/test/frontend/features/preview/components/preview-pane.test.js b/services/web/test/frontend/features/preview/components/preview-pane.test.js
index 9d727a1b52..b552b92aaa 100644
--- a/services/web/test/frontend/features/preview/components/preview-pane.test.js
+++ b/services/web/test/frontend/features/preview/components/preview-pane.test.js
@@ -9,31 +9,31 @@ describe('', function () {
file: 'main.tex',
level: 'error',
line: 17,
- message: 'Misplaced alignment tab character &.'
+ message: 'Misplaced alignment tab character &.',
}
const sampleError2 = {
content: 'error 1 content',
file: 'main.tex',
level: 'error',
line: 22,
- message: 'Extra alignment tab has been changed to cr.'
+ message: 'Extra alignment tab has been changed to cr.',
}
const sampleWarning = {
file: 'main.tex',
level: 'warning',
line: 30,
- message: "Reference `idontexist' on page 1 undefined on input line 30."
+ message: "Reference `idontexist' on page 1 undefined on input line 30.",
}
describe('first error pop-up', function () {
it('renders a first error pop-up with the first error', function () {
const propsAfterCompileWithErrors = getProps(false, {
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
})
render()
screen.getByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
screen.getByText(sampleError1.message)
})
@@ -41,12 +41,12 @@ describe('', function () {
it('does not render a first error pop-up when there are only warnings', function () {
const propsAfterCompileWithWarningsOnly = getProps(false, {
errors: [],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
})
render()
expect(
screen.queryByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
).to.not.exist
})
@@ -54,12 +54,12 @@ describe('', function () {
it('does not render a first error pop-up when a compile is ongoing', function () {
const propsWhileCompiling = getProps(true, {
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
})
render()
expect(
screen.queryByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
).to.not.exist
})
@@ -69,7 +69,7 @@ describe('', function () {
false,
{
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
},
Date.now(),
true
@@ -77,7 +77,7 @@ describe('', function () {
render()
expect(
screen.queryByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
).to.not.exist
})
@@ -88,7 +88,7 @@ describe('', function () {
false,
{
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
},
nowTimestamp,
true
@@ -97,7 +97,7 @@ describe('', function () {
false,
{
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
},
nowTimestamp,
false
@@ -108,7 +108,7 @@ describe('', function () {
rerender()
expect(
screen.queryByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
).to.not.exist
})
@@ -120,7 +120,7 @@ describe('', function () {
false,
{
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
},
nowTimestamp,
true
@@ -129,7 +129,7 @@ describe('', function () {
false,
{
errors: [sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
},
laterTimestamp,
false
@@ -139,7 +139,7 @@ describe('', function () {
)
rerender()
screen.getByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
screen.getByText(sampleError2.message)
})
@@ -147,17 +147,17 @@ describe('', function () {
it('allows dismissing the first error pop-up', function () {
const propsWithErrors = getProps(false, {
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
})
render()
const dismissPopUpButton = screen.getByRole('button', {
- name: 'Dismiss first error alert'
+ name: 'Dismiss first error alert',
})
fireEvent.click(dismissPopUpButton)
expect(
screen.queryByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
).to.not.exist
})
@@ -169,7 +169,7 @@ describe('', function () {
false,
{
errors: [sampleError1, sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
},
nowTimestamp
)
@@ -177,7 +177,7 @@ describe('', function () {
false,
{
errors: [sampleError2],
- warnings: [sampleWarning]
+ warnings: [sampleWarning],
},
laterTimestamp
)
@@ -185,13 +185,13 @@ describe('', function () {
)
const dismissPopUpButton = screen.getByRole('button', {
- name: 'Dismiss first error alert'
+ name: 'Dismiss first error alert',
})
fireEvent.click(dismissPopUpButton)
rerender()
expect(
screen.queryByRole('alertdialog', {
- name: 'This project has errors. This is the first one.'
+ name: 'This project has errors. This is the first one.',
})
).to.not.exist
})
@@ -203,7 +203,7 @@ describe('', function () {
const warnings = [sampleWarning]
const propsWithErrorsAndWarnings = getProps(false, {
errors,
- warnings
+ warnings,
})
render()
@@ -214,7 +214,7 @@ describe('', function () {
})
it('renders an accessible description for failed compiles with CLSI errors', function () {
const sampleCLSIError = {
- clsiMaintenance: true
+ clsiMaintenance: true,
}
const propsWithCLSIError = getProps(
@@ -233,7 +233,7 @@ describe('', function () {
it('renders an accessible description for failed compiles with validation issues', function () {
const sampleValidationIssue = {
- clsiMaintenance: true
+ clsiMaintenance: true,
}
const propsWithValidationIssue = getProps(
@@ -266,12 +266,12 @@ describe('', function () {
errors: [],
warnings: [],
typesetting: [],
- ...logEntries
+ ...logEntries,
}
logEntriesWithDefaults.all = [
...logEntriesWithDefaults.errors,
...logEntriesWithDefaults.warnings,
- ...logEntriesWithDefaults.typesetting
+ ...logEntriesWithDefaults.typesetting,
]
return {
compilerState: {
@@ -285,7 +285,7 @@ describe('', function () {
logEntries: logEntriesWithDefaults,
compileFailed,
validationIssues,
- errors
+ errors,
},
onClearCache: () => {},
onLogEntryLocationClick: () => {},
@@ -300,7 +300,7 @@ describe('', function () {
onSetFullLayout: () => {},
onStopCompilation: () => {},
showLogs: isShowingLogs,
- splitLayout: true
+ splitLayout: true,
}
}
})
diff --git a/services/web/test/frontend/features/preview/components/preview-recompile-button.test.js b/services/web/test/frontend/features/preview/components/preview-recompile-button.test.js
index 8799d3b34c..7f27eb9ff3 100644
--- a/services/web/test/frontend/features/preview/components/preview-recompile-button.test.js
+++ b/services/web/test/frontend/features/preview/components/preview-recompile-button.test.js
@@ -27,7 +27,7 @@ describe('', function () {
"Don't check syntax",
'Run syntax check now',
'Stop compilation',
- 'Recompile from scratch'
+ 'Recompile from scratch',
])
const menuHeadingItems = screen.getAllByRole('heading')
@@ -35,7 +35,7 @@ describe('', function () {
expect(menuHeadingItems.map(item => item.textContent)).to.deep.equal([
'Auto Compile',
'Compile Mode',
- 'Syntax Checks'
+ 'Syntax Checks',
])
})
@@ -45,7 +45,7 @@ describe('', function () {
renderPreviewRecompileButton()
const button = screen.getByRole('menuitem', {
- name: 'Recompile from scratch'
+ name: 'Recompile from scratch',
})
await fireEvent.click(button)
expect(onRecompileFromScratch).to.have.been.calledOnce
@@ -59,14 +59,14 @@ describe('', function () {
expect(
screen
.getByRole('menuitem', {
- name: 'Recompile from scratch'
+ name: 'Recompile from scratch',
})
.getAttribute('aria-disabled')
).to.equal('true')
expect(
screen
.getByRole('menuitem', {
- name: 'Recompile from scratch'
+ name: 'Recompile from scratch',
})
.closest('li')
.getAttribute('class')
@@ -92,7 +92,7 @@ describe('', function () {
it('shows animated visual feedback via CSS class when there are uncompiled changes', function () {
const { container } = renderPreviewRecompileButton({
autoCompileHasChanges: true,
- autoCompileHasLintingError: false
+ autoCompileHasLintingError: false,
})
const recompileBtnGroupEl = container.querySelector(
'.btn-recompile-group'
@@ -106,7 +106,7 @@ describe('', function () {
it('does not show animated visual feedback via CSS class when there are no uncompiled changes', function () {
const { container } = renderPreviewRecompileButton({
autoCompileHasChanges: false,
- autoCompileHasLintingError: false
+ autoCompileHasLintingError: false,
})
const recompileBtnGroupEl = container.querySelector(
'.btn-recompile-group'
@@ -133,7 +133,7 @@ describe('', function () {
isCompiling: false,
isDraftModeOn: false,
isSyntaxCheckOn: false,
- ...compilerState
+ ...compilerState,
}}
onRecompile={onRecompile}
onRunSyntaxCheckNow={() => {}}
diff --git a/services/web/test/frontend/features/preview/components/preview-toolbar.test.js b/services/web/test/frontend/features/preview/components/preview-toolbar.test.js
index fe6643c2d9..08c5df71c4 100644
--- a/services/web/test/frontend/features/preview/components/preview-toolbar.test.js
+++ b/services/web/test/frontend/features/preview/components/preview-toolbar.test.js
@@ -32,7 +32,7 @@ describe('', function () {
isDraftModeOn: false,
isSyntaxCheckOn: false,
logEntries: {},
- ...compilerState
+ ...compilerState,
}}
logsState={{ nErrors: 0, nWarnings: 0, ...logState }}
onRecompile={onRecompile}
diff --git a/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js b/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js
index 251160a305..a7c4b4fa5d 100644
--- a/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js
+++ b/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js
@@ -7,7 +7,7 @@ import {
screen,
fireEvent,
waitFor,
- waitForElementToBeRemoved
+ waitForElementToBeRemoved,
} from '@testing-library/react'
import fetchMock from 'fetch-mock'
import ShareProjectModal from '../../../../../frontend/js/features/share-project-modal/components/share-project-modal'
@@ -18,13 +18,13 @@ describe('', function () {
_id: 'test-project',
name: 'Test Project',
features: {
- collaborators: 10
+ collaborators: 10,
},
owner: {
- email: 'project-owner@example.com'
+ email: 'project-owner@example.com',
},
members: [],
- invites: []
+ invites: [],
}
const contacts = [
@@ -34,39 +34,39 @@ describe('', function () {
email: 'test-user@example.com',
first_name: 'Test',
last_name: 'User',
- name: 'Test User'
+ name: 'Test User',
},
// user with default name (email prefix)
{
type: 'user',
email: 'test@example.com',
- first_name: 'test'
+ first_name: 'test',
},
// no last name
{
type: 'user',
first_name: 'Eratosthenes',
- email: 'eratosthenes@example.com'
+ email: 'eratosthenes@example.com',
},
// more users
{
type: 'user',
first_name: 'Claudius',
last_name: 'Ptolemy',
- email: 'ptolemy@example.com'
+ email: 'ptolemy@example.com',
},
{
type: 'user',
first_name: 'Abd al-Rahman',
last_name: 'Al-Sufi',
- email: 'al-sufi@example.com'
+ email: 'al-sufi@example.com',
},
{
type: 'user',
first_name: 'Nicolaus',
last_name: 'Copernicus',
- email: 'copernicus@example.com'
- }
+ email: 'copernicus@example.com',
+ },
]
const ideWithProject = project => {
@@ -74,8 +74,8 @@ describe('', function () {
$scope: {
$watch: () => () => {},
$applyAsync: () => {},
- project
- }
+ project,
+ },
}
}
@@ -83,7 +83,7 @@ describe('', function () {
ide: ideWithProject(project),
show: true,
isAdmin: true,
- handleHide: sinon.stub()
+ handleHide: sinon.stub(),
}
const originalExposedSettings = window.ExposedSettings
@@ -118,7 +118,7 @@ describe('', function () {
const [
headerCloseButton,
- footerCloseButton
+ footerCloseButton,
] = await screen.findAllByRole('button', { name: 'Close' })
fireEvent.click(headerCloseButton)
@@ -196,8 +196,8 @@ describe('', function () {
{
_id: 'invited-author',
email: 'invited-author@example.com',
- privileges: 'readAndWrite'
- }
+ privileges: 'readAndWrite',
+ },
]
// render as admin: actions should be present
@@ -207,7 +207,7 @@ describe('', function () {
ide={ideWithProject({
...project,
invites,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
isAdmin
/>
@@ -223,7 +223,7 @@ describe('', function () {
ide={ideWithProject({
...project,
invites,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
isAdmin={false}
/>
@@ -246,7 +246,7 @@ describe('', function () {
ide={ideWithProject({
...project,
invites,
- publicAccesLevel: 'private'
+ publicAccesLevel: 'private',
})}
isAdmin={false}
/>
@@ -292,26 +292,26 @@ describe('', function () {
{
_id: 'member-author',
email: 'member-author@example.com',
- privileges: 'readAndWrite'
+ privileges: 'readAndWrite',
},
{
_id: 'member-viewer',
email: 'member-viewer@example.com',
- privileges: 'readOnly'
- }
+ privileges: 'readOnly',
+ },
]
const invites = [
{
_id: 'invited-author',
email: 'invited-author@example.com',
- privileges: 'readAndWrite'
+ privileges: 'readAndWrite',
},
{
_id: 'invited-viewer',
email: 'invited-viewer@example.com',
- privileges: 'readOnly'
- }
+ privileges: 'readOnly',
+ },
]
render(
@@ -321,7 +321,7 @@ describe('', function () {
...project,
members,
invites,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
@@ -354,8 +354,8 @@ describe('', function () {
{
_id: 'invited-author',
email: 'invited-author@example.com',
- privileges: 'readAndWrite'
- }
+ privileges: 'readAndWrite',
+ },
]
render(
@@ -364,13 +364,13 @@ describe('', function () {
ide={ideWithProject({
...project,
invites,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
const [, closeButton] = screen.getAllByRole('button', {
- name: 'Close'
+ name: 'Close',
})
const resendButton = screen.getByRole('button', { name: 'Resend' })
@@ -389,8 +389,8 @@ describe('', function () {
{
_id: 'invited-author',
email: 'invited-author@example.com',
- privileges: 'readAndWrite'
- }
+ privileges: 'readAndWrite',
+ },
]
render(
@@ -399,13 +399,13 @@ describe('', function () {
ide={ideWithProject({
...project,
invites,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
const [, closeButton] = screen.getAllByRole('button', {
- name: 'Close'
+ name: 'Close',
})
const revokeButton = screen.getByRole('button', { name: 'Revoke' })
@@ -423,8 +423,8 @@ describe('', function () {
{
_id: 'member-viewer',
email: 'member-viewer@example.com',
- privileges: 'readOnly'
- }
+ privileges: 'readOnly',
+ },
]
render(
@@ -433,13 +433,13 @@ describe('', function () {
ide={ideWithProject({
...project,
members,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
const [, closeButton] = await screen.getAllByRole('button', {
- name: 'Close'
+ name: 'Close',
})
expect(screen.queryAllByText('member-viewer@example.com')).to.have.length(1)
@@ -466,8 +466,8 @@ describe('', function () {
{
_id: 'member-viewer',
email: 'member-viewer@example.com',
- privileges: 'readOnly'
- }
+ privileges: 'readOnly',
+ },
]
render(
@@ -476,7 +476,7 @@ describe('', function () {
ide={ideWithProject({
...project,
members,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
@@ -484,7 +484,7 @@ describe('', function () {
expect(screen.queryAllByText('member-viewer@example.com')).to.have.length(1)
const removeButton = screen.getByRole('button', {
- name: 'Remove from project'
+ name: 'Remove from project',
})
fireEvent.click(removeButton)
@@ -506,8 +506,8 @@ describe('', function () {
{
_id: 'member-viewer',
email: 'member-viewer@example.com',
- privileges: 'readOnly'
- }
+ privileges: 'readOnly',
+ },
]
render(
@@ -516,7 +516,7 @@ describe('', function () {
ide={ideWithProject({
...project,
members,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
@@ -539,7 +539,7 @@ describe('', function () {
const reloadStub = sinon.stub(locationModule, 'reload')
const confirmButton = screen.getByRole('button', {
- name: 'Change owner'
+ name: 'Change owner',
})
fireEvent.click(confirmButton)
await waitFor(() => expect(confirmButton.disabled).to.be.true)
@@ -558,7 +558,7 @@ describe('', function () {
{...modalProps}
ide={ideWithProject({
...project,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
@@ -586,7 +586,7 @@ describe('', function () {
if (data.email === 'a@b.c') {
return {
status: 400,
- body: { errorReason: 'invalid_email' }
+ body: { errorReason: 'invalid_email' },
}
}
@@ -595,17 +595,17 @@ describe('', function () {
body: {
invite: {
...data,
- _id: data.email
- }
- }
+ _id: data.email,
+ },
+ },
}
})
fireEvent.paste(inputElement, {
clipboardData: {
getData: () =>
- 'test@example.com, foo@example.com, bar@example.com, a@b.c'
- }
+ 'test@example.com, foo@example.com, bar@example.com, a@b.c',
+ },
})
const privilegesElement = screen.getByDisplayValue('Can Edit')
@@ -652,8 +652,8 @@ describe('', function () {
...project,
publicAccesLevel: 'tokenBased',
features: {
- collaborators: 0
- }
+ collaborators: 0,
+ },
})}
/>
)
@@ -673,7 +673,7 @@ describe('', function () {
{...modalProps}
ide={ideWithProject({
...project,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
})}
/>
)
@@ -692,7 +692,7 @@ describe('', function () {
const respondWithError = async function (errorReason) {
inputElement.focus()
fireEvent.change(inputElement, {
- target: { value: 'invited-author-1@example.com' }
+ target: { value: 'invited-author-1@example.com' },
})
inputElement.blur()
@@ -700,7 +700,7 @@ describe('', function () {
'express:/project/:projectId/invite',
{
status: 400,
- body: { errorReason }
+ body: { errorReason },
},
{ overwriteRoutes: true }
)
@@ -746,8 +746,8 @@ describe('', function () {
return () => {}
},
$applyAsync: () => {},
- project
- }
+ project,
+ },
}
}
@@ -763,14 +763,14 @@ describe('', function () {
)
const enableButton = await screen.findByRole('button', {
- name: 'Turn on link sharing'
+ name: 'Turn on link sharing',
})
fireEvent.click(enableButton)
await waitFor(() => expect(enableButton.disabled).to.be.true)
const { body: tokenBody } = fetchMock.lastOptions()
expect(JSON.parse(tokenBody)).to.deep.equal({
- publicAccessLevel: 'tokenBased'
+ publicAccessLevel: 'tokenBased',
})
// NOTE: updating the scoped project data manually,
@@ -779,14 +779,14 @@ describe('', function () {
await screen.findByText('Link sharing is on')
const disableButton = await screen.findByRole('button', {
- name: 'Turn off link sharing'
+ name: 'Turn off link sharing',
})
fireEvent.click(disableButton)
await waitFor(() => expect(disableButton.disabled).to.be.true)
const { body: privateBody } = fetchMock.lastOptions()
expect(JSON.parse(privateBody)).to.deep.equal({
- publicAccessLevel: 'private'
+ publicAccessLevel: 'private',
})
// NOTE: updating the scoped project data manually,
@@ -817,18 +817,18 @@ describe('', function () {
// The matching contact should now be present and selected
await screen.findByRole('option', {
name: `Claudius Ptolemy `,
- selected: true
+ selected: true,
})
// Keep entering text so the contact no longer matches
fireEvent.change(inputElement, {
- target: { value: 'ptolemy.new@example.com' }
+ target: { value: 'ptolemy.new@example.com' },
})
// The matching contact should no longer be present
expect(
screen.queryByRole('option', {
- name: `Claudius Ptolemy `
+ name: `Claudius Ptolemy `,
})
).to.be.null
diff --git a/services/web/test/frontend/features/word-count-modal/components/word-count-modal.test.js b/services/web/test/frontend/features/word-count-modal/components/word-count-modal.test.js
index 24f579619c..50e5ca3f3f 100644
--- a/services/web/test/frontend/features/word-count-modal/components/word-count-modal.test.js
+++ b/services/web/test/frontend/features/word-count-modal/components/word-count-modal.test.js
@@ -15,7 +15,7 @@ describe('', function () {
projectId: 'project-1',
clsiServerId: 'clsi-server-1',
show: true,
- handleHide: sinon.stub()
+ handleHide: sinon.stub(),
}
it('renders the translated modal title', async function () {
@@ -50,9 +50,9 @@ describe('', function () {
status: 200,
body: {
texcount: {
- messages: 'This is a test'
- }
- }
+ messages: 'This is a test',
+ },
+ },
}
})
@@ -70,9 +70,9 @@ describe('', function () {
textWords: 100,
mathDisplay: 200,
mathInline: 300,
- headers: 400
- }
- }
+ headers: 400,
+ },
+ },
}
})
diff --git a/services/web/test/frontend/helpers/render-with-context.js b/services/web/test/frontend/helpers/render-with-context.js
index 3e7952389f..3b1e1a8666 100644
--- a/services/web/test/frontend/helpers/render-with-context.js
+++ b/services/web/test/frontend/helpers/render-with-context.js
@@ -14,9 +14,9 @@ export function EditorProviders({
projectId = 'project123',
socket = {
on: sinon.stub(),
- removeListener: sinon.stub()
+ removeListener: sinon.stub(),
},
- children
+ children,
}) {
window.user = user || window.user
window.ExposedSettings.appName = 'test'
@@ -27,16 +27,16 @@ export function EditorProviders({
$scope: {
project: {
owner: {
- _id: '124abd'
- }
+ _id: '124abd',
+ },
},
ui: {
chatOpen: true,
- pdfLayout: 'flat'
+ pdfLayout: 'flat',
},
- $watch: () => {}
+ $watch: () => {},
},
- socket
+ socket,
}
return (
diff --git a/services/web/test/frontend/ide/history/util/displayNameForUserTests.js b/services/web/test/frontend/ide/history/util/displayNameForUserTests.js
index c186a61660..8b34ff4d96 100644
--- a/services/web/test/frontend/ide/history/util/displayNameForUserTests.js
+++ b/services/web/test/frontend/ide/history/util/displayNameForUserTests.js
@@ -28,7 +28,7 @@ export default describe('displayNameForUser', function () {
id: window.user.id,
email: 'james.allen@overleaf.com',
first_name: 'James',
- last_name: 'Allen'
+ last_name: 'Allen',
})
).to.equal('you')
})
@@ -39,7 +39,7 @@ export default describe('displayNameForUser', function () {
id: window.user.id + 1,
email: 'james.allen@overleaf.com',
first_name: 'James',
- last_name: 'Allen'
+ last_name: 'Allen',
})
).to.equal('James Allen')
})
@@ -50,7 +50,7 @@ export default describe('displayNameForUser', function () {
id: window.user.id + 1,
email: 'james.allen@overleaf.com',
first_name: 'James',
- last_name: ''
+ last_name: '',
})
).to.equal('James')
})
@@ -61,7 +61,7 @@ export default describe('displayNameForUser', function () {
id: window.user.id + 1,
email: 'james.allen@overleaf.com',
first_name: '',
- last_name: ''
+ last_name: '',
})
).to.equal('james.allen')
})
@@ -72,7 +72,7 @@ export default describe('displayNameForUser', function () {
id: window.user.id + 1,
email: '',
first_name: '',
- last_name: ''
+ last_name: '',
})
).to.equal('?')
})
diff --git a/services/web/test/frontend/infrastructure/fetch-json.test.js b/services/web/test/frontend/infrastructure/fetch-json.test.js
index 5dde14a5bf..ae71151306 100644
--- a/services/web/test/frontend/infrastructure/fetch-json.test.js
+++ b/services/web/test/frontend/infrastructure/fetch-json.test.js
@@ -5,7 +5,7 @@ import {
FetchError,
getJSON,
postJSON,
- putJSON
+ putJSON,
} from '../../../frontend/js/infrastructure/fetch-json'
describe('fetchJSON', function () {
@@ -19,7 +19,7 @@ describe('fetchJSON', function () {
const headers = {
Accept: 'application/json',
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json',
}
it('handles GET requests', function () {
@@ -29,14 +29,14 @@ describe('fetchJSON', function () {
)
return expect(getJSON('/test')).to.eventually.deep.equal({
- result: 'success'
+ result: 'success',
})
})
it('handles 4xx responses', function () {
fetchMock.get('/test', {
status: 400,
- body: { message: 'The request was invalid' }
+ body: { message: 'The request was invalid' },
})
return expect(getJSON('/test'))
@@ -46,7 +46,7 @@ describe('fetchJSON', function () {
message: 'Bad Request',
'data.message': 'The request was invalid',
'response.status': 400,
- 'info.statusCode': 400
+ 'info.statusCode': 400,
})
})
@@ -58,7 +58,7 @@ describe('fetchJSON', function () {
.and.be.an.instanceOf(FetchError)
.to.nested.include({
'response.status': 500,
- 'info.statusCode': 500
+ 'info.statusCode': 500,
})
})
@@ -71,7 +71,7 @@ describe('fetchJSON', function () {
)
return expect(postJSON('/test', { body })).to.eventually.deep.equal({
- result: 'success'
+ result: 'success',
})
})
@@ -84,7 +84,7 @@ describe('fetchJSON', function () {
)
return expect(putJSON('/test', { body })).to.eventually.deep.equal({
- result: 'success'
+ result: 'success',
})
})
diff --git a/services/web/test/frontend/infrastructure/local-storage.test.js b/services/web/test/frontend/infrastructure/local-storage.test.js
index bbc8e06c31..7e843332d8 100644
--- a/services/web/test/frontend/infrastructure/local-storage.test.js
+++ b/services/web/test/frontend/infrastructure/local-storage.test.js
@@ -11,7 +11,7 @@ describe('localStorage', function () {
after(function () {
Object.defineProperty(global, 'localStorage', {
- value: originalLocalStorage
+ value: originalLocalStorage,
})
})
@@ -21,8 +21,8 @@ describe('localStorage', function () {
getItem: sinon.stub().returns(null),
setItem: sinon.stub(),
clear: sinon.stub(),
- removeItem: sinon.stub()
- }
+ removeItem: sinon.stub(),
+ },
})
global.console.error = sinon.stub()
diff --git a/services/web/test/frontend/shared/hooks/use-expand-collapse.test.js b/services/web/test/frontend/shared/hooks/use-expand-collapse.test.js
index 9d7e76324d..7b84a1d382 100644
--- a/services/web/test/frontend/shared/hooks/use-expand-collapse.test.js
+++ b/services/web/test/frontend/shared/hooks/use-expand-collapse.test.js
@@ -32,7 +32,7 @@ function ExpandCollapseTestUI({ expandCollapseArgs }) {
)
}
ExpandCollapseTestUI.propTypes = {
- expandCollapseArgs: PropTypes.object
+ expandCollapseArgs: PropTypes.object,
}
describe('useExpandCollapse', function () {
@@ -42,11 +42,11 @@ describe('useExpandCollapse', function () {
beforeEach(function () {
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', {
configurable: true,
- value: 500
+ value: 500,
})
Object.defineProperty(HTMLElement.prototype, 'scrollWidth', {
configurable: true,
- value: 500
+ value: 500,
})
})
@@ -67,8 +67,8 @@ describe('useExpandCollapse', function () {
it('supports a custom CSS class', function () {
const testArgs = {
classes: {
- container: 'my-custom-class'
- }
+ container: 'my-custom-class',
+ },
}
const { container } = render(
@@ -79,8 +79,8 @@ describe('useExpandCollapse', function () {
it('supports an extra custom CSS class for the collapsed state', function () {
const testArgs = {
classes: {
- containerCollapsed: 'my-custom-collapsed-class'
- }
+ containerCollapsed: 'my-custom-collapsed-class',
+ },
}
const { container } = render(
@@ -95,8 +95,8 @@ describe('useExpandCollapse', function () {
const testArgs = {
initiallyExpanded: true,
classes: {
- containerCollapsed: 'my-custom-collapsed-class'
- }
+ containerCollapsed: 'my-custom-collapsed-class',
+ },
}
const { container } = render(
@@ -116,7 +116,7 @@ describe('useExpandCollapse', function () {
})
it('supports width', function () {
const testArgs = {
- dimension: 'width'
+ dimension: 'width',
}
const { container } = render(
@@ -134,7 +134,7 @@ describe('useExpandCollapse', function () {
})
it('supports a custom collapsed size', function () {
const testArgs = {
- collapsedSize: 200
+ collapsedSize: 200,
}
const { container } = render(
@@ -145,7 +145,7 @@ describe('useExpandCollapse', function () {
it('supports a custom collapsed size for width', function () {
const testArgs = {
collapsedSize: 200,
- dimension: 'width'
+ dimension: 'width',
}
const { container } = render(
diff --git a/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js b/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js
index 18f82fc44c..a8e05225da 100644
--- a/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js
+++ b/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js
@@ -19,19 +19,19 @@ export default describe('SpellCheckManager', function () {
this.scope = {
$watch: sinon.stub(),
spellCheck: true,
- spellCheckLanguage: 'en'
+ spellCheckLanguage: 'en',
}
this.highlightedWordManager = {
reset: sinon.stub(),
clearRow: sinon.stub(),
- addHighlight: sinon.stub()
+ addHighlight: sinon.stub(),
}
this.adapter = {
getLineCount: sinon.stub(),
getFirstVisibleRowNum: sinon.stub(),
getLastVisibleRowNum: sinon.stub(),
getLinesByRows: sinon.stub(),
- highlightedWordManager: this.highlightedWordManager
+ highlightedWordManager: this.highlightedWordManager,
}
return inject(($q, $http, $httpBackend, $cacheFactory) => {
this.$http = $http
@@ -57,9 +57,9 @@ export default describe('SpellCheckManager', function () {
misspellings: [
{
index: 0,
- suggestions: ['opposition']
- }
- ]
+ suggestions: ['opposition'],
+ },
+ ],
})
this.adapter.getLinesByRows.returns(['oppozition'])
this.spellCheckManager.init()
@@ -76,15 +76,15 @@ export default describe('SpellCheckManager', function () {
this.adapter.getLinesByRows.returns([
'Lorem ipsum dolor sit amet',
'consectetur adipisicing elit',
- 'sed do eiusmod'
+ 'sed do eiusmod',
])
this.$httpBackend.when('POST', '/spelling/check').respond({
misspellings: [
{
index: 0,
- suggestions: ['opposition']
- }
- ]
+ suggestions: ['opposition'],
+ },
+ ],
})
})
describe('when doing the first check', function () {
@@ -109,7 +109,7 @@ export default describe('SpellCheckManager', function () {
6,
7,
8,
- 9
+ 9,
])
})
})
@@ -172,9 +172,9 @@ export default describe('SpellCheckManager', function () {
misspellings: [
{
index: 0,
- suggestions: ['foobarbaz']
- }
- ]
+ suggestions: ['foobarbaz'],
+ },
+ ],
})
})
@@ -224,15 +224,15 @@ export default describe('SpellCheckManager', function () {
language: this.scope.spellCheckLanguage,
words: ['Lorem', 'ipsum', 'dolor'],
token: window.user.id,
- _csrf: window.csrfToken
+ _csrf: window.csrfToken,
})
.respond({
misspellings: [
{
index: 0,
- suggestions: ['foobarbaz']
- }
- ]
+ suggestions: ['foobarbaz'],
+ },
+ ],
})
this.spellCheckManager.init()
this.timelord.tick(500)
@@ -245,15 +245,15 @@ export default describe('SpellCheckManager', function () {
language: this.scope.spellCheckLanguage,
words: ['Lorem', 'ipsum', 'dolor'],
token: window.user.id,
- _csrf: window.csrfToken
+ _csrf: window.csrfToken,
})
.respond({
misspellings: [
{
index: 0,
- suggestions: ['foobarbaz']
- }
- ]
+ suggestions: ['foobarbaz'],
+ },
+ ],
})
this.spellCheckManager.init()
this.timelord.tick(500)
@@ -268,15 +268,15 @@ export default describe('SpellCheckManager', function () {
language: this.scope.spellCheckLanguage,
words: ['Lorem', 'ipsum', 'dolor'],
token: window.user.id,
- _csrf: window.csrfToken
+ _csrf: window.csrfToken,
})
.respond({
misspellings: [
{
index: 0,
- suggestions: ['foobarbaz']
- }
- ]
+ suggestions: ['foobarbaz'],
+ },
+ ],
})
this.spellCheckManager.init()
this.timelord.tick(500)
@@ -288,15 +288,15 @@ export default describe('SpellCheckManager', function () {
language: this.scope.spellCheckLanguage,
words: ['sit', 'amet'],
token: window.user.id,
- _csrf: window.csrfToken
+ _csrf: window.csrfToken,
})
.respond({
misspellings: [
{
index: 0,
- suggestions: ['bazbarfoo']
- }
- ]
+ suggestions: ['bazbarfoo'],
+ },
+ ],
})
this.spellCheckManager.init()
this.timelord.tick(500)
diff --git a/services/web/test/karma/ide/history/HistoryV2ManagerTests.js b/services/web/test/karma/ide/history/HistoryV2ManagerTests.js
index ef5f5872f0..68eeceb401 100644
--- a/services/web/test/karma/ide/history/HistoryV2ManagerTests.js
+++ b/services/web/test/karma/ide/history/HistoryV2ManagerTests.js
@@ -28,20 +28,20 @@ export default describe('HistoryV2Manager', function () {
pathname: null,
range: {
fromV: null,
- toV: null
+ toV: null,
},
hoveredRange: {
fromV: null,
- toV: null
+ toV: null,
},
diff: null,
files: [],
- file: null
+ file: null,
},
error: null,
showOnlyLabels: false,
labels: null,
- loadingFileTree: true
+ loadingFileTree: true,
}
this.sampleUpdates = [
@@ -55,11 +55,11 @@ export default describe('HistoryV2Manager', function () {
last_name: '',
email: 'john.doe@domain.tld',
id: '5b57299087712202fb599ab4',
- hue: 200
- }
+ hue: 200,
+ },
],
start_ts: 1544021278346,
- end_ts: 1544021278346
+ end_ts: 1544021278346,
},
labels: [
{
@@ -67,18 +67,18 @@ export default describe('HistoryV2Manager', function () {
comment: 'My first label',
version: 5,
user_id: '5b57299087712202fb599ab4',
- created_at: '2018-12-05T15:00:50.688Z'
- }
+ created_at: '2018-12-05T15:00:50.688Z',
+ },
],
pathnames: [],
project_ops: [
{
add: {
- pathname: 'chapters/chapter1.tex'
+ pathname: 'chapters/chapter1.tex',
},
- atV: 4
- }
- ]
+ atV: 4,
+ },
+ ],
},
{
fromV: 3,
@@ -90,15 +90,15 @@ export default describe('HistoryV2Manager', function () {
last_name: '',
email: 'john.doe@domain.tld',
id: '5b57299087712202fb599ab4',
- hue: 200
- }
+ hue: 200,
+ },
],
start_ts: 1544021262622,
- end_ts: 1544021262622
+ end_ts: 1544021262622,
},
labels: [],
pathnames: ['main.tex'],
- project_ops: []
+ project_ops: [],
},
{
fromV: 0,
@@ -110,52 +110,52 @@ export default describe('HistoryV2Manager', function () {
last_name: '',
email: 'john.doe@domain.tld',
id: '5b57299087712202fb599ab4',
- hue: 200
- }
+ hue: 200,
+ },
],
start_ts: 1544021213540,
- end_ts: 1544021213618
+ end_ts: 1544021213618,
},
labels: [],
pathnames: [],
project_ops: [
{
add: {
- pathname: 'universe.jpg'
+ pathname: 'universe.jpg',
},
- atV: 2
+ atV: 2,
},
{
add: {
- pathname: 'references.bib'
+ pathname: 'references.bib',
},
- atV: 1
+ atV: 1,
},
{
add: {
- pathname: 'main.tex'
+ pathname: 'main.tex',
},
- atV: 0
- }
- ]
- }
+ atV: 0,
+ },
+ ],
+ },
]
inject(($q, $http, $filter, $rootScope) => {
this.$scope = $rootScope.$new()
this.$scope.project = {
features: {
- versioning: true
- }
+ versioning: true,
+ },
}
this.$scope.user = {
- isAdmin: false
+ isAdmin: false,
}
this.ide = {
globalEditorWatchdogManager: { attachToEditor() {} },
$q: $q,
$http: $http,
- $filter: $filter
+ $filter: $filter,
}
this.localStorage = sinon.stub().returns(null)
this.historyManager = new HistoryV2Manager(
@@ -173,7 +173,7 @@ export default describe('HistoryV2Manager', function () {
it('should keep history updates after performing a soft reset', function () {
let historyScopeWithUpdates = Object.assign({}, this.defaultHistoryScope, {
- updates: this.sampleUpdates
+ updates: this.sampleUpdates,
})
this.$scope.history.updates = this.sampleUpdates
this.historyManager.softReset()
@@ -219,35 +219,35 @@ export default describe('HistoryV2Manager', function () {
beforeEach(function () {
this.mockedFilesList = [
{
- pathname: 'main.tex'
+ pathname: 'main.tex',
},
{
- pathname: 'references.bib'
+ pathname: 'references.bib',
},
{
- pathname: 'universe.jpg'
+ pathname: 'universe.jpg',
},
{
- pathname: 'chapters/chapter2.tex'
+ pathname: 'chapters/chapter2.tex',
},
{
pathname: 'chapters/draft.tex',
operation: 'removed',
- deletedAtV: 47
+ deletedAtV: 47,
},
{
pathname: 'chapters/chapter3.tex',
- operation: 'added'
+ operation: 'added',
},
{
pathname: 'chapters/chapter1.tex',
- operation: 'edited'
+ operation: 'edited',
},
{
pathname: 'chapters/foo.tex',
oldPathname: 'chapters/bar.tex',
- operation: 'renamed'
- }
+ operation: 'renamed',
+ },
]
this.mockedMainTex = this.mockedFilesList[0]
this.mockedReferencesFile = this.mockedFilesList[1]
@@ -342,17 +342,17 @@ export default describe('HistoryV2Manager', function () {
beforeEach(function () {
this.mockedFilesListWithNoOps = [
{
- pathname: 'main.tex'
+ pathname: 'main.tex',
},
{
- pathname: 'references.bib'
+ pathname: 'references.bib',
},
{
- pathname: 'other.tex'
+ pathname: 'other.tex',
},
{
- pathname: 'universe.jpg'
- }
+ pathname: 'universe.jpg',
+ },
]
this.mockedMainTex = this.mockedFilesListWithNoOps[0]
this.mockedReferencesFile = this.mockedFilesListWithNoOps[1]
@@ -409,27 +409,27 @@ export default describe('HistoryV2Manager', function () {
last_name: '',
email: 'john.doe@domain.tld',
id: '5b57299087712202fb599ab4',
- hue: 200
- }
+ hue: 200,
+ },
],
start_ts: 1544021278346,
- end_ts: 1544021278346
+ end_ts: 1544021278346,
},
pathnames: ['main.tex'],
project_ops: [
{
add: {
- pathname: 'chapters/chapter1.tex'
+ pathname: 'chapters/chapter1.tex',
},
- atV: 4
+ atV: 4,
},
{
rename: {
pathname: 'foo.tex',
- newPathname: 'bar.tex'
- }
- }
- ]
+ newPathname: 'bar.tex',
+ },
+ },
+ ],
}
this.sampleUpdateEditedFile = this.sampleUpdates[0].pathnames[0]
this.sampleUpdateAddedFile = this.sampleUpdates[0].project_ops[0].add.pathname
@@ -437,33 +437,33 @@ export default describe('HistoryV2Manager', function () {
this.$scope.history.updates = this.sampleUpdates
this.$scope.history.selection.range = {
fromV: this.sampleUpdates[0].toV,
- toV: this.sampleUpdates[0].toV
+ toV: this.sampleUpdates[0].toV,
}
this.mockedFilesList = [
{
- pathname: 'main.tex'
+ pathname: 'main.tex',
},
{
- pathname: 'references.bib'
+ pathname: 'references.bib',
},
{
- pathname: 'universe.jpg'
+ pathname: 'universe.jpg',
},
{
- pathname: 'chapters/chapter2.tex'
+ pathname: 'chapters/chapter2.tex',
},
{
- pathname: 'chapters/draft.tex'
+ pathname: 'chapters/draft.tex',
},
{
- pathname: 'chapters/chapter3.tex'
+ pathname: 'chapters/chapter3.tex',
},
{
- pathname: 'chapters/chapter1.tex'
+ pathname: 'chapters/chapter1.tex',
},
{
- pathname: 'bar.tex'
- }
+ pathname: 'bar.tex',
+ },
]
this.$scope.history.selection.files = this.mockedFilesList
})
@@ -554,20 +554,20 @@ export default describe('HistoryV2Manager', function () {
id: '1',
version: 1,
comment: 'foo',
- created_at: new Date().toISOString()
+ created_at: new Date().toISOString(),
},
{
id: '2',
version: 2,
comment: 'bar',
- created_at: new Date().toISOString()
+ created_at: new Date().toISOString(),
},
{
id: '3',
version: 3,
comment: 'baz',
- created_at: new Date().toISOString()
- }
+ created_at: new Date().toISOString(),
+ },
]
const lastUpdate = 3
@@ -582,20 +582,20 @@ export default describe('HistoryV2Manager', function () {
id: '1',
version: 1,
comment: 'foo',
- created_at: new Date().toISOString()
+ created_at: new Date().toISOString(),
},
{
id: '2',
version: 2,
comment: 'bar',
- created_at: new Date().toISOString()
+ created_at: new Date().toISOString(),
},
{
id: '3',
version: 3,
comment: 'baz',
- created_at: new Date().toISOString()
- }
+ created_at: new Date().toISOString(),
+ },
]
const lastUpdate = 5
@@ -612,8 +612,8 @@ export default describe('HistoryV2Manager', function () {
id: '1',
version: 1,
comment: 'foo',
- created_at: new Date().toISOString()
- }
+ created_at: new Date().toISOString(),
+ },
]
const lastUpdate = 5
diff --git a/services/web/test/smoke/src/SmokeTests.js b/services/web/test/smoke/src/SmokeTests.js
index 7d79afc7de..79d35d6224 100644
--- a/services/web/test/smoke/src/SmokeTests.js
+++ b/services/web/test/smoke/src/SmokeTests.js
@@ -6,7 +6,7 @@ const { getCsrfTokenForFactory } = require('./support/Csrf')
const { SmokeTestFailure } = require('./support/Errors')
const {
requestFactory,
- assertHasStatusCode
+ assertHasStatusCode,
} = require('./support/requestHelper')
const { processWithTimeout } = require('./support/timeoutHelper')
@@ -38,7 +38,7 @@ async function runSmokeTests({ isAborted, stats }) {
processWithTimeout,
request,
stats,
- timeout: STEP_TIMEOUT
+ timeout: STEP_TIMEOUT,
}
const cleanupSteps = []
@@ -87,7 +87,7 @@ async function runSmokeTests({ isAborted, stats }) {
if (cleanupErrors.length === 1) throw cleanupErrors[0]
throw new SmokeTestFailure('multiple cleanup steps failed', {
stats,
- cleanupErrors
+ cleanupErrors,
})
}
}
diff --git a/services/web/test/smoke/src/steps/001_clearRateLimits.js b/services/web/test/smoke/src/steps/001_clearRateLimits.js
index 3663d6b2ca..8e17d71b73 100644
--- a/services/web/test/smoke/src/steps/001_clearRateLimits.js
+++ b/services/web/test/smoke/src/steps/001_clearRateLimits.js
@@ -35,10 +35,10 @@ async function run({ processWithTimeout, timeout }) {
work: Promise.all([
clearLoginRateLimit(),
clearOverleafLoginRateLimit(),
- clearOpenProjectRateLimit()
+ clearOpenProjectRateLimit(),
]),
timeout,
- message: 'cleanupRateLimits timed out'
+ message: 'cleanupRateLimits timed out',
})
}
diff --git a/services/web/test/smoke/src/steps/002_login.js b/services/web/test/smoke/src/steps/002_login.js
index 0af4f0fbe4..7d3a64efea 100644
--- a/services/web/test/smoke/src/steps/002_login.js
+++ b/services/web/test/smoke/src/steps/002_login.js
@@ -6,8 +6,8 @@ async function run({ assertHasStatusCode, loginCsrfToken, request }) {
json: {
_csrf: loginCsrfToken,
email: Settings.smokeTest.user,
- password: Settings.smokeTest.password
- }
+ password: Settings.smokeTest.password,
+ },
})
const body = response.body
@@ -26,8 +26,8 @@ async function cleanup({ assertHasStatusCode, getCsrfTokenFor, request }) {
const response = await request('/logout', {
method: 'POST',
headers: {
- 'X-CSRF-Token': logoutCsrfToken
- }
+ 'X-CSRF-Token': logoutCsrfToken,
+ },
})
assertHasStatusCode(response, 302)
}
diff --git a/services/web/test/smoke/src/support/Csrf.js b/services/web/test/smoke/src/support/Csrf.js
index eab171657d..820ec7a3ab 100644
--- a/services/web/test/smoke/src/support/Csrf.js
+++ b/services/web/test/smoke/src/support/Csrf.js
@@ -23,5 +23,5 @@ function getCsrfTokenForFactory({ request }) {
}
module.exports = {
- getCsrfTokenForFactory
+ getCsrfTokenForFactory,
}
diff --git a/services/web/test/smoke/src/support/Errors.js b/services/web/test/smoke/src/support/Errors.js
index 4d9a1f3e59..a40586e225 100644
--- a/services/web/test/smoke/src/support/Errors.js
+++ b/services/web/test/smoke/src/support/Errors.js
@@ -3,5 +3,5 @@ const OError = require('@overleaf/o-error')
class SmokeTestFailure extends OError {}
module.exports = {
- SmokeTestFailure
+ SmokeTestFailure,
}
diff --git a/services/web/test/smoke/src/support/requestHelper.js b/services/web/test/smoke/src/support/requestHelper.js
index 943d85b0d6..a704be9798 100644
--- a/services/web/test/smoke/src/support/requestHelper.js
+++ b/services/web/test/smoke/src/support/requestHelper.js
@@ -35,10 +35,10 @@ function requestFactory({ timeout }) {
headers: {
// emulate the header of a https proxy
// express wont emit a 'Secure;' cookie on a plain-text connection.
- 'X-Forwarded-Proto': 'https'
+ 'X-Forwarded-Proto': 'https',
},
jar: new InsecureCookieJar(),
- timeout
+ timeout,
})
)
}
@@ -49,12 +49,12 @@ function assertHasStatusCode(response, expected) {
throw new OError('unexpected response code', {
url: response.request.uri.href,
actual,
- expected
+ expected,
})
}
}
module.exports = {
assertHasStatusCode,
- requestFactory
+ requestFactory,
}
diff --git a/services/web/test/smoke/src/support/timeoutHelper.js b/services/web/test/smoke/src/support/timeoutHelper.js
index 711de629f1..6e7ea9c66e 100644
--- a/services/web/test/smoke/src/support/timeoutHelper.js
+++ b/services/web/test/smoke/src/support/timeoutHelper.js
@@ -9,10 +9,10 @@ async function processWithTimeout({ work, timeout, message }) {
reject(new Error(message))
}, timeout)
}),
- work.finally(checkInResults)
+ work.finally(checkInResults),
])
}
module.exports = {
- processWithTimeout
+ processWithTimeout,
}
diff --git a/services/web/test/unit/bootstrap.js b/services/web/test/unit/bootstrap.js
index eae144d620..c8d8fc6134 100644
--- a/services/web/test/unit/bootstrap.js
+++ b/services/web/test/unit/bootstrap.js
@@ -34,8 +34,8 @@ const globalStubs = {
warn: globalStubsSandbox.stub(),
err: globalStubsSandbox.stub(),
error: globalStubsSandbox.stub(),
- fatal: globalStubsSandbox.stub()
- }
+ fatal: globalStubsSandbox.stub(),
+ },
}
/*
@@ -60,19 +60,19 @@ SandboxedModule.configure({
return compiled
}
return source
- }
- }
+ },
+ },
})
function getSandboxedModuleRequires() {
const requires = {
- 'logger-sharelatex': globalStubs.logger
+ 'logger-sharelatex': globalStubs.logger,
}
const internalModules = [
'../../app/src/util/promises',
'../../app/src/Features/Errors/Errors',
- '../../app/src/Features/Helpers/Mongo'
+ '../../app/src/Features/Helpers/Mongo',
]
const externalLibs = [
'async',
@@ -84,7 +84,7 @@ function getSandboxedModuleRequires() {
'sanitize-html',
'sshpk',
'underscore',
- 'xml2js'
+ 'xml2js',
]
for (const modulePath of internalModules) {
requires[Path.resolve(__dirname, modulePath)] = require(modulePath)
@@ -125,5 +125,5 @@ exports.mochaHooks = {
// Restore other stubs
sinon.restore()
- }
+ },
}
diff --git a/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js b/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js
index ae99971bbc..cdba614336 100644
--- a/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js
+++ b/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js
@@ -12,11 +12,11 @@ describe('AnalyticsController', function () {
this.AnalyticsManager = {
updateEditingSession: sinon.stub(),
- recordEvent: sinon.stub()
+ recordEvent: sinon.stub(),
}
this.Features = {
- hasFeature: sinon.stub().returns(true)
+ hasFeature: sinon.stub().returns(true),
}
this.controller = SandboxedModule.require(modulePath, {
@@ -26,14 +26,14 @@ describe('AnalyticsController', function () {
.AuthenticationController,
'../../infrastructure/Features': this.Features,
'../../infrastructure/GeoIpLookup': (this.GeoIpLookup = {
- getDetails: sinon.stub()
- })
- }
+ getDetails: sinon.stub(),
+ }),
+ },
})
this.res = {
send() {},
- sendStatus() {}
+ sendStatus() {},
}
})
@@ -41,8 +41,8 @@ describe('AnalyticsController', function () {
beforeEach(function () {
this.req = {
params: {
- projectId: 'a project id'
- }
+ projectId: 'a project id',
+ },
}
this.GeoIpLookup.getDetails = sinon
.stub()
@@ -64,11 +64,11 @@ describe('AnalyticsController', function () {
beforeEach(function () {
this.req = {
params: {
- event: 'i_did_something'
+ event: 'i_did_something',
},
body: 'stuff',
sessionID: 'sessionIDHere',
- session: {}
+ session: {},
}
})
diff --git a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js
index 1bca1bbfbc..3827d9a995 100644
--- a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js
+++ b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js
@@ -11,19 +11,19 @@ describe('AnalyticsManager', function () {
beforeEach(function () {
this.fakeUserId = '123abc'
this.Settings = {
- analytics: { enabled: true }
+ analytics: { enabled: true },
}
this.analyticsEventsQueue = {
add: sinon.stub().resolves(),
- process: sinon.stub().resolves()
+ process: sinon.stub().resolves(),
}
this.analyticsEditingSessionQueue = {
add: sinon.stub().resolves(),
- process: sinon.stub().resolves()
+ process: sinon.stub().resolves(),
}
this.onboardingEmailsQueue = {
add: sinon.stub().resolves(),
- process: sinon.stub().resolves()
+ process: sinon.stub().resolves(),
}
const self = this
this.Queues = {
@@ -35,15 +35,15 @@ describe('AnalyticsManager', function () {
},
getOnboardingEmailsQueue: () => {
return self.onboardingEmailsQueue
- }
+ },
}
this.backgroundRequest = sinon.stub().yields()
this.request = sinon.stub().yields()
this.AnalyticsManager = SandboxedModule.require(MODULE_PATH, {
requires: {
'settings-sharelatex': this.Settings,
- '../../infrastructure/Queues': this.Queues
- }
+ '../../infrastructure/Queues': this.Queues,
+ },
})
})
@@ -67,7 +67,7 @@ describe('AnalyticsManager', function () {
this.AnalyticsManager.identifyUser(this.fakeUserId, oldUserId)
sinon.assert.calledWithMatch(this.analyticsEventsQueue.add, 'identify', {
userId: this.fakeUserId,
- oldUserId
+ oldUserId,
})
})
@@ -77,7 +77,7 @@ describe('AnalyticsManager', function () {
sinon.assert.calledWithMatch(this.analyticsEventsQueue.add, 'event', {
event,
userId: this.fakeUserId,
- segmentation: null
+ segmentation: null,
})
})
@@ -92,7 +92,7 @@ describe('AnalyticsManager', function () {
sinon.assert.calledWithMatch(this.analyticsEditingSessionQueue.add, {
userId: this.fakeUserId,
projectId,
- countryCode
+ countryCode,
})
})
})
diff --git a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js
index 613a875fbc..e261c7f6c1 100644
--- a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js
+++ b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js
@@ -13,66 +13,66 @@ describe('AuthenticationController', function () {
tk.freeze(Date.now())
this.UserModel = { findOne: sinon.stub() }
this.httpAuthUsers = {
- 'valid-test-user': Math.random().toString(16).slice(2)
+ 'valid-test-user': Math.random().toString(16).slice(2),
}
this.AuthenticationController = SandboxedModule.require(modulePath, {
requires: {
'../User/UserAuditLogHandler': (this.UserAuditLogHandler = {
- addEntry: sinon.stub().yields(null)
+ addEntry: sinon.stub().yields(null),
}),
'../Helpers/AsyncFormHelper': (this.AsyncFormHelper = {
- redirect: sinon.stub()
+ redirect: sinon.stub(),
}),
'../../infrastructure/RequestContentTypeDetection': {
- acceptsJson: (this.acceptsJson = sinon.stub().returns(false))
+ acceptsJson: (this.acceptsJson = sinon.stub().returns(false)),
},
'./AuthenticationManager': (this.AuthenticationManager = {}),
'../User/UserUpdater': (this.UserUpdater = {
- updateUser: sinon.stub()
+ updateUser: sinon.stub(),
}),
'@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }),
'../Security/LoginRateLimiter': (this.LoginRateLimiter = {
processLoginRequest: sinon.stub(),
- recordSuccessfulLogin: sinon.stub()
+ recordSuccessfulLogin: sinon.stub(),
}),
'../User/UserHandler': (this.UserHandler = {
- setupLoginData: sinon.stub()
+ setupLoginData: sinon.stub(),
}),
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
recordEvent: sinon.stub(),
- identifyUser: sinon.stub()
+ identifyUser: sinon.stub(),
}),
'../../infrastructure/SessionStoreManager': (this.SessionStoreManager = {}),
'settings-sharelatex': (this.Settings = {
siteUrl: 'http://www.foo.bar',
- httpAuthUsers: this.httpAuthUsers
+ httpAuthUsers: this.httpAuthUsers,
}),
passport: (this.passport = {
- authenticate: sinon.stub().returns(sinon.stub())
+ authenticate: sinon.stub().returns(sinon.stub()),
}),
'../User/UserSessionsManager': (this.UserSessionsManager = {
trackSession: sinon.stub(),
untrackSession: sinon.stub(),
- revokeAllUserSessions: sinon.stub().callsArgWith(1, null)
+ revokeAllUserSessions: sinon.stub().callsArgWith(1, null),
}),
'../../infrastructure/Modules': (this.Modules = {
- hooks: { fire: sinon.stub().yields(null, []) }
+ hooks: { fire: sinon.stub().yields(null, []) },
}),
'../Notifications/NotificationsBuilder': (this.NotificationsBuilder = {
- ipMatcherAffiliation: sinon.stub().returns({ create: sinon.stub() })
+ ipMatcherAffiliation: sinon.stub().returns({ create: sinon.stub() }),
}),
'../../models/User': { User: this.UserModel },
'../../../../modules/oauth2-server/app/src/Oauth2Server': (this.Oauth2Server = {
Request: sinon.stub(),
Response: sinon.stub(),
server: {
- authenticate: sinon.stub()
- }
+ authenticate: sinon.stub(),
+ },
}),
'../Helpers/UrlHelper': (this.UrlHelper = {
- getSafeRedirectPath: sinon.stub()
- })
- }
+ getSafeRedirectPath: sinon.stub(),
+ }),
+ },
})
this.UrlHelper.getSafeRedirectPath
.withArgs('https://evil.com')
@@ -84,7 +84,7 @@ describe('AuthenticationController', function () {
first_name: 'bob',
last_name: 'brown',
referal_id: 1234,
- isAdmin: false
+ isAdmin: false,
}
this.password = 'banana'
this.req = new MockRequest()
@@ -102,15 +102,15 @@ describe('AuthenticationController', function () {
this.Settings.adminDomains = ['good.example.com']
this.goodAdmin = {
email: 'alice@good.example.com',
- isAdmin: true
+ isAdmin: true,
}
this.badAdmin = {
email: 'beatrice@bad.example.com',
- isAdmin: true
+ isAdmin: true,
}
this.normalUser = {
email: 'claire@whatever.example.com',
- isAdmin: false
+ isAdmin: false,
}
})
@@ -206,7 +206,7 @@ describe('AuthenticationController', function () {
_id: 'id',
first_name: 'a',
last_name: 'b',
- email: 'c'
+ email: 'c',
}
this.AuthenticationController.getSessionUser = sinon
.stub()
@@ -216,13 +216,13 @@ describe('AuthenticationController', function () {
it('should update the right properties', function () {
this.AuthenticationController.setInSessionUser(this.req, {
first_name: 'new_first_name',
- email: 'new_email'
+ email: 'new_email',
})
const expectedUser = {
_id: 'id',
first_name: 'new_first_name',
last_name: 'b',
- email: 'new_email'
+ email: 'new_email',
}
expect(this.user).to.deep.equal(expectedUser)
expect(this.user).to.deep.equal(expectedUser)
@@ -236,7 +236,7 @@ describe('AuthenticationController', function () {
this.res.json = sinon.stub()
this.req.session = {
passport: { user: this.user },
- postLoginRedirect: '/path/to/redir/to'
+ postLoginRedirect: '/path/to/redir/to',
}
this.req.session.destroy = sinon.stub().callsArgWith(0, null)
this.req.session.save = sinon.stub().callsArgWith(0, null)
@@ -327,8 +327,8 @@ describe('AuthenticationController', function () {
email: this.email,
password: this.password,
session: {
- postLoginRedirect: '/path/to/redir/to'
- }
+ postLoginRedirect: '/path/to/redir/to',
+ },
}
this.cb = sinon.stub()
})
@@ -461,9 +461,9 @@ describe('AuthenticationController', function () {
this.req.session = {
passport: {
user: {
- _id: this.user_id
- }
- }
+ _id: this.user_id,
+ },
+ },
}
const result = this.AuthenticationController.getLoggedInUserId(this.req)
expect(result).to.equal(this.user_id)
@@ -491,7 +491,7 @@ describe('AuthenticationController', function () {
beforeEach(function () {
this.user = {
_id: 'user-id-123',
- email: 'user@sharelatex.com'
+ email: 'user@sharelatex.com',
}
this.middleware = this.AuthenticationController.requireLogin()
})
@@ -501,8 +501,8 @@ describe('AuthenticationController', function () {
this.req.session = {
user: (this.user = {
_id: 'user-id-123',
- email: 'user@sharelatex.com'
- })
+ email: 'user@sharelatex.com',
+ }),
}
this.middleware(this.req, this.res, this.next)
})
@@ -532,7 +532,7 @@ describe('AuthenticationController', function () {
beforeEach(function () {
this.user = {
_id: 'user-id-123',
- email: 'user@sharelatex.com'
+ email: 'user@sharelatex.com',
}
this.middleware = this.AuthenticationController.validateUserSession()
})
@@ -553,7 +553,7 @@ describe('AuthenticationController', function () {
beforeEach(function () {
this.req.session = {
user: this.user,
- regenerate: sinon.stub().yields()
+ regenerate: sinon.stub().yields(),
}
this.req.user = this.user
this.AuthenticationController._redirectToLoginOrRegisterPage = sinon.stub()
@@ -588,7 +588,7 @@ describe('AuthenticationController', function () {
beforeEach(function () {
this.token = {
accessToken: 'token',
- user: 'user'
+ user: 'user',
}
this.Oauth2Server.server.authenticate.yields(null, this.token)
this.middleware(this.req, this.res, this.next)
@@ -730,7 +730,7 @@ describe('AuthenticationController', function () {
describe('with http auth', function () {
it('should error with incorrect user', function (done) {
this.req.headers = {
- authorization: `Basic ${Buffer.from('user:nope').toString('base64')}`
+ authorization: `Basic ${Buffer.from('user:nope').toString('base64')}`,
}
this.req.end = status => {
expect(status).to.equal('Unauthorized')
@@ -743,7 +743,7 @@ describe('AuthenticationController', function () {
this.req.headers = {
authorization: `Basic ${Buffer.from('valid-test-user:nope').toString(
'base64'
- )}`
+ )}`,
}
this.req.end = status => {
expect(status).to.equal('Unauthorized')
@@ -756,7 +756,7 @@ describe('AuthenticationController', function () {
this.req.headers = {
authorization: `Basic ${Buffer.from(`invalid-test-user:`).toString(
'base64'
- )}`
+ )}`,
}
this.req.end = status => {
expect(status).to.equal('Unauthorized')
@@ -769,7 +769,7 @@ describe('AuthenticationController', function () {
this.req.headers = {
authorization: `Basic ${Buffer.from(
`valid-test-user:${this.httpAuthUsers['valid-test-user']}`
- ).toString('base64')}`
+ ).toString('base64')}`,
}
this.AuthenticationController.httpAuth(this.req, this.res, done)
})
@@ -1016,7 +1016,7 @@ describe('AuthenticationController', function () {
this.req.sessionID = 'thisisacryptographicallysecurerandomid'
this.req.session = {
- passport: { user: { _id: 'one' } }
+ passport: { user: { _id: 'one' } },
}
this.req.session.destroy = sinon.stub().callsArgWith(0, null)
this.req.session.save = sinon.stub().callsArgWith(0, null)
diff --git a/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js b/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js
index c39c4f3eef..6b7bc1f625 100644
--- a/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js
+++ b/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js
@@ -13,17 +13,17 @@ describe('AuthenticationManager', function () {
this.AuthenticationManager = SandboxedModule.require(modulePath, {
requires: {
'../../models/User': {
- User: (this.User = {})
+ User: (this.User = {}),
},
'../../infrastructure/mongodb': {
db: (this.db = { users: {} }),
- ObjectId
+ ObjectId,
},
bcrypt: (this.bcrypt = {}),
'settings-sharelatex': this.settings,
'../User/UserGetter': (this.UserGetter = {}),
- './AuthenticationErrors': AuthenticationErrors
- }
+ './AuthenticationErrors': AuthenticationErrors,
+ },
})
this.callback = sinon.stub()
})
@@ -44,7 +44,7 @@ describe('AuthenticationManager', function () {
beforeEach(function () {
this.user = {
_id: 'user-id',
- email: (this.email = 'USER@sharelatex.com')
+ email: (this.email = 'USER@sharelatex.com'),
}
this.User.findOne = sinon.stub().callsArgWith(1, null, this.user)
})
@@ -91,7 +91,7 @@ describe('AuthenticationManager', function () {
beforeEach(function () {
this.user = {
_id: '5c8791477192a80b5e76ca7e',
- email: (this.email = 'USER@sharelatex.com')
+ email: (this.email = 'USER@sharelatex.com'),
}
this.db.users.updateOne = sinon
this.User.findOne = sinon.stub().callsArgWith(2, null, this.user)
@@ -119,7 +119,7 @@ describe('AuthenticationManager', function () {
err => {
expect(err).to.not.exist
const {
- hashedPassword
+ hashedPassword,
} = this.db.users.updateOne.lastCall.args[1].$set
expect(hashedPassword).to.exist
expect(hashedPassword.length).to.equal(60)
@@ -136,7 +136,7 @@ describe('AuthenticationManager', function () {
beforeEach(function () {
this.user = {
_id: 'user-id',
- email: (this.email = 'USER@sharelatex.com')
+ email: (this.email = 'USER@sharelatex.com'),
}
this.unencryptedPassword = 'banana'
this.User.findOne = sinon.stub().callsArgWith(1, null, this.user)
@@ -368,8 +368,8 @@ describe('AuthenticationManager', function () {
this.settings.passwordStrengthOptions = {
length: {
min: 10,
- max: 12
- }
+ max: 12,
+ },
}
})
@@ -414,8 +414,8 @@ describe('AuthenticationManager', function () {
beforeEach(function () {
this.settings.passwordStrengthOptions = {
length: {
- max: 128
- }
+ max: 128,
+ },
}
})
@@ -467,8 +467,8 @@ describe('AuthenticationManager', function () {
beforeEach(function () {
this.settings.passwordStrengthOptions = {
chars: {
- symbols: ' '
- }
+ symbols: ' ',
+ },
}
})
@@ -498,7 +498,7 @@ describe('AuthenticationManager', function () {
describe('when allowAnyChars is set', function () {
beforeEach(function () {
this.settings.passwordStrengthOptions = {
- allowAnyChars: true
+ allowAnyChars: true,
}
})
@@ -523,7 +523,7 @@ describe('AuthenticationManager', function () {
this.user_id = ObjectId()
this.user = {
_id: this.user_id,
- email: 'user@example.com'
+ email: 'user@example.com',
}
this.password = 'banana'
this.hashedPassword = 'asdkjfa;osiuvandf'
@@ -538,8 +538,8 @@ describe('AuthenticationManager', function () {
beforeEach(function () {
this.settings.passwordStrengthOptions = {
length: {
- max: 10
- }
+ max: 10,
+ },
}
this.password = 'dsdsadsadsadsadsadkjsadjsadjsadljs'
})
@@ -609,8 +609,8 @@ describe('AuthenticationManager', function () {
this.settings.passwordStrengthOptions = {
length: {
max: 10,
- min: 6
- }
+ min: 6,
+ },
}
this.password = 'dsd'
})
@@ -652,15 +652,15 @@ describe('AuthenticationManager', function () {
it("should update the user's password in the database", function () {
const { args } = this.db.users.updateOne.lastCall
expect(args[0]).to.deep.equal({
- _id: ObjectId(this.user_id.toString())
+ _id: ObjectId(this.user_id.toString()),
})
expect(args[1]).to.deep.equal({
$set: {
- hashedPassword: this.hashedPassword
+ hashedPassword: this.hashedPassword,
},
$unset: {
- password: true
- }
+ password: true,
+ },
})
})
diff --git a/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js b/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js
index 9a7d88eba8..04bf5ac4cf 100644
--- a/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js
+++ b/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js
@@ -28,15 +28,15 @@ describe('AuthorizationManager', function () {
'../Collaborators/CollaboratorsHandler': (this.CollaboratorsHandler = {}),
'../Project/ProjectGetter': (this.ProjectGetter = {}),
'../../models/User': {
- User: (this.User = {})
+ User: (this.User = {}),
},
'../TokenAccess/TokenAccessHandler': (this.TokenAccessHandler = {
validateTokenForAnonymousAccess: sinon
.stub()
- .callsArgWith(2, null, false, false)
+ .callsArgWith(2, null, false, false),
}),
- 'settings-sharelatex': { passwordStrengthOptions: {} }
- }
+ 'settings-sharelatex': { passwordStrengthOptions: {} },
+ },
})
this.user_id = 'user-id-1'
this.project_id = 'project-id-1'
@@ -49,7 +49,7 @@ describe('AuthorizationManager', function () {
const notRestrictedScenarios = [
[null, 'readAndWrite', false],
['id', 'readAndWrite', true],
- ['id', 'readOnly', false]
+ ['id', 'readOnly', false],
]
const restrictedScenarios = [
[null, 'readOnly', false],
@@ -57,7 +57,7 @@ describe('AuthorizationManager', function () {
[null, false, true],
[null, false, false],
['id', false, true],
- ['id', false, false]
+ ['id', false, false],
]
for (var notRestrictedArgs of notRestrictedScenarios) {
expect(
diff --git a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js
index 0deba99cc4..765b8d3344 100644
--- a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js
+++ b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js
@@ -13,30 +13,30 @@ describe('AuthorizationMiddleware', function () {
this.token = 'some-token'
this.AuthenticationController = {
getLoggedInUserId: sinon.stub().returns(this.userId),
- isUserLoggedIn: sinon.stub().returns(true)
+ isUserLoggedIn: sinon.stub().returns(true),
}
this.AuthorizationManager = {}
this.HttpErrorHandler = {
- forbidden: sinon.stub()
+ forbidden: sinon.stub(),
}
this.TokenAccessHandler = {
- getRequestToken: sinon.stub().returns(this.token)
+ getRequestToken: sinon.stub().returns(this.token),
}
this.ObjectId = {
- isValid: sinon.stub().withArgs(this.project_id).returns(true)
+ isValid: sinon.stub().withArgs(this.project_id).returns(true),
}
this.AuthorizationManager = {}
this.AuthorizationMiddleware = SandboxedModule.require(MODULE_PATH, {
requires: {
'./AuthorizationManager': this.AuthorizationManager,
mongodb: {
- ObjectId: this.ObjectId
+ ObjectId: this.ObjectId,
},
'../Errors/HttpErrorHandler': this.HttpErrorHandler,
'../Authentication/AuthenticationController': this
.AuthenticationController,
- '../TokenAccess/TokenAccessHandler': this.TokenAccessHandler
- }
+ '../TokenAccess/TokenAccessHandler': this.TokenAccessHandler,
+ },
})
this.req = {}
this.res = {}
@@ -87,7 +87,7 @@ describe('AuthorizationMiddleware', function () {
const METHODS_TO_TEST = {
ensureUserCanReadProject: 'canUserReadProject',
ensureUserCanWriteProjectSettings: 'canUserWriteProjectSettings',
- ensureUserCanWriteProjectContent: 'canUserWriteProjectContent'
+ ensureUserCanWriteProjectContent: 'canUserWriteProjectContent',
}
Object.entries(METHODS_TO_TEST).forEach(
([middlewareMethod, managerMethod]) => {
diff --git a/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js b/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js
index f3ce4aaf40..a22581585a 100644
--- a/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js
+++ b/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js
@@ -13,35 +13,35 @@ describe('BetaProgramController', function () {
_id: (this.user_id = 'a_simple_id'),
email: 'user@example.com',
features: {},
- betaProgram: false
+ betaProgram: false,
}
this.req = {
query: {},
session: {
- user: this.user
- }
+ user: this.user,
+ },
}
this.BetaProgramController = SandboxedModule.require(modulePath, {
requires: {
'./BetaProgramHandler': (this.BetaProgramHandler = {
optIn: sinon.stub(),
- optOut: sinon.stub()
+ optOut: sinon.stub(),
}),
'../User/UserGetter': (this.UserGetter = {
- getUser: sinon.stub()
+ getUser: sinon.stub(),
}),
'settings-sharelatex': (this.settings = {
- languages: {}
+ languages: {},
}),
'../Authentication/AuthenticationController': (this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.user._id)
- })
- }
+ getLoggedInUserId: sinon.stub().returns(this.user._id),
+ }),
+ },
})
this.res = {
send: sinon.stub(),
redirect: sinon.stub(),
- render: sinon.stub()
+ render: sinon.stub(),
}
this.next = sinon.stub()
})
diff --git a/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js b/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js
index 1ebe1b5563..2c8270d4ea 100644
--- a/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js
+++ b/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js
@@ -15,19 +15,19 @@ describe('BetaProgramHandler', function () {
email: 'user@example.com',
features: {},
betaProgram: false,
- save: sinon.stub().callsArgWith(0, null)
+ save: sinon.stub().callsArgWith(0, null),
}
this.handler = SandboxedModule.require(modulePath, {
requires: {
'@overleaf/metrics': {
- inc: sinon.stub()
+ inc: sinon.stub(),
},
'../User/UserUpdater': (this.UserUpdater = {
promises: {
- updateUser: sinon.stub().resolves()
- }
- })
- }
+ updateUser: sinon.stub().resolves(),
+ },
+ }),
+ },
})
})
diff --git a/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js b/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js
index aa0fa8b6c6..35f4cea35d 100644
--- a/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js
+++ b/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js
@@ -26,26 +26,26 @@ describe('BrandVariationsHandler', function () {
this.settings = {
apis: {
v1: {
- url: 'http://overleaf.example.com'
- }
+ url: 'http://overleaf.example.com',
+ },
},
modules: {
sanitize: {
options: {
allowedTags: ['br', 'strong'],
allowedAttributes: {
- strong: ['style']
- }
- }
- }
- }
+ strong: ['style'],
+ },
+ },
+ },
+ },
}
this.V1Api = { request: sinon.stub() }
this.BrandVariationsHandler = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': this.settings,
- '../V1/V1Api': this.V1Api
- }
+ '../V1/V1Api': this.V1Api,
+ },
})
return (this.mockedBrandVariationDetails = {
id: '12',
@@ -54,7 +54,7 @@ describe('BrandVariationsHandler', function () {
logo_url: 'http://my.cdn.tld/journal-logo.png',
journal_cover_url: 'http://my.cdn.tld/journal-cover.jpg',
home_url: 'http://www.thejournal.com/',
- publish_menu_link_html: 'Submit your paper to the The Journal'
+ publish_menu_link_html: 'Submit your paper to the The Journal',
})
})
diff --git a/services/web/test/unit/src/Chat/ChatApiHandlerTests.js b/services/web/test/unit/src/Chat/ChatApiHandlerTests.js
index 00fa10fa7f..e06d95c222 100644
--- a/services/web/test/unit/src/Chat/ChatApiHandlerTests.js
+++ b/services/web/test/unit/src/Chat/ChatApiHandlerTests.js
@@ -25,16 +25,16 @@ describe('ChatApiHandler', function () {
this.settings = {
apis: {
chat: {
- internal_url: 'chat.sharelatex.env'
- }
- }
+ internal_url: 'chat.sharelatex.env',
+ },
+ },
}
this.request = sinon.stub()
this.ChatApiHandler = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': this.settings,
- request: this.request
- }
+ request: this.request,
+ },
})
this.project_id = '3213213kl12j'
this.user_id = '2k3jlkjs9'
@@ -62,8 +62,8 @@ describe('ChatApiHandler', function () {
method: 'POST',
json: {
content: this.content,
- user_id: this.user_id
- }
+ user_id: this.user_id,
+ },
})
.should.equal(true)
})
@@ -117,9 +117,9 @@ describe('ChatApiHandler', function () {
url: `${this.settings.apis.chat.internal_url}/project/${this.project_id}/messages`,
qs: {
limit: this.limit,
- before: this.before
+ before: this.before,
},
- json: true
+ json: true,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Chat/ChatControllerTests.js b/services/web/test/unit/src/Chat/ChatControllerTests.js
index b6dfdee70d..77ba582cd1 100644
--- a/services/web/test/unit/src/Chat/ChatControllerTests.js
+++ b/services/web/test/unit/src/Chat/ChatControllerTests.js
@@ -29,7 +29,7 @@ describe('ChatController', function () {
this.ChatApiHandler = {}
this.EditorRealTimeController = { emitToRoom: sinon.stub() }
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.user_id)
+ getLoggedInUserId: sinon.stub().returns(this.user_id),
}
this.ChatController = SandboxedModule.require(modulePath, {
requires: {
@@ -39,18 +39,18 @@ describe('ChatController', function () {
'../Authentication/AuthenticationController': this
.AuthenticationController,
'../User/UserInfoManager': (this.UserInfoManager = {}),
- '../User/UserInfoController': (this.UserInfoController = {})
- }
+ '../User/UserInfoController': (this.UserInfoController = {}),
+ },
})
this.req = {
params: {
- project_id: this.project_id
- }
+ project_id: this.project_id,
+ },
}
this.res = {
json: sinon.stub(),
send: sinon.stub(),
- sendStatus: sinon.stub()
+ sendStatus: sinon.stub(),
}
})
@@ -106,7 +106,7 @@ describe('ChatController', function () {
beforeEach(function () {
this.req.query = {
limit: (this.limit = '30'),
- before: (this.before = '12345')
+ before: (this.before = '12345'),
}
this.ChatController._injectUserInfoIntoThreads = sinon.stub().yields()
this.ChatApiHandler.getGlobalMessages = sinon
@@ -130,18 +130,18 @@ describe('ChatController', function () {
beforeEach(function () {
this.users = {
user_id_1: {
- mock: 'user_1'
+ mock: 'user_1',
},
user_id_2: {
- mock: 'user_2'
- }
+ mock: 'user_2',
+ },
}
this.UserInfoManager.getPersonalInfo = (user_id, callback) => {
return callback(null, this.users[user_id])
}
sinon.spy(this.UserInfoManager, 'getPersonalInfo')
return (this.UserInfoController.formatPersonalInfo = user => ({
- formatted: user.mock
+ formatted: user.mock,
}))
})
@@ -154,22 +154,22 @@ describe('ChatController', function () {
messages: [
{
user_id: 'user_id_1',
- content: 'foo'
+ content: 'foo',
},
{
user_id: 'user_id_2',
- content: 'bar'
- }
- ]
+ content: 'bar',
+ },
+ ],
},
thread2: {
messages: [
{
user_id: 'user_id_1',
- content: 'baz'
- }
- ]
- }
+ content: 'baz',
+ },
+ ],
+ },
},
(error, threads) => {
expect(threads).to.deep.equal({
@@ -181,24 +181,24 @@ describe('ChatController', function () {
{
user_id: 'user_id_1',
user: { formatted: 'user_1' },
- content: 'foo'
+ content: 'foo',
},
{
user_id: 'user_id_2',
user: { formatted: 'user_2' },
- content: 'bar'
- }
- ]
+ content: 'bar',
+ },
+ ],
},
thread2: {
messages: [
{
user_id: 'user_id_1',
user: { formatted: 'user_1' },
- content: 'baz'
- }
- ]
- }
+ content: 'baz',
+ },
+ ],
+ },
})
return done()
}
@@ -212,14 +212,14 @@ describe('ChatController', function () {
messages: [
{
user_id: 'user_id_1',
- content: 'foo'
+ content: 'foo',
},
{
user_id: 'user_id_1',
- content: 'bar'
- }
- ]
- }
+ content: 'bar',
+ },
+ ],
+ },
],
(error, threads) => {
this.UserInfoManager.getPersonalInfo.calledOnce.should.equal(true)
diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js
index 692a97e407..2ba1954efc 100644
--- a/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js
+++ b/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js
@@ -21,34 +21,34 @@ describe('CollaboratorsController', function () {
this.CollaboratorsHandler = {
promises: {
removeUserFromProject: sinon.stub().resolves(),
- setCollaboratorPrivilegeLevel: sinon.stub().resolves()
- }
+ setCollaboratorPrivilegeLevel: sinon.stub().resolves(),
+ },
}
this.CollaboratorsGetter = {
promises: {
- getAllInvitedMembers: sinon.stub()
- }
+ getAllInvitedMembers: sinon.stub(),
+ },
}
this.EditorRealTimeController = {
- emitToRoom: sinon.stub()
+ emitToRoom: sinon.stub(),
}
this.HttpErrorHandler = {
forbidden: sinon.stub(),
- notFound: sinon.stub()
+ notFound: sinon.stub(),
}
this.TagsHandler = {
promises: {
- removeProjectFromAllTags: sinon.stub().resolves()
- }
+ removeProjectFromAllTags: sinon.stub().resolves(),
+ },
}
this.AuthenticationController = {
getSessionUser: sinon.stub().returns(this.user),
- getLoggedInUserId: sinon.stub().returns(this.user._id)
+ getLoggedInUserId: sinon.stub().returns(this.user._id),
}
this.OwnershipTransferHandler = {
promises: {
- transferOwnership: sinon.stub().resolves()
- }
+ transferOwnership: sinon.stub().resolves(),
+ },
}
this.CollaboratorsController = SandboxedModule.require(MODULE_PATH, {
@@ -61,8 +61,8 @@ describe('CollaboratorsController', function () {
'../../Features/Errors/HttpErrorHandler': this.HttpErrorHandler,
'../Tags/TagsHandler': this.TagsHandler,
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
})
})
@@ -70,7 +70,7 @@ describe('CollaboratorsController', function () {
beforeEach(function (done) {
this.req.params = {
Project_id: this.projectId,
- user_id: this.user._id
+ user_id: this.user._id,
}
this.res.sendStatus = sinon.spy(() => {
done()
@@ -199,7 +199,7 @@ describe('CollaboratorsController', function () {
beforeEach(function () {
this.req.params = {
Project_id: this.projectId,
- user_id: this.user._id
+ user_id: this.user._id,
}
this.req.body = { privilegeLevel: 'readOnly' }
})
diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js
index 9a9b604ff1..bc0490141c 100644
--- a/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js
+++ b/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js
@@ -29,22 +29,22 @@ describe('CollaboratorsGetter', function () {
collaberator_refs: [this.readWriteRef1, this.readWriteRef2],
tokenAccessReadAndWrite_refs: [this.readWriteTokenRef],
tokenAccessReadOnly_refs: [this.readOnlyTokenRef],
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
}
this.UserGetter = {
promises: {
- getUser: sinon.stub().resolves(null)
- }
+ getUser: sinon.stub().resolves(null),
+ },
}
this.ProjectMock = sinon.mock(Project)
this.ProjectGetter = {
promises: {
- getProject: sinon.stub().resolves(this.project)
- }
+ getProject: sinon.stub().resolves(this.project),
+ },
}
this.ProjectEditorHandler = {
- buildOwnerAndMembersViews: sinon.stub()
+ buildOwnerAndMembersViews: sinon.stub(),
}
this.CollaboratorsGetter = SandboxedModule.require(MODULE_PATH, {
requires: {
@@ -52,8 +52,8 @@ describe('CollaboratorsGetter', function () {
'../User/UserGetter': this.UserGetter,
'../../models/Project': { Project },
'../Project/ProjectGetter': this.ProjectGetter,
- '../Project/ProjectEditorHandler': this.ProjectEditorHandler
- }
+ '../Project/ProjectEditorHandler': this.ProjectEditorHandler,
+ },
})
})
@@ -71,38 +71,38 @@ describe('CollaboratorsGetter', function () {
{
id: this.ownerRef.toString(),
privilegeLevel: 'owner',
- source: 'owner'
+ source: 'owner',
},
{
id: this.readWriteRef1.toString(),
privilegeLevel: 'readAndWrite',
- source: 'invite'
+ source: 'invite',
},
{
id: this.readWriteRef2.toString(),
privilegeLevel: 'readAndWrite',
- source: 'invite'
+ source: 'invite',
},
{
id: this.readOnlyRef1.toString(),
privilegeLevel: 'readOnly',
- source: 'invite'
+ source: 'invite',
},
{
id: this.readOnlyRef2.toString(),
privilegeLevel: 'readOnly',
- source: 'invite'
+ source: 'invite',
},
{
id: this.readOnlyTokenRef.toString(),
privilegeLevel: 'readOnly',
- source: 'token'
+ source: 'token',
},
{
id: this.readWriteTokenRef.toString(),
privilegeLevel: 'readAndWrite',
- source: 'token'
- }
+ source: 'token',
+ },
])
})
})
@@ -134,7 +134,7 @@ describe('CollaboratorsGetter', function () {
this.readWriteRef1.toString(),
this.readWriteRef2.toString(),
this.readWriteTokenRef.toString(),
- this.readOnlyTokenRef.toString()
+ this.readOnlyTokenRef.toString(),
])
})
})
@@ -149,7 +149,7 @@ describe('CollaboratorsGetter', function () {
this.readOnlyRef1.toString(),
this.readOnlyRef2.toString(),
this.readWriteRef1.toString(),
- this.readWriteRef2.toString()
+ this.readWriteRef2.toString(),
])
})
})
@@ -176,7 +176,7 @@ describe('CollaboratorsGetter', function () {
)
expect(result).to.have.deep.members([
{ user: { _id: this.readOnlyRef1 }, privilegeLevel: 'readOnly' },
- { user: { _id: this.readWriteRef2 }, privilegeLevel: 'readAndWrite' }
+ { user: { _id: this.readWriteRef2 }, privilegeLevel: 'readAndWrite' },
])
})
})
@@ -235,27 +235,27 @@ describe('CollaboratorsGetter', function () {
.withArgs(
{
tokenAccessReadAndWrite_refs: this.userId,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
},
this.fields
)
.chain('exec')
.resolves([
'mock-token-read-write-project-1',
- 'mock-token-read-write-project-2'
+ 'mock-token-read-write-project-2',
])
this.ProjectMock.expects('find')
.withArgs(
{
tokenAccessReadOnly_refs: this.userId,
- publicAccesLevel: 'tokenBased'
+ publicAccesLevel: 'tokenBased',
},
this.fields
)
.chain('exec')
.resolves([
'mock-token-read-only-project-1',
- 'mock-token-read-only-project-2'
+ 'mock-token-read-only-project-2',
])
})
@@ -267,17 +267,17 @@ describe('CollaboratorsGetter', function () {
expect(projects).to.deep.equal({
readAndWrite: [
'mock-read-write-project-1',
- 'mock-read-write-project-2'
+ 'mock-read-write-project-2',
],
readOnly: ['mock-read-only-project-1', 'mock-read-only-project-2'],
tokenReadAndWrite: [
'mock-token-read-write-project-1',
- 'mock-token-read-write-project-2'
+ 'mock-token-read-write-project-2',
],
tokenReadOnly: [
'mock-token-read-only-project-1',
- 'mock-token-read-only-project-2'
- ]
+ 'mock-token-read-only-project-2',
+ ],
})
})
})
@@ -287,22 +287,22 @@ describe('CollaboratorsGetter', function () {
this.owningUser = {
_id: this.ownerRef,
email: 'owner@example.com',
- features: { a: 1 }
+ features: { a: 1 },
}
this.readWriteUser = {
_id: this.readWriteRef1,
- email: 'readwrite@example.com'
+ email: 'readwrite@example.com',
}
this.members = [
{ user: this.owningUser, privilegeLevel: 'owner' },
- { user: this.readWriteUser, privilegeLevel: 'readAndWrite' }
+ { user: this.readWriteUser, privilegeLevel: 'readAndWrite' },
]
this.views = {
owner: this.owningUser,
ownerFeatures: this.owningUser.features,
members: [
- { _id: this.readWriteUser._id, email: this.readWriteUser.email }
- ]
+ { _id: this.readWriteUser._id, email: this.readWriteUser.email },
+ ],
}
this.UserGetter.promises.getUser
.withArgs(this.owningUser._id.toString())
diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js
index 3b3790c7fc..a5e345e2dc 100644
--- a/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js
+++ b/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js
@@ -19,46 +19,46 @@ describe('CollaboratorsHandler', function () {
this.userId = ObjectId()
this.addingUserId = ObjectId()
this.project = {
- _id: ObjectId()
+ _id: ObjectId(),
}
this.archivedProject = {
_id: ObjectId(),
- archived: [ObjectId(this.userId)]
+ archived: [ObjectId(this.userId)],
}
this.oldArchivedProject = {
_id: ObjectId(),
- archived: true
+ archived: true,
}
this.UserGetter = {
promises: {
- getUser: sinon.stub().resolves(null)
- }
+ getUser: sinon.stub().resolves(null),
+ },
}
this.ContactManager = {
- addContact: sinon.stub()
+ addContact: sinon.stub(),
}
this.ProjectMock = sinon.mock(Project)
this.TpdsProjectFlusher = {
promises: {
- flushProjectToTpds: sinon.stub().resolves()
- }
+ flushProjectToTpds: sinon.stub().resolves(),
+ },
}
this.ProjectGetter = {
promises: {
- getProject: sinon.stub().resolves(this.project)
- }
+ getProject: sinon.stub().resolves(this.project),
+ },
}
this.ProjectHelper = {
- calculateArchivedArray: sinon.stub()
+ calculateArchivedArray: sinon.stub(),
}
this.CollaboratorsGetter = {
promises: {
- getProjectsUserIsMemberOf: sinon.stub()
- }
+ getProjectsUserIsMemberOf: sinon.stub(),
+ },
}
this.CollaboratorsHandler = SandboxedModule.require(MODULE_PATH, {
requires: {
@@ -68,8 +68,8 @@ describe('CollaboratorsHandler', function () {
'../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher,
'../Project/ProjectGetter': this.ProjectGetter,
'../Project/ProjectHelper': this.ProjectHelper,
- './CollaboratorsGetter': this.CollaboratorsGetter
- }
+ './CollaboratorsGetter': this.CollaboratorsGetter,
+ },
})
})
@@ -82,7 +82,7 @@ describe('CollaboratorsHandler', function () {
beforeEach(function () {
this.ProjectMock.expects('findOne')
.withArgs({
- _id: this.project._id
+ _id: this.project._id,
})
.chain('exec')
.resolves(this.project)
@@ -92,7 +92,7 @@ describe('CollaboratorsHandler', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.project._id
+ _id: this.project._id,
},
{
$pull: {
@@ -101,8 +101,8 @@ describe('CollaboratorsHandler', function () {
tokenAccessReadOnly_refs: this.userId,
tokenAccessReadAndWrite_refs: this.userId,
archived: this.userId,
- trashed: this.userId
- }
+ trashed: this.userId,
+ },
}
)
.chain('exec')
@@ -121,7 +121,7 @@ describe('CollaboratorsHandler', function () {
this.ProjectMock.expects('findOne')
.withArgs({
- _id: this.oldArchivedProject._id
+ _id: this.oldArchivedProject._id,
})
.chain('exec')
.resolves(this.oldArchivedProject)
@@ -131,19 +131,19 @@ describe('CollaboratorsHandler', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.oldArchivedProject._id
+ _id: this.oldArchivedProject._id,
},
{
$set: {
- archived: []
+ archived: [],
},
$pull: {
collaberator_refs: this.userId,
readOnly_refs: this.userId,
tokenAccessReadOnly_refs: this.userId,
tokenAccessReadAndWrite_refs: this.userId,
- trashed: this.userId
- }
+ trashed: this.userId,
+ },
}
)
.resolves()
@@ -158,7 +158,7 @@ describe('CollaboratorsHandler', function () {
beforeEach(function () {
this.ProjectMock.expects('findOne')
.withArgs({
- _id: this.archivedProject._id
+ _id: this.archivedProject._id,
})
.chain('exec')
.resolves(this.archivedProject)
@@ -168,7 +168,7 @@ describe('CollaboratorsHandler', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.archivedProject._id
+ _id: this.archivedProject._id,
},
{
$pull: {
@@ -177,8 +177,8 @@ describe('CollaboratorsHandler', function () {
tokenAccessReadOnly_refs: this.userId,
tokenAccessReadAndWrite_refs: this.userId,
archived: this.userId,
- trashed: this.userId
- }
+ trashed: this.userId,
+ },
}
)
.resolves()
@@ -196,10 +196,10 @@ describe('CollaboratorsHandler', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.project._id
+ _id: this.project._id,
},
{
- $addToSet: { readOnly_refs: this.userId }
+ $addToSet: { readOnly_refs: this.userId },
}
)
.chain('exec')
@@ -231,10 +231,10 @@ describe('CollaboratorsHandler', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.project._id
+ _id: this.project._id,
},
{
- $addToSet: { collaberator_refs: this.userId }
+ $addToSet: { collaberator_refs: this.userId },
}
)
.chain('exec')
@@ -308,17 +308,17 @@ describe('CollaboratorsHandler', function () {
.resolves({
readAndWrite: [
{ _id: 'read-and-write-0' },
- { _id: 'read-and-write-1' }
+ { _id: 'read-and-write-1' },
],
readOnly: [{ _id: 'read-only-0' }, { _id: 'read-only-1' }],
tokenReadAndWrite: [
{ _id: 'token-read-and-write-0' },
- { _id: 'token-read-and-write-1' }
+ { _id: 'token-read-and-write-1' },
],
tokenReadOnly: [
{ _id: 'token-read-only-0' },
- { _id: 'token-read-only-1' }
- ]
+ { _id: 'token-read-only-1' },
+ ],
})
const expectedProjects = [
'read-and-write-0',
@@ -328,12 +328,12 @@ describe('CollaboratorsHandler', function () {
'token-read-and-write-0',
'token-read-and-write-1',
'token-read-only-0',
- 'token-read-only-1'
+ 'token-read-only-1',
]
for (const projectId of expectedProjects) {
this.ProjectMock.expects('findOne')
.withArgs({
- _id: projectId
+ _id: projectId,
})
.chain('exec')
.resolves({ _id: projectId })
@@ -341,7 +341,7 @@ describe('CollaboratorsHandler', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: projectId
+ _id: projectId,
},
{
$pull: {
@@ -350,8 +350,8 @@ describe('CollaboratorsHandler', function () {
tokenAccessReadOnly_refs: this.userId,
tokenAccessReadAndWrite_refs: this.userId,
archived: this.userId,
- trashed: this.userId
- }
+ trashed: this.userId,
+ },
}
)
.resolves()
@@ -368,19 +368,19 @@ describe('CollaboratorsHandler', function () {
this.toUserId = ObjectId()
this.projects = [
{
- _id: ObjectId()
+ _id: ObjectId(),
},
{
- _id: ObjectId()
- }
+ _id: ObjectId(),
+ },
]
this.ProjectMock.expects('find')
.withArgs({
$or: [
{ owner_ref: this.fromUserId },
{ collaberator_refs: this.fromUserId },
- { readOnly_refs: this.fromUserId }
- ]
+ { readOnly_refs: this.fromUserId },
+ ],
})
.chain('exec')
.resolves(this.projects)
@@ -395,7 +395,7 @@ describe('CollaboratorsHandler', function () {
.withArgs(
{ collaberator_refs: this.fromUserId },
{
- $addToSet: { collaberator_refs: this.toUserId }
+ $addToSet: { collaberator_refs: this.toUserId },
}
)
.chain('exec')
@@ -404,7 +404,7 @@ describe('CollaboratorsHandler', function () {
.withArgs(
{ collaberator_refs: this.fromUserId },
{
- $pull: { collaberator_refs: this.fromUserId }
+ $pull: { collaberator_refs: this.fromUserId },
}
)
.chain('exec')
@@ -413,7 +413,7 @@ describe('CollaboratorsHandler', function () {
.withArgs(
{ readOnly_refs: this.fromUserId },
{
- $addToSet: { readOnly_refs: this.toUserId }
+ $addToSet: { readOnly_refs: this.toUserId },
}
)
.chain('exec')
@@ -422,7 +422,7 @@ describe('CollaboratorsHandler', function () {
.withArgs(
{ readOnly_refs: this.fromUserId },
{
- $pull: { readOnly_refs: this.fromUserId }
+ $pull: { readOnly_refs: this.fromUserId },
}
)
.chain('exec')
@@ -467,12 +467,12 @@ describe('CollaboratorsHandler', function () {
_id: this.projectId,
$or: [
{ collaberator_refs: this.userId },
- { readOnly_refs: this.userId }
- ]
+ { readOnly_refs: this.userId },
+ ],
},
{
$pull: { collaberator_refs: this.userId },
- $addToSet: { readOnly_refs: this.userId }
+ $addToSet: { readOnly_refs: this.userId },
}
)
.chain('exec')
@@ -491,12 +491,12 @@ describe('CollaboratorsHandler', function () {
_id: this.projectId,
$or: [
{ collaberator_refs: this.userId },
- { readOnly_refs: this.userId }
- ]
+ { readOnly_refs: this.userId },
+ ],
},
{
$addToSet: { collaberator_refs: this.userId },
- $pull: { readOnly_refs: this.userId }
+ $pull: { readOnly_refs: this.userId },
}
)
.chain('exec')
diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js
index b39cb21a39..40660c7474 100644
--- a/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js
+++ b/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js
@@ -30,7 +30,7 @@ describe('CollaboratorsInviteController', function () {
getSessionUser: req => {
this.sendingUser = req.session.user
return this.sendingUser
- }
+ },
}
this.RateLimiter = { addCount: sinon.stub }
@@ -38,7 +38,7 @@ describe('CollaboratorsInviteController', function () {
this.LimitationsManager = {}
this.UserGetter = {
getUserByAnyEmail: sinon.stub(),
- getUser: sinon.stub()
+ getUser: sinon.stub(),
}
this.CollaboratorsInviteController = SandboxedModule.require(modulePath, {
@@ -49,14 +49,14 @@ describe('CollaboratorsInviteController', function () {
'./CollaboratorsGetter': (this.CollaboratorsGetter = {}),
'./CollaboratorsInviteHandler': (this.CollaboratorsInviteHandler = {}),
'../Editor/EditorRealTimeController': (this.EditorRealTimeController = {
- emitToRoom: sinon.stub()
+ emitToRoom: sinon.stub(),
}),
'../Analytics/AnalyticsManager': this.AnalyticsManger,
'../Authentication/AuthenticationController': this
.AuthenticationController,
'settings-sharelatex': (this.settings = {}),
- '../../infrastructure/RateLimiter': this.RateLimiter
- }
+ '../../infrastructure/RateLimiter': this.RateLimiter,
+ },
})
this.res = new MockResponse()
this.req = new MockRequest()
@@ -69,7 +69,7 @@ describe('CollaboratorsInviteController', function () {
beforeEach(function () {
this.fakeInvites = [
{ _id: ObjectId(), one: 1 },
- { _id: ObjectId(), two: 2 }
+ { _id: ObjectId(), two: 2 },
]
this.req.params = { Project_id: this.project_id }
this.res.json = sinon.stub()
@@ -134,7 +134,7 @@ describe('CollaboratorsInviteController', function () {
this.req.session = { user: this.current_user }
this.req.body = {
email: this.targetEmail,
- privileges: (this.privileges = 'readAndWrite')
+ privileges: (this.privileges = 'readAndWrite'),
}
this.res.json = sinon.stub()
this.res.sendStatus = sinon.stub()
@@ -144,7 +144,7 @@ describe('CollaboratorsInviteController', function () {
sendingUserId: this.current_user_id,
projectId: this.targetEmail,
targetEmail: 'user@example.com',
- createdAt: new Date()
+ createdAt: new Date(),
}
this.LimitationsManager.canAddXCollaborators = sinon
.stub()
@@ -377,7 +377,7 @@ describe('CollaboratorsInviteController', function () {
this.res.json.callCount.should.equal(1)
return {
invite: null,
- error: 'cannot_invite_non_user'
+ error: 'cannot_invite_non_user',
}.should.deep.equal(this.res.json.firstCall.args[0])
})
@@ -531,10 +531,10 @@ describe('CollaboratorsInviteController', function () {
this.token = 'some-opaque-token'
this.req.params = {
Project_id: this.project_id,
- token: this.token
+ token: this.token,
}
this.req.session = {
- user: { _id: (this.current_user_id = 'current-user-id') }
+ user: { _id: (this.current_user_id = 'current-user-id') },
}
this.res.render = sinon.stub()
this.res.redirect = sinon.stub()
@@ -545,20 +545,20 @@ describe('CollaboratorsInviteController', function () {
sendingUserId: ObjectId(),
projectId: this.project_id,
targetEmail: 'user@example.com',
- createdAt: new Date()
+ createdAt: new Date(),
}
this.fakeProject = {
_id: this.project_id,
name: 'some project',
owner_ref: this.invite.sendingUserId,
collaberator_refs: [],
- readOnly_refs: []
+ readOnly_refs: [],
}
this.owner = {
_id: this.fakeProject.owner_ref,
first_name: 'John',
last_name: 'Doe',
- email: 'john@example.com'
+ email: 'john@example.com',
}
this.CollaboratorsGetter.isUserInvitedMemberOfProject = sinon
@@ -1001,10 +1001,10 @@ describe('CollaboratorsInviteController', function () {
beforeEach(function () {
this.req.params = {
Project_id: this.project_id,
- invite_id: (this.invite_id = 'thuseoautoh')
+ invite_id: (this.invite_id = 'thuseoautoh'),
}
this.req.session = {
- user: { _id: (this.current_user_id = 'current-user-id') }
+ user: { _id: (this.current_user_id = 'current-user-id') },
}
this.res.render = sinon.stub()
this.res.sendStatus = sinon.stub()
@@ -1080,7 +1080,7 @@ describe('CollaboratorsInviteController', function () {
beforeEach(function () {
this.req.params = {
Project_id: this.project_id,
- invite_id: (this.invite_id = 'thuseoautoh')
+ invite_id: (this.invite_id = 'thuseoautoh'),
}
this.current_user = { _id: (this.current_user_id = 'current-user-id') }
this.req.session = { user: this.current_user }
@@ -1156,10 +1156,10 @@ describe('CollaboratorsInviteController', function () {
beforeEach(function () {
this.req.params = {
Project_id: this.project_id,
- token: (this.token = 'mock-token')
+ token: (this.token = 'mock-token'),
}
this.req.session = {
- user: { _id: (this.current_user_id = 'current-user-id') }
+ user: { _id: (this.current_user_id = 'current-user-id') },
}
this.res.render = sinon.stub()
this.res.redirect = sinon.stub()
diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js
index 99aba4c37f..506d8be571 100644
--- a/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js
+++ b/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js
@@ -58,26 +58,26 @@ describe('CollaboratorsInviteHandler', function () {
'../../models/ProjectInvite': { ProjectInvite: this.ProjectInvite },
'./CollaboratorsEmailHandler': (this.CollaboratorsEmailHandler = {}),
'./CollaboratorsHandler': (this.CollaboratorsHandler = {
- addUserIdToProject: sinon.stub()
+ addUserIdToProject: sinon.stub(),
}),
'../User/UserGetter': (this.UserGetter = { getUser: sinon.stub() }),
'../Project/ProjectGetter': (this.ProjectGetter = {}),
'../Notifications/NotificationsBuilder': (this.NotificationsBuilder = {}),
- crypto: this.Crypto
- }
+ crypto: this.Crypto,
+ },
})
this.projectId = ObjectId()
this.sendingUserId = ObjectId()
this.sendingUser = {
_id: this.sendingUserId,
- name: 'Bob'
+ name: 'Bob',
}
this.email = 'user@example.com'
this.userId = ObjectId()
this.user = {
_id: this.userId,
- email: 'someone@example.com'
+ email: 'someone@example.com',
}
this.inviteId = ObjectId()
this.token = 'hnhteaosuhtaeosuahs'
@@ -89,7 +89,7 @@ describe('CollaboratorsInviteHandler', function () {
sendingUserId: this.sendingUserId,
projectId: this.projectId,
privileges: this.privileges,
- createdAt: new Date()
+ createdAt: new Date(),
})
})
@@ -140,7 +140,7 @@ describe('CollaboratorsInviteHandler', function () {
beforeEach(function () {
this.fakeInvites = [
{ _id: ObjectId(), one: 1 },
- { _id: ObjectId(), two: 2 }
+ { _id: ObjectId(), two: 2 },
]
this.ProjectInvite.find.callsArgWith(1, null, this.fakeInvites)
return (this.call = callback => {
@@ -241,7 +241,7 @@ describe('CollaboratorsInviteHandler', function () {
'token',
'sendingUserId',
'projectId',
- 'privileges'
+ 'privileges',
])
return done()
})
@@ -623,7 +623,7 @@ describe('CollaboratorsInviteHandler', function () {
this.fakeProject = {
_id: this.projectId,
collaberator_refs: [],
- readOnly_refs: []
+ readOnly_refs: [],
}
this.CollaboratorsHandler.addUserIdToProject.callsArgWith(4, null)
this._getInviteByToken = sinon.stub(
@@ -928,7 +928,7 @@ describe('CollaboratorsInviteHandler', function () {
describe('when notification.read produces an error', function () {
beforeEach(function () {
this.notification = {
- read: sinon.stub().callsArgWith(0, new Error('woops'))
+ read: sinon.stub().callsArgWith(0, new Error('woops')),
}
return (this.NotificationsBuilder.projectInvite = sinon
.stub()
@@ -952,11 +952,11 @@ describe('CollaboratorsInviteHandler', function () {
sendingUserId: ObjectId(),
projectId: this.project_id,
targetEmail: 'user@example.com',
- createdAt: new Date()
+ createdAt: new Date(),
}
this.sendingUser = {
_id: ObjectId(),
- first_name: 'jim'
+ first_name: 'jim',
}
this.existingUser = { _id: ObjectId() }
this.UserGetter.getUserByAnyEmail = sinon
@@ -964,7 +964,7 @@ describe('CollaboratorsInviteHandler', function () {
.callsArgWith(2, null, this.existingUser)
this.fakeProject = {
_id: this.project_id,
- name: 'some project'
+ name: 'some project',
}
this.ProjectGetter.getProject = sinon
.stub()
diff --git a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js
index 220e30760d..07663a13d3 100644
--- a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js
+++ b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js
@@ -16,61 +16,61 @@ describe('OwnershipTransferHandler', function () {
_id: ObjectId(),
name: 'project',
owner_ref: this.user._id,
- collaberator_refs: [this.collaborator._id]
+ collaberator_refs: [this.collaborator._id],
}
this.ProjectGetter = {
promises: {
- getProject: sinon.stub().resolves(this.project)
- }
+ getProject: sinon.stub().resolves(this.project),
+ },
}
this.ProjectModel = {
updateOne: sinon.stub().returns({
- exec: sinon.stub().resolves()
- })
+ exec: sinon.stub().resolves(),
+ }),
}
this.UserGetter = {
promises: {
- getUser: sinon.stub().resolves(this.user)
- }
+ getUser: sinon.stub().resolves(this.user),
+ },
}
this.TpdsUpdateSender = {
promises: {
- moveEntity: sinon.stub().resolves()
- }
+ moveEntity: sinon.stub().resolves(),
+ },
}
this.TpdsProjectFlusher = {
promises: {
- flushProjectToTpds: sinon.stub().resolves()
- }
+ flushProjectToTpds: sinon.stub().resolves(),
+ },
}
this.CollaboratorsHandler = {
promises: {
removeUserFromProject: sinon.stub().resolves(),
- addUserIdToProject: sinon.stub().resolves()
- }
+ addUserIdToProject: sinon.stub().resolves(),
+ },
}
this.EmailHandler = {
promises: {
- sendEmail: sinon.stub().resolves()
- }
+ sendEmail: sinon.stub().resolves(),
+ },
}
this.ProjectAuditLogHandler = {
promises: {
- addEntry: sinon.stub().resolves()
- }
+ addEntry: sinon.stub().resolves(),
+ },
}
this.handler = SandboxedModule.require(MODULE_PATH, {
requires: {
'../Project/ProjectGetter': this.ProjectGetter,
'../../models/Project': {
- Project: this.ProjectModel
+ Project: this.ProjectModel,
},
'../User/UserGetter': this.UserGetter,
'../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher,
'../Project/ProjectAuditLogHandler': this.ProjectAuditLogHandler,
'../Email/EmailHandler': this.EmailHandler,
- './CollaboratorsHandler': this.CollaboratorsHandler
- }
+ './CollaboratorsHandler': this.CollaboratorsHandler,
+ },
})
})
@@ -179,7 +179,7 @@ describe('OwnershipTransferHandler', function () {
{
to: this.user.email,
project: this.project,
- newOwner: this.collaborator
+ newOwner: this.collaborator,
}
)
expect(this.EmailHandler.promises.sendEmail).to.have.been.calledWith(
@@ -187,7 +187,7 @@ describe('OwnershipTransferHandler', function () {
{
to: this.collaborator.email,
project: this.project,
- previousOwner: this.user
+ previousOwner: this.user,
}
)
})
@@ -207,7 +207,7 @@ describe('OwnershipTransferHandler', function () {
sessionUserId,
{
previousOwnerId: this.user._id,
- newOwnerId: this.collaborator._id
+ newOwnerId: this.collaborator._id,
}
)
})
diff --git a/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js b/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js
index 4418d3befc..e9fdea0115 100644
--- a/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js
+++ b/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js
@@ -23,7 +23,7 @@ describe('ClsiCookieManager', function () {
this.redis = {
auth() {},
get: sinon.stub(),
- setex: sinon.stub().callsArg(3)
+ setex: sinon.stub().callsArg(3),
}
this.project_id = '123423431321'
this.request = {
@@ -32,31 +32,31 @@ describe('ClsiCookieManager', function () {
jar: realRequst.jar,
defaults: () => {
return this.request
- }
+ },
}
this.settings = {
redis: {
- web: 'redis.something'
+ web: 'redis.something',
},
apis: {
clsi: {
- url: 'http://clsi.example.com'
- }
+ url: 'http://clsi.example.com',
+ },
},
clsiCookie: {
ttl: Math.random(),
- key: 'coooookie'
- }
+ key: 'coooookie',
+ },
}
this.requires = {
'../../infrastructure/RedisWrapper': (this.RedisWrapper = {
- client: () => this.redis
+ client: () => this.redis,
}),
'settings-sharelatex': this.settings,
- request: this.request
+ request: this.request,
}
return (this.ClsiCookieManager = SandboxedModule.require(modulePath, {
- requires: this.requires
+ requires: this.requires,
})())
})
@@ -180,9 +180,9 @@ describe('ClsiCookieManager', function () {
delete this.settings.clsiCookie.key
this.ClsiCookieManager = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
- requires: this.requires
+ requires: this.requires,
})()
return this.ClsiCookieManager.setServerId(
this.project_id,
@@ -218,9 +218,9 @@ describe('ClsiCookieManager', function () {
.returns(this.redis_secondary)
this.ClsiCookieManager = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
- requires: this.requires
+ requires: this.requires,
})()
this.ClsiCookieManager._parseServerIdFromResponse = sinon
.stub()
@@ -268,9 +268,9 @@ describe('ClsiCookieManager', function () {
delete this.settings.clsiCookie.key
this.ClsiCookieManager = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
- requires: this.requires
+ requires: this.requires,
})()
return this.ClsiCookieManager.getCookieJar(
this.project_id,
diff --git a/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js b/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js
index 391a8fceaf..41844f5d57 100644
--- a/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js
+++ b/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js
@@ -20,8 +20,8 @@ describe('ClsiFormatChecker', function () {
beforeEach(function () {
this.ClsiFormatChecker = SandboxedModule.require(modulePath, {
requires: {
- 'settings-sharelatex': (this.settings = { compileBodySizeLimitMb: 5 })
- }
+ 'settings-sharelatex': (this.settings = { compileBodySizeLimitMb: 5 }),
+ },
})
return (this.project_id = 'project-id')
})
@@ -31,17 +31,17 @@ describe('ClsiFormatChecker', function () {
return (this.resources = [
{
path: 'main.tex',
- content: 'stuff'
+ content: 'stuff',
},
{
path: 'chapters/chapter1',
- content: 'other stuff'
+ content: 'other stuff',
},
{
path: 'stuff/image/image.png',
url: `http:somewhere.com/project/${this.project_id}/file/1234124321312`,
- modified: 'more stuff'
- }
+ modified: 'more stuff',
+ },
])
})
@@ -108,7 +108,7 @@ describe('ClsiFormatChecker', function () {
.stub()
.callsArgWith(1, null, {
resources: [{ 'a.tex': 'a.tex' }, { 'b.tex': 'b.tex' }],
- totalSize: 1000000
+ totalSize: 1000000,
})
return this.ClsiFormatChecker.checkRecoursesForProblems(
this.resources,
@@ -125,19 +125,19 @@ describe('ClsiFormatChecker', function () {
beforeEach(function () {
this.resources.push({
path: 'chapters/chapter1.tex',
- content: 'other stuff'
+ content: 'other stuff',
})
return this.resources.push({
path: 'chapters.tex',
- content: 'other stuff'
+ content: 'other stuff',
})
})
it('should flag up when a nested file has folder with same subpath as file elsewhere', function (done) {
this.resources.push({
path: 'stuff/image',
- url: 'http://somwhere.com'
+ url: 'http://somwhere.com',
})
return this.ClsiFormatChecker._checkForConflictingPaths(
@@ -153,7 +153,7 @@ describe('ClsiFormatChecker', function () {
it('should flag up when a root level file has folder with same subpath as file elsewhere', function (done) {
this.resources.push({
path: 'stuff',
- content: 'other stuff'
+ content: 'other stuff',
})
return this.ClsiFormatChecker._checkForConflictingPaths(
@@ -169,7 +169,7 @@ describe('ClsiFormatChecker', function () {
it('should not flag up when the file is a substring of a path', function (done) {
this.resources.push({
path: 'stuf',
- content: 'other stuff'
+ content: 'other stuff',
})
return this.ClsiFormatChecker._checkForConflictingPaths(
@@ -186,13 +186,13 @@ describe('ClsiFormatChecker', function () {
it('should error when there is more than 5mb of data', function (done) {
this.resources.push({
path: 'massive.tex',
- content: 'hello world'.repeat(833333) // over 5mb limit
+ content: 'hello world'.repeat(833333), // over 5mb limit
})
while (this.resources.length < 20) {
this.resources.push({
path: 'chapters/chapter1.tex',
- url: 'http://somwhere.com'
+ url: 'http://somwhere.com',
})
}
@@ -211,13 +211,13 @@ describe('ClsiFormatChecker', function () {
it('should return nothing when project is correct size', function (done) {
this.resources.push({
path: 'massive.tex',
- content: 'x'.repeat(2 * 1000 * 1000)
+ content: 'x'.repeat(2 * 1000 * 1000),
})
while (this.resources.length < 20) {
this.resources.push({
path: 'chapters/chapter1.tex',
- url: 'http://somwhere.com'
+ url: 'http://somwhere.com',
})
}
diff --git a/services/web/test/unit/src/Compile/ClsiManagerTests.js b/services/web/test/unit/src/Compile/ClsiManagerTests.js
index 0ff98df914..5caa5d9ad2 100644
--- a/services/web/test/unit/src/Compile/ClsiManagerTests.js
+++ b/services/web/test/unit/src/Compile/ClsiManagerTests.js
@@ -10,19 +10,19 @@ describe('ClsiManager', function () {
clearServerId: sinon.stub().yields(),
getCookieJar: sinon.stub().callsArgWith(1, null, this.jar),
setServerId: sinon.stub().callsArgWith(2),
- _getServerId: sinon.stub()
+ _getServerId: sinon.stub(),
}
this.ClsiStateManager = {
- computeHash: sinon.stub().callsArgWith(2, null, '01234567890abcdef')
+ computeHash: sinon.stub().callsArgWith(2, null, '01234567890abcdef'),
}
this.ClsiFormatChecker = {
- checkRecoursesForProblems: sinon.stub().callsArgWith(1)
+ checkRecoursesForProblems: sinon.stub().callsArgWith(1),
}
this.Project = {}
this.ProjectEntityHandler = {}
this.ProjectGetter = {}
this.DocumentUpdaterHandler = {
- getProjectDocsIfMatch: sinon.stub().callsArgWith(2, null, null)
+ getProjectDocsIfMatch: sinon.stub().callsArgWith(2, null, null),
}
this.request = sinon.stub()
this.Metrics = {
@@ -31,7 +31,7 @@ describe('ClsiManager', function () {
this.done = sinon.stub()
}
},
- inc: sinon.stub()
+ inc: sinon.stub(),
}
this.ClsiManager = SandboxedModule.require(modulePath, {
requires: {
@@ -39,18 +39,18 @@ describe('ClsiManager', function () {
apis: {
filestore: {
url: 'filestore.example.com',
- secret: 'secret'
+ secret: 'secret',
},
clsi: {
- url: 'http://clsi.example.com'
+ url: 'http://clsi.example.com',
},
clsi_priority: {
- url: 'https://clsipremium.example.com'
- }
- }
+ url: 'https://clsipremium.example.com',
+ },
+ },
}),
'../../models/Project': {
- Project: this.Project
+ Project: this.Project,
},
'../Project/ProjectEntityHandler': this.ProjectEntityHandler,
'../Project/ProjectGetter': this.ProjectGetter,
@@ -60,8 +60,8 @@ describe('ClsiManager', function () {
'./ClsiStateManager': this.ClsiStateManager,
request: this.request,
'./ClsiFormatChecker': this.ClsiFormatChecker,
- '@overleaf/metrics': this.Metrics
- }
+ '@overleaf/metrics': this.Metrics,
+ },
})
this.project_id = 'project-id'
this.user_id = 'user-id'
@@ -86,16 +86,16 @@ describe('ClsiManager', function () {
url: `${this.settings.apis.clsi.url}/project/${this.project_id}/user/${this.user_id}/build/1234/output/output.pdf`,
path: 'output.pdf',
type: 'pdf',
- build: 1234
+ build: 1234,
},
{
url: `${this.settings.apis.clsi.url}/project/${this.project_id}/user/${this.user_id}/build/1234/output/output.log`,
path: 'output.log',
type: 'log',
- build: 1234
- }
- ]
- }
+ build: 1234,
+ },
+ ],
+ },
})
this.ClsiManager.sendRequest(
this.project_id,
@@ -123,14 +123,14 @@ describe('ClsiManager', function () {
url: `/project/${this.project_id}/user/${this.user_id}/build/1234/output/output.pdf`,
path: 'output.pdf',
type: 'pdf',
- build: 1234
+ build: 1234,
},
{
url: `/project/${this.project_id}/user/${this.user_id}/build/1234/output/output.log`,
path: 'output.log',
type: 'log',
- build: 1234
- }
+ build: 1234,
+ },
]
this.callback
.calledWith(null, this.status, outputFiles)
@@ -142,8 +142,8 @@ describe('ClsiManager', function () {
beforeEach(function () {
this.ClsiManager._postToClsi = sinon.stub().callsArgWith(4, null, {
compile: {
- status: (this.status = 'failure')
- }
+ status: (this.status = 'failure'),
+ },
})
this.ClsiManager.sendRequest(
this.project_id,
@@ -202,7 +202,7 @@ describe('ClsiManager', function () {
this.ClsiManager.sendRequestOnce
.withArgs(this.project_id, this.user_id, {
syncType: 'full',
- forceNewClsiServer: true
+ forceNewClsiServer: true,
})
.callsArgWith(3, null, (this.status = 'success'))
this.ClsiManager.sendRequestOnce
@@ -224,7 +224,7 @@ describe('ClsiManager', function () {
this.ClsiManager.sendRequestOnce
.calledWith(this.project_id, this.user_id, {
forceNewClsiServer: true,
- syncType: 'full'
+ syncType: 'full',
})
.should.equal(true)
})
@@ -247,8 +247,8 @@ describe('ClsiManager', function () {
.callsArgWith(1, new Error('failed'))
this.ClsiManager._postToClsi = sinon.stub().callsArgWith(4, null, {
compile: {
- status: (this.status = 'failure')
- }
+ status: (this.status = 'failure'),
+ },
})
this.ClsiManager.sendRequest(
this.project_id,
@@ -285,16 +285,16 @@ describe('ClsiManager', function () {
url: `${this.settings.apis.clsi.url}/project/${this.submission_id}/build/1234/output/output.pdf`,
path: 'output.pdf',
type: 'pdf',
- build: 1234
+ build: 1234,
},
{
url: `${this.settings.apis.clsi.url}/project/${this.submission_id}/build/1234/output/output.log`,
path: 'output.log',
type: 'log',
- build: 1234
- }
- ]
- }
+ build: 1234,
+ },
+ ],
+ },
})
this.ClsiManager.sendExternalRequest(
this.submission_id,
@@ -316,14 +316,14 @@ describe('ClsiManager', function () {
url: `/project/${this.submission_id}/build/1234/output/output.pdf`,
path: 'output.pdf',
type: 'pdf',
- build: 1234
+ build: 1234,
},
{
url: `/project/${this.submission_id}/build/1234/output/output.log`,
path: 'output.log',
type: 'log',
- build: 1234
- }
+ build: 1234,
+ },
]
this.callback
.calledWith(null, this.status, outputFiles)
@@ -335,8 +335,8 @@ describe('ClsiManager', function () {
beforeEach(function () {
this.ClsiManager._postToClsi = sinon.stub().callsArgWith(4, null, {
compile: {
- status: (this.status = 'failure')
- }
+ status: (this.status = 'failure'),
+ },
})
this.ClsiManager.sendExternalRequest(
this.submission_id,
@@ -358,8 +358,8 @@ describe('ClsiManager', function () {
.callsArgWith(1, new Error('failed'))
this.ClsiManager._postToClsi = sinon.stub().callsArgWith(4, null, {
compile: {
- status: (this.status = 'failure')
- }
+ status: (this.status = 'failure'),
+ },
})
this.ClsiManager.sendExternalRequest(
this.submission_id,
@@ -402,7 +402,7 @@ describe('ClsiManager', function () {
this.project_id,
{
method: 'DELETE',
- url: `${this.settings.apis.clsi.url}/project/${this.project_id}/user/${this.user_id}`
+ url: `${this.settings.apis.clsi.url}/project/${this.project_id}/user/${this.user_id}`,
},
'node-1'
)
@@ -433,28 +433,28 @@ describe('ClsiManager', function () {
_id: this.project_id,
compiler: (this.compiler = 'latex'),
rootDoc_id: 'mock-doc-id-1',
- imageName: (this.image = 'mock-image-name')
+ imageName: (this.image = 'mock-image-name'),
}
this.docs = {
'/main.tex': (this.doc_1 = {
name: 'main.tex',
_id: 'mock-doc-id-1',
- lines: ['Hello', 'world']
+ lines: ['Hello', 'world'],
}),
'/chapters/chapter1.tex': (this.doc_2 = {
name: 'chapter1.tex',
_id: 'mock-doc-id-2',
- lines: ['Chapter 1']
- })
+ lines: ['Chapter 1'],
+ }),
}
this.files = {
'/images/image.png': (this.file_1 = {
name: 'image.png',
_id: 'mock-file-id-1',
- created: new Date()
- })
+ created: new Date(),
+ }),
}
this.Project.findById = sinon.stub().callsArgWith(2, null, this.project)
@@ -493,7 +493,7 @@ describe('ClsiManager', function () {
compiler: 1,
rootDoc_id: 1,
imageName: 1,
- rootFolder: 1
+ rootFolder: 1,
})
.should.equal(true)
})
@@ -527,25 +527,25 @@ describe('ClsiManager', function () {
check: undefined,
syncType: undefined, // "full"
syncState: undefined,
- compileGroup: 'standard'
+ compileGroup: 'standard',
}, // "01234567890abcdef"
rootResourcePath: 'main.tex',
resources: [
{
path: 'main.tex',
- content: this.doc_1.lines.join('\n')
+ content: this.doc_1.lines.join('\n'),
},
{
path: 'chapters/chapter1.tex',
- content: this.doc_2.lines.join('\n')
+ content: this.doc_2.lines.join('\n'),
},
{
path: 'images/image.png',
url: `${this.settings.apis.filestore.url}/project/${this.project_id}/file/${this.file_1._id}`,
- modified: this.file_1.created.getTime()
- }
- ]
- }
+ modified: this.file_1.created.getTime(),
+ },
+ ],
+ },
})
})
})
@@ -562,7 +562,7 @@ describe('ClsiManager', function () {
this.DocumentUpdaterHandler.getProjectDocsIfMatch = sinon
.stub()
.callsArgWith(2, null, [
- { _id: this.doc_1._id, lines: this.doc_1.lines, v: 123 }
+ { _id: this.doc_1._id, lines: this.doc_1.lines, v: 123 },
])
this.ProjectEntityHandler.getAllDocPathsFromProject = sinon
.stub()
@@ -572,7 +572,7 @@ describe('ClsiManager', function () {
{
timeout: 100,
incrementalCompilesEnabled: true,
- compileGroup: 'priority'
+ compileGroup: 'priority',
},
(err, request) => {
if (err != null) {
@@ -590,7 +590,7 @@ describe('ClsiManager', function () {
compiler: 1,
rootDoc_id: 1,
imageName: 1,
- rootFolder: 1
+ rootFolder: 1,
})
.should.equal(true)
})
@@ -622,16 +622,16 @@ describe('ClsiManager', function () {
check: undefined,
syncType: 'incremental',
syncState: '01234567890abcdef',
- compileGroup: 'priority'
+ compileGroup: 'priority',
},
rootResourcePath: 'main.tex',
resources: [
{
path: 'main.tex',
- content: this.doc_1.lines.join('\n')
- }
- ]
- }
+ content: this.doc_1.lines.join('\n'),
+ },
+ ],
+ },
})
})
@@ -647,20 +647,20 @@ describe('ClsiManager', function () {
this.DocumentUpdaterHandler.getProjectDocsIfMatch = sinon
.stub()
.callsArgWith(2, null, [
- { _id: this.doc_1._id, lines: this.doc_1.lines, v: 123 }
+ { _id: this.doc_1._id, lines: this.doc_1.lines, v: 123 },
])
this.ProjectEntityHandler.getAllDocPathsFromProject = sinon
.stub()
.callsArgWith(1, null, {
'mock-doc-id-1': 'main.tex',
- 'mock-doc-id-2': '/chapters/chapter1.tex'
+ 'mock-doc-id-2': '/chapters/chapter1.tex',
})
this.ClsiManager._buildRequest(
this.project_id,
{
timeout: 100,
incrementalCompilesEnabled: true,
- rootDoc_id: 'mock-doc-id-2'
+ rootDoc_id: 'mock-doc-id-2',
},
(err, request) => {
if (err != null) {
@@ -761,13 +761,13 @@ describe('ClsiManager', function () {
'/other.tex': (this.doc_1 = {
name: 'other.tex',
_id: 'mock-doc-id-1',
- lines: ['Hello', 'world']
+ lines: ['Hello', 'world'],
}),
'/chapters/chapter1.tex': (this.doc_2 = {
name: 'chapter1.tex',
_id: 'mock-doc-id-2',
- lines: ['Chapter 1']
- })
+ lines: ['Chapter 1'],
+ }),
}
this.ProjectEntityHandler.getAllDocs = sinon
.stub()
@@ -787,8 +787,8 @@ describe('ClsiManager', function () {
'/other.tex': (this.doc_1 = {
name: 'other.tex',
_id: 'mock-doc-id-1',
- lines: ['Hello', 'world']
- })
+ lines: ['Hello', 'world'],
+ }),
}
this.ProjectEntityHandler.getAllDocs = sinon
.stub()
@@ -852,7 +852,7 @@ describe('ClsiManager', function () {
.calledWith(this.project_id, {
method: 'POST',
url,
- json: this.req
+ json: this.req,
})
.should.equal(true)
})
@@ -896,7 +896,7 @@ describe('ClsiManager', function () {
2,
null,
(this.req = {
- compile: { rootResourcePath: 'rootfile.text', options: {} }
+ compile: { rootResourcePath: 'rootfile.text', options: {} },
})
)
})
@@ -922,8 +922,8 @@ describe('ClsiManager', function () {
url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
qs: {
file: 'rootfile.text',
- image: undefined
- }
+ image: undefined,
+ },
},
'node-1'
)
@@ -954,7 +954,7 @@ describe('ClsiManager', function () {
{
method: 'GET',
url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
- qs: { file: 'main.tex', image: undefined }
+ qs: { file: 'main.tex', image: undefined },
},
'node-2'
)
@@ -983,7 +983,7 @@ describe('ClsiManager', function () {
{
method: 'GET',
url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
- qs: { file: 'main.tex', image: this.image }
+ qs: { file: 'main.tex', image: this.image },
},
'node-3'
)
@@ -998,7 +998,7 @@ describe('ClsiManager', function () {
this.request.callsArgWith(1, null, this.response)
this.opts = {
method: 'SOMETHIGN',
- url: 'http://a place on the web'
+ url: 'http://a place on the web',
}
})
@@ -1028,7 +1028,7 @@ describe('ClsiManager', function () {
this.request.yields(null, this.response)
this.opts = {
method: 'GET',
- url: 'http://clsi'
+ url: 'http://clsi',
}
})
@@ -1105,7 +1105,7 @@ describe('ClsiManager', function () {
this.response = { there: 'something' }
this.request.callsArgWith(1, null, this.response)
this.opts = {
- url: this.ClsiManager._getCompilerUrl(null, this.project_id)
+ url: this.ClsiManager._getCompilerUrl(null, this.project_id),
}
})
diff --git a/services/web/test/unit/src/Compile/ClsiStateManagerTests.js b/services/web/test/unit/src/Compile/ClsiStateManagerTests.js
index c00e2b2e0d..bd23086c76 100644
--- a/services/web/test/unit/src/Compile/ClsiStateManagerTests.js
+++ b/services/web/test/unit/src/Compile/ClsiStateManagerTests.js
@@ -22,8 +22,8 @@ describe('ClsiStateManager', function () {
this.ClsiStateManager = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': (this.settings = {}),
- '../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {})
- }
+ '../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}),
+ },
})
this.project = 'project'
this.options = { draft: true, isAutoCompile: false }
@@ -34,17 +34,17 @@ describe('ClsiStateManager', function () {
beforeEach(function (done) {
this.docs = [
{ path: '/main.tex', doc: { _id: 'doc-id-1' } },
- { path: '/folder/sub.tex', doc: { _id: 'doc-id-2' } }
+ { path: '/folder/sub.tex', doc: { _id: 'doc-id-2' } },
]
this.files = [
{
path: '/figure.pdf',
- file: { _id: 'file-id-1', rev: 123, created: 'aaaaaa' }
+ file: { _id: 'file-id-1', rev: 123, created: 'aaaaaa' },
},
{
path: '/folder/fig2.pdf',
- file: { _id: 'file-id-2', rev: 456, created: 'bbbbbb' }
- }
+ file: { _id: 'file-id-2', rev: 456, created: 'bbbbbb' },
+ },
]
this.ProjectEntityHandler.getAllEntitiesFromProject = sinon
.stub()
@@ -80,7 +80,7 @@ describe('ClsiStateManager', function () {
;[this.docs[0], this.docs[1]] = Array.from([this.docs[1], this.docs[0]])
;[this.files[0], this.files[1]] = Array.from([
this.files[1],
- this.files[0]
+ this.files[0],
])
return this.ClsiStateManager.computeHash(
this.project,
@@ -158,7 +158,7 @@ describe('ClsiStateManager', function () {
beforeEach(function (done) {
this.files.push({
path: '/newfile.tex',
- file: { _id: 'newfile-id', rev: 123 }
+ file: { _id: 'newfile-id', rev: 123 },
})
return this.ClsiStateManager.computeHash(
this.project,
diff --git a/services/web/test/unit/src/Compile/CompileControllerTests.js b/services/web/test/unit/src/Compile/CompileControllerTests.js
index 363a5d197d..9f92e3427f 100644
--- a/services/web/test/unit/src/Compile/CompileControllerTests.js
+++ b/services/web/test/unit/src/Compile/CompileControllerTests.js
@@ -26,8 +26,8 @@ describe('CompileController', function () {
email: 'user@example.com',
features: {
compileGroup: 'premium',
- compileTimeout: 100
- }
+ compileTimeout: 100,
+ },
}
this.CompileManager = { compile: sinon.stub() }
this.ClsiManager = {}
@@ -36,26 +36,26 @@ describe('CompileController', function () {
this.settings = {
apis: {
clsi: {
- url: 'clsi.example.com'
+ url: 'clsi.example.com',
},
clsi_priority: {
- url: 'clsi-priority.example.com'
- }
+ url: 'clsi-priority.example.com',
+ },
},
defaultFeatures: {
compileGroup: 'standard',
- compileTimeout: 60
- }
+ compileTimeout: 60,
+ },
}
this.jar = { cookie: 'stuff' }
this.ClsiCookieManager = {
- getCookieJar: sinon.stub().callsArgWith(1, null, this.jar)
+ getCookieJar: sinon.stub().callsArgWith(1, null, this.jar),
}
this.AuthenticationController = {
getLoggedInUser: sinon.stub().callsArgWith(1, null, this.user),
getLoggedInUserId: sinon.stub().returns(this.user_id),
getSessionUser: sinon.stub().returns(this.user),
- isUserLoggedIn: sinon.stub().returns(true)
+ isUserLoggedIn: sinon.stub().returns(true),
}
this.CompileController = SandboxedModule.require(modulePath, {
requires: {
@@ -69,8 +69,8 @@ describe('CompileController', function () {
'../Authentication/AuthenticationController': this
.AuthenticationController,
'../../infrastructure/RateLimiter': this.RateLimiter,
- './ClsiCookieManager': () => this.ClsiCookieManager
- }
+ './ClsiCookieManager': () => this.ClsiCookieManager,
+ },
})
this.project_id = 'project-id'
this.next = sinon.stub()
@@ -118,7 +118,7 @@ describe('CompileController', function () {
this.res.body.should.equal(
JSON.stringify({
status: this.status,
- outputFiles: this.outputFiles
+ outputFiles: this.outputFiles,
})
)
})
@@ -147,7 +147,7 @@ describe('CompileController', function () {
return this.CompileManager.compile
.calledWith(this.project_id, this.user_id, {
isAutoCompile: false,
- draft: true
+ draft: true,
})
.should.equal(true)
})
@@ -186,7 +186,7 @@ describe('CompileController', function () {
status: this.status,
outputFiles: this.outputFiles,
clsiServerId: 'mock-server-id',
- validationProblems: null
+ validationProblems: null,
})
)
})
@@ -195,7 +195,7 @@ describe('CompileController', function () {
beforeEach(function () {
this.req.body = {
compileGroup: 'special',
- timeout: 600
+ timeout: 600,
}
return this.CompileController.compileSubmission(
this.req,
@@ -221,7 +221,7 @@ describe('CompileController', function () {
rootResourcePath: 'main.tex',
compiler: 'lualatex',
draft: true,
- check: 'validate'
+ check: 'validate',
}
return this.CompileController.compileSubmission(
this.req,
@@ -238,7 +238,7 @@ describe('CompileController', function () {
rootResourcePath: 'main.tex',
compiler: 'lualatex',
draft: true,
- check: 'validate'
+ check: 'validate',
},
{
rootResourcePath: 'main.tex',
@@ -246,7 +246,7 @@ describe('CompileController', function () {
draft: true,
check: 'validate',
compileGroup: 'standard',
- timeout: 60
+ timeout: 60,
}
)
.should.equal(true)
@@ -359,7 +359,7 @@ describe('CompileController', function () {
this.req.params = {
submission_id: this.submission_id,
build_id: this.build_id,
- file: this.file
+ file: this.file,
}
this.req.body = {}
this.expected_url = `/project/${this.submission_id}/build/${this.build_id}/output/${this.file}`
@@ -378,7 +378,7 @@ describe('CompileController', function () {
it('should proxy to CLSI with correct URL and default limits', function () {
return this.CompileController.proxyToClsiWithLimits
.calledWith(this.submission_id, this.expected_url, {
- compileGroup: 'standard'
+ compileGroup: 'standard',
})
.should.equal(true)
})
@@ -397,7 +397,7 @@ describe('CompileController', function () {
it('should proxy to CLSI with correct URL and specified limits', function () {
return this.CompileController.proxyToClsiWithLimits
.calledWith(this.submission_id, this.expected_url, {
- compileGroup: 'special'
+ compileGroup: 'special',
})
.should.equal(true)
})
@@ -428,7 +428,7 @@ describe('CompileController', function () {
this.project_id,
{
url: `/project/${this.project_id}/user/${this.user_id}/sync/code`,
- qs: { file, line, column, imageName }
+ qs: { file, line, column, imageName },
},
this.req,
this.res,
@@ -462,7 +462,7 @@ describe('CompileController', function () {
this.project_id,
{
url: `/project/${this.project_id}/user/${this.user_id}/sync/pdf`,
- qs: { page, h, v, imageName }
+ qs: { page, h, v, imageName },
},
this.req,
this.res,
@@ -476,19 +476,19 @@ describe('CompileController', function () {
this.request.returns(
(this.proxy = {
pipe: sinon.stub(),
- on: sinon.stub()
+ on: sinon.stub(),
})
)
this.upstream = {
statusCode: 204,
- headers: { mock: 'header' }
+ headers: { mock: 'header' },
}
this.req.method = 'mock-method'
return (this.req.headers = {
Mock: 'Headers',
Range: '123-456',
'If-Range': 'abcdef',
- 'If-Modified-Since': 'Mon, 15 Dec 2014 15:23:56 GMT'
+ 'If-Modified-Since': 'Mon, 15 Dec 2014 15:23:56 GMT',
})
})
@@ -513,7 +513,7 @@ describe('CompileController', function () {
jar: this.jar,
method: this.req.method,
url: `${this.settings.apis.clsi.url}${this.url}`,
- timeout: 60 * 1000
+ timeout: 60 * 1000,
})
.should.equal(true)
})
@@ -560,7 +560,7 @@ describe('CompileController', function () {
jar: this.jar,
method: this.req.method,
url: `${this.settings.apis.clsi.url}${this.url}`,
- timeout: 60 * 1000
+ timeout: 60 * 1000,
})
.should.equal(true)
})
@@ -592,7 +592,7 @@ describe('CompileController', function () {
jar: this.jar,
method: this.req.method,
url: `${this.settings.apis.clsi.url}${this.url}`,
- timeout: 60 * 1000
+ timeout: 60 * 1000,
})
.should.equal(true)
})
@@ -619,7 +619,7 @@ describe('CompileController', function () {
jar: this.jar,
method: this.req.method,
url: `${this.settings.apis.clsi.url}${this.url}`,
- timeout: 60 * 1000
+ timeout: 60 * 1000,
})
.should.equal(true)
})
@@ -654,8 +654,8 @@ describe('CompileController', function () {
headers: {
Range: '123-456',
'If-Range': 'abcdef',
- 'If-Modified-Since': 'Mon, 15 Dec 2014 15:23:56 GMT'
- }
+ 'If-Modified-Since': 'Mon, 15 Dec 2014 15:23:56 GMT',
+ },
})
.should.equal(true)
})
@@ -695,8 +695,8 @@ describe('CompileController', function () {
headers: {
Range: '123-456',
'If-Range': 'abcdef',
- 'If-Modified-Since': 'Mon, 15 Dec 2014 15:23:56 GMT'
- }
+ 'If-Modified-Since': 'Mon, 15 Dec 2014 15:23:56 GMT',
+ },
})
.should.equal(true)
})
@@ -732,8 +732,8 @@ describe('CompileController', function () {
beforeEach(function () {
this.req = {
params: {
- project_id: this.project_id
- }
+ project_id: this.project_id,
+ },
}
this.CompileManager.compile.callsArgWith(3)
this.CompileController.proxyToClsi = sinon.stub()
diff --git a/services/web/test/unit/src/Compile/CompileManagerTests.js b/services/web/test/unit/src/Compile/CompileManagerTests.js
index 2d880e0096..5fcf9a33c1 100644
--- a/services/web/test/unit/src/Compile/CompileManagerTests.js
+++ b/services/web/test/unit/src/Compile/CompileManagerTests.js
@@ -27,12 +27,12 @@ describe('CompileManager', function () {
requires: {
'settings-sharelatex': (this.settings = {
redis: { web: { host: 'localhost', port: 42 } },
- rateLimit: { autoCompile: {} }
+ rateLimit: { autoCompile: {} },
}),
'../../infrastructure/RedisWrapper': {
client: () => {
return (this.rclient = { auth() {} })
- }
+ },
},
'../Project/ProjectRootDocManager': (this.ProjectRootDocManager = {}),
'../Project/ProjectGetter': (this.ProjectGetter = {}),
@@ -49,15 +49,15 @@ describe('CompileManager', function () {
Timer.initClass()
return Timer
})()),
- inc: sinon.stub()
- })
- }
+ inc: sinon.stub(),
+ }),
+ },
})
this.project_id = 'mock-project-id-123'
this.user_id = 'mock-user-id-123'
this.callback = sinon.stub()
return (this.limits = {
- timeout: 42
+ timeout: 42,
})
})
@@ -119,7 +119,7 @@ describe('CompileManager', function () {
it('should run the compile with the compile limits', function () {
return this.ClsiManager.sendRequest
.calledWith(this.project_id, this.user_id, {
- timeout: this.limits.timeout
+ timeout: this.limits.timeout,
})
.should.equal(true)
})
@@ -179,7 +179,7 @@ describe('CompileManager', function () {
beforeEach(function () {
this.features = {
compileTimeout: (this.timeout = 42),
- compileGroup: (this.group = 'priority')
+ compileGroup: (this.group = 'priority'),
}
this.ProjectGetter.getProject = sinon
.stub()
@@ -208,7 +208,7 @@ describe('CompileManager', function () {
.calledWith(this.project.owner_ref, {
alphaProgram: 1,
betaProgram: 1,
- features: 1
+ features: 1,
})
.should.equal(true)
})
@@ -217,7 +217,7 @@ describe('CompileManager', function () {
return this.callback
.calledWith(null, {
timeout: this.timeout,
- compileGroup: this.group
+ compileGroup: this.group,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Contact/ContactControllerTests.js b/services/web/test/unit/src/Contact/ContactControllerTests.js
index e595e46773..9ddf5d1d77 100644
--- a/services/web/test/unit/src/Contact/ContactControllerTests.js
+++ b/services/web/test/unit/src/Contact/ContactControllerTests.js
@@ -26,8 +26,8 @@ describe('ContactController', function () {
'../Authentication/AuthenticationController': (this.AuthenticationController = {}),
'../../infrastructure/Modules': (this.Modules = { hooks: {} }),
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
})
this.next = sinon.stub()
@@ -47,7 +47,7 @@ describe('ContactController', function () {
email: 'joe@example.com',
first_name: 'Joe',
last_name: 'Example',
- unsued: 'foo'
+ unsued: 'foo',
},
{
_id: 'contact-2',
@@ -55,15 +55,15 @@ describe('ContactController', function () {
first_name: 'Jane',
last_name: 'Example',
unsued: 'foo',
- holdingAccount: true
+ holdingAccount: true,
},
{
_id: 'contact-3',
email: 'jim@example.com',
first_name: 'Jim',
last_name: 'Example',
- unsued: 'foo'
- }
+ unsued: 'foo',
+ },
]
this.AuthenticationController.getLoggedInUserId = sinon
.stub()
@@ -97,7 +97,7 @@ describe('ContactController', function () {
email: 1,
first_name: 1,
last_name: 1,
- holdingAccount: 1
+ holdingAccount: 1,
})
.should.equal(true)
})
@@ -115,15 +115,15 @@ describe('ContactController', function () {
email: 'joe@example.com',
first_name: 'Joe',
last_name: 'Example',
- type: 'user'
+ type: 'user',
},
{
id: 'contact-3',
email: 'jim@example.com',
first_name: 'Jim',
last_name: 'Example',
- type: 'user'
- }
+ type: 'user',
+ },
])
})
})
diff --git a/services/web/test/unit/src/Contact/ContactManagerTests.js b/services/web/test/unit/src/Contact/ContactManagerTests.js
index a7d04ff35e..0eeb2a101f 100644
--- a/services/web/test/unit/src/Contact/ContactManagerTests.js
+++ b/services/web/test/unit/src/Contact/ContactManagerTests.js
@@ -21,11 +21,11 @@ describe('ContactManager', function () {
'settings-sharelatex': (this.settings = {
apis: {
contacts: {
- url: 'contacts.sharelatex.com'
- }
- }
- })
- }
+ url: 'contacts.sharelatex.com',
+ },
+ },
+ }),
+ },
})
this.user_id = 'user-id-123'
@@ -57,7 +57,7 @@ describe('ContactManager', function () {
url: `${this.settings.apis.contacts.url}/user/${this.user_id}/contacts`,
qs: { limit: 42 },
json: true,
- jar: false
+ jar: false,
})
.should.equal(true)
})
@@ -116,9 +116,9 @@ describe('ContactManager', function () {
.calledWith({
url: `${this.settings.apis.contacts.url}/user/${this.user_id}/contacts`,
json: {
- contact_id: this.contact_id
+ contact_id: this.contact_id,
},
- jar: false
+ jar: false,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Cooldown/CooldownManagerTests.js b/services/web/test/unit/src/Cooldown/CooldownManagerTests.js
index 8e73e30c3c..1b7768bfd2 100644
--- a/services/web/test/unit/src/Cooldown/CooldownManagerTests.js
+++ b/services/web/test/unit/src/Cooldown/CooldownManagerTests.js
@@ -25,8 +25,8 @@ describe('CooldownManager', function () {
this.RedisWrapper = { client: () => this.rclient }
return (this.CooldownManager = SandboxedModule.require(modulePath, {
requires: {
- '../../infrastructure/RedisWrapper': this.RedisWrapper
- }
+ '../../infrastructure/RedisWrapper': this.RedisWrapper,
+ },
}))
})
diff --git a/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js b/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js
index 2564c0bf44..e4d8a1f514 100644
--- a/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js
+++ b/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js
@@ -22,8 +22,8 @@ describe('CooldownMiddleware', function () {
this.CooldownManager = { isProjectOnCooldown: sinon.stub() }
return (this.CooldownMiddleware = SandboxedModule.require(modulePath, {
requires: {
- './CooldownManager': this.CooldownManager
- }
+ './CooldownManager': this.CooldownManager,
+ },
}))
})
diff --git a/services/web/test/unit/src/Docstore/DocstoreManagerTests.js b/services/web/test/unit/src/Docstore/DocstoreManagerTests.js
index d3f2731aa1..ebfcbb9816 100644
--- a/services/web/test/unit/src/Docstore/DocstoreManagerTests.js
+++ b/services/web/test/unit/src/Docstore/DocstoreManagerTests.js
@@ -21,16 +21,16 @@ describe('DocstoreManager', function () {
this.DocstoreManager = SandboxedModule.require(modulePath, {
requires: {
request: {
- defaults: this.requestDefaults
+ defaults: this.requestDefaults,
},
'settings-sharelatex': (this.settings = {
apis: {
docstore: {
- url: 'docstore.sharelatex.com'
- }
- }
- })
- }
+ url: 'docstore.sharelatex.com',
+ },
+ },
+ }),
+ },
})
this.requestDefaults.calledWith({ jar: false }).should.equal(true)
@@ -68,7 +68,7 @@ describe('DocstoreManager', function () {
.calledWith({
url: `${this.settings.apis.docstore.url}/project/${this.project_id}/doc/${this.doc_id}`,
json: { deleted: true, deletedAt: new Date(), name: 'wombat.tex' },
- timeout: 30 * 1000
+ timeout: 30 * 1000,
})
.should.equal(true)
})
@@ -176,8 +176,8 @@ describe('DocstoreManager', function () {
json: {
lines: this.lines,
version: this.version,
- ranges: this.ranges
- }
+ ranges: this.ranges,
+ },
})
.should.equal(true)
})
@@ -227,7 +227,7 @@ describe('DocstoreManager', function () {
lines: (this.lines = ['mock', 'doc', 'lines']),
rev: (this.rev = 5),
version: (this.version = 42),
- ranges: (this.ranges = { mock: 'ranges' })
+ ranges: (this.ranges = { mock: 'ranges' }),
})
})
@@ -248,7 +248,7 @@ describe('DocstoreManager', function () {
.calledWith({
url: `${this.settings.apis.docstore.url}/project/${this.project_id}/doc/${this.doc_id}`,
timeout: 30 * 1000,
- json: true
+ json: true,
})
.should.equal(true)
})
@@ -306,7 +306,7 @@ describe('DocstoreManager', function () {
.calledWith({
url: `${this.settings.apis.docstore.url}/project/${this.project_id}/doc/${this.doc_id}?include_deleted=true`,
timeout: 30 * 1000,
- json: true
+ json: true,
})
.should.equal(true)
})
@@ -361,7 +361,7 @@ describe('DocstoreManager', function () {
.calledWith({
url: `${this.settings.apis.docstore.url}/project/${this.project_id}/doc`,
timeout: 30 * 1000,
- json: true
+ json: true,
})
.should.equal(true)
})
@@ -411,7 +411,7 @@ describe('DocstoreManager', function () {
this.request.get.should.have.been.calledWith({
url: `${this.settings.apis.docstore.url}/project/${this.project_id}/doc-deleted`,
timeout: 30 * 1000,
- json: true
+ json: true,
})
})
@@ -481,7 +481,7 @@ describe('DocstoreManager', function () {
.calledWith({
url: `${this.settings.apis.docstore.url}/project/${this.project_id}/ranges`,
timeout: 30 * 1000,
- json: true
+ json: true,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js b/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js
index 035009f1aa..e0c4d8ce27 100644
--- a/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js
+++ b/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js
@@ -22,12 +22,12 @@ describe('DocumentUpdaterHandler', function () {
this.settings = {
apis: {
documentupdater: {
- url: 'http://document_updater.example.com'
+ url: 'http://document_updater.example.com',
},
project_history: {
- url: 'http://project_history.example.com'
- }
- }
+ url: 'http://project_history.example.com',
+ },
+ },
}
this.callback = sinon.stub()
@@ -36,20 +36,20 @@ describe('DocumentUpdaterHandler', function () {
request: {
defaults: () => {
return this.request
- }
+ },
},
'settings-sharelatex': this.settings,
'../Project/ProjectEntityHandler': this.projectEntityHandler,
'../../models/Project': {
- Project: (this.Project = {})
+ Project: (this.Project = {}),
},
'../../Features/Project/ProjectLocator': {},
'@overleaf/metrics': {
Timer: class {
done() {}
- }
- }
- }
+ },
+ },
+ },
})
})
@@ -64,7 +64,7 @@ describe('DocumentUpdaterHandler', function () {
this.request
.calledWithMatch({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}/flush`,
- method: 'POST'
+ method: 'POST',
})
.should.equal(true)
})
@@ -129,7 +129,7 @@ describe('DocumentUpdaterHandler', function () {
this.request
.calledWithMatch({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}`,
- method: 'DELETE'
+ method: 'DELETE',
})
.should.equal(true)
})
@@ -201,7 +201,7 @@ describe('DocumentUpdaterHandler', function () {
this.request
.calledWithMatch({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}/flush`,
- method: 'POST'
+ method: 'POST',
})
.should.equal(true)
})
@@ -271,7 +271,7 @@ describe('DocumentUpdaterHandler', function () {
this.request
.calledWithMatch({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}`,
- method: 'DELETE'
+ method: 'DELETE',
})
.should.equal(true)
})
@@ -347,9 +347,9 @@ describe('DocumentUpdaterHandler', function () {
json: {
lines: this.lines,
source: this.source,
- user_id: this.user_id
+ user_id: this.user_id,
},
- method: 'POST'
+ method: 'POST',
})
.should.equal(true)
})
@@ -421,7 +421,7 @@ describe('DocumentUpdaterHandler', function () {
lines: this.lines,
version: this.version,
ops: (this.ops = ['mock-op-1', 'mock-op-2']),
- ranges: (this.ranges = { mock: 'ranges' })
+ ranges: (this.ranges = { mock: 'ranges' }),
}
this.fromVersion = 2
this.request.callsArgWith(1, null, { statusCode: 200 }, this.body)
@@ -438,7 +438,7 @@ describe('DocumentUpdaterHandler', function () {
.calledWith({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}?fromVersion=${this.fromVersion}`,
method: 'GET',
- json: true
+ json: true,
})
.should.equal(true)
})
@@ -511,7 +511,7 @@ describe('DocumentUpdaterHandler', function () {
this.doc0 = {
_id: this.doc_id,
lines: this.lines,
- v: this.version
+ v: this.version,
}
this.docs = [this.doc0, this.doc0, this.doc0]
this.body = JSON.stringify(this.docs)
@@ -583,7 +583,7 @@ describe('DocumentUpdaterHandler', function () {
this.request
.calledWithMatch({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}/clearState`,
- method: 'POST'
+ method: 'POST',
})
.should.equal(true)
})
@@ -655,9 +655,9 @@ describe('DocumentUpdaterHandler', function () {
.calledWith({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}/change/accept`,
json: {
- change_ids: [this.change_id]
+ change_ids: [this.change_id],
},
- method: 'POST'
+ method: 'POST',
})
.should.equal(true)
})
@@ -738,7 +738,7 @@ describe('DocumentUpdaterHandler', function () {
this.request
.calledWithMatch({
url: `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}/comment/${this.thread_id}`,
- method: 'DELETE'
+ method: 'DELETE',
})
.should.equal(true)
})
@@ -840,20 +840,20 @@ describe('DocumentUpdaterHandler', function () {
this.changes = {
oldDocs: [
{ path: '/old_a', doc: { _id: this.docIdA } },
- { path: '/old_b', doc: { _id: this.docIdB } }
+ { path: '/old_b', doc: { _id: this.docIdB } },
],
// create new instances of the same ObjectIds so that == doesn't pass
newDocs: [
{
path: '/old_a',
- doc: { _id: new ObjectId(this.docIdA.toString()) }
+ doc: { _id: new ObjectId(this.docIdA.toString()) },
},
{
path: '/new_b',
- doc: { _id: new ObjectId(this.docIdB.toString()) }
- }
+ doc: { _id: new ObjectId(this.docIdB.toString()) },
+ },
],
- newProject: { version: this.version }
+ newProject: { version: this.version },
}
const updates = [
@@ -861,8 +861,8 @@ describe('DocumentUpdaterHandler', function () {
type: 'rename-doc',
id: this.docIdB.toString(),
pathname: '/old_b',
- newPathname: '/new_b'
- }
+ newPathname: '/new_b',
+ },
]
this.handler.updateProjectStructure(
@@ -879,8 +879,8 @@ describe('DocumentUpdaterHandler', function () {
updates,
userId: this.user_id,
version: this.version,
- projectHistoryId: this.projectHistoryId
- }
+ projectHistoryId: this.projectHistoryId,
+ },
})
.should.equal(true)
done()
@@ -894,9 +894,9 @@ describe('DocumentUpdaterHandler', function () {
this.docId = new ObjectId()
this.changes = {
newDocs: [
- { path: '/foo', docLines: 'a\nb', doc: { _id: this.docId } }
+ { path: '/foo', docLines: 'a\nb', doc: { _id: this.docId } },
],
- newProject: { version: this.version }
+ newProject: { version: this.version },
}
const updates = [
@@ -906,8 +906,8 @@ describe('DocumentUpdaterHandler', function () {
pathname: '/foo',
docLines: 'a\nb',
url: undefined,
- hash: undefined
- }
+ hash: undefined,
+ },
]
this.handler.updateProjectStructure(
@@ -924,8 +924,8 @@ describe('DocumentUpdaterHandler', function () {
updates,
userId: this.user_id,
version: this.version,
- projectHistoryId: this.projectHistoryId
- }
+ projectHistoryId: this.projectHistoryId,
+ },
})
.should.equal(true)
done()
@@ -942,10 +942,10 @@ describe('DocumentUpdaterHandler', function () {
{
path: '/bar',
url: 'filestore.example.com/file',
- file: { _id: this.fileId, hash: '12345' }
- }
+ file: { _id: this.fileId, hash: '12345' },
+ },
],
- newProject: { version: this.version }
+ newProject: { version: this.version },
}
const updates = [
@@ -955,8 +955,8 @@ describe('DocumentUpdaterHandler', function () {
pathname: '/bar',
url: 'filestore.example.com/file',
docLines: undefined,
- hash: '12345'
- }
+ hash: '12345',
+ },
]
this.handler.updateProjectStructure(
@@ -973,8 +973,8 @@ describe('DocumentUpdaterHandler', function () {
updates,
userId: this.user_id,
version: this.version,
- projectHistoryId: this.projectHistoryId
- }
+ projectHistoryId: this.projectHistoryId,
+ },
})
.should.equal(true)
done()
@@ -988,9 +988,9 @@ describe('DocumentUpdaterHandler', function () {
this.docId = new ObjectId()
this.changes = {
oldDocs: [
- { path: '/foo', docLines: 'a\nb', doc: { _id: this.docId } }
+ { path: '/foo', docLines: 'a\nb', doc: { _id: this.docId } },
],
- newProject: { version: this.version }
+ newProject: { version: this.version },
}
const updates = [
@@ -998,8 +998,8 @@ describe('DocumentUpdaterHandler', function () {
type: 'rename-doc',
id: this.docId.toString(),
pathname: '/foo',
- newPathname: ''
- }
+ newPathname: '',
+ },
]
this.handler.updateProjectStructure(
@@ -1016,8 +1016,8 @@ describe('DocumentUpdaterHandler', function () {
updates,
userId: this.user_id,
version: this.version,
- projectHistoryId: this.projectHistoryId
- }
+ projectHistoryId: this.projectHistoryId,
+ },
})
.should.equal(true)
done()
@@ -1035,17 +1035,17 @@ describe('DocumentUpdaterHandler', function () {
{
path: '/foo.doc',
url: 'filestore.example.com/file',
- file: { _id: this.fileId }
- }
+ file: { _id: this.fileId },
+ },
],
newDocs: [
{
path: '/foo.doc',
docLines: 'hello there',
- doc: { _id: this.docId }
- }
+ doc: { _id: this.docId },
+ },
],
- newProject: { version: this.version }
+ newProject: { version: this.version },
}
const updates = [
@@ -1053,7 +1053,7 @@ describe('DocumentUpdaterHandler', function () {
type: 'rename-file',
id: this.fileId.toString(),
pathname: '/foo.doc',
- newPathname: ''
+ newPathname: '',
},
{
type: 'add-doc',
@@ -1061,8 +1061,8 @@ describe('DocumentUpdaterHandler', function () {
pathname: '/foo.doc',
docLines: 'hello there',
url: undefined,
- hash: undefined
- }
+ hash: undefined,
+ },
]
this.handler.updateProjectStructure(
@@ -1078,8 +1078,8 @@ describe('DocumentUpdaterHandler', function () {
updates,
userId: this.user_id,
version: this.version,
- projectHistoryId: this.projectHistoryId
- }
+ projectHistoryId: this.projectHistoryId,
+ },
})
done()
}
@@ -1092,8 +1092,8 @@ describe('DocumentUpdaterHandler', function () {
this.docId = new ObjectId()
this.changes = {
oldDocs: [
- { path: '/foo', docLines: 'a\nb', doc: { _id: this.docId } }
- ]
+ { path: '/foo', docLines: 'a\nb', doc: { _id: this.docId } },
+ ],
}
this.handler.updateProjectStructure(
diff --git a/services/web/test/unit/src/Documents/DocumentControllerTests.js b/services/web/test/unit/src/Documents/DocumentControllerTests.js
index 90d2917082..4eedcf7006 100644
--- a/services/web/test/unit/src/Documents/DocumentControllerTests.js
+++ b/services/web/test/unit/src/Documents/DocumentControllerTests.js
@@ -27,8 +27,8 @@ describe('DocumentController', function () {
'../Project/ProjectGetter': (this.ProjectGetter = {}),
'../Project/ProjectLocator': (this.ProjectLocator = {}),
'../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}),
- '../Project/ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {})
- }
+ '../Project/ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {}),
+ },
})
this.res = new MockResponse()
this.req = new MockRequest()
@@ -48,7 +48,7 @@ describe('DocumentController', function () {
beforeEach(function () {
return (this.req.params = {
Project_id: this.project_id,
- doc_id: this.doc_id
+ doc_id: this.doc_id,
})
})
@@ -94,7 +94,7 @@ describe('DocumentController', function () {
.calledWith({
project: this.project,
element_id: this.doc_id,
- type: 'doc'
+ type: 'doc',
})
.should.equal(true)
})
@@ -112,7 +112,7 @@ describe('DocumentController', function () {
lines: this.doc_lines,
version: this.version,
ranges: this.ranges,
- pathname: this.pathname
+ pathname: this.pathname,
})
)
})
@@ -149,9 +149,9 @@ describe('DocumentController', function () {
overleaf: {
history: {
id: this.projectHistoryId,
- display: this.projectHistoryDisplay
- }
- }
+ display: this.projectHistoryDisplay,
+ },
+ },
}
this.ProjectGetter.getProject = sinon
.stub()
@@ -185,7 +185,7 @@ describe('DocumentController', function () {
ranges: this.ranges,
pathname: this.pathname,
projectHistoryId: this.projectHistoryId,
- projectHistoryType: this.projectHistoryType
+ projectHistoryType: this.projectHistoryType,
})
)
})
@@ -211,7 +211,7 @@ describe('DocumentController', function () {
beforeEach(function () {
return (this.req.params = {
Project_id: this.project_id,
- doc_id: this.doc_id
+ doc_id: this.doc_id,
})
})
@@ -223,7 +223,7 @@ describe('DocumentController', function () {
version: this.version,
ranges: this.ranges,
lastUpdatedAt: this.lastUpdatedAt,
- lastUpdatedBy: this.lastUpdatedBy
+ lastUpdatedBy: this.lastUpdatedBy,
}
return this.DocumentController.setDocument(
this.req,
diff --git a/services/web/test/unit/src/Documents/DocumentHelperTests.js b/services/web/test/unit/src/Documents/DocumentHelperTests.js
index 268c78edb3..7a4017a821 100644
--- a/services/web/test/unit/src/Documents/DocumentHelperTests.js
+++ b/services/web/test/unit/src/Documents/DocumentHelperTests.js
@@ -145,7 +145,7 @@ describe('DocumentHelper', function () {
'% line',
'% line',
'% line',
- ' asdf \\documentclass'
+ ' asdf \\documentclass',
]
return expect(
this.DocumentHelper.contentHasDocumentclass(document)
diff --git a/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js b/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js
index 13863b156e..538c5bc7bd 100644
--- a/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js
+++ b/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js
@@ -33,8 +33,8 @@ describe('ProjectDownloadsController', function () {
'../Project/ProjectGetter': (this.ProjectGetter = {}),
'@overleaf/metrics': (this.metrics = {}),
'../DocumentUpdater/DocumentUpdaterHandler': this
- .DocumentUpdaterHandler
- }
+ .DocumentUpdaterHandler,
+ },
}
))
})
@@ -148,7 +148,7 @@ describe('ProjectDownloadsController', function () {
it('should name the downloaded file after the project', function () {
return this.res.setContentDisposition
.calledWith('attachment', {
- filename: 'Overleaf Projects (2 items).zip'
+ filename: 'Overleaf Projects (2 items).zip',
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js b/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js
index acb072d50f..98c71e1754 100644
--- a/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js
+++ b/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js
@@ -28,15 +28,15 @@ describe('ProjectZipStreamManager', function () {
this.callback = sinon.stub()
this.archive = {
on() {},
- append: sinon.stub()
+ append: sinon.stub(),
}
return (this.ProjectZipStreamManager = SandboxedModule.require(modulePath, {
requires: {
archiver: (this.archiver = sinon.stub().returns(this.archive)),
'../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}),
'../FileStore/FileStoreHandler': (this.FileStoreHandler = {}),
- '../Project/ProjectGetter': (this.ProjectGetter = {})
- }
+ '../Project/ProjectGetter': (this.ProjectGetter = {}),
+ },
}))
})
@@ -46,12 +46,12 @@ describe('ProjectZipStreamManager', function () {
this.project_ids = ['project-1', 'project-2']
this.zip_streams = {
'project-1': new EventEmitter(),
- 'project-2': new EventEmitter()
+ 'project-2': new EventEmitter(),
}
this.project_names = {
'project-1': 'Project One Name',
- 'project-2': 'Project Two Name'
+ 'project-2': 'Project Two Name',
}
this.ProjectZipStreamManager.createZipStreamForProject = (
@@ -114,7 +114,7 @@ describe('ProjectZipStreamManager', function () {
return Array.from(this.project_ids).map(project_id =>
this.archive.append
.calledWith(this.zip_streams[project_id], {
- name: this.project_names[project_id] + '.zip'
+ name: this.project_names[project_id] + '.zip',
})
.should.equal(true)
)
@@ -244,12 +244,12 @@ describe('ProjectZipStreamManager', function () {
'\\documentclass{article}',
'\\begin{document}',
'Hello world',
- '\\end{document}'
- ]
+ '\\end{document}',
+ ],
},
'/chapters/chapter1.tex': {
- lines: ['chapter1', 'content']
- }
+ lines: ['chapter1', 'content'],
+ },
}
this.ProjectEntityHandler.getAllDocs = sinon
.stub()
@@ -291,15 +291,15 @@ describe('ProjectZipStreamManager', function () {
beforeEach(function () {
this.files = {
'/image.png': {
- _id: 'file-id-1'
+ _id: 'file-id-1',
},
'/folder/picture.png': {
- _id: 'file-id-2'
- }
+ _id: 'file-id-2',
+ },
}
this.streams = {
'file-id-1': new EventEmitter(),
- 'file-id-2': new EventEmitter()
+ 'file-id-2': new EventEmitter(),
}
this.ProjectEntityHandler.getAllFiles = sinon
.stub()
diff --git a/services/web/test/unit/src/Editor/EditorControllerTests.js b/services/web/test/unit/src/Editor/EditorControllerTests.js
index aca5be3623..8dca636c2d 100644
--- a/services/web/test/unit/src/Editor/EditorControllerTests.js
+++ b/services/web/test/unit/src/Editor/EditorControllerTests.js
@@ -51,23 +51,23 @@ describe('EditorController', function () {
'../Project/ProjectOptionsHandler': (this.ProjectOptionsHandler = {
setCompiler: sinon.stub().yields(),
setImageName: sinon.stub().yields(),
- setSpellCheckLanguage: sinon.stub().yields()
+ setSpellCheckLanguage: sinon.stub().yields(),
}),
'../Project/ProjectDetailsHandler': (this.ProjectDetailsHandler = {
setProjectDescription: sinon.stub().yields(),
renameProject: sinon.stub().yields(),
- setPublicAccessLevel: sinon.stub().yields()
+ setPublicAccessLevel: sinon.stub().yields(),
}),
'../Project/ProjectDeleter': (this.ProjectDeleter = {}),
'../DocumentUpdater/DocumentUpdaterHandler': (this.DocumentUpdaterHandler = {
flushDocToMongo: sinon.stub().yields(),
- setDocument: sinon.stub().yields()
+ setDocument: sinon.stub().yields(),
}),
'./EditorRealTimeController': (this.EditorRealTimeController = {
- emitToRoom: sinon.stub()
+ emitToRoom: sinon.stub(),
}),
- '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() })
- }
+ '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }),
+ },
}))
})
@@ -352,7 +352,7 @@ describe('EditorController', function () {
beforeEach(function () {
const folders = [
(this.folderA = { _id: 2, parentFolder_id: 1 }),
- (this.folderB = { _id: 3, parentFolder_id: 2 })
+ (this.folderB = { _id: 3, parentFolder_id: 2 }),
]
this.ProjectEntityUpdateHandler.upsertDocWithPath = sinon
.stub()
@@ -452,7 +452,7 @@ describe('EditorController', function () {
beforeEach(function () {
const folders = [
(this.folderA = { _id: 2, parentFolder_id: 1 }),
- (this.folderB = { _id: 3, parentFolder_id: 2 })
+ (this.folderB = { _id: 3, parentFolder_id: 2 }),
]
this.ProjectEntityUpdateHandler.upsertFileWithPath = sinon
.stub()
@@ -529,7 +529,7 @@ describe('EditorController', function () {
this.path = 'folder1/folder2'
this.folders = [
(this.folderA = { _id: 2, parentFolder_id: 1 }),
- (this.folderB = { _id: 3, parentFolder_id: 2 })
+ (this.folderB = { _id: 3, parentFolder_id: 2 }),
]
this.EditorController._notifyProjectUsersOfNewFolders = sinon
.stub()
@@ -884,7 +884,7 @@ describe('EditorController', function () {
it('should not broadcast a token change', function () {
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:tokens:changed', {
- tokens: this.tokens
+ tokens: this.tokens,
})
.should.equal(false)
})
@@ -925,7 +925,7 @@ describe('EditorController', function () {
it('should broadcast the token change too', function () {
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:tokens:changed', {
- tokens: this.tokens
+ tokens: this.tokens,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Editor/EditorHttpControllerTests.js b/services/web/test/unit/src/Editor/EditorHttpControllerTests.js
index 8673282249..43af5de144 100644
--- a/services/web/test/unit/src/Editor/EditorHttpControllerTests.js
+++ b/services/web/test/unit/src/Editor/EditorHttpControllerTests.js
@@ -11,25 +11,25 @@ describe('EditorHttpController', function () {
this.ownerId = new ObjectId()
this.project = {
_id: new ObjectId(),
- owner_ref: this.ownerId
+ owner_ref: this.ownerId,
}
this.user = {
_id: new ObjectId(),
- projects: {}
+ projects: {},
}
this.projectView = {
_id: this.project._id,
owner: {
_id: 'owner',
email: 'owner@example.com',
- other_property: true
+ other_property: true,
},
- members: [{ one: 1 }, { two: 2 }]
+ members: [{ one: 1 }, { two: 2 }],
}
this.reducedProjectView = {
_id: this.projectView._id,
owner: { _id: this.projectView.owner._id },
- members: []
+ members: [],
}
this.doc = { _id: new ObjectId(), name: 'excellent-original-idea.tex' }
this.file = { _id: new ObjectId() }
@@ -41,7 +41,7 @@ describe('EditorHttpController', function () {
send: sinon.stub().returns(this.res),
status: sinon.stub().returns(this.res),
sendStatus: sinon.stub().returns(this.res),
- json: sinon.stub().returns(this.res)
+ json: sinon.stub().returns(this.res),
}
this.next = sinon.stub()
this.token = null
@@ -50,20 +50,20 @@ describe('EditorHttpController', function () {
this.AuthorizationManager = {
isRestrictedUser: sinon.stub().returns(false),
promises: {
- getPrivilegeLevelForProject: sinon.stub().resolves('owner')
- }
+ getPrivilegeLevelForProject: sinon.stub().resolves('owner'),
+ },
}
this.CollaboratorsGetter = {
promises: {
getInvitedMembersWithPrivilegeLevels: sinon
.stub()
- .resolves(['members', 'mock'])
- }
+ .resolves(['members', 'mock']),
+ },
}
this.CollaboratorsHandler = {
promises: {
- userIsTokenMember: sinon.stub().resolves(false)
- }
+ userIsTokenMember: sinon.stub().resolves(false),
+ },
}
this.CollaboratorsInviteHandler = {
promises: {
@@ -72,16 +72,16 @@ describe('EditorHttpController', function () {
_id: 'invite_one',
email: 'user-one@example.com',
privileges: 'readOnly',
- projectId: this.project._id
+ projectId: this.project._id,
},
{
_id: 'invite_two',
email: 'user-two@example.com',
privileges: 'readOnly',
- projectId: this.project._id
- }
- ])
- }
+ projectId: this.project._id,
+ },
+ ]),
+ },
}
this.EditorController = {
promises: {
@@ -90,43 +90,43 @@ describe('EditorHttpController', function () {
addFolder: sinon.stub().resolves(this.folder),
renameEntity: sinon.stub().resolves(),
moveEntity: sinon.stub().resolves(),
- deleteEntity: sinon.stub().resolves()
- }
+ deleteEntity: sinon.stub().resolves(),
+ },
}
this.ProjectDeleter = {
promises: {
- unmarkAsDeletedByExternalSource: sinon.stub().resolves()
- }
+ unmarkAsDeletedByExternalSource: sinon.stub().resolves(),
+ },
}
this.ProjectGetter = {
promises: {
- getProjectWithoutDocLines: sinon.stub().resolves(this.project)
- }
+ getProjectWithoutDocLines: sinon.stub().resolves(this.project),
+ },
}
this.ProjectEditorHandler = {
- buildProjectModelView: sinon.stub().returns(this.projectView)
+ buildProjectModelView: sinon.stub().returns(this.projectView),
}
this.Metrics = { inc: sinon.stub() }
this.TokenAccessHandler = {
getRequestToken: sinon.stub().returns(this.token),
- protectTokens: sinon.stub()
+ protectTokens: sinon.stub(),
}
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.user._id)
+ getLoggedInUserId: sinon.stub().returns(this.user._id),
}
this.ProjectEntityUpdateHandler = {
promises: {
- convertDocToFile: sinon.stub().resolves(this.file)
- }
+ convertDocToFile: sinon.stub().resolves(this.file),
+ },
}
this.DocstoreManager = {
promises: {
- getAllDeletedDocs: sinon.stub().resolves([])
- }
+ getAllDeletedDocs: sinon.stub().resolves([]),
+ },
}
this.HttpErrorHandler = {
notFound: sinon.stub(),
- unprocessableEntity: sinon.stub()
+ unprocessableEntity: sinon.stub(),
}
this.EditorHttpController = SandboxedModule.require(MODULE_PATH, {
requires: {
@@ -147,8 +147,8 @@ describe('EditorHttpController', function () {
'../Project/ProjectEntityUpdateHandler': this
.ProjectEntityUpdateHandler,
'../Docstore/DocstoreManager': this.DocstoreManager,
- '../Errors/HttpErrorHandler': this.HttpErrorHandler
- }
+ '../Errors/HttpErrorHandler': this.HttpErrorHandler,
+ },
})
})
@@ -168,7 +168,7 @@ describe('EditorHttpController', function () {
expect(this.res.json).to.have.been.calledWith({
project: this.projectView,
privilegeLevel: 'owner',
- isRestrictedUser: false
+ isRestrictedUser: false,
})
})
@@ -210,7 +210,7 @@ describe('EditorHttpController', function () {
expect(this.res.json).to.have.been.calledWith({
project: this.reducedProjectView,
privilegeLevel: 'readOnly',
- isRestrictedUser: true
+ isRestrictedUser: true,
})
})
})
@@ -246,7 +246,7 @@ describe('EditorHttpController', function () {
expect(this.res.json).to.have.been.calledWith({
project: this.reducedProjectView,
privilegeLevel: 'readOnly',
- isRestrictedUser: true
+ isRestrictedUser: true,
})
})
})
@@ -271,7 +271,7 @@ describe('EditorHttpController', function () {
this.req.params = { Project_id: this.project._id }
this.req.body = {
name: (this.name = 'doc-name'),
- parent_folder_id: this.parentFolderId
+ parent_folder_id: this.parentFolderId,
}
})
@@ -328,7 +328,7 @@ describe('EditorHttpController', function () {
this.req.params = { Project_id: this.project._id }
this.req.body = {
name: this.folderName,
- parent_folder_id: this.parentFolderId
+ parent_folder_id: this.parentFolderId,
}
})
@@ -399,7 +399,7 @@ describe('EditorHttpController', function () {
this.req.params = {
Project_id: this.project._id,
entity_id: this.entityId,
- entity_type: this.entityType
+ entity_type: this.entityType,
}
})
@@ -460,7 +460,7 @@ describe('EditorHttpController', function () {
this.req.params = {
Project_id: this.project._id,
entity_id: this.entityId,
- entity_type: this.entityType
+ entity_type: this.entityType,
}
this.req.body = { folder_id: this.folderId }
this.res.sendStatus.callsFake(() => done())
@@ -489,7 +489,7 @@ describe('EditorHttpController', function () {
this.req.params = {
Project_id: this.project._id,
entity_id: this.entityId,
- entity_type: this.entityType
+ entity_type: this.entityType,
}
this.res.sendStatus.callsFake(() => done())
this.EditorHttpController.deleteEntity(this.req, this.res)
@@ -516,7 +516,7 @@ describe('EditorHttpController', function () {
beforeEach(function (done) {
this.req.params = {
Project_id: this.project._id.toString(),
- entity_id: this.doc._id.toString()
+ entity_id: this.doc._id.toString(),
}
this.req.body = { userId: this.user._id.toString() }
this.res.json.callsFake(() => done())
@@ -536,7 +536,7 @@ describe('EditorHttpController', function () {
it('should return the file id in the response', function () {
expect(this.res.json).to.have.been.calledWith({
- fileId: this.file._id.toString()
+ fileId: this.file._id.toString(),
})
})
})
diff --git a/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js b/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js
index 79abe87c14..2f82333822 100644
--- a/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js
+++ b/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js
@@ -24,10 +24,10 @@ describe('EditorRealTimeController', function () {
this.EditorRealTimeController = SandboxedModule.require(modulePath, {
requires: {
'../../infrastructure/RedisWrapper': {
- client: () => this.rclient
+ client: () => this.rclient,
},
'../../infrastructure/Server': {
- io: (this.io = {})
+ io: (this.io = {}),
},
'settings-sharelatex': { redis: {} },
'@overleaf/metrics': this.Metrics,
@@ -35,10 +35,10 @@ describe('EditorRealTimeController', function () {
randomBytes: sinon
.stub()
.withArgs(4)
- .returns(Buffer.from([0x1, 0x2, 0x3, 0x4]))
+ .returns(Buffer.from([0x1, 0x2, 0x3, 0x4])),
}),
- os: (this.os = { hostname: sinon.stub().returns('somehost') })
- }
+ os: (this.os = { hostname: sinon.stub().returns('somehost') }),
+ },
})
this.room_id = 'room-id'
@@ -64,7 +64,7 @@ describe('EditorRealTimeController', function () {
room_id: this.room_id,
message: this.message,
payload: this.payload,
- _id: this.message_id
+ _id: this.message_id,
})
)
.should.equal(true)
@@ -78,7 +78,7 @@ describe('EditorRealTimeController', function () {
room_id: this.room_id,
message: this.message,
payload: this.payload,
- _id: this.message_id
+ _id: this.message_id,
}).length
)
.should.equal(true)
diff --git a/services/web/test/unit/src/Email/EmailBuilderTests.js b/services/web/test/unit/src/Email/EmailBuilderTests.js
index bde69edb17..e0f7e8863b 100644
--- a/services/web/test/unit/src/Email/EmailBuilderTests.js
+++ b/services/web/test/unit/src/Email/EmailBuilderTests.js
@@ -17,7 +17,7 @@ describe('EmailBuilder', function () {
before(function () {
this.settings = {
appName: 'testApp',
- siteUrl: 'https://www.overleaf.com'
+ siteUrl: 'https://www.overleaf.com',
}
this.EmailBuilder = SandboxedModule.require(MODULE_PATH, {
requires: {
@@ -25,8 +25,8 @@ describe('EmailBuilder', function () {
'./Bodies/cta-email': ctaEmailBody,
'./Bodies/NoCTAEmailBody': NoCTAEmailBody,
'./Layouts/BaseWithHeaderEmailLayout': BaseWithHeaderEmailLayout,
- 'settings-sharelatex': this.settings
- }
+ 'settings-sharelatex': this.settings,
+ },
})
})
@@ -36,13 +36,13 @@ describe('EmailBuilder', function () {
to: 'bob@bob.com',
first_name: 'bob',
owner: {
- email: 'sally@hally.com'
+ email: 'sally@hally.com',
},
inviteUrl: 'http://example.com/invite',
project: {
url: 'http://www.project.com',
- name: 'standard project'
- }
+ name: 'standard project',
+ },
}
})
@@ -85,13 +85,13 @@ describe('EmailBuilder', function () {
to: 'bob@joe.com',
first_name: 'bob',
owner: {
- email: 'sally@hally.com'
+ email: 'sally@hally.com',
},
inviteUrl: 'http://example.com/invite',
project: {
url: 'http://www.project.com',
- name: 'come buy my product at http://notascam.com'
- }
+ name: 'come buy my product at http://notascam.com',
+ },
}
this.email = this.EmailBuilder.buildEmail('projectInvite', this.opts)
})
@@ -111,7 +111,7 @@ describe('EmailBuilder', function () {
secondaryMessage: () => {},
ctaText: () => {},
ctaURL: () => {},
- gmailGoToAction: () => {}
+ gmailGoToAction: () => {},
}
it('should throw an error when missing title', function () {
let { title, ...missing } = content
@@ -146,7 +146,7 @@ describe('EmailBuilder', function () {
beforeEach(function () {
this.emailAddress = 'example@overleaf.com'
this.opts = {
- to: this.emailAddress
+ to: this.emailAddress,
}
this.email = this.EmailBuilder.buildEmail(
'canceledSubscription',
@@ -188,7 +188,7 @@ describe('EmailBuilder', function () {
this.opts = {
to: this.emailAddress,
confirmEmailUrl: `${this.settings.siteUrl}/user/emails/confirm?token=aToken123`,
- sendingUser_id: this.userId
+ sendingUser_id: this.userId,
}
this.email = this.EmailBuilder.buildEmail('confirmEmail', this.opts)
})
@@ -226,8 +226,8 @@ describe('EmailBuilder', function () {
previousOwner: {},
project: {
_id: 'abc123',
- name: 'example project'
- }
+ name: 'example project',
+ },
}
this.email = this.EmailBuilder.buildEmail(
'ownershipTransferConfirmationNewOwner',
@@ -272,7 +272,7 @@ describe('EmailBuilder', function () {
this.settings.siteUrl
}/user/password/set?passwordResetToken=aToken&email=${encodeURIComponent(
this.emailAddress
- )}`
+ )}`,
}
this.email = this.EmailBuilder.buildEmail(
'passwordResetRequested',
@@ -314,7 +314,7 @@ describe('EmailBuilder', function () {
this.opts = {
to: this.emailAddress,
confirmEmailUrl: `${this.settings.siteUrl}/user/emails/confirm?token=aToken123`,
- sendingUser_id: this.userId
+ sendingUser_id: this.userId,
}
this.email = this.EmailBuilder.buildEmail('reconfirmEmail', this.opts)
})
@@ -353,8 +353,8 @@ describe('EmailBuilder', function () {
inviter: {
email: 'deanna@overleaf.com',
first_name: 'Deanna',
- last_name: 'Troi'
- }
+ last_name: 'Troi',
+ },
}
this.email = this.EmailBuilder.buildEmail(
'verifyEmailToJoinTeam',
@@ -391,7 +391,7 @@ describe('EmailBuilder', function () {
before(function () {
this.emailAddress = 'example@overleaf.com'
this.opts = {
- to: this.emailAddress
+ to: this.emailAddress,
}
this.email = this.EmailBuilder.buildEmail(
'reactivatedSubscription',
@@ -429,7 +429,7 @@ describe('EmailBuilder', function () {
before(function () {
this.emailAddress = 'example@overleaf.com'
this.opts = {
- to: this.emailAddress
+ to: this.emailAddress,
}
this.email = this.EmailBuilder.buildEmail('testEmail', this.opts)
})
@@ -468,7 +468,7 @@ describe('EmailBuilder', function () {
this.emailAddress = 'example@overleaf.com'
this.opts = {
to: this.emailAddress,
- setNewPasswordUrl: `${this.settings.siteUrl}/user/activate?token=aToken123&user_id=aUserId123`
+ setNewPasswordUrl: `${this.settings.siteUrl}/user/activate?token=aToken123&user_id=aUserId123`,
}
this.email = this.EmailBuilder.buildEmail('registered', this.opts)
})
@@ -505,7 +505,7 @@ describe('EmailBuilder', function () {
this.emailAddress = 'example@overleaf.com'
this.owner = {
email: 'owner@example.com',
- name: 'Bailey'
+ name: 'Bailey',
}
this.projectName = 'Top Secret'
this.opts = {
@@ -513,15 +513,15 @@ describe('EmailBuilder', function () {
`${this.settings.siteUrl}/project/projectId123/invite/token/aToken123?` +
[
`project_name=${encodeURIComponent(this.projectName)}`,
- `user_first_name=${encodeURIComponent(this.owner.name)}`
+ `user_first_name=${encodeURIComponent(this.owner.name)}`,
].join('&'),
owner: {
- email: this.owner.email
+ email: this.owner.email,
},
project: {
- name: this.projectName
+ name: this.projectName,
},
- to: this.emailAddress
+ to: this.emailAddress,
}
this.email = this.EmailBuilder.buildEmail('projectInvite', this.opts)
})
@@ -566,7 +566,7 @@ describe('EmailBuilder', function () {
to: this.email,
actionDescribed: this.actionDescribedNotAllowedHTML,
action: 'an action',
- message: [this.messageNotAllowedHTML]
+ message: [this.messageNotAllowedHTML],
}
this.email = this.EmailBuilder.buildEmail('securityAlert', this.opts)
})
diff --git a/services/web/test/unit/src/Email/EmailHandlerTests.js b/services/web/test/unit/src/Email/EmailHandlerTests.js
index 6ea65b7106..262e8bf8c2 100644
--- a/services/web/test/unit/src/Email/EmailHandlerTests.js
+++ b/services/web/test/unit/src/Email/EmailHandlerTests.js
@@ -13,19 +13,19 @@ describe('EmailHandler', function () {
this.html = 'hello'
this.Settings = { email: {} }
this.EmailBuilder = {
- buildEmail: sinon.stub().returns({ html: this.html })
+ buildEmail: sinon.stub().returns({ html: this.html }),
}
this.EmailSender = {
promises: {
- sendEmail: sinon.stub().resolves()
- }
+ sendEmail: sinon.stub().resolves(),
+ },
}
this.EmailHandler = SandboxedModule.require(MODULE_PATH, {
requires: {
'./EmailBuilder': this.EmailBuilder,
'./EmailSender': this.EmailSender,
- 'settings-sharelatex': this.Settings
- }
+ 'settings-sharelatex': this.Settings,
+ },
})
})
@@ -34,7 +34,7 @@ describe('EmailHandler', function () {
const opts = { to: 'bob@bob.com' }
await this.EmailHandler.promises.sendEmail('welcome', opts)
expect(this.EmailSender.promises.sendEmail).to.have.been.calledWithMatch({
- html: this.html
+ html: this.html,
})
})
@@ -42,7 +42,7 @@ describe('EmailHandler', function () {
this.EmailSender.promises.sendEmail.rejects(new Error('boom'))
const opts = {
to: 'bob@bob.com',
- subject: 'hello bob'
+ subject: 'hello bob',
}
await expect(this.EmailHandler.promises.sendEmail('welcome', opts)).to.be
.rejected
@@ -79,7 +79,7 @@ describe('EmailHandler', function () {
it('should pass along the text field', async function () {
this.EmailBuilder.buildEmail.returns({
html: this.html,
- text: this.text
+ text: this.text,
})
const opts = { to: 'bob@bob.com' }
await this.EmailHandler.promises.sendEmail('welcome', opts)
@@ -87,7 +87,7 @@ describe('EmailHandler', function () {
this.EmailSender.promises.sendEmail
).to.have.been.calledWithMatch({
html: this.html,
- text: this.text
+ text: this.text,
})
})
})
diff --git a/services/web/test/unit/src/Email/EmailSenderTests.js b/services/web/test/unit/src/Email/EmailSenderTests.js
index b4fbfbdd54..5f4a451343 100644
--- a/services/web/test/unit/src/Email/EmailSenderTests.js
+++ b/services/web/test/unit/src/Email/EmailSenderTests.js
@@ -12,8 +12,8 @@ describe('EmailSender', function () {
beforeEach(function () {
this.RateLimiter = {
promises: {
- addCount: sinon.stub()
- }
+ addCount: sinon.stub(),
+ },
}
this.Settings = {
@@ -21,11 +21,11 @@ describe('EmailSender', function () {
transport: 'ses',
parameters: {
AWSAccessKeyID: 'key',
- AWSSecretKey: 'secret'
+ AWSSecretKey: 'secret',
},
fromAddress: 'bob@bob.com',
- replyToAddress: 'sally@gmail.com'
- }
+ replyToAddress: 'sally@gmail.com',
+ },
}
this.sesClient = { sendMail: sinon.stub().resolves() }
@@ -40,15 +40,15 @@ describe('EmailSender', function () {
'settings-sharelatex': this.Settings,
'../../infrastructure/RateLimiter': this.RateLimiter,
'@overleaf/metrics': {
- inc() {}
- }
- }
+ inc() {},
+ },
+ },
})
this.opts = {
to: 'bob@bob.com',
subject: 'new email',
- html: ''
+ html: '',
}
})
@@ -58,7 +58,7 @@ describe('EmailSender', function () {
expect(this.sesClient.sendMail).to.have.been.calledWithMatch({
html: this.opts.html,
to: this.opts.to,
- subject: this.opts.subject
+ subject: this.opts.subject,
})
})
@@ -72,14 +72,14 @@ describe('EmailSender', function () {
it('should use the from address from settings', async function () {
await this.EmailSender.promises.sendEmail(this.opts)
expect(this.sesClient.sendMail).to.have.been.calledWithMatch({
- from: this.Settings.email.fromAddress
+ from: this.Settings.email.fromAddress,
})
})
it('should use the reply to address from settings', async function () {
await this.EmailSender.promises.sendEmail(this.opts)
expect(this.sesClient.sendMail).to.have.been.calledWithMatch({
- replyTo: this.Settings.email.replyToAddress
+ replyTo: this.Settings.email.replyToAddress,
})
})
@@ -87,7 +87,7 @@ describe('EmailSender', function () {
this.opts.replyTo = 'someone@else.com'
await this.EmailSender.promises.sendEmail(this.opts)
expect(this.sesClient.sendMail).to.have.been.calledWithMatch({
- replyTo: this.opts.replyTo
+ replyTo: this.opts.replyTo,
})
})
@@ -124,7 +124,7 @@ describe('EmailSender', function () {
html: this.opts.html,
text: this.opts.text,
to: this.opts.to,
- subject: this.opts.subject
+ subject: this.opts.subject,
})
})
})
diff --git a/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js b/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js
index 6d335fbf21..c6e4fb46ad 100644
--- a/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js
+++ b/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js
@@ -13,9 +13,9 @@ describe('HttpErrorHandler', function () {
requires: {
'settings-sharelatex': {
appName: 'Overleaf',
- statusPageUrl: 'https://status.overlaf.com'
- }
- }
+ statusPageUrl: 'https://status.overlaf.com',
+ },
+ },
})
})
@@ -155,7 +155,7 @@ describe('HttpErrorHandler', function () {
expect(this.res.renderedTemplate).to.equal('general/400')
expect(this.res.renderedVariables).to.deep.equal({
title: 'Client Error',
- message: 'an error'
+ message: 'an error',
})
})
@@ -165,18 +165,18 @@ describe('HttpErrorHandler', function () {
expect(this.res.renderedTemplate).to.equal('general/400')
expect(this.res.renderedVariables).to.deep.equal({
title: 'Client Error',
- message: undefined
+ message: undefined,
})
})
it("should return a json object when content-type is 'json'", function () {
this.req.accepts = () => 'json'
this.HttpErrorHandler.badRequest(this.req, this.res, 'an error', {
- foo: 'bar'
+ foo: 'bar',
})
expect(JSON.parse(this.res.body)).to.deep.equal({
message: 'an error',
- foo: 'bar'
+ foo: 'bar',
})
})
@@ -204,7 +204,7 @@ describe('HttpErrorHandler', function () {
expect(this.res.renderedTemplate).to.equal('general/400')
expect(this.res.renderedVariables).to.deep.equal({
title: 'Client Error',
- message: 'an error'
+ message: 'an error',
})
})
@@ -215,12 +215,12 @@ describe('HttpErrorHandler', function () {
this.res,
'an error',
{
- foo: 'bar'
+ foo: 'bar',
}
)
expect(JSON.parse(this.res.body)).to.deep.equal({
message: 'an error',
- foo: 'bar'
+ foo: 'bar',
})
})
})
@@ -241,18 +241,18 @@ describe('HttpErrorHandler', function () {
this.HttpErrorHandler.forbidden(this.req, this.res)
expect(this.res.renderedTemplate).to.equal('user/restricted')
expect(this.res.renderedVariables).to.deep.equal({
- title: 'restricted'
+ title: 'restricted',
})
})
it("should return a json object when content-type is 'json'", function () {
this.req.accepts = () => 'json'
this.HttpErrorHandler.forbidden(this.req, this.res, 'an error', {
- foo: 'bar'
+ foo: 'bar',
})
expect(JSON.parse(this.res.body)).to.deep.equal({
message: 'an error',
- foo: 'bar'
+ foo: 'bar',
})
})
})
@@ -273,18 +273,18 @@ describe('HttpErrorHandler', function () {
this.HttpErrorHandler.notFound(this.req, this.res)
expect(this.res.renderedTemplate).to.equal('general/404')
expect(this.res.renderedVariables).to.deep.equal({
- title: 'page_not_found'
+ title: 'page_not_found',
})
})
it("should return a json object when content-type is 'json'", function () {
this.req.accepts = () => 'json'
this.HttpErrorHandler.notFound(this.req, this.res, 'an error', {
- foo: 'bar'
+ foo: 'bar',
})
expect(JSON.parse(this.res.body)).to.deep.equal({
message: 'an error',
- foo: 'bar'
+ foo: 'bar',
})
})
})
@@ -306,7 +306,7 @@ describe('HttpErrorHandler', function () {
expect(this.res.renderedTemplate).to.equal('general/400')
expect(this.res.renderedVariables).to.deep.equal({
title: 'Client Error',
- message: 'an error'
+ message: 'an error',
})
})
@@ -317,12 +317,12 @@ describe('HttpErrorHandler', function () {
this.res,
'an error',
{
- foo: 'bar'
+ foo: 'bar',
}
)
expect(JSON.parse(this.res.body)).to.deep.equal({
message: 'an error',
- foo: 'bar'
+ foo: 'bar',
})
})
@@ -353,7 +353,7 @@ describe('HttpErrorHandler', function () {
this.HttpErrorHandler.legacyInternal(this.req, this.res, new Error())
expect(this.res.renderedTemplate).to.equal('general/500')
expect(this.res.renderedVariables).to.deep.equal({
- title: 'Server Error'
+ title: 'Server Error',
})
})
@@ -366,7 +366,7 @@ describe('HttpErrorHandler', function () {
new Error()
)
expect(JSON.parse(this.res.body)).to.deep.equal({
- message: 'a message'
+ message: 'a message',
})
})
})
diff --git a/services/web/test/unit/src/Exports/ExportsControllerTests.js b/services/web/test/unit/src/Exports/ExportsControllerTests.js
index b071228e01..66fdfabc9b 100644
--- a/services/web/test/unit/src/Exports/ExportsControllerTests.js
+++ b/services/web/test/unit/src/Exports/ExportsControllerTests.js
@@ -38,36 +38,36 @@ describe('ExportsController', function () {
this.req = {
params: {
project_id,
- brand_variation_id
+ brand_variation_id,
},
body: {
firstName,
- lastName
+ lastName,
},
session: {
user: {
- _id: user_id
- }
+ _id: user_id,
+ },
},
i18n: {
- translate() {}
- }
+ translate() {},
+ },
}
this.res = {
json: sinon.stub(),
- status: sinon.stub()
+ status: sinon.stub(),
}
this.res.status.returns(this.res)
this.next = sinon.stub()
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.req.session.user._id)
+ getLoggedInUserId: sinon.stub().returns(this.req.session.user._id),
}
return (this.controller = SandboxedModule.require(modulePath, {
requires: {
'./ExportsHandler': this.handler,
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
}))
})
@@ -81,14 +81,14 @@ describe('ExportsController', function () {
user_id,
brand_variation_id,
first_name: firstName,
- last_name: lastName
+ last_name: lastName,
}
return this.controller.exportProject(this.req, {
json: body => {
expect(this.handler.exportProject.args[0][0]).to.deep.equal(expected)
expect(body).to.deep.equal({ export_v1_id: 897, message: undefined })
return done()
- }
+ },
})
})
})
@@ -98,24 +98,24 @@ describe('ExportsController', function () {
this.handler.exportProject = sinon.stub().yields(null, {
iAmAnExport: true,
v1_id: 897,
- message: 'RESUBMISSION'
+ message: 'RESUBMISSION',
})
const expected = {
project_id,
user_id,
brand_variation_id,
first_name: firstName,
- last_name: lastName
+ last_name: lastName,
}
return this.controller.exportProject(this.req, {
json: body => {
expect(this.handler.exportProject.args[0][0]).to.deep.equal(expected)
expect(body).to.deep.equal({
export_v1_id: 897,
- message: 'RESUBMISSION'
+ message: 'RESUBMISSION',
})
return done()
- }
+ },
})
})
})
@@ -143,14 +143,14 @@ describe('ExportsController', function () {
description,
author,
license,
- show_source
+ show_source,
}
return this.controller.exportProject(this.req, {
json: body => {
expect(this.handler.exportProject.args[0][0]).to.deep.equal(expected)
expect(body).to.deep.equal({ export_v1_id: 897, message: undefined })
return done()
- }
+ },
})
})
})
@@ -196,11 +196,11 @@ describe('ExportsController', function () {
v2_user_first_name: 'Arthur',
v2_user_last_name: 'Author',
title: 'my project',
- token: 'token'
- }
+ token: 'token',
+ },
})
return done()
- }
+ },
})
})
})
diff --git a/services/web/test/unit/src/Exports/ExportsHandlerTests.js b/services/web/test/unit/src/Exports/ExportsHandlerTests.js
index 873881c9ac..f0b250e5ba 100644
--- a/services/web/test/unit/src/Exports/ExportsHandlerTests.js
+++ b/services/web/test/unit/src/Exports/ExportsHandlerTests.js
@@ -22,7 +22,7 @@ describe('ExportsHandler', function () {
this.request = {
defaults: () => {
return this.stubRequest
- }
+ },
}
this.ExportsHandler = SandboxedModule.require(modulePath, {
requires: {
@@ -32,8 +32,8 @@ describe('ExportsHandler', function () {
'../Project/ProjectRootDocManager': (this.ProjectRootDocManager = {}),
'../User/UserGetter': (this.UserGetter = {}),
'settings-sharelatex': (this.settings = {}),
- request: this.request
- }
+ request: this.request,
+ },
})
this.project_id = 'project-id-123'
this.project_history_id = 987
@@ -52,7 +52,7 @@ describe('ExportsHandler', function () {
description: this.description,
author: this.author,
license: this.license,
- show_source: this.show_source
+ show_source: this.show_source,
}
return (this.callback = sinon.stub())
})
@@ -136,7 +136,7 @@ describe('ExportsHandler', function () {
it('should return success and the response to forward', function () {
;(this.callback.args[0][0] instanceof Error).should.equal(false)
return this.callback.calledWith(null, {
- forwardResponse: this.error_json
+ forwardResponse: this.error_json,
})
})
})
@@ -152,9 +152,9 @@ describe('ExportsHandler', function () {
overleaf: {
id: this.project_history_id, // for projects imported from v1
history: {
- id: this.project_history_id
- }
- }
+ id: this.project_history_id,
+ },
+ },
}
this.user = {
id: this.user_id,
@@ -162,8 +162,8 @@ describe('ExportsHandler', function () {
last_name: 'Author',
email: 'arthur.author@arthurauthoring.org',
overleaf: {
- id: 876
- }
+ id: 876,
+ },
}
this.rootDocPath = 'main.tex'
this.historyVersion = 777
@@ -220,8 +220,8 @@ describe('ExportsHandler', function () {
description: this.description,
author: this.author,
license: this.license,
- showSource: this.show_source
- }
+ showSource: this.show_source,
+ },
},
user: {
id: this.user_id,
@@ -229,14 +229,14 @@ describe('ExportsHandler', function () {
lastName: this.user.last_name,
email: this.user.email,
orcidId: null,
- v1UserId: 876
+ v1UserId: 876,
},
destination: {
- brandVariationId: this.brand_variation_id
+ brandVariationId: this.brand_variation_id,
},
options: {
- callbackUrl: null
- }
+ callbackUrl: null,
+ },
}
return this.callback
.calledWith(null, expected_export_data)
@@ -274,8 +274,8 @@ describe('ExportsHandler', function () {
description: this.description,
author: this.author,
license: this.license,
- showSource: this.show_source
- }
+ showSource: this.show_source,
+ },
},
user: {
id: this.user_id,
@@ -283,14 +283,14 @@ describe('ExportsHandler', function () {
lastName: this.custom_last_name,
email: this.user.email,
orcidId: null,
- v1UserId: 876
+ v1UserId: 876,
},
destination: {
- brandVariationId: this.brand_variation_id
+ brandVariationId: this.brand_variation_id,
},
options: {
- callbackUrl: null
- }
+ callbackUrl: null,
+ },
}
return this.callback
.calledWith(null, expected_export_data)
@@ -354,8 +354,8 @@ describe('ExportsHandler', function () {
description: this.description,
author: this.author,
license: this.license,
- showSource: this.show_source
- }
+ showSource: this.show_source,
+ },
},
user: {
id: this.user_id,
@@ -363,14 +363,14 @@ describe('ExportsHandler', function () {
lastName: this.user.last_name,
email: this.user.email,
orcidId: null,
- v1UserId: 876
+ v1UserId: 876,
},
destination: {
- brandVariationId: this.brand_variation_id
+ brandVariationId: this.brand_variation_id,
},
options: {
- callbackUrl: null
- }
+ callbackUrl: null,
+ },
}
return this.callback
.calledWith(null, expected_export_data)
@@ -417,8 +417,8 @@ describe('ExportsHandler', function () {
description: this.description,
author: this.author,
license: this.license,
- showSource: this.show_source
- }
+ showSource: this.show_source,
+ },
},
user: {
id: this.user_id,
@@ -426,14 +426,14 @@ describe('ExportsHandler', function () {
lastName: this.user.last_name,
email: this.user.email,
orcidId: null,
- v1UserId: 876
+ v1UserId: 876,
},
destination: {
- brandVariationId: this.brand_variation_id
+ brandVariationId: this.brand_variation_id,
},
options: {
- callbackUrl: null
- }
+ callbackUrl: null,
+ },
}
return this.callback
.calledWith(null, expected_export_data)
@@ -506,8 +506,8 @@ describe('ExportsHandler', function () {
v1: {
url: 'http://localhost:5000',
user: 'overleaf',
- pass: 'pass'
- }
+ pass: 'pass',
+ },
}
this.export_data = { iAmAnExport: true }
this.export_id = 4096
@@ -534,9 +534,9 @@ describe('ExportsHandler', function () {
url: this.settings.apis.v1.url + '/api/v1/sharelatex/exports',
auth: {
user: this.settings.apis.v1.user,
- pass: this.settings.apis.v1.pass
+ pass: this.settings.apis.v1.pass,
},
- json: this.export_data
+ json: this.export_data,
})
})
@@ -585,7 +585,7 @@ describe('ExportsHandler', function () {
it('should return success and the response to forward', function () {
;(this.callback.args[0][0] instanceof Error).should.equal(false)
return this.callback.calledWith(null, {
- forwardResponse: this.error_json
+ forwardResponse: this.error_json,
})
})
})
@@ -597,8 +597,8 @@ describe('ExportsHandler', function () {
v1: {
url: 'http://localhost:5000',
user: 'overleaf',
- pass: 'pass'
- }
+ pass: 'pass',
+ },
}
this.export_id = 897
this.body = '{"id":897, "status_summary":"completed"}'
@@ -628,8 +628,8 @@ describe('ExportsHandler', function () {
this.export_id,
auth: {
user: this.settings.apis.v1.user,
- pass: this.settings.apis.v1.pass
- }
+ pass: this.settings.apis.v1.pass,
+ },
})
})
@@ -647,8 +647,8 @@ describe('ExportsHandler', function () {
v1: {
url: 'http://localhost:5000',
user: 'overleaf',
- pass: 'pass'
- }
+ pass: 'pass',
+ },
}
this.export_id = 897
this.body =
@@ -681,8 +681,8 @@ describe('ExportsHandler', function () {
'/zip_url',
auth: {
user: this.settings.apis.v1.user,
- pass: this.settings.apis.v1.pass
- }
+ pass: this.settings.apis.v1.pass,
+ },
})
})
diff --git a/services/web/test/unit/src/FileStore/FileStoreControllerTests.js b/services/web/test/unit/src/FileStore/FileStoreControllerTests.js
index 7162417879..b4a5f5b6e1 100644
--- a/services/web/test/unit/src/FileStore/FileStoreControllerTests.js
+++ b/services/web/test/unit/src/FileStore/FileStoreControllerTests.js
@@ -10,15 +10,15 @@ describe('FileStoreController', function () {
beforeEach(function () {
this.FileStoreHandler = {
getFileStream: sinon.stub(),
- getFileSize: sinon.stub()
+ getFileSize: sinon.stub(),
}
this.ProjectLocator = { findElement: sinon.stub() }
this.controller = SandboxedModule.require(MODULE_PATH, {
requires: {
'settings-sharelatex': this.settings,
'../Project/ProjectLocator': this.ProjectLocator,
- './FileStoreHandler': this.FileStoreHandler
- }
+ './FileStoreHandler': this.FileStoreHandler,
+ },
})
this.stream = {}
this.projectId = '2k3j1lk3j21lk3j'
@@ -26,18 +26,18 @@ describe('FileStoreController', function () {
this.req = {
params: {
Project_id: this.projectId,
- File_id: this.fileId
+ File_id: this.fileId,
},
query: 'query string here',
get(key) {
return undefined
- }
+ },
}
this.res = {
set: sinon.stub().returnsThis(),
setHeader: sinon.stub(),
setContentDisposition: sinon.stub(),
- status: sinon.stub().returnsThis()
+ status: sinon.stub().returnsThis(),
}
this.file = { name: 'myfile.png' }
})
@@ -75,7 +75,7 @@ describe('FileStoreController', function () {
const opts = {
project_id: this.projectId,
element_id: this.fileId,
- type: 'file'
+ type: 'file',
}
this.ProjectLocator.findElement.calledWith(opts).should.equal(true)
done()
@@ -163,7 +163,7 @@ describe('FileStoreController', function () {
('x.html-is-rad',
'html.pdf',
'.html-is-good-for-hidden-files',
- 'somefile')
+ 'somefile'),
].forEach(filename => {
describe(`with filename as '${filename}'`, function () {
beforeEach(function () {
@@ -210,7 +210,7 @@ describe('FileStoreController', function () {
expect(this.res.status.lastCall.args).to.deep.equal([200])
expect(this.res.set.lastCall.args).to.deep.equal([
'Content-Length',
- expectedFileSize
+ expectedFileSize,
])
done()
}
diff --git a/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js b/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js
index 8ffbde73c2..740a624ad3 100644
--- a/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js
+++ b/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js
@@ -16,8 +16,8 @@ describe('FileStoreHandler', function () {
},
isDirectory() {
return false
- }
- })
+ },
+ }),
}
this.writeStream = {
my: 'writeStream',
@@ -25,14 +25,14 @@ describe('FileStoreHandler', function () {
if (type === 'response') {
cb({ statusCode: 200 })
}
- }
+ },
}
this.readStream = { my: 'readStream', on: sinon.stub() }
this.request = sinon.stub()
this.request.head = sinon.stub()
this.filestoreUrl = 'http://filestore.sharelatex.test'
this.settings = {
- apis: { filestore: { url: this.filestoreUrl } }
+ apis: { filestore: { url: this.filestoreUrl } },
}
this.hashValue = '0123456789'
this.fileArgs = { name: 'upload-filename' }
@@ -54,7 +54,7 @@ describe('FileStoreHandler', function () {
}
}
this.FileHashManager = {
- computeHash: sinon.stub().callsArgWith(1, null, this.hashValue)
+ computeHash: sinon.stub().callsArgWith(1, null, this.hashValue),
}
this.handler = SandboxedModule.require(MODULE_PATH, {
requires: {
@@ -63,10 +63,10 @@ describe('FileStoreHandler', function () {
'./FileHashManager': this.FileHashManager,
// FIXME: need to stub File object here
'../../models/File': {
- File: this.FileModel
+ File: this.FileModel,
},
- fs: this.fs
- }
+ fs: this.fs,
+ },
})
})
@@ -82,7 +82,7 @@ describe('FileStoreHandler', function () {
if (type === 'open') {
cb()
}
- }
+ },
})
this.handler.uploadFileFromDisk(
this.projectId,
@@ -106,7 +106,7 @@ describe('FileStoreHandler', function () {
pipe: o => {
this.writeStream.should.equal(o)
done()
- }
+ },
})
this.handler.uploadFileFromDisk(
this.projectId,
@@ -124,7 +124,7 @@ describe('FileStoreHandler', function () {
if (type === 'open') {
cb()
}
- }
+ },
})
this.handler.uploadFileFromDisk(
this.projectId,
@@ -146,7 +146,7 @@ describe('FileStoreHandler', function () {
if (type === 'open') {
cb()
}
- }
+ },
})
this.handler.uploadFileFromDisk(
this.projectId,
@@ -170,7 +170,7 @@ describe('FileStoreHandler', function () {
},
isDirectory() {
return false
- }
+ },
})
this.handler.uploadFileFromDisk(
@@ -215,7 +215,7 @@ describe('FileStoreHandler', function () {
if (type === 'open') {
cb()
}
- }
+ },
})
this.handler.uploadFileFromDisk(
this.projectId,
@@ -396,8 +396,8 @@ describe('FileStoreHandler', function () {
this.request.head.withArgs(fileUrl).yields(null, {
statusCode: 200,
headers: {
- 'content-length': expectedFileSize
- }
+ 'content-length': expectedFileSize,
+ },
})
this.handler.getFileSize(this.projectId, this.fileId, (err, fileSize) => {
diff --git a/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js b/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js
index a956e27c30..9c58acfb9b 100644
--- a/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js
+++ b/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js
@@ -16,12 +16,12 @@ describe('AuthorizationHelper', function () {
institutionManagement: {},
groupMetrics: {},
groupManagement: {},
- adminMetrics: {}
- }
- }
- }
- }
- }
+ adminMetrics: {},
+ },
+ },
+ },
+ },
+ },
})
})
diff --git a/services/web/test/unit/src/HelperFiles/NewLogsUITests.js b/services/web/test/unit/src/HelperFiles/NewLogsUITests.js
index fc1aa10219..4ed03c0e98 100644
--- a/services/web/test/unit/src/HelperFiles/NewLogsUITests.js
+++ b/services/web/test/unit/src/HelperFiles/NewLogsUITests.js
@@ -31,19 +31,19 @@ describe('NewLogsUI helper', function () {
this.user = {
alphaProgram: false,
betaProgram: false,
- _id: ObjectId('60085414b76eeb00737d93aa')
+ _id: ObjectId('60085414b76eeb00737d93aa'),
}
this.settings = {
logsUIPercentageBeta: 0,
logsUIPercentageWithoutPopupBeta: 0,
logsUIPercentage: 0,
- logsUIPercentageWithoutPopup: 0
+ logsUIPercentageWithoutPopup: 0,
}
NewLogsUI = SandboxedModule.require(MODULE_PATH, {
requires: {
mongodb: { ObjectId },
- 'settings-sharelatex': this.settings
- }
+ 'settings-sharelatex': this.settings,
+ },
})
})
diff --git a/services/web/test/unit/src/HelperFiles/SafeHTMLSubstituteTests.js b/services/web/test/unit/src/HelperFiles/SafeHTMLSubstituteTests.js
index 94a09d06b1..8bd093c4a1 100644
--- a/services/web/test/unit/src/HelperFiles/SafeHTMLSubstituteTests.js
+++ b/services/web/test/unit/src/HelperFiles/SafeHTMLSubstituteTests.js
@@ -18,7 +18,7 @@ describe('SafeHTMLSubstitution', function () {
'<0>0>': ['', '0', '', ''],
'<0>INNER0><0>INNER20>': ['', '0', 'INNER', '', '0', 'INNER2', ''],
'<0><1>INNER1>0>': ['', '0', '<1>INNER1>', ''],
- 'PLAIN TEXT': ['PLAIN TEXT']
+ 'PLAIN TEXT': ['PLAIN TEXT'],
}
Object.entries(CASES).forEach(([input, output]) => {
it(`should parse "${input}" as expected`, function () {
@@ -53,7 +53,7 @@ describe('SafeHTMLSubstitution', function () {
expect(
SafeHTMLSubstitution.render('<0>one0><1>two1>', [
{ name: 'b' },
- { name: 'i' }
+ { name: 'i' },
])
).to.equal('onetwo')
})
@@ -64,9 +64,9 @@ describe('SafeHTMLSubstitution', function () {
{
name: 'b',
attrs: {
- class: 'magic'
- }
- }
+ class: 'magic',
+ },
+ },
])
).to.equal('text')
})
@@ -75,7 +75,7 @@ describe('SafeHTMLSubstitution', function () {
expect(
SafeHTMLSubstitution.render('<0><1>nested1>0>', [
{ name: 'b' },
- { name: 'i' }
+ { name: 'i' },
])
).to.equal('nested')
})
@@ -83,7 +83,7 @@ describe('SafeHTMLSubstitution', function () {
it('should handle links', function () {
expect(
SafeHTMLSubstitution.render('<0>Go to Login0>', [
- { name: 'a', attrs: { href: 'https://www.overleaf.com/login' } }
+ { name: 'a', attrs: { href: 'https://www.overleaf.com/login' } },
])
).to.equal('Go to Login')
})
@@ -93,7 +93,7 @@ describe('SafeHTMLSubstitution', function () {
SafeHTMLSubstitution.render('<0>good0>', [
{ name: 'b' },
{ name: 'i' },
- { name: 'u' }
+ { name: 'u' },
])
).to.equal('good')
})
@@ -147,7 +147,7 @@ describe('SafeHTMLSubstitution', function () {
it('should escape text after of a component', function () {
expect(
SafeHTMLSubstitution.render('<0>inner0>POST', [
- { name: 'b' }
+ { name: 'b' },
])
).to.equal('inner<i>POST</i>')
})
diff --git a/services/web/test/unit/src/HelperFiles/UrlHelperTests.js b/services/web/test/unit/src/HelperFiles/UrlHelperTests.js
index d397014375..b147bcb95a 100644
--- a/services/web/test/unit/src/HelperFiles/UrlHelperTests.js
+++ b/services/web/test/unit/src/HelperFiles/UrlHelperTests.js
@@ -9,10 +9,10 @@ describe('UrlHelper', function () {
beforeEach(function () {
this.settings = {
apis: { linkedUrlProxy: { url: undefined } },
- siteUrl: 'http://localhost:3000'
+ siteUrl: 'http://localhost:3000',
}
this.UrlHelper = SandboxedModule.require(modulePath, {
- requires: { 'settings-sharelatex': this.settings }
+ requires: { 'settings-sharelatex': this.settings },
})
})
describe('getSafeRedirectPath', function () {
diff --git a/services/web/test/unit/src/History/HistoryControllerTests.js b/services/web/test/unit/src/History/HistoryControllerTests.js
index 34258d9c83..b355deb3fd 100644
--- a/services/web/test/unit/src/History/HistoryControllerTests.js
+++ b/services/web/test/unit/src/History/HistoryControllerTests.js
@@ -21,7 +21,7 @@ describe('HistoryController', function () {
this.callback = sinon.stub()
this.user_id = 'user-id-123'
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.user_id)
+ getLoggedInUserId: sinon.stub().returns(this.user_id),
}
this.HistoryController = SandboxedModule.require(modulePath, {
requires: {
@@ -33,17 +33,17 @@ describe('HistoryController', function () {
'../Project/ProjectDetailsHandler': (this.ProjectDetailsHandler = {}),
'../Project/ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {}),
'../User/UserGetter': (this.UserGetter = {}),
- './RestoreManager': (this.RestoreManager = {})
- }
+ './RestoreManager': (this.RestoreManager = {}),
+ },
})
return (this.settings.apis = {
trackchanges: {
enabled: false,
- url: 'http://trackchanges.example.com'
+ url: 'http://trackchanges.example.com',
},
project_history: {
- url: 'http://project_history.example.com'
- }
+ url: 'http://project_history.example.com',
+ },
})
})
@@ -59,7 +59,7 @@ describe('HistoryController', function () {
this.ProjectDetailsHandler.getDetails = sinon
.stub()
.callsArgWith(1, null, {
- overleaf: { history: { id: 42, display: true } }
+ overleaf: { history: { id: 42, display: true } },
})
return this.HistoryController.selectHistoryApi(
this.req,
@@ -101,7 +101,7 @@ describe('HistoryController', function () {
pipe: sinon.stub(),
on(event, handler) {
return (this.events[event] = handler)
- }
+ },
}
return this.request.returns(this.proxy)
})
@@ -128,8 +128,8 @@ describe('HistoryController', function () {
url: `${this.settings.apis.project_history.url}${this.req.url}`,
method: this.req.method,
headers: {
- 'X-User-Id': this.user_id
- }
+ 'X-User-Id': this.user_id,
+ },
})
.should.equal(true)
})
@@ -161,8 +161,8 @@ describe('HistoryController', function () {
url: `${this.settings.apis.trackchanges.url}${this.req.url}`,
method: this.req.method,
headers: {
- 'X-User-Id': this.user_id
- }
+ 'X-User-Id': this.user_id,
+ },
})
.should.equal(true)
})
@@ -221,8 +221,8 @@ describe('HistoryController', function () {
method: this.req.method,
json: true,
headers: {
- 'X-User-Id': this.user_id
- }
+ 'X-User-Id': this.user_id,
+ },
})
.should.equal(true)
})
@@ -261,8 +261,8 @@ describe('HistoryController', function () {
method: this.req.method,
json: true,
headers: {
- 'X-User-Id': this.user_id
- }
+ 'X-User-Id': this.user_id,
+ },
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/History/HistoryManagerTests.js b/services/web/test/unit/src/History/HistoryManagerTests.js
index b9f8d1fca6..eb86a84da3 100644
--- a/services/web/test/unit/src/History/HistoryManagerTests.js
+++ b/services/web/test/unit/src/History/HistoryManagerTests.js
@@ -9,11 +9,11 @@ describe('HistoryManager', function () {
beforeEach(function () {
this.user_id = 'user-id-123'
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.user_id)
+ getLoggedInUserId: sinon.stub().returns(this.user_id),
}
this.request = {
post: sinon.stub(),
- delete: sinon.stub().resolves()
+ delete: sinon.stub().resolves(),
}
this.projectHistoryUrl = 'http://project_history.example.com'
this.v1HistoryUrl = 'http://v1_history.example.com'
@@ -23,32 +23,32 @@ describe('HistoryManager', function () {
apis: {
trackchanges: {
enabled: false,
- url: 'http://trackchanges.example.com'
+ url: 'http://trackchanges.example.com',
},
project_history: {
- url: this.projectHistoryUrl
+ url: this.projectHistoryUrl,
},
v1_history: {
url: this.v1HistoryUrl,
user: this.v1HistoryUser,
- pass: this.v1HistoryPassword
- }
- }
+ pass: this.v1HistoryPassword,
+ },
+ },
}
this.UserGetter = {
promises: {
getUsersByV1Ids: sinon.stub(),
- getUsers: sinon.stub()
- }
+ getUsers: sinon.stub(),
+ },
}
this.HistoryManager = SandboxedModule.require(MODULE_PATH, {
requires: {
'request-promise-native': this.request,
'settings-sharelatex': this.settings,
- '../User/UserGetter': this.UserGetter
- }
+ '../User/UserGetter': this.UserGetter,
+ },
})
})
@@ -70,7 +70,7 @@ describe('HistoryManager', function () {
it('should call the project history api', function () {
this.request.post
.calledWith({
- url: `${this.settings.apis.project_history.url}/project`
+ url: `${this.settings.apis.project_history.url}/project`,
})
.should.equal(true)
})
@@ -113,25 +113,25 @@ describe('HistoryManager', function () {
first_name: 'Jane',
last_name: 'Doe',
email: 'jane@example.com',
- overleaf: { id: 5011 }
+ overleaf: { id: 5011 },
}
this.user1_view = {
id: this.user_id1,
first_name: 'Jane',
last_name: 'Doe',
- email: 'jane@example.com'
+ email: 'jane@example.com',
}
this.user2 = {
_id: (this.user_id2 = 'abcdef'),
first_name: 'John',
last_name: 'Doe',
- email: 'john@example.com'
+ email: 'john@example.com',
}
this.user2_view = {
id: this.user_id2,
first_name: 'John',
last_name: 'Doe',
- email: 'john@example.com'
+ email: 'john@example.com',
}
this.UserGetter.promises.getUsersByV1Ids.resolves([this.user1])
this.UserGetter.promises.getUsers.resolves([this.user1, this.user2])
@@ -144,16 +144,16 @@ describe('HistoryManager', function () {
{
i: 'foo',
meta: {
- users: [this.user_id1]
- }
+ users: [this.user_id1],
+ },
},
{
i: 'bar',
meta: {
- users: [this.user_id2]
- }
- }
- ]
+ users: [this.user_id2],
+ },
+ },
+ ],
})
expect(diff.diff[0].meta.users).to.deep.equal([this.user1_view])
expect(diff.diff[1].meta.users).to.deep.equal([this.user2_view])
@@ -165,16 +165,16 @@ describe('HistoryManager', function () {
{
i: 'foo',
meta: {
- users: [5011]
- }
+ users: [5011],
+ },
},
{
i: 'bar',
meta: {
- users: [this.user_id2]
- }
- }
- ]
+ users: [this.user_id2],
+ },
+ },
+ ],
})
expect(diff.diff[0].meta.users).to.deep.equal([this.user1_view])
expect(diff.diff[1].meta.users).to.deep.equal([this.user2_view])
@@ -186,16 +186,16 @@ describe('HistoryManager', function () {
{
i: 'foo',
meta: {
- users: [this.user1_view]
- }
+ users: [this.user1_view],
+ },
},
{
i: 'bar',
meta: {
- users: [this.user_id2]
- }
- }
- ]
+ users: [this.user_id2],
+ },
+ },
+ ],
})
expect(diff.diff[0].meta.users).to.deep.equal([this.user1_view])
expect(diff.diff[1].meta.users).to.deep.equal([this.user2_view])
@@ -203,7 +203,7 @@ describe('HistoryManager', function () {
it('should handle a binary diff marker', async function () {
const diff = await this.HistoryManager.promises.injectUserDetails({
- diff: { binary: true }
+ diff: { binary: true },
})
expect(diff.diff.binary).to.be.true
})
@@ -217,17 +217,17 @@ describe('HistoryManager', function () {
fromV: 5,
toV: 8,
meta: {
- users: [this.user_id1]
- }
+ users: [this.user_id1],
+ },
},
{
fromV: 4,
toV: 5,
meta: {
- users: [this.user_id2]
- }
- }
- ]
+ users: [this.user_id2],
+ },
+ },
+ ],
})
expect(updates.updates[0].meta.users).to.deep.equal([this.user1_view])
expect(updates.updates[1].meta.users).to.deep.equal([this.user2_view])
@@ -240,17 +240,17 @@ describe('HistoryManager', function () {
fromV: 5,
toV: 8,
meta: {
- users: [this.user1_view]
- }
+ users: [this.user1_view],
+ },
},
{
fromV: 4,
toV: 5,
meta: {
- users: [this.user_id2]
- }
- }
- ]
+ users: [this.user_id2],
+ },
+ },
+ ],
})
expect(updates.updates[0].meta.users).to.deep.equal([this.user1_view])
expect(updates.updates[1].meta.users).to.deep.equal([this.user2_view])
@@ -277,8 +277,8 @@ describe('HistoryManager', function () {
url: `${this.v1HistoryUrl}/projects/${historyId}`,
auth: {
user: this.v1HistoryUser,
- pass: this.v1HistoryPassword
- }
+ pass: this.v1HistoryPassword,
+ },
})
})
})
diff --git a/services/web/test/unit/src/History/RestoreManagerTests.js b/services/web/test/unit/src/History/RestoreManagerTests.js
index a8d5dfcfd9..410f19a23c 100644
--- a/services/web/test/unit/src/History/RestoreManagerTests.js
+++ b/services/web/test/unit/src/History/RestoreManagerTests.js
@@ -31,8 +31,8 @@ describe('RestoreManager', function () {
'../../infrastructure/FileWriter': (this.FileWriter = {}),
'../Uploads/FileSystemImportManager': (this.FileSystemImportManager = {}),
'../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}),
- '../Editor/EditorController': (this.EditorController = {})
- }
+ '../Editor/EditorController': (this.EditorController = {}),
+ },
})
this.user_id = 'mock-user-id'
this.project_id = 'mock-project-id'
diff --git a/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js b/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js
index 0a8b589fb4..656383fc43 100644
--- a/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js
+++ b/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js
@@ -27,11 +27,11 @@ describe('InactiveProjectManager', function () {
this.settings = {}
this.DocstoreManager = {
unarchiveProject: sinon.stub(),
- archiveProject: sinon.stub()
+ archiveProject: sinon.stub(),
}
this.ProjectUpdateHandler = {
markAsActive: sinon.stub(),
- markAsInactive: sinon.stub()
+ markAsInactive: sinon.stub(),
}
this.ProjectGetter = { getProject: sinon.stub() }
this.InactiveProjectManager = SandboxedModule.require(modulePath, {
@@ -41,8 +41,8 @@ describe('InactiveProjectManager', function () {
'../Docstore/DocstoreManager': this.DocstoreManager,
'../Project/ProjectUpdateHandler': this.ProjectUpdateHandler,
'../Project/ProjectGetter': this.ProjectGetter,
- '../../models/Project': {}
- }
+ '../../models/Project': {},
+ },
})
return (this.project_id = '1234')
})
diff --git a/services/web/test/unit/src/Institutions/InstitutionHelperTests.js b/services/web/test/unit/src/Institutions/InstitutionHelperTests.js
index d29b6a5c74..edd6669ca1 100644
--- a/services/web/test/unit/src/Institutions/InstitutionHelperTests.js
+++ b/services/web/test/unit/src/Institutions/InstitutionHelperTests.js
@@ -12,8 +12,8 @@ describe('InstitutionsHelper', function () {
confirmedAt: new Date(),
affiliation: {
institution: { confirmed: true },
- licence: 'pro_plus'
- }
+ licence: 'pro_plus',
+ },
})
expect(emailHasLicence).to.be.true
})
@@ -23,8 +23,8 @@ describe('InstitutionsHelper', function () {
confirmedAt: new Date(),
affiliation: {
institution: { confirmed: true },
- licence: 'free'
- }
+ licence: 'free',
+ },
})
expect(emailHasLicence).to.be.false
})
@@ -34,8 +34,8 @@ describe('InstitutionsHelper', function () {
confirmedAt: new Date(),
affiliation: {
institution: { confirmed: true },
- licence: null
- }
+ licence: null,
+ },
})
expect(emailHasLicence).to.be.false
})
@@ -45,8 +45,8 @@ describe('InstitutionsHelper', function () {
confirmedAt: new Date(),
affiliation: {
institution: { confirmed: false },
- licence: 'pro_plus'
- }
+ licence: 'pro_plus',
+ },
})
expect(emailHasLicence).to.be.false
})
@@ -56,8 +56,8 @@ describe('InstitutionsHelper', function () {
confirmedAt: null,
affiliation: {
institution: { confirmed: true },
- licence: 'pro_plus'
- }
+ licence: 'pro_plus',
+ },
})
expect(emailHasLicence).to.be.false
})
diff --git a/services/web/test/unit/src/Institutions/InstitutionsAPITests.js b/services/web/test/unit/src/Institutions/InstitutionsAPITests.js
index a28deb78dd..83d3dc6678 100644
--- a/services/web/test/unit/src/Institutions/InstitutionsAPITests.js
+++ b/services/web/test/unit/src/Institutions/InstitutionsAPITests.js
@@ -13,25 +13,27 @@ describe('InstitutionsAPI', function () {
this.settings = { apis: { v1: { url: 'v1.url', user: '', pass: '' } } }
this.request = sinon.stub()
this.ipMatcherNotification = {
- read: (this.markAsReadIpMatcher = sinon.stub().callsArgWith(1, null))
+ read: (this.markAsReadIpMatcher = sinon.stub().callsArgWith(1, null)),
}
this.InstitutionsAPI = SandboxedModule.require(modulePath, {
requires: {
'@overleaf/metrics': {
- timeAsyncMethod: sinon.stub()
+ timeAsyncMethod: sinon.stub(),
},
'settings-sharelatex': this.settings,
request: this.request,
'../Notifications/NotificationsBuilder': {
- ipMatcherAffiliation: sinon.stub().returns(this.ipMatcherNotification)
- }
- }
+ ipMatcherAffiliation: sinon
+ .stub()
+ .returns(this.ipMatcherNotification),
+ },
+ },
})
this.stubbedUser = {
_id: '3131231',
name: 'bob',
- email: 'hello@world.com'
+ email: 'hello@world.com',
}
this.newEmail = 'bob@bob.com'
})
@@ -77,7 +79,7 @@ describe('InstitutionsAPI', function () {
this.institutionId = 123
const responseBody = {
lag: 'monthly',
- data: [{ key: 'users', values: [{ x: '2018-01-01', y: 1 }] }]
+ data: [{ key: 'users', values: [{ x: '2018-01-01', y: 1 }] }],
}
this.request.yields(null, { statusCode: 200 }, responseBody)
const startDate = '1417392000'
@@ -113,8 +115,8 @@ describe('InstitutionsAPI', function () {
date: queryDate,
data: {
user_counts: { total: [], new: [] },
- max_confirmation_months: []
- }
+ max_confirmation_months: [],
+ },
}
this.request.callsArgWith(1, null, { statusCode: 201 }, v1Result)
this.InstitutionsAPI.getLicencesForAnalytics(
@@ -197,7 +199,7 @@ describe('InstitutionsAPI', function () {
role: 'Prof',
department: 'Math',
confirmedAt: new Date(),
- entitlement: true
+ entitlement: true,
}
this.InstitutionsAPI.addAffiliation(
this.stubbedUser._id,
diff --git a/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js b/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js
index d4701536de..15ca2dcd3c 100644
--- a/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js
+++ b/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js
@@ -30,33 +30,33 @@ describe('InstitutionsController', function () {
emails: [
{ email: 'stubb1@mit.edu', reversedHostname: this.host },
{ email: 'test@test.com', reversedHostname: 'test.com' },
- { email: 'another@mit.edu', reversedHostname: this.host }
- ]
+ { email: 'another@mit.edu', reversedHostname: this.host },
+ ],
}
this.stubbedUser1DecoratedEmails = [
{
email: 'stubb1@mit.edu',
reversedHostname: this.host,
- samlIdentifier: { hasEntitlement: false }
+ samlIdentifier: { hasEntitlement: false },
},
{ email: 'test@test.com', reversedHostname: 'test.com' },
{
email: 'another@mit.edu',
reversedHostname: this.host,
- samlIdentifier: { hasEntitlement: true }
- }
+ samlIdentifier: { hasEntitlement: true },
+ },
]
this.stubbedUser2 = {
_id: '3131232',
name: 'test',
email: 'hello2@world.com',
- emails: [{ email: 'subb2@mit.edu', reversedHostname: this.host }]
+ emails: [{ email: 'subb2@mit.edu', reversedHostname: this.host }],
}
this.stubbedUser2DecoratedEmails = [
{
email: 'subb2@mit.edu',
- reversedHostname: this.host
- }
+ reversedHostname: this.host,
+ },
]
this.getUsersByHostname = sinon.stub().callsArgWith(
@@ -79,22 +79,22 @@ describe('InstitutionsController', function () {
requires: {
'../User/UserGetter': {
getUsersByHostname: this.getUsersByHostname,
- getUserFullEmails: this.getUserFullEmails
+ getUserFullEmails: this.getUserFullEmails,
},
'../Institutions/InstitutionsAPI': {
- addAffiliation: this.addAffiliation
+ addAffiliation: this.addAffiliation,
},
'../Subscription/FeaturesUpdater': {
- refreshFeatures: this.refreshFeatures
- }
- }
+ refreshFeatures: this.refreshFeatures,
+ },
+ },
})
this.req = { body: { hostname: 'mit.edu' } }
this.res = {
send: sinon.stub(),
- json: sinon.stub()
+ json: sinon.stub(),
}
return (this.next = sinon.stub())
})
diff --git a/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js b/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js
index c5b0683c11..66e71f4e43 100644
--- a/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js
+++ b/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js
@@ -29,9 +29,9 @@ describe('InstitutionsFeatures', function () {
'../User/UserGetter': this.UserGetter,
'../Subscription/PlansLocator': this.PlansLocator,
'settings-sharelatex': {
- institutionPlanCode: this.institutionPlanCode
- }
- }
+ institutionPlanCode: this.institutionPlanCode,
+ },
+ },
})
return (this.userId = '12345abcde')
@@ -65,7 +65,7 @@ describe('InstitutionsFeatures', function () {
it('should return true if user has confirmed paid affiliation', function (done) {
const emailData = [
{ emailHasInstitutionLicence: true },
- { emailHasInstitutionLicence: false }
+ { emailHasInstitutionLicence: false },
]
this.UserGetter.getUserFullEmails.yields(null, emailData)
return this.InstitutionsFeatures.hasLicence(
diff --git a/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js b/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js
index 29a5f61ef0..df509c6540 100644
--- a/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js
+++ b/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js
@@ -24,8 +24,8 @@ describe('InstitutionsGetter', function () {
requires: {
'../User/UserGetter': this.UserGetter,
'../UserMembership/UserMembershipsHandler': (this.UserMembershipsHandler = {}),
- '../UserMembership/UserMembershipEntityConfigs': (this.UserMembershipEntityConfigs = {})
- }
+ '../UserMembership/UserMembershipEntityConfigs': (this.UserMembershipEntityConfigs = {}),
+ },
})
return (this.userId = '12345abcde')
@@ -36,18 +36,18 @@ describe('InstitutionsGetter', function () {
this.userEmails = [
{
confirmedAt: null,
- affiliation: { institution: { id: 123, confirmed: true } }
+ affiliation: { institution: { id: 123, confirmed: true } },
},
{
confirmedAt: new Date(),
- affiliation: { institution: { id: 456, confirmed: true } }
+ affiliation: { institution: { id: 456, confirmed: true } },
},
{ confirmedAt: new Date(), affiliation: null },
{ confirmedAt: new Date(), affiliation: { institution: null } },
{
confirmedAt: new Date(),
- affiliation: { institution: { id: 789, confirmed: false } }
- }
+ affiliation: { institution: { id: 789, confirmed: false } },
+ },
]
this.UserGetter.getUserFullEmails.yields(null, this.userEmails)
return this.InstitutionsGetter.getConfirmedInstitutions(
diff --git a/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js b/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js
index cc763cb3b7..47f007880d 100644
--- a/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js
+++ b/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js
@@ -15,49 +15,49 @@ describe('InstitutionsManager', function () {
this.refreshFeatures = sinon.stub().yields()
this.UserGetter = {
getUsersByAnyConfirmedEmail: sinon.stub().yields(),
- getUser: sinon.stub().callsArgWith(1, null, this.user)
+ getUser: sinon.stub().callsArgWith(1, null, this.user),
}
this.creator = { create: sinon.stub().callsArg(0) }
this.NotificationsBuilder = {
featuresUpgradedByAffiliation: sinon.stub().returns(this.creator),
- redundantPersonalSubscription: sinon.stub().returns(this.creator)
+ redundantPersonalSubscription: sinon.stub().returns(this.creator),
}
this.SubscriptionLocator = {
- getUsersSubscription: sinon.stub().callsArg(1)
+ getUsersSubscription: sinon.stub().callsArg(1),
}
this.institutionWithV1Data = { name: 'Wombat University' }
this.institution = {
fetchV1Data: sinon
.stub()
- .callsArgWith(0, null, this.institutionWithV1Data)
+ .callsArgWith(0, null, this.institutionWithV1Data),
}
this.InstitutionModel = {
Institution: {
- findOne: sinon.stub().callsArgWith(1, null, this.institution)
- }
+ findOne: sinon.stub().callsArgWith(1, null, this.institution),
+ },
}
this.subscriptionExec = sinon.stub().yields()
this.SAMLIdentityManager = {
- userHasEntitlement: sinon.stub().returns(false)
+ userHasEntitlement: sinon.stub().returns(false),
}
const SubscriptionModel = {
Subscription: {
find: () => ({
populate: () => ({
- exec: this.subscriptionExec
- })
- })
- }
+ exec: this.subscriptionExec,
+ }),
+ }),
+ },
}
this.Mongo = { ObjectId: sinon.stub().returnsArg(0) }
this.InstitutionsManager = SandboxedModule.require(modulePath, {
requires: {
'./InstitutionsAPI': {
- getInstitutionAffiliations: this.getInstitutionAffiliations
+ getInstitutionAffiliations: this.getInstitutionAffiliations,
},
'../Subscription/FeaturesUpdater': {
- refreshFeatures: this.refreshFeatures
+ refreshFeatures: this.refreshFeatures,
},
'../User/UserGetter': this.UserGetter,
'../Notifications/NotificationsBuilder': this.NotificationsBuilder,
@@ -65,8 +65,8 @@ describe('InstitutionsManager', function () {
'../../models/Institution': this.InstitutionModel,
'../../models/Subscription': SubscriptionModel,
mongodb: this.Mongo,
- '../User/SAMLIdentityManager': this.SAMLIdentityManager
- }
+ '../User/SAMLIdentityManager': this.SAMLIdentityManager,
+ },
})
})
@@ -79,7 +79,7 @@ describe('InstitutionsManager', function () {
this.user2 = { _id: this.user2Id }
this.subscription = {
planCode: 'pro',
- groupPlan: false
+ groupPlan: false,
}
this.UserGetter.getUser
.withArgs(this.user1Id)
@@ -159,16 +159,16 @@ describe('InstitutionsManager', function () {
const stubbedUsers = [
{
_id: '123abc123abc123abc123abc',
- features: { collaborators: -1, trackChanges: true }
+ features: { collaborators: -1, trackChanges: true },
},
{
_id: '456def456def456def456def',
- features: { collaborators: 10, trackChanges: false }
+ features: { collaborators: 10, trackChanges: false },
},
{
_id: '789def789def789def789def',
- features: { collaborators: -1, trackChanges: false }
- }
+ features: { collaborators: -1, trackChanges: false },
+ },
]
this.getInstitutionAffiliations.yields(null, affiliations)
this.UserGetter.getUsersByAnyConfirmedEmail.yields(null, stubbedUsers)
@@ -185,14 +185,14 @@ describe('InstitutionsManager', function () {
usersSummary.confirmedEmailUsers.totalNonProUsers.should.equal(2)
expect(usersSummary.confirmedEmailUsers.nonProUsers).to.deep.equal([
'456def456def456def456def',
- '789def789def789def789def'
+ '789def789def789def789def',
])
usersSummary.entitledSSOUsers.total.should.equal(2)
usersSummary.entitledSSOUsers.totalProUsers.should.equal(1)
usersSummary.entitledSSOUsers.totalNonProUsers.should.equal(1)
expect(usersSummary.entitledSSOUsers.nonProUsers).to.deep.equal([
- '456def456def456def456def'
+ '456def456def456def456def',
])
done()
}
@@ -205,7 +205,7 @@ describe('InstitutionsManager', function () {
const stubbedUsers = [
{ user_id: '123abc123abc123abc123abc' },
{ user_id: '456def456def456def456def' },
- { user_id: '789def789def789def789def' }
+ { user_id: '789def789def789def789def' },
]
this.getInstitutionAffiliations.yields(null, stubbedUsers)
this.InstitutionsManager.getInstitutionUsersSubscriptions(
diff --git a/services/web/test/unit/src/Metadata/MetaControllerTests.js b/services/web/test/unit/src/Metadata/MetaControllerTests.js
index a41419d674..68ebdd6212 100644
--- a/services/web/test/unit/src/Metadata/MetaControllerTests.js
+++ b/services/web/test/unit/src/Metadata/MetaControllerTests.js
@@ -18,17 +18,17 @@ describe('MetaController', function () {
beforeEach(function () {
this.projectId = 'somekindofid'
this.EditorRealTimeController = {
- emitToRoom: sinon.stub()
+ emitToRoom: sinon.stub(),
}
this.MetaHandler = {
getAllMetaForProject: sinon.stub(),
- getMetaForDoc: sinon.stub()
+ getMetaForDoc: sinon.stub(),
}
return (this.MetadataController = SandboxedModule.require(modulePath, {
requires: {
'../Editor/EditorRealTimeController': this.EditorRealTimeController,
- './MetaHandler': this.MetaHandler
- }
+ './MetaHandler': this.MetaHandler,
+ },
}))
})
@@ -61,7 +61,7 @@ describe('MetaController', function () {
this.res.json.callCount.should.equal(1)
return expect(this.res.json.lastCall.args[0]).to.have.all.keys([
'projectId',
- 'projectMeta'
+ 'projectMeta',
])
})
@@ -111,7 +111,7 @@ describe('MetaController', function () {
beforeEach(function () {
this.req = {
params: { project_id: this.projectId, doc_id: this.docId },
- body: { broadcast: true }
+ body: { broadcast: true },
}
})
@@ -164,7 +164,7 @@ describe('MetaController', function () {
beforeEach(function () {
this.req = {
params: { project_id: this.projectId, doc_id: this.docId },
- body: { broadcast: false }
+ body: { broadcast: false },
}
})
@@ -222,7 +222,7 @@ describe('MetaController', function () {
this.docId = 'somedoc'
this.req = {
params: { project_id: this.projectId, doc_id: this.docId },
- body: { broadcast: true }
+ body: { broadcast: true },
}
this.res = { json: sinon.stub() }
return (this.next = sinon.stub())
diff --git a/services/web/test/unit/src/Metadata/MetaHandlerTests.js b/services/web/test/unit/src/Metadata/MetaHandlerTests.js
index 688f1817c4..31a460e299 100644
--- a/services/web/test/unit/src/Metadata/MetaHandlerTests.js
+++ b/services/web/test/unit/src/Metadata/MetaHandlerTests.js
@@ -21,10 +21,10 @@ describe('MetaHandler', function () {
this.docId = 'somedocid'
this.ProjectEntityHandler = {
getAllDocs: sinon.stub(),
- getDoc: sinon.stub()
+ getDoc: sinon.stub(),
}
this.DocumentUpdaterHandler = {
- flushDocToMongo: sinon.stub()
+ flushDocToMongo: sinon.stub(),
}
this.packageMapping = {
foo: [
@@ -32,23 +32,23 @@ describe('MetaHandler', function () {
caption: '\\bar',
snippet: '\\bar',
meta: 'foo-cmd',
- score: 12
+ score: 12,
},
{
caption: '\\bat[]{}',
snippet: '\\bar[$1]{$2}',
meta: 'foo-cmd',
- score: 10
- }
+ score: 10,
+ },
],
baz: [
{
caption: '\\longercommandtest{}',
snippet: '\\longercommandtest{$1}',
meta: 'baz-cmd',
- score: 50
- }
- ]
+ score: 50,
+ },
+ ],
}
return (this.MetaHandler = SandboxedModule.require(modulePath, {
@@ -56,8 +56,8 @@ describe('MetaHandler', function () {
'../Project/ProjectEntityHandler': this.ProjectEntityHandler,
'../DocumentUpdater/DocumentUpdaterHandler': this
.DocumentUpdaterHandler,
- './packageMapping': this.packageMapping
- }
+ './packageMapping': this.packageMapping,
+ },
}))
})
@@ -71,7 +71,7 @@ describe('MetaHandler', function () {
'three \\label{aaa}',
'four five',
'\\label{bbb}',
- 'six seven'
+ 'six seven',
])
})
@@ -85,16 +85,16 @@ describe('MetaHandler', function () {
caption: '\\bar',
snippet: '\\bar',
meta: 'foo-cmd',
- score: 12
+ score: 12,
},
{
caption: '\\bat[]{}',
snippet: '\\bar[$1]{$2}',
meta: 'foo-cmd',
- score: 10
- }
- ]
- }
+ score: 10,
+ },
+ ],
+ },
})
})
})
@@ -104,22 +104,22 @@ describe('MetaHandler', function () {
return (this.docs = {
doc_one: {
_id: 'id_one',
- lines: ['one', '\\label{aaa} two', 'three']
+ lines: ['one', '\\label{aaa} two', 'three'],
},
doc_two: {
_id: 'id_two',
- lines: ['four']
+ lines: ['four'],
},
doc_three: {
_id: 'id_three',
- lines: ['\\label{bbb}', 'five six', 'seven eight \\label{ccc} nine']
+ lines: ['\\label{bbb}', 'five six', 'seven eight \\label{ccc} nine'],
},
doc_four: {
_id: 'id_four',
lines: [
'\\usepackage[width=\\textwidth]{baz}',
- '\\usepackage{amsmath}'
- ]
+ '\\usepackage{amsmath}',
+ ],
},
doc_five: {
_id: 'id_five',
@@ -129,9 +129,9 @@ describe('MetaHandler', function () {
'some text',
'\\section{this}\\label{sec:intro}',
'In Section \\ref{sec:intro} we saw',
- 'nothing'
- ]
- }
+ 'nothing',
+ ],
+ },
})
})
@@ -149,10 +149,10 @@ describe('MetaHandler', function () {
caption: '\\longercommandtest{}',
snippet: '\\longercommandtest{$1}',
meta: 'baz-cmd',
- score: 50
- }
- ]
- }
+ score: 50,
+ },
+ ],
+ },
},
id_five: {
labels: ['sec:intro'],
@@ -162,25 +162,25 @@ describe('MetaHandler', function () {
caption: '\\bar',
snippet: '\\bar',
meta: 'foo-cmd',
- score: 12
+ score: 12,
},
{
caption: '\\bat[]{}',
snippet: '\\bar[$1]{$2}',
meta: 'foo-cmd',
- score: 10
- }
+ score: 10,
+ },
],
baz: [
{
caption: '\\longercommandtest{}',
snippet: '\\longercommandtest{$1}',
meta: 'baz-cmd',
- score: 50
- }
- ]
- }
- }
+ score: 50,
+ },
+ ],
+ },
+ },
})
})
})
@@ -254,8 +254,8 @@ describe('MetaHandler', function () {
beforeEach(function () {
this.fakeDocs = {
doc_one: {
- lines: ['\\usepackage[some-options,more=foo]{foo}', '\\label{aaa}']
- }
+ lines: ['\\usepackage[some-options,more=foo]{foo}', '\\label{aaa}'],
+ },
}
this.fakeMeta = {
@@ -266,16 +266,16 @@ describe('MetaHandler', function () {
caption: '\\bar',
snippet: '\\bar',
meta: 'foo-cmd',
- score: 12
+ score: 12,
},
{
caption: '\\bat[]{}',
snippet: '\\bar[$1]{$2}',
meta: 'foo-cmd',
- score: 10
- }
- ]
- }
+ score: 10,
+ },
+ ],
+ },
}
this.DocumentUpdaterHandler.flushProjectToMongo = sinon
.stub()
diff --git a/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js b/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js
index 29972668d0..7b1625328b 100644
--- a/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js
+++ b/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js
@@ -9,34 +9,34 @@ describe('NewsletterManager', function () {
this.Settings = {
mailchimp: {
api_key: 'api_key',
- list_id: 'list_id'
- }
+ list_id: 'list_id',
+ },
}
this.mailchimp = {
put: sinon.stub(),
patch: sinon.stub(),
- delete: sinon.stub()
+ delete: sinon.stub(),
}
this.Mailchimp = sinon.stub().returns(this.mailchimp)
this.mergeFields = {
FNAME: 'Overleaf',
LNAME: 'Duck',
- MONGO_ID: 'user_id'
+ MONGO_ID: 'user_id',
}
this.NewsletterManager = SandboxedModule.require(MODULE_PATH, {
requires: {
'mailchimp-api-v3': this.Mailchimp,
- 'settings-sharelatex': this.Settings
- }
+ 'settings-sharelatex': this.Settings,
+ },
}).promises
this.user = {
_id: 'user_id',
email: 'overleaf.duck@example.com',
first_name: 'Overleaf',
- last_name: 'Duck'
+ last_name: 'Duck',
}
// MD5 sum of the user email
this.emailHash = 'c02f60ed0ef51818186274e406c9a48f'
@@ -51,7 +51,7 @@ describe('NewsletterManager', function () {
email_address: this.user.email,
status: 'subscribed',
status_if_new: 'subscribed',
- merge_fields: this.mergeFields
+ merge_fields: this.mergeFields,
}
)
})
@@ -65,7 +65,7 @@ describe('NewsletterManager', function () {
`/lists/list_id/members/${this.emailHash}`,
{
status: 'unsubscribed',
- merge_fields: this.mergeFields
+ merge_fields: this.mergeFields,
}
)
})
@@ -129,7 +129,7 @@ describe('NewsletterManager', function () {
`/lists/list_id/members/${this.emailHash}`,
{
email_address: 'overleaf.squirrel@example.com',
- merge_fields: this.mergeFields
+ merge_fields: this.mergeFields,
}
)
})
@@ -138,7 +138,7 @@ describe('NewsletterManager', function () {
this.mailchimp.patch
.withArgs(`/lists/list_id/members/${this.emailHash}`, {
email_address: 'overleaf.squirrel@example.com',
- merge_fields: this.mergeFields
+ merge_fields: this.mergeFields,
})
.rejects(new Error('that did not work'))
diff --git a/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js b/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js
index a373446c1c..3a810303b6 100644
--- a/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js
+++ b/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js
@@ -17,8 +17,8 @@ describe('NotificationsBuilder', function () {
requires: {
'./NotificationsHandler': this.handler,
'settings-sharelatex': this.settings,
- request: this.request
- }
+ request: this.request,
+ },
})
})
@@ -30,7 +30,7 @@ describe('NotificationsBuilder', function () {
enrolment_ad_html: 'v1 ad content',
is_university: true,
portal_slug: null,
- sso_enabled: false
+ sso_enabled: false,
}
this.request.callsArgWith(1, null, { statusCode: 200 }, this.body)
})
@@ -44,7 +44,7 @@ describe('NotificationsBuilder', function () {
university_name: this.body.name,
content: this.body.enrolment_ad_html,
ssoEnabled: false,
- portalPath: undefined
+ portalPath: undefined,
}
this.handler.createNotification
.calledWith(
@@ -66,7 +66,7 @@ describe('NotificationsBuilder', function () {
enrolment_ad_html: 'v1 ad content',
is_university: true,
portal_slug: 'stanford',
- sso_enabled: true
+ sso_enabled: true,
}
this.request.callsArgWith(1, null, { statusCode: 200 }, this.body)
})
@@ -80,7 +80,7 @@ describe('NotificationsBuilder', function () {
university_name: this.body.name,
content: this.body.enrolment_ad_html,
ssoEnabled: true,
- portalPath: '/edu/stanford'
+ portalPath: '/edu/stanford',
}
this.handler.createNotification
.calledWith(
diff --git a/services/web/test/unit/src/Notifications/NotificationsControllerTests.js b/services/web/test/unit/src/Notifications/NotificationsControllerTests.js
index 2c18a6407e..3dcd55ffb0 100644
--- a/services/web/test/unit/src/Notifications/NotificationsControllerTests.js
+++ b/services/web/test/unit/src/Notifications/NotificationsControllerTests.js
@@ -26,30 +26,30 @@ describe('NotificationsController', function () {
beforeEach(function () {
this.handler = {
getUserNotifications: sinon.stub().callsArgWith(1),
- markAsRead: sinon.stub().callsArgWith(2)
+ markAsRead: sinon.stub().callsArgWith(2),
}
this.req = {
params: {
- notification_id
+ notification_id,
},
session: {
user: {
- _id: user_id
- }
+ _id: user_id,
+ },
},
i18n: {
- translate() {}
- }
+ translate() {},
+ },
}
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.req.session.user._id)
+ getLoggedInUserId: sinon.stub().returns(this.req.session.user._id),
}
return (this.controller = SandboxedModule.require(modulePath, {
requires: {
'./NotificationsHandler': this.handler,
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
}))
})
@@ -63,7 +63,7 @@ describe('NotificationsController', function () {
body.should.deep.equal(allNotifications)
this.handler.getUserNotifications.calledWith(user_id).should.equal(true)
return done()
- }
+ },
})
})
@@ -74,7 +74,7 @@ describe('NotificationsController', function () {
.calledWith(user_id, notification_id)
.should.equal(true)
return done()
- }
+ },
})
})
})
diff --git a/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js b/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js
index ebbaf681b6..b6f590daca 100644
--- a/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js
+++ b/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js
@@ -31,10 +31,10 @@ describe('NotificationsHandler', function () {
return (this.handler = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': {
- apis: { notifications: { url: notificationUrl } }
+ apis: { notifications: { url: notificationUrl } },
},
- request: this.request
- }
+ request: this.request,
+ },
}))
})
@@ -55,7 +55,7 @@ describe('NotificationsHandler', function () {
uri: `${notificationUrl}/user/${user_id}`,
json: true,
timeout: 1000,
- method: 'GET'
+ method: 'GET',
}
this.request.calledWith(getOpts).should.equal(true)
return done()
@@ -84,10 +84,10 @@ describe('NotificationsHandler', function () {
const opts = {
uri: `${notificationUrl}/user/${user_id}`,
json: {
- key: this.key
+ key: this.key,
},
timeout: 1000,
- method: 'DELETE'
+ method: 'DELETE',
}
this.request.calledWith(opts).should.equal(true)
return done()
@@ -118,7 +118,7 @@ describe('NotificationsHandler', function () {
key: this.key,
templateKey: this.templateKey,
messageOpts: this.messageOpts,
- forceCreate: true
+ forceCreate: true,
}
assert.deepEqual(args.json, expectedJson)
return done()
@@ -150,7 +150,7 @@ describe('NotificationsHandler', function () {
templateKey: this.templateKey,
messageOpts: this.messageOpts,
expires: this.expiry,
- forceCreate: true
+ forceCreate: true,
}
assert.deepEqual(args.json, expectedJson)
return done()
@@ -170,7 +170,7 @@ describe('NotificationsHandler', function () {
const opts = {
uri: `${notificationUrl}/key/${this.key}`,
timeout: 1000,
- method: 'DELETE'
+ method: 'DELETE',
}
this.request.calledWith(opts).should.equal(true)
return done()
diff --git a/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js b/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js
index e8bd654cb0..c4066debf5 100644
--- a/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js
+++ b/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js
@@ -19,13 +19,13 @@ describe('PasswordResetController', function () {
body: {
email: this.email,
passwordResetToken: this.token,
- password: this.password
+ password: this.password,
},
i18n: {
- translate() {}
+ translate() {},
},
session: {},
- query: {}
+ query: {},
}
this.res = new MockResponse()
@@ -35,19 +35,19 @@ describe('PasswordResetController', function () {
promises: {
setNewUserPassword: sinon
.stub()
- .resolves({ found: true, reset: true, userID: this.user_id })
- }
+ .resolves({ found: true, reset: true, userID: this.user_id }),
+ },
}
this.RateLimiter = { addCount: sinon.stub() }
this.UserSessionsManager = {
promises: {
- revokeAllUserSessions: sinon.stub().resolves()
- }
+ revokeAllUserSessions: sinon.stub().resolves(),
+ },
}
this.UserUpdater = {
promises: {
- removeReconfirmFlag: sinon.stub().resolves()
- }
+ removeReconfirmFlag: sinon.stub().resolves(),
+ },
}
this.PasswordResetController = SandboxedModule.require(MODULE_PATH, {
requires: {
@@ -56,16 +56,16 @@ describe('PasswordResetController', function () {
'../../infrastructure/RateLimiter': this.RateLimiter,
'../Authentication/AuthenticationController': (this.AuthenticationController = {
getLoggedInUserId: sinon.stub(),
- finishLogin: sinon.stub()
+ finishLogin: sinon.stub(),
}),
'../User/UserGetter': (this.UserGetter = {
promises: {
- getUser: sinon.stub()
- }
+ getUser: sinon.stub(),
+ },
}),
'../User/UserSessionsManager': this.UserSessionsManager,
- '../User/UserUpdater': this.UserUpdater
- }
+ '../User/UserUpdater': this.UserUpdater,
+ },
})
})
@@ -187,7 +187,7 @@ describe('PasswordResetController', function () {
this.PasswordResetHandler.promises.setNewUserPassword.resolves({
found: false,
reset: false,
- userId: this.user_id
+ userId: this.user_id,
})
this.res.sendStatus = code => {
code.should.equal(404)
@@ -200,7 +200,7 @@ describe('PasswordResetController', function () {
this.PasswordResetHandler.promises.setNewUserPassword.resolves({
found: true,
reset: false,
- userId: this.user_id
+ userId: this.user_id,
})
this.res.sendStatus = code => {
code.should.equal(500)
@@ -311,7 +311,7 @@ describe('PasswordResetController', function () {
beforeEach(function () {
this.user = {
_id: this.userId,
- email: 'joe@example.com'
+ email: 'joe@example.com',
}
this.UserGetter.promises.getUser.resolves(this.user)
this.req.session.doLoginAfterPasswordReset = 'true'
diff --git a/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js b/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js
index 90ccc5d49f..c768b56e0e 100644
--- a/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js
+++ b/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js
@@ -26,33 +26,33 @@ describe('PasswordResetHandler', function () {
this.settings = { siteUrl: 'www.sharelatex.com' }
this.OneTimeTokenHandler = {
getNewToken: sinon.stub(),
- getValueFromTokenAndExpire: sinon.stub()
+ getValueFromTokenAndExpire: sinon.stub(),
}
this.UserGetter = {
getUserByMainEmail: sinon.stub(),
getUser: sinon.stub(),
- getUserByAnyEmail: sinon.stub()
+ getUserByAnyEmail: sinon.stub(),
}
this.EmailHandler = { sendEmail: sinon.stub() }
this.AuthenticationManager = {
setUserPasswordInV2: sinon.stub(),
promises: {
- setUserPassword: sinon.stub().resolves()
- }
+ setUserPassword: sinon.stub().resolves(),
+ },
}
this.PasswordResetHandler = SandboxedModule.require(modulePath, {
requires: {
'../User/UserAuditLogHandler': (this.UserAuditLogHandler = {
promises: {
- addEntry: sinon.stub().resolves()
- }
+ addEntry: sinon.stub().resolves(),
+ },
}),
'../User/UserGetter': this.UserGetter,
'../Security/OneTimeTokenHandler': this.OneTimeTokenHandler,
'../Email/EmailHandler': this.EmailHandler,
'../Authentication/AuthenticationManager': this.AuthenticationManager,
- 'settings-sharelatex': this.settings
- }
+ 'settings-sharelatex': this.settings,
+ },
})
this.token = '12312321i'
this.user_id = 'user_id_here'
@@ -116,7 +116,7 @@ describe('PasswordResetHandler', function () {
'password',
{
email: this.email,
- user_id: this.user._id
+ user_id: this.user._id,
}
)
})
@@ -201,7 +201,7 @@ describe('PasswordResetHandler', function () {
expect(result).to.deep.equal({
found: false,
reset: false,
- userId: null
+ userId: null,
})
}
)
@@ -214,7 +214,7 @@ describe('PasswordResetHandler', function () {
.withArgs('password', this.token)
.yields(null, {
user_id: this.user._id,
- email: this.email
+ email: this.email,
})
this.AuthenticationManager.promises.setUserPassword
.withArgs(this.user, this.password)
@@ -373,7 +373,7 @@ describe('PasswordResetHandler', function () {
.withArgs('password', this.token)
.yields(null, {
v1_user_id: this.user.overleaf.id,
- email: this.email
+ email: this.email,
})
this.AuthenticationManager.promises.setUserPassword
.withArgs(this.user, this.password)
@@ -407,7 +407,7 @@ describe('PasswordResetHandler', function () {
this.UserGetter.getUserByMainEmail.withArgs(this.email).yields(null, {
_id: this.user._id,
email: this.email,
- overleaf: { id: 'not-the-same' }
+ overleaf: { id: 'not-the-same' },
})
})
diff --git a/services/web/test/unit/src/Project/FolderStructureBuilderTests.js b/services/web/test/unit/src/Project/FolderStructureBuilderTests.js
index 73414af725..3febe37ebd 100644
--- a/services/web/test/unit/src/Project/FolderStructureBuilderTests.js
+++ b/services/web/test/unit/src/Project/FolderStructureBuilderTests.js
@@ -11,8 +11,8 @@ describe('FolderStructureBuilder', function () {
this.ObjectId = sinon.stub().returns(MOCK_OBJECT_ID)
this.FolderStructureBuilder = SandboxedModule.require(MODULE_PATH, {
requires: {
- mongodb: { ObjectId: this.ObjectId }
- }
+ mongodb: { ObjectId: this.ObjectId },
+ },
})
})
@@ -28,7 +28,7 @@ describe('FolderStructureBuilder', function () {
name: 'rootFolder',
folders: [],
docs: [],
- fileRefs: []
+ fileRefs: [],
})
})
})
@@ -41,13 +41,13 @@ describe('FolderStructureBuilder', function () {
{ path: '/foo/other.bib', doc: { _id: 'doc-3', name: 'other.bib' } },
{
path: '/foo/foo1/foo2/another.tex',
- doc: { _id: 'doc-4', name: 'another.tex' }
- }
+ doc: { _id: 'doc-4', name: 'another.tex' },
+ },
]
const fileUploads = [
{ path: '/aaa.jpg', file: { _id: 'file-1', name: 'aaa.jpg' } },
{ path: '/foo/bbb.jpg', file: { _id: 'file-2', name: 'bbb.jpg' } },
- { path: '/bar/ccc.jpg', file: { _id: 'file-3', name: 'ccc.jpg' } }
+ { path: '/bar/ccc.jpg', file: { _id: 'file-3', name: 'ccc.jpg' } },
]
this.result = this.FolderStructureBuilder.buildFolderStructure(
docUploads,
@@ -67,7 +67,7 @@ describe('FolderStructureBuilder', function () {
name: 'foo',
docs: [
{ _id: 'doc-2', name: 'other.tex' },
- { _id: 'doc-3', name: 'other.bib' }
+ { _id: 'doc-3', name: 'other.bib' },
],
fileRefs: [{ _id: 'file-2', name: 'bbb.jpg' }],
folders: [
@@ -82,20 +82,20 @@ describe('FolderStructureBuilder', function () {
name: 'foo2',
docs: [{ _id: 'doc-4', name: 'another.tex' }],
fileRefs: [],
- folders: []
- }
- ]
- }
- ]
+ folders: [],
+ },
+ ],
+ },
+ ],
},
{
_id: MOCK_OBJECT_ID,
name: 'bar',
docs: [],
fileRefs: [{ _id: 'file-3', name: 'ccc.jpg' }],
- folders: []
- }
- ]
+ folders: [],
+ },
+ ],
})
})
})
@@ -104,7 +104,7 @@ describe('FolderStructureBuilder', function () {
it('throws an error', function () {
const docUploads = [
{ path: '/foo/doc.tex', doc: { _id: 'doc-1', name: 'doc.tex' } },
- { path: '/foo/doc.tex', doc: { _id: 'doc-2', name: 'doc.tex' } }
+ { path: '/foo/doc.tex', doc: { _id: 'doc-2', name: 'doc.tex' } },
]
expect(() =>
this.FolderStructureBuilder.buildFolderStructure(docUploads, [])
diff --git a/services/web/test/unit/src/Project/ProjectApiControllerTests.js b/services/web/test/unit/src/Project/ProjectApiControllerTests.js
index 7985ec1b98..f3eb7c32ed 100644
--- a/services/web/test/unit/src/Project/ProjectApiControllerTests.js
+++ b/services/web/test/unit/src/Project/ProjectApiControllerTests.js
@@ -19,17 +19,17 @@ describe('Project api controller', function () {
this.ProjectDetailsHandler = { getDetails: sinon.stub() }
this.controller = SandboxedModule.require(modulePath, {
requires: {
- './ProjectDetailsHandler': this.ProjectDetailsHandler
- }
+ './ProjectDetailsHandler': this.ProjectDetailsHandler,
+ },
})
this.project_id = '321l3j1kjkjl'
this.req = {
params: {
- project_id: this.project_id
+ project_id: this.project_id,
},
session: {
- destroy: sinon.stub()
- }
+ destroy: sinon.stub(),
+ },
}
this.res = {}
this.next = sinon.stub()
diff --git a/services/web/test/unit/src/Project/ProjectAuditLogHandlerTests.js b/services/web/test/unit/src/Project/ProjectAuditLogHandlerTests.js
index 4943f6cec2..6e92577c4a 100644
--- a/services/web/test/unit/src/Project/ProjectAuditLogHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectAuditLogHandlerTests.js
@@ -14,8 +14,8 @@ describe('ProjectAuditLogHandler', function () {
this.ProjectMock = sinon.mock(Project)
this.ProjectAuditLogHandler = SandboxedModule.require(MODULE_PATH, {
requires: {
- '../../models/Project': { Project }
- }
+ '../../models/Project': { Project },
+ },
})
})
@@ -36,12 +36,12 @@ describe('ProjectAuditLogHandler', function () {
operation: 'translate',
initiatorId: this.userId,
info: { destinationLanguage: 'tagalog' },
- timestamp: sinon.match.typeOf('date')
- }
+ timestamp: sinon.match.typeOf('date'),
+ },
],
- $slice: -200
- }
- }
+ $slice: -200,
+ },
+ },
}
)
this.dbUpdate.chain('exec').resolves({ nModified: 1 })
diff --git a/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js b/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js
index 2f59eb90d2..800bb0f81e 100644
--- a/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js
+++ b/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js
@@ -34,8 +34,8 @@ describe('ProjectCollabratecDetailsHandler', function () {
{
requires: {
mongodb: { ObjectId },
- '../../models/Project': { Project: this.ProjectModel }
- }
+ '../../models/Project': { Project: this.ProjectModel },
+ },
}
)
return (this.callback = sinon.stub())
@@ -61,10 +61,10 @@ describe('ProjectCollabratecDetailsHandler', function () {
{
user_id: this.userId,
collabratec_document_id: 'collabratec-document-id',
- collabratec_privategroup_id: 'collabratec-private-group-id'
- }
- ]
- }
+ collabratec_privategroup_id: 'collabratec-private-group-id',
+ },
+ ],
+ },
}
return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.projectId },
@@ -135,9 +135,9 @@ describe('ProjectCollabratecDetailsHandler', function () {
_id: ObjectId(this.projectId),
collabratecUsers: {
$elemMatch: {
- user_id: ObjectId(this.userId)
- }
- }
+ user_id: ObjectId(this.userId),
+ },
+ },
}
)
})
@@ -217,18 +217,18 @@ describe('ProjectCollabratecDetailsHandler', function () {
$not: {
$elemMatch: {
collabratec_document_id: 'collabratec-document-id',
- user_id: this.userId
- }
- }
- }
+ user_id: this.userId,
+ },
+ },
+ },
}
const update = {
$push: {
collabratecUsers: {
collabratec_document_id: 'collabratec-document-id',
- user_id: this.userId
- }
- }
+ user_id: this.userId,
+ },
+ },
}
return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
query,
@@ -281,13 +281,13 @@ describe('ProjectCollabratecDetailsHandler', function () {
{
user_id: this.userId,
collabratec_document_id: 'collabratec-document-id-1',
- collabratec_privategroup_id: 'collabratec-private-group-id-1'
+ collabratec_privategroup_id: 'collabratec-private-group-id-1',
},
{
user_id: this.userId2,
collabratec_document_id: 'collabratec-document-id-2',
- collabratec_privategroup_id: 'collabratec-private-group-id-2'
- }
+ collabratec_privategroup_id: 'collabratec-private-group-id-2',
+ },
])
})
@@ -304,8 +304,8 @@ describe('ProjectCollabratecDetailsHandler', function () {
it('should update project model', function () {
const update = {
$set: {
- collabratecUsers: this.collabratecUsers
- }
+ collabratecUsers: this.collabratecUsers,
+ },
}
return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.projectId },
@@ -386,9 +386,9 @@ describe('ProjectCollabratecDetailsHandler', function () {
const update = {
$pull: {
collabratecUsers: {
- user_id: this.userId
- }
- }
+ user_id: this.userId,
+ },
+ },
}
return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
query,
diff --git a/services/web/test/unit/src/Project/ProjectControllerTests.js b/services/web/test/unit/src/Project/ProjectControllerTests.js
index 87d6bf4ef1..e243c9197a 100644
--- a/services/web/test/unit/src/Project/ProjectControllerTests.js
+++ b/services/web/test/unit/src/Project/ProjectControllerTests.js
@@ -19,32 +19,32 @@ describe('ProjectController', function () {
email: 'test@overleaf.com',
first_name: 'bjkdsjfk',
features: {},
- emails: [{ email: 'test@overleaf.com' }]
+ emails: [{ email: 'test@overleaf.com' }],
}
this.settings = {
apis: {
chat: {
- url: 'chat.com'
- }
+ url: 'chat.com',
+ },
},
siteUrl: 'mysite.com',
- algolia: {}
+ algolia: {},
}
this.brandVariationDetails = {
id: '12',
active: true,
brand_name: 'The journal',
home_url: 'http://www.thejournal.com/',
- publish_menu_link_html: 'Submit your paper to the The Journal'
+ publish_menu_link_html: 'Submit your paper to the The Journal',
}
this.token = 'some-token'
this.ProjectDeleter = {
deleteProject: sinon.stub().callsArg(2),
restoreProject: sinon.stub().callsArg(1),
- findArchivedProjects: sinon.stub()
+ findArchivedProjects: sinon.stub(),
}
this.ProjectDuplicator = {
- duplicate: sinon.stub().callsArgWith(3, null, { _id: this.project_id })
+ duplicate: sinon.stub().callsArgWith(3, null, { _id: this.project_id }),
}
this.ProjectCreationHandler = {
createExampleProject: sinon
@@ -52,7 +52,7 @@ describe('ProjectController', function () {
.callsArgWith(2, null, { _id: this.project_id }),
createBasicProject: sinon
.stub()
- .callsArgWith(2, null, { _id: this.project_id })
+ .callsArgWith(2, null, { _id: this.project_id }),
}
this.SubscriptionLocator = { getUsersSubscription: sinon.stub() }
this.LimitationsManager = { hasPaidSubscription: sinon.stub() }
@@ -61,68 +61,68 @@ describe('ProjectController', function () {
this.UserModel = { findById: sinon.stub() }
this.AuthorizationManager = {
getPrivilegeLevelForProject: sinon.stub(),
- isRestrictedUser: sinon.stub().returns(false)
+ isRestrictedUser: sinon.stub().returns(false),
}
this.EditorController = { renameProject: sinon.stub() }
this.InactiveProjectManager = { reactivateProjectIfRequired: sinon.stub() }
this.ProjectUpdateHandler = { markAsOpened: sinon.stub() }
this.ProjectGetter = {
findAllUsersProjects: sinon.stub(),
- getProject: sinon.stub()
+ getProject: sinon.stub(),
}
this.ProjectHelper = {
isArchived: sinon.stub(),
isTrashed: sinon.stub(),
isArchivedOrTrashed: sinon.stub(),
- getAllowedImagesForUser: sinon.stub().returns([])
+ getAllowedImagesForUser: sinon.stub().returns([]),
}
this.AuthenticationController = {
getLoggedInUser: sinon.stub().callsArgWith(1, null, this.user),
getLoggedInUserId: sinon.stub().returns(this.user._id),
getSessionUser: sinon.stub().returns(this.user),
- isUserLoggedIn: sinon.stub().returns(true)
+ isUserLoggedIn: sinon.stub().returns(true),
}
this.UserController = {
- logout: sinon.stub()
+ logout: sinon.stub(),
}
this.TokenAccessHandler = {
getRequestToken: sinon.stub().returns(this.token),
- protectTokens: sinon.stub()
+ protectTokens: sinon.stub(),
}
this.CollaboratorsGetter = {
- userIsTokenMember: sinon.stub().callsArgWith(2, null, false)
+ userIsTokenMember: sinon.stub().callsArgWith(2, null, false),
}
this.ProjectEntityHandler = {}
this.NotificationBuilder = {
- ipMatcherAffiliation: sinon.stub().returns({ create: sinon.stub() })
+ ipMatcherAffiliation: sinon.stub().returns({ create: sinon.stub() }),
}
this.UserGetter = {
getUserFullEmails: sinon.stub().yields(null, []),
getUser: sinon
.stub()
- .callsArgWith(2, null, { lastLoginIp: '192.170.18.2' })
+ .callsArgWith(2, null, { lastLoginIp: '192.170.18.2' }),
}
this.Features = {
- hasFeature: sinon.stub()
+ hasFeature: sinon.stub(),
}
this.BrandVariationsHandler = {
getBrandVariationById: sinon
.stub()
- .callsArgWith(1, null, this.brandVariationDetails)
+ .callsArgWith(1, null, this.brandVariationDetails),
}
this.TpdsProjectFlusher = {
- flushProjectToTpdsIfNeeded: sinon.stub().yields()
+ flushProjectToTpdsIfNeeded: sinon.stub().yields(),
}
this.Metrics = {
Timer: class {
done() {}
},
- inc: sinon.stub()
+ inc: sinon.stub(),
}
this.NewLogsUIHelper = {
getNewLogsUIVariantForUser: sinon
.stub()
- .returns({ newLogsUI: false, subvariant: null })
+ .returns({ newLogsUI: false, subvariant: null }),
}
this.ProjectController = SandboxedModule.require(MODULE_PATH, {
@@ -160,37 +160,37 @@ describe('ProjectController', function () {
'../../models/Project': {},
'../Analytics/AnalyticsManager': { recordEvent: () => {} },
'../../infrastructure/Modules': {
- hooks: { fire: sinon.stub().yields(null, []) }
+ hooks: { fire: sinon.stub().yields(null, []) },
},
- '../Helpers/NewLogsUI': this.NewLogsUIHelper
- }
+ '../Helpers/NewLogsUI': this.NewLogsUIHelper,
+ },
})
this.projectName = '£12321jkj9ujkljds'
this.req = {
params: {
- Project_id: this.project_id
+ Project_id: this.project_id,
},
headers: {},
connection: {
- remoteAddress: '192.170.18.1'
+ remoteAddress: '192.170.18.1',
},
session: {
- user: this.user
+ user: this.user,
},
body: {
- projectName: this.projectName
+ projectName: this.projectName,
},
i18n: {
- translate() {}
+ translate() {},
},
- ip: '192.170.18.1'
+ ip: '192.170.18.1',
}
this.res = {
locals: {
- jsPath: 'js path here'
+ jsPath: 'js path here',
},
- setTimeout: sinon.stub()
+ setTimeout: sinon.stub(),
}
})
@@ -265,7 +265,7 @@ describe('ProjectController', function () {
it('should update the public access level', function (done) {
this.EditorController.setPublicAccessLevel = sinon.stub().callsArg(2)
this.req.body = {
- publicAccessLevel: (this.publicAccessLevel = 'readonly')
+ publicAccessLevel: (this.publicAccessLevel = 'readonly'),
}
this.res.sendStatus = code => {
this.EditorController.setPublicAccessLevel
@@ -284,7 +284,7 @@ describe('ProjectController', function () {
this.ProjectDeleter.deleteProject
.calledWith(this.project_id, {
deleterUser: this.user,
- ipAddress: this.req.ip
+ ipAddress: this.req.ip,
})
.should.equal(true)
code.should.equal(200)
@@ -355,14 +355,25 @@ describe('ProjectController', function () {
this.tags = [
{ name: 1, project_ids: ['1', '2', '3'] },
{ name: 2, project_ids: ['a', '1'] },
- { name: 3, project_ids: ['a', 'b', 'c', 'd'] }
+ { name: 3, project_ids: ['a', 'b', 'c', 'd'] },
]
this.notifications = [
- { _id: '1', user_id: '2', templateKey: '3', messageOpts: '4', key: '5' }
+ {
+ _id: '1',
+ user_id: '2',
+ templateKey: '3',
+ messageOpts: '4',
+ key: '5',
+ },
]
this.projects = [
{ _id: 1, lastUpdated: 1, owner_ref: 'user-1' },
- { _id: 2, lastUpdated: 2, owner_ref: 'user-2', lastUpdatedBy: 'user-1' }
+ {
+ _id: 2,
+ lastUpdated: 2,
+ owner_ref: 'user-2',
+ lastUpdatedBy: 'user-1',
+ },
]
this.collabertions = [{ _id: 5, lastUpdated: 5, owner_ref: 'user-1' }]
this.readOnly = [{ _id: 3, lastUpdated: 3, owner_ref: 'user-1' }]
@@ -373,16 +384,16 @@ describe('ProjectController', function () {
readAndWrite: this.collabertions,
readOnly: this.readOnly,
tokenReadAndWrite: this.tokenReadAndWrite,
- tokenReadOnly: this.tokenReadOnly
+ tokenReadOnly: this.tokenReadOnly,
}
this.users = {
'user-1': {
- first_name: 'James'
+ first_name: 'James',
},
'user-2': {
- first_name: 'Henry'
- }
+ first_name: 'Henry',
+ },
}
this.users[this.user._id] = this.user // Owner
this.UserModel.findById = (id, fields, callback) => {
@@ -489,7 +500,7 @@ describe('ProjectController', function () {
describe('front widget', function (done) {
beforeEach(function () {
this.settings.overleaf = {
- front_chat_widget_room_id: 'chat-room-id'
+ front_chat_widget_room_id: 'chat-room-id',
}
})
@@ -545,17 +556,17 @@ describe('ProjectController', function () {
confirmed: true,
name: 'Overleaf',
ssoBeta: false,
- ssoEnabled: true
- }
- }
- }
+ ssoEnabled: true,
+ },
+ },
+ },
])
this.res.render = (pageName, opts) => {
expect(opts.notificationsInstitution).to.deep.include({
email: this.institutionEmail,
institutionId: 1,
institutionName: this.institutionName,
- templateKey: 'notification_institution_sso_available'
+ templateKey: 'notification_institution_sso_available',
})
}
this.ProjectController.projectListPage(this.req, this.res)
@@ -565,14 +576,14 @@ describe('ProjectController', function () {
institutionEmail: this.institutionEmail,
linked: {
hasEntitlement: false,
- universityName: this.institutionName
- }
+ universityName: this.institutionName,
+ },
}
this.res.render = (pageName, opts) => {
expect(opts.notificationsInstitution).to.deep.include({
email: this.institutionEmail,
institutionName: this.institutionName,
- templateKey: 'notification_institution_sso_linked'
+ templateKey: 'notification_institution_sso_linked',
})
}
this.ProjectController.projectListPage(this.req, this.res)
@@ -584,7 +595,7 @@ describe('ProjectController', function () {
expect(opts.notificationsInstitution).to.deep.include({
institutionEmail: this.institutionEmail,
requestedEmail: 'requested@overleaf.com',
- templateKey: 'notification_institution_sso_non_canonical'
+ templateKey: 'notification_institution_sso_non_canonical',
})
}
this.req.session.saml = {
@@ -593,8 +604,8 @@ describe('ProjectController', function () {
requestedEmail: 'requested@overleaf.com',
linked: {
hasEntitlement: false,
- universityName: this.institutionName
- }
+ universityName: this.institutionName,
+ },
}
this.ProjectController.projectListPage(this.req, this.res)
})
@@ -603,19 +614,19 @@ describe('ProjectController', function () {
this.res.render = (pageName, opts) => {
expect(opts.notificationsInstitution).to.deep.include({
email: this.institutionEmail,
- templateKey: 'notification_institution_sso_already_registered'
+ templateKey: 'notification_institution_sso_already_registered',
})
}
this.req.session.saml = {
institutionEmail: this.institutionEmail,
linked: {
hasEntitlement: false,
- universityName: 'Overleaf'
+ universityName: 'Overleaf',
},
registerIntercept: {
id: 1,
- name: 'Example University'
- }
+ name: 'Example University',
+ },
}
this.ProjectController.projectListPage(this.req, this.res)
})
@@ -626,14 +637,14 @@ describe('ProjectController', function () {
this.res.render = (pageName, opts) => {
expect(opts.notificationsInstitution).to.deep.not.include({
email: 'test@overleaf.com',
- templateKey: 'notification_institution_sso_already_registered'
+ templateKey: 'notification_institution_sso_already_registered',
})
}
this.req.session.saml = {
registerIntercept: {
id: 1,
- name: 'Example University'
- }
+ name: 'Example University',
+ },
}
this.ProjectController.projectListPage(this.req, this.res)
})
@@ -650,7 +661,7 @@ describe('ProjectController', function () {
}
this.req.session.saml = {
institutionEmail: this.institutionEmail,
- error: new Errors.SAMLAlreadyLinkedError()
+ error: new Errors.SAMLAlreadyLinkedError(),
}
this.ProjectController.projectListPage(this.req, this.res)
})
@@ -666,10 +677,10 @@ describe('ProjectController', function () {
confirmed: false,
name: 'Overleaf',
ssoBeta: false,
- ssoEnabled: true
- }
- }
- }
+ ssoEnabled: true,
+ },
+ },
+ },
])
done()
})
@@ -688,7 +699,7 @@ describe('ProjectController', function () {
expect(opts.notificationsInstitution).to.not.deep.include({
institutionEmail: this.institutionEmail,
requestedEmail: undefined,
- templateKey: 'notification_institution_sso_non_canonical'
+ templateKey: 'notification_institution_sso_non_canonical',
})
}
this.req.session.saml = {
@@ -696,8 +707,8 @@ describe('ProjectController', function () {
institutionEmail: this.institutionEmail,
linked: {
hasEntitlement: false,
- universityName: this.institutionName
- }
+ universityName: this.institutionName,
+ },
}
this.ProjectController.projectListPage(this.req, this.res)
})
@@ -713,10 +724,10 @@ describe('ProjectController', function () {
confirmed: true,
name: 'Beta University',
ssoBeta: true,
- ssoEnabled: false
- }
- }
- }
+ ssoEnabled: false,
+ },
+ },
+ },
])
done()
})
@@ -727,7 +738,7 @@ describe('ProjectController', function () {
email: 'beta@beta.com',
institutionId: 2,
institutionName: 'Beta University',
- templateKey: 'notification_institution_sso_available'
+ templateKey: 'notification_institution_sso_available',
})
}
this.ProjectController.projectListPage(this.req, this.res)
@@ -739,7 +750,7 @@ describe('ProjectController', function () {
email: 'test@overleaf.com',
institutionId: 1,
institutionName: 'Overleaf',
- templateKey: 'notification_institution_sso_available'
+ templateKey: 'notification_institution_sso_available',
})
}
this.ProjectController.projectListPage(this.req, this.res)
@@ -758,7 +769,7 @@ describe('ProjectController', function () {
email: 'test@overleaf.com',
institutionId: 1,
institutionName: 'Overleaf',
- templateKey: 'notification_institution_sso_available'
+ templateKey: 'notification_institution_sso_available',
})
}
this.ProjectController.projectListPage(this.req, this.res)
@@ -771,37 +782,43 @@ describe('ProjectController', function () {
this.tags = [
{ name: 1, project_ids: ['1', '2', '3'] },
{ name: 2, project_ids: ['a', '1'] },
- { name: 3, project_ids: ['a', 'b', 'c', 'd'] }
+ { name: 3, project_ids: ['a', 'b', 'c', 'd'] },
]
this.notifications = [
- { _id: '1', user_id: '2', templateKey: '3', messageOpts: '4', key: '5' }
+ {
+ _id: '1',
+ user_id: '2',
+ templateKey: '3',
+ messageOpts: '4',
+ key: '5',
+ },
]
this.projects = [
{ _id: 1, lastUpdated: 1, owner_ref: 'user-1' },
- { _id: 2, lastUpdated: 2, owner_ref: 'user-2' }
+ { _id: 2, lastUpdated: 2, owner_ref: 'user-2' },
]
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
- { _id: 7, lastUpdated: 4, owner_ref: 'user-5' }
+ { _id: 7, lastUpdated: 4, owner_ref: 'user-5' },
]
this.allProjects = {
owned: this.projects,
readAndWrite: this.collabertions,
readOnly: this.readOnly,
tokenReadAndWrite: this.tokenReadAndWrite,
- tokenReadOnly: this.tokenReadOnly
+ tokenReadOnly: this.tokenReadOnly,
}
this.users = {
'user-1': {
- first_name: 'James'
+ first_name: 'James',
},
'user-2': {
- first_name: 'Henry'
- }
+ first_name: 'Henry',
+ },
}
this.users[this.user._id] = this.user // Owner
this.UserModel.findById = (id, fields, callback) => {
@@ -882,25 +899,25 @@ describe('ProjectController', function () {
this.project = {
name: 'my proj',
_id: '213123kjlkj',
- owner_ref: '59fc84d5fbea77482d436e1b'
+ owner_ref: '59fc84d5fbea77482d436e1b',
}
this.brandedProject = {
name: 'my branded proj',
_id: '3252332',
owner_ref: '59fc84d5fbea77482d436e1b',
- brandVariationId: '12'
+ brandVariationId: '12',
}
this.user = {
_id: '588f3ddae8ebc1bac07c9fa4',
ace: {
fontSize: 'massive',
- theme: 'sexy'
+ theme: 'sexy',
},
email: 'bob@bob.com',
refProviders: {
mendeley: { encrypted: 'aaaa' },
- zotero: { encrypted: 'bbbb' }
- }
+ zotero: { encrypted: 'bbbb' },
+ },
}
this.ProjectGetter.getProject.callsArgWith(2, null, this.project)
this.UserModel.findById.callsArgWith(2, null, this.user)
@@ -935,7 +952,7 @@ describe('ProjectController', function () {
this.res.render = (_pageName, opts) => {
expect(opts.user.refProviders).to.deep.equal({
mendeley: true,
- zotero: true
+ zotero: true,
})
done()
}
@@ -1288,14 +1305,14 @@ describe('ProjectController', function () {
id: 'a',
name: 'A',
accessLevel: 'a',
- somethingElse: 1
+ somethingElse: 1,
},
{
archived: false,
id: 'b',
name: 'B',
accessLevel: 'b',
- somethingElse: 1
+ somethingElse: 1,
},
{
archived: false,
@@ -1303,7 +1320,7 @@ describe('ProjectController', function () {
id: 'c',
name: 'C',
accessLevel: 'c',
- somethingElse: 1
+ somethingElse: 1,
},
{
archived: false,
@@ -1311,8 +1328,8 @@ describe('ProjectController', function () {
id: 'd',
name: 'D',
accessLevel: 'd',
- somethingElse: 1
- }
+ somethingElse: 1,
+ },
]
this.ProjectHelper.isArchivedOrTrashed
@@ -1343,8 +1360,8 @@ describe('ProjectController', function () {
expect(data).to.deep.equal({
projects: [
{ _id: 'b', name: 'B', accessLevel: 'b' },
- { _id: 'd', name: 'D', accessLevel: 'd' }
- ]
+ { _id: 'd', name: 'D', accessLevel: 'd' },
+ ],
})
done()
}
@@ -1361,7 +1378,7 @@ describe('ProjectController', function () {
this.project = { _id: 'abcd' }
this.docs = [
{ path: '/things/b.txt', doc: true },
- { path: '/main.tex', doc: true }
+ { path: '/main.tex', doc: true },
]
this.files = [{ path: '/things/a.txt' }]
this.ProjectGetter.getProject = sinon
@@ -1379,8 +1396,8 @@ describe('ProjectController', function () {
entities: [
{ path: '/main.tex', type: 'doc' },
{ path: '/things/a.txt', type: 'file' },
- { path: '/things/b.txt', type: 'doc' }
- ]
+ { path: '/things/b.txt', type: 'doc' },
+ ],
})
expect(this.ProjectGetter.getProject.callCount).to.equal(1)
expect(
@@ -1408,8 +1425,8 @@ describe('ProjectController', function () {
tokens: {
readAndWrite: '1abcd',
readAndWritePrefix: '1',
- readOnly: 'neiotsranteoia'
- }
+ readOnly: 'neiotsranteoia',
+ },
}
})
@@ -1434,7 +1451,7 @@ describe('ProjectController', function () {
archived: false,
trashed: false,
owner_ref: 'defg',
- isV1Project: false
+ isV1Project: false,
})
})
})
@@ -1465,7 +1482,7 @@ describe('ProjectController', function () {
archived: true,
trashed: false,
owner_ref: 'defg',
- isV1Project: false
+ isV1Project: false,
})
})
})
@@ -1491,7 +1508,7 @@ describe('ProjectController', function () {
archived: false,
trashed: false,
owner_ref: null,
- isV1Project: false
+ isV1Project: false,
})
})
})
@@ -1518,7 +1535,7 @@ describe('ProjectController', function () {
'5a05cd8421f9fe22be131750',
'5a05cd8421f9fe22be131751',
'5a05cd8421f9fe22be131752',
- '5a05cd8521f9fe22be131753'
+ '5a05cd8521f9fe22be131753',
]
})
@@ -1547,7 +1564,7 @@ describe('ProjectController', function () {
false,
true,
false,
- true
+ true,
])
expect(
this.ids.map(i =>
@@ -1573,7 +1590,7 @@ describe('ProjectController', function () {
true,
true,
false,
- false
+ false,
])
})
})
diff --git a/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js b/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js
index e4da7c1a07..a22b98ee9a 100644
--- a/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js
@@ -29,8 +29,8 @@ describe('ProjectCreationHandler', function () {
this.ProjectModel.prototype.rootFolder = [
{
_id: rootFolderId,
- docs: []
- }
+ docs: [],
+ },
]
this.FolderModel = class Folder {
constructor(options) {
@@ -40,7 +40,7 @@ describe('ProjectCreationHandler', function () {
this.ProjectEntityUpdateHandler = {
addDoc: sinon.stub().callsArgWith(5, null, { _id: docId }),
addFile: sinon.stub().callsArg(6),
- setRootDoc: sinon.stub().callsArg(2)
+ setRootDoc: sinon.stub().callsArg(2),
}
this.ProjectDetailsHandler = { validateProjectName: sinon.stub().yields() }
this.HistoryManager = { initializeProject: sinon.stub().callsArg(0) }
@@ -49,8 +49,8 @@ describe('ProjectCreationHandler', function () {
first_name: 'first name here',
last_name: 'last name here',
ace: {
- spellCheckLanguage: 'de'
- }
+ spellCheckLanguage: 'de',
+ },
}
this.User = { findById: sinon.stub().callsArgWith(2, null, this.user) }
@@ -64,7 +64,7 @@ describe('ProjectCreationHandler', function () {
requires: {
mongodb: { ObjectId },
'../../models/User': {
- User: this.User
+ User: this.User,
},
'../../models/Project': { Project: this.ProjectModel },
'../../models/Folder': { Folder: this.FolderModel },
@@ -75,9 +75,9 @@ describe('ProjectCreationHandler', function () {
'../Analytics/AnalyticsManager': this.AnalyticsManager,
'@overleaf/metrics': {
inc() {},
- timeAsyncMethod() {}
- }
- }
+ timeAsyncMethod() {},
+ },
+ },
})
})
@@ -138,9 +138,9 @@ describe('ProjectCreationHandler', function () {
const attributes = {
overleaf: {
history: {
- id: overleafId
- }
- }
+ id: overleafId,
+ },
+ },
}
this.handler.createBlankProject(
ownerId,
@@ -269,7 +269,7 @@ describe('ProjectCreationHandler', function () {
it('should send a project-created event with template information if provided', function (done) {
const attributes = {
- fromV1TemplateId: 100
+ fromV1TemplateId: 100,
}
this.handler.createBlankProject(
ownerId,
@@ -296,9 +296,9 @@ describe('ProjectCreationHandler', function () {
const attributes = {
overleaf: {
history: {
- id: 100
- }
- }
+ id: 100,
+ },
+ },
}
this.handler.createBlankProject(
ownerId,
diff --git a/services/web/test/unit/src/Project/ProjectDeleterTests.js b/services/web/test/unit/src/Project/ProjectDeleterTests.js
index 9158cd8fdb..624c323467 100644
--- a/services/web/test/unit/src/Project/ProjectDeleterTests.js
+++ b/services/web/test/unit/src/Project/ProjectDeleterTests.js
@@ -17,14 +17,14 @@ describe('ProjectDeleter', function () {
this.user = {
_id: '588f3ddae8ebc1bac07c9fa4',
first_name: 'bjkdsjfk',
- features: {}
+ features: {},
}
this.doc = {
_id: '5bd975f54f62e803cb8a8fec',
lines: ['a bunch of lines', 'for a sunny day', 'in London town'],
ranges: {},
- project_id: '5cf9270b4eff6e186cf8b05e'
+ project_id: '5cf9270b4eff6e186cf8b05e',
}
this.deletedProjects = [
@@ -35,16 +35,16 @@ describe('ProjectDeleter', function () {
deletedAt: moment().subtract(95, 'days').toDate(),
deleterId: '588f3ddae8ebc1bac07c9fa4',
deleterIpAddress: '172.19.0.1',
- deletedProjectId: '5cf9270b4eff6e186cf8b05e'
+ deletedProjectId: '5cf9270b4eff6e186cf8b05e',
},
project: {
_id: '5cf9270b4eff6e186cf8b05e',
overleaf: {
history: {
- id: new ObjectId()
- }
- }
- }
+ id: new ObjectId(),
+ },
+ },
+ },
},
{
_id: '5cf8eb11c1401f0ca0eb1ad7',
@@ -53,79 +53,79 @@ describe('ProjectDeleter', function () {
deletedAt: moment().subtract(95, 'days').toDate(),
deleterId: '588f3ddae8ebc1bac07c9fa4',
deleterIpAddress: '172.20.0.1',
- deletedProjectId: '5cf8f95a0c87371362c23919'
+ deletedProjectId: '5cf8f95a0c87371362c23919',
},
project: {
- _id: '5cf8f95a0c87371362c23919'
- }
- }
+ _id: '5cf8f95a0c87371362c23919',
+ },
+ },
]
this.DocumentUpdaterHandler = {
promises: {
- flushProjectToMongoAndDelete: sinon.stub().resolves()
- }
+ flushProjectToMongoAndDelete: sinon.stub().resolves(),
+ },
}
this.EditorRealTimeController = {
- emitToRoom: sinon.stub()
+ emitToRoom: sinon.stub(),
}
this.TagsHandler = {
promises: {
- removeProjectFromAllTags: sinon.stub().resolves()
- }
+ removeProjectFromAllTags: sinon.stub().resolves(),
+ },
}
this.CollaboratorsHandler = {
promises: {
- removeUserFromAllProjects: sinon.stub().resolves()
- }
+ removeUserFromAllProjects: sinon.stub().resolves(),
+ },
}
this.CollaboratorsGetter = {
promises: {
getMemberIds: sinon
.stub()
.withArgs(this.project._id)
- .resolves(['member-id-1', 'member-id-2'])
- }
+ .resolves(['member-id-1', 'member-id-2']),
+ },
}
this.ProjectDetailsHandler = {
promises: {
- generateUniqueName: sinon.stub().resolves(this.project.name)
- }
+ generateUniqueName: sinon.stub().resolves(this.project.name),
+ },
}
this.ProjectHelper = {
- calculateArchivedArray: sinon.stub()
+ calculateArchivedArray: sinon.stub(),
}
this.db = {
deletedFiles: {
indexExists: sinon.stub().resolves(false),
- deleteMany: sinon.stub()
+ deleteMany: sinon.stub(),
},
projects: {
- insertOne: sinon.stub().resolves()
- }
+ insertOne: sinon.stub().resolves(),
+ },
}
this.DocstoreManager = {
promises: {
archiveProject: sinon.stub().resolves(),
- destroyProject: sinon.stub().resolves()
- }
+ destroyProject: sinon.stub().resolves(),
+ },
}
this.HistoryManager = {
promises: {
- deleteProject: sinon.stub().resolves()
- }
+ deleteProject: sinon.stub().resolves(),
+ },
}
this.ProjectMock = sinon.mock(Project)
this.DeletedProjectMock = sinon.mock(DeletedProject)
this.FileStoreHandler = {
promises: {
- deleteProject: sinon.stub().resolves()
- }
+ deleteProject: sinon.stub().resolves(),
+ },
}
this.ProjectDeleter = SandboxedModule.require(modulePath, {
@@ -143,8 +143,8 @@ describe('ProjectDeleter', function () {
'../Docstore/DocstoreManager': this.DocstoreManager,
'./ProjectDetailsHandler': this.ProjectDetailsHandler,
'../../infrastructure/mongodb': { db: this.db, ObjectId },
- '../History/HistoryManager': this.HistoryManager
- }
+ '../History/HistoryManager': this.HistoryManager,
+ },
})
})
@@ -223,7 +223,7 @@ describe('ProjectDeleter', function () {
{ 'deleterData.deletedProjectId': project._id },
{
project,
- deleterData: sinon.match.object
+ deleterData: sinon.match.object,
},
{ upsert: true }
)
@@ -265,7 +265,7 @@ describe('ProjectDeleter', function () {
deletedProjectReadOnlyToken: this.project.tokens.readOnly,
deletedProjectOverleafId: this.project.overleaf.id,
deletedProjectOverleafHistoryId: this.project.overleaf.history.id,
- deletedProjectLastUpdatedAt: this.project.lastUpdated
+ deletedProjectLastUpdatedAt: this.project.lastUpdated,
}
this.ProjectMock.expects('findOne')
@@ -284,7 +284,7 @@ describe('ProjectDeleter', function () {
{ 'deleterData.deletedProjectId': this.project._id },
{
project: this.project,
- deleterData: this.deleterData
+ deleterData: this.deleterData,
},
{ upsert: true }
)
@@ -292,7 +292,7 @@ describe('ProjectDeleter', function () {
await this.ProjectDeleter.promises.deleteProject(this.project._id, {
deleterUser: this.user,
- ipAddress: this.ip
+ ipAddress: this.ip,
})
this.DeletedProjectMock.verify()
})
@@ -303,7 +303,7 @@ describe('ProjectDeleter', function () {
await this.ProjectDeleter.promises.deleteProject(this.project._id, {
deleterUser: this.user,
- ipAddress: this.ip
+ ipAddress: this.ip,
})
this.DocumentUpdaterHandler.promises.flushProjectToMongoAndDelete
.calledWith(this.project._id)
@@ -315,7 +315,7 @@ describe('ProjectDeleter', function () {
this.DeletedProjectMock.expects('updateOne').resolves()
await this.ProjectDeleter.promises.deleteProject(this.project._id, {
deleterUser: this.user,
- ipAddress: this.ip
+ ipAddress: this.ip,
})
expect(
this.DocstoreManager.promises.archiveProject
@@ -328,7 +328,7 @@ describe('ProjectDeleter', function () {
this.DocstoreManager.promises.archiveProject.rejects(new Error('foo'))
await this.ProjectDeleter.promises.deleteProject(this.project._id, {
deleterUser: this.user,
- ipAddress: this.ip
+ ipAddress: this.ip,
})
})
@@ -366,11 +366,11 @@ describe('ProjectDeleter', function () {
this.DeletedProjectMock.expects('find')
.withArgs({
'deleterData.deletedAt': {
- $lt: new Date(moment().subtract(90, 'days'))
+ $lt: new Date(moment().subtract(90, 'days')),
},
project: {
- $ne: null
- }
+ $ne: null,
+ },
})
.chain('exec')
.resolves(this.deletedProjects)
@@ -378,20 +378,20 @@ describe('ProjectDeleter', function () {
for (const deletedProject of this.deletedProjects) {
this.DeletedProjectMock.expects('findOne')
.withArgs({
- 'deleterData.deletedProjectId': deletedProject.project._id
+ 'deleterData.deletedProjectId': deletedProject.project._id,
})
.chain('exec')
.resolves(deletedProject)
this.DeletedProjectMock.expects('updateOne')
.withArgs(
{
- _id: deletedProject._id
+ _id: deletedProject._id,
},
{
$set: {
'deleterData.deleterIpAddress': null,
- project: null
- }
+ project: null,
+ },
}
)
.chain('exec')
@@ -411,13 +411,13 @@ describe('ProjectDeleter', function () {
this.DeletedProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.deletedProjects[0]._id
+ _id: this.deletedProjects[0]._id,
},
{
$set: {
'deleterData.deleterIpAddress': null,
- project: null
- }
+ project: null,
+ },
}
)
.chain('exec')
@@ -425,7 +425,7 @@ describe('ProjectDeleter', function () {
this.DeletedProjectMock.expects('findOne')
.withArgs({
- 'deleterData.deletedProjectId': this.deletedProjects[0].project._id
+ 'deleterData.deletedProjectId': this.deletedProjects[0].project._id,
})
.chain('exec')
.resolves(this.deletedProjects[0])
@@ -476,7 +476,7 @@ describe('ProjectDeleter', function () {
{ _id: this.project._id },
{
$set: { archived: archived },
- $pull: { trashed: ObjectId(this.user._id) }
+ $pull: { trashed: ObjectId(this.user._id) },
}
)
.resolves()
@@ -554,7 +554,7 @@ describe('ProjectDeleter', function () {
{ _id: this.project._id },
{
$addToSet: { trashed: ObjectId(this.user._id) },
- $set: { archived: archived }
+ $set: { archived: archived },
}
)
.resolves()
@@ -610,10 +610,10 @@ describe('ProjectDeleter', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.project._id
+ _id: this.project._id,
},
{
- $unset: { archived: true }
+ $unset: { archived: true },
}
)
.chain('exec')
@@ -635,15 +635,15 @@ describe('ProjectDeleter', function () {
project: this.project,
deleterData: {
deletedProjectId: this.project._id,
- deletedProjectOwnerId: this.project.owner_ref
- }
+ deletedProjectOwnerId: this.project.owner_ref,
+ },
}
this.purgedProject = {
_id: 'purged',
deleterData: {
deletedProjectId: this.purgedProjectId,
- deletedProjectOwnerId: 'potato'
- }
+ deletedProjectOwnerId: 'potato',
+ },
}
this.DeletedProjectMock.expects('findOne')
@@ -683,7 +683,7 @@ describe('ProjectDeleter', function () {
this.db.projects.insertOne,
sinon.match({
_id: this.project._id,
- name: this.project.name
+ name: this.project.name,
})
)
})
@@ -745,14 +745,14 @@ function dummyProject() {
owner_ref: new ObjectId(),
tokens: {
readOnly: 'wombat',
- readAndWrite: 'potato'
+ readAndWrite: 'potato',
},
overleaf: {
id: 1234,
history: {
- id: 5678
- }
+ id: 5678,
+ },
},
- name: 'a very scientific analysis of spooky ghosts'
+ name: 'a very scientific analysis of spooky ghosts',
}
}
diff --git a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js b/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js
index 48d6bde698..cf632236e5 100644
--- a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js
@@ -12,11 +12,11 @@ describe('ProjectDetailsHandler', function () {
this.user = {
_id: ObjectId(),
email: 'user@example.com',
- features: 'mock-features'
+ features: 'mock-features',
}
this.collaborator = {
_id: ObjectId(),
- email: 'collaborator@example.com'
+ email: 'collaborator@example.com',
}
this.project = {
_id: ObjectId(),
@@ -25,7 +25,7 @@ describe('ProjectDetailsHandler', function () {
something: 'should not exist',
compiler: 'latexxxxxx',
owner_ref: this.user._id,
- collaberator_refs: [this.collaborator._id]
+ collaberator_refs: [this.collaborator._id],
}
this.ProjectGetter = {
promises: {
@@ -36,47 +36,47 @@ describe('ProjectDetailsHandler', function () {
readAndWrite: [],
readOnly: [],
tokenReadAndWrite: [],
- tokenReadOnly: []
- })
- }
+ tokenReadOnly: [],
+ }),
+ },
}
this.ProjectModelUpdateQuery = {
- exec: sinon.stub().resolves()
+ exec: sinon.stub().resolves(),
}
this.ProjectModel = {
- updateOne: sinon.stub().returns(this.ProjectModelUpdateQuery)
+ updateOne: sinon.stub().returns(this.ProjectModelUpdateQuery),
}
this.UserGetter = {
promises: {
- getUser: sinon.stub().resolves(this.user)
- }
+ getUser: sinon.stub().resolves(this.user),
+ },
}
this.TpdsUpdateSender = {
promises: {
- moveEntity: sinon.stub().resolves()
- }
+ moveEntity: sinon.stub().resolves(),
+ },
}
this.TokenGenerator = {
readAndWriteToken: sinon.stub(),
promises: {
- generateUniqueReadOnlyToken: sinon.stub()
- }
+ generateUniqueReadOnlyToken: sinon.stub(),
+ },
}
this.settings = {
- defaultFeatures: 'default-features'
+ defaultFeatures: 'default-features',
}
this.handler = SandboxedModule.require(MODULE_PATH, {
requires: {
'./ProjectHelper': ProjectHelper,
'./ProjectGetter': this.ProjectGetter,
'../../models/Project': {
- Project: this.ProjectModel
+ Project: this.ProjectModel,
},
'../User/UserGetter': this.UserGetter,
'../ThirdPartyDataStore/TpdsUpdateSender': this.TpdsUpdateSender,
'../TokenGenerator/TokenGenerator': this.TokenGenerator,
- 'settings-sharelatex': this.settings
- }
+ 'settings-sharelatex': this.settings,
+ },
})
})
@@ -129,7 +129,7 @@ describe('ProjectDetailsHandler', function () {
it('should return what the mongo call returns', async function () {
const expectedDescription = 'cool project'
this.ProjectGetter.promises.getProject.resolves({
- description: expectedDescription
+ description: expectedDescription,
})
const description = await this.handler.promises.getProjectDescription(
this.project._id
@@ -174,7 +174,7 @@ describe('ProjectDetailsHandler', function () {
{
project_id: this.project._id,
project_name: this.project.name,
- newProjectName: this.newName
+ newProjectName: this.newName,
}
)
})
@@ -258,25 +258,25 @@ describe('ProjectDetailsHandler', function () {
{ _id: 137, name: 'numeric (37)' },
{ _id: 138, name: 'numeric (38)' },
{ _id: 139, name: 'numeric (39)' },
- { _id: 140, name: 'numeric (40)' }
+ { _id: 140, name: 'numeric (40)' },
],
readAndWrite: [
{ _id: 4, name: 'name2' },
- { _id: 5, name: 'name22' }
+ { _id: 5, name: 'name22' },
],
readOnly: [
{ _id: 6, name: 'name3' },
- { _id: 7, name: 'name33' }
+ { _id: 7, name: 'name33' },
],
tokenReadAndWrite: [
{ _id: 8, name: 'name4' },
- { _id: 9, name: 'name44' }
+ { _id: 9, name: 'name44' },
],
tokenReadOnly: [
{ _id: 10, name: 'name5' },
{ _id: 11, name: 'name55' },
- { _id: 12, name: this.longName }
- ]
+ { _id: 12, name: this.longName },
+ ],
}
this.ProjectGetter.promises.findAllUsersProjects.resolves(usersProjects)
})
@@ -439,8 +439,8 @@ describe('ProjectDetailsHandler', function () {
tokens: {
readOnly: 'aaa',
readAndWrite: '42bbb',
- readAndWritePrefix: '42'
- }
+ readAndWritePrefix: '42',
+ },
}
this.ProjectGetter.promises.getProject.resolves(this.project)
})
@@ -451,7 +451,7 @@ describe('ProjectDetailsHandler', function () {
expect(this.ProjectGetter.promises.getProject).to.have.been.calledWith(
this.project._id,
{
- tokens: 1
+ tokens: 1,
}
)
})
@@ -481,7 +481,7 @@ describe('ProjectDetailsHandler', function () {
)
this.TokenGenerator.readAndWriteToken.returns({
token: this.readAndWriteToken,
- numericPrefix: this.readAndWriteTokenPrefix
+ numericPrefix: this.readAndWriteTokenPrefix,
})
})
@@ -491,7 +491,7 @@ describe('ProjectDetailsHandler', function () {
expect(this.ProjectGetter.promises.getProject).to.have.been.calledWith(
this.project._id,
{
- tokens: 1
+ tokens: 1,
}
)
})
@@ -509,9 +509,9 @@ describe('ProjectDetailsHandler', function () {
tokens: {
readOnly: this.readOnlyToken,
readAndWrite: this.readAndWriteToken,
- readAndWritePrefix: this.readAndWriteTokenPrefix
- }
- }
+ readAndWritePrefix: this.readAndWriteTokenPrefix,
+ },
+ },
}
)
})
@@ -523,7 +523,7 @@ describe('ProjectDetailsHandler', function () {
expect(tokens).to.deep.equal({
readOnly: this.readOnlyToken,
readAndWrite: this.readAndWriteToken,
- readAndWritePrefix: this.readAndWriteTokenPrefix
+ readAndWritePrefix: this.readAndWriteTokenPrefix,
})
})
})
diff --git a/services/web/test/unit/src/Project/ProjectDuplicatorTests.js b/services/web/test/unit/src/Project/ProjectDuplicatorTests.js
index 37708e1e21..8968a4554b 100644
--- a/services/web/test/unit/src/Project/ProjectDuplicatorTests.js
+++ b/services/web/test/unit/src/Project/ProjectDuplicatorTests.js
@@ -19,34 +19,34 @@ describe('ProjectDuplicator', function () {
name: 'file2',
_id: 'file2',
linkedFileData: { provider: 'url' },
- hash: '123456'
+ hash: '123456',
}
this.level2folder = {
name: 'level2folderName',
_id: 'level2folderId',
docs: [this.doc2, undefined],
folders: [],
- fileRefs: [this.file2]
+ fileRefs: [this.file2],
}
this.level1folder = {
name: 'level1folder',
_id: 'level1folderId',
docs: [this.doc1],
folders: [this.level2folder],
- fileRefs: [this.file1, null] // the null is intentional to test null docs/files
+ fileRefs: [this.file1, null], // the null is intentional to test null docs/files
}
this.rootFolder = {
name: 'rootFolder',
_id: 'rootFolderId',
docs: [this.doc0],
folders: [this.level1folder, {}],
- fileRefs: [this.file0]
+ fileRefs: [this.file0],
}
this.project = {
_id: 'this_is_the_old_project_id',
rootDoc_id: this.doc0._id,
rootFolder: [this.rootFolder],
- compiler: 'this_is_a_Compiler'
+ compiler: 'this_is_a_Compiler',
}
this.doc0Path = '/rootDocHere'
this.doc1Path = '/level1folder/level1folderDocName'
@@ -58,7 +58,7 @@ describe('ProjectDuplicator', function () {
this.docContents = [
{ _id: this.doc0._id, lines: this.doc0Lines },
{ _id: this.doc1._id, lines: this.doc1Lines },
- { _id: this.doc2._id, lines: this.doc2Lines }
+ { _id: this.doc2._id, lines: this.doc2Lines },
]
this.rootDoc = this.doc0
@@ -69,7 +69,7 @@ describe('ProjectDuplicator', function () {
overleaf: { history: { id: 339123 } },
readOnly_refs: [],
collaberator_refs: [],
- rootFolder: [{ _id: 'new_root_folder_id' }]
+ rootFolder: [{ _id: 'new_root_folder_id' }],
}
this.newFolder = { _id: 'newFolderId' }
this.filestoreUrl = 'filestore-url'
@@ -88,35 +88,35 @@ describe('ProjectDuplicator', function () {
{
path: this.doc0Path,
doc: this.newDoc0,
- docLines: this.doc0Lines.join('\n')
+ docLines: this.doc0Lines.join('\n'),
},
{
path: this.doc1Path,
doc: this.newDoc1,
- docLines: this.doc1Lines.join('\n')
+ docLines: this.doc1Lines.join('\n'),
},
{
path: this.doc2Path,
doc: this.newDoc2,
- docLines: this.doc2Lines.join('\n')
- }
+ docLines: this.doc2Lines.join('\n'),
+ },
]
this.fileEntries = [
{
path: this.file0Path,
file: this.newFile0,
- url: this.filestoreUrl
+ url: this.filestoreUrl,
},
{
path: this.file1Path,
file: this.newFile1,
- url: this.filestoreUrl
+ url: this.filestoreUrl,
},
{
path: this.file2Path,
file: this.newFile2,
- url: this.filestoreUrl
- }
+ url: this.filestoreUrl,
+ },
]
this.Doc = sinon
@@ -129,74 +129,74 @@ describe('ProjectDuplicator', function () {
this.DocstoreManager = {
promises: {
updateDoc: sinon.stub().resolves(),
- getAllDocs: sinon.stub().resolves(this.docContents)
- }
+ getAllDocs: sinon.stub().resolves(this.docContents),
+ },
}
this.DocumentUpdaterHandler = {
promises: {
flushProjectToMongo: sinon.stub().resolves(),
- updateProjectStructure: sinon.stub().resolves()
- }
+ updateProjectStructure: sinon.stub().resolves(),
+ },
}
this.FileStoreHandler = {
promises: {
- copyFile: sinon.stub().resolves(this.filestoreUrl)
- }
+ copyFile: sinon.stub().resolves(this.filestoreUrl),
+ },
}
this.ProjectCreationHandler = {
promises: {
- createBlankProject: sinon.stub().resolves(this.newBlankProject)
- }
+ createBlankProject: sinon.stub().resolves(this.newBlankProject),
+ },
}
this.ProjectDeleter = {
promises: {
- deleteProject: sinon.stub().resolves()
- }
+ deleteProject: sinon.stub().resolves(),
+ },
}
this.ProjectEntityMongoUpdateHandler = {
promises: {
- createNewFolderStructure: sinon.stub().resolves(this.newProjectVersion)
- }
+ createNewFolderStructure: sinon.stub().resolves(this.newProjectVersion),
+ },
}
this.ProjectEntityUpdateHandler = {
isPathValidForRootDoc: sinon.stub().returns(true),
promises: {
- setRootDoc: sinon.stub().resolves()
- }
+ setRootDoc: sinon.stub().resolves(),
+ },
}
this.ProjectGetter = {
promises: {
getProject: sinon
.stub()
.withArgs(this.project._id)
- .resolves(this.project)
- }
+ .resolves(this.project),
+ },
}
this.ProjectLocator = {
promises: {
findRootDoc: sinon.stub().resolves({
element: this.rootDoc,
- path: { fileSystem: this.rootDocPath }
+ path: { fileSystem: this.rootDocPath },
}),
findElementByPath: sinon
.stub()
.withArgs({
project_id: this.newBlankProject._id,
path: this.rootDocPath,
- exactCaseMatch: true
+ exactCaseMatch: true,
})
- .resolves({ element: this.doc0 })
- }
+ .resolves({ element: this.doc0 }),
+ },
}
this.ProjectOptionsHandler = {
promises: {
- setCompiler: sinon.stub().resolves()
- }
+ setCompiler: sinon.stub().resolves(),
+ },
}
this.TpdsProjectFlusher = {
promises: {
- flushProjectToTpds: sinon.stub().resolves()
- }
+ flushProjectToTpds: sinon.stub().resolves(),
+ },
}
this.ProjectDuplicator = SandboxedModule.require(MODULE_PATH, {
@@ -215,8 +215,8 @@ describe('ProjectDuplicator', function () {
'./ProjectGetter': this.ProjectGetter,
'./ProjectLocator': this.ProjectLocator,
'./ProjectOptionsHandler': this.ProjectOptionsHandler,
- '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher
- }
+ '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher,
+ },
})
})
@@ -302,7 +302,7 @@ describe('ProjectDuplicator', function () {
{
newDocs: this.docEntries,
newFiles: this.fileEntries,
- newProject: { version: this.newProjectVersion }
+ newProject: { version: this.newProjectVersion },
}
)
})
@@ -318,7 +318,7 @@ describe('ProjectDuplicator', function () {
beforeEach(async function () {
this.ProjectLocator.promises.findRootDoc.resolves({
element: null,
- path: null
+ path: null,
})
this.newProject = await this.ProjectDuplicator.promises.duplicate(
this.owner,
diff --git a/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js b/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js
index 3c5c77a854..494e4ed4f9 100644
--- a/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js
@@ -37,29 +37,29 @@ describe('ProjectEditorHandler', function () {
{
_id: 'doc-id',
name: 'main.tex',
- lines: (this.lines = ['line 1', 'line 2', 'line 3'])
- }
+ lines: (this.lines = ['line 1', 'line 2', 'line 3']),
+ },
],
fileRefs: [
{
_id: 'file-id',
name: 'image.png',
created: (this.created = new Date()),
- size: 1234
- }
+ size: 1234,
+ },
],
- folders: []
- }
- ]
- }
+ folders: [],
+ },
+ ],
+ },
],
deletedDocs: [
{
_id: 'deleted-doc-id',
name: 'main.tex',
- deletedAt: (this.deletedAt = new Date('2017-01-01'))
- }
- ]
+ deletedAt: (this.deletedAt = new Date('2017-01-01')),
+ },
+ ],
}
this.members = [
{
@@ -67,28 +67,28 @@ describe('ProjectEditorHandler', function () {
_id: 'owner-id',
first_name: 'Owner',
last_name: 'ShareLaTeX',
- email: 'owner@sharelatex.com'
+ email: 'owner@sharelatex.com',
}),
- privilegeLevel: 'owner'
+ privilegeLevel: 'owner',
},
{
user: {
_id: 'read-only-id',
first_name: 'Read',
last_name: 'Only',
- email: 'read-only@sharelatex.com'
+ email: 'read-only@sharelatex.com',
},
- privilegeLevel: 'readOnly'
+ privilegeLevel: 'readOnly',
},
{
user: {
_id: 'read-write-id',
first_name: 'Read',
last_name: 'Write',
- email: 'read-write@sharelatex.com'
+ email: 'read-write@sharelatex.com',
},
- privilegeLevel: 'readAndWrite'
- }
+ privilegeLevel: 'readAndWrite',
+ },
]
this.invites = [
{
@@ -96,18 +96,18 @@ describe('ProjectEditorHandler', function () {
email: 'user-one@example.com',
privileges: 'readOnly',
projectId: this.project._id,
- token: 'my-secret-token1'
+ token: 'my-secret-token1',
},
{
_id: 'invite_two',
email: 'user-two@example.com',
privileges: 'readOnly',
projectId: this.project._id,
- token: 'my-secret-token2'
- }
+ token: 'my-secret-token2',
+ },
]
this.deletedDocsFromDocstore = [
- { _id: 'deleted-doc-id-from-docstore', name: 'docstore.tex' }
+ { _id: 'deleted-doc-id-from-docstore', name: 'docstore.tex' },
]
return (this.handler = SandboxedModule.require(modulePath))
})
@@ -158,9 +158,9 @@ describe('ProjectEditorHandler', function () {
{
// omit deletedAt field
_id: this.project.deletedDocs[0]._id,
- name: this.project.deletedDocs[0].name
+ name: this.project.deletedDocs[0].name,
},
- this.deletedDocsFromDocstore[0]
+ this.deletedDocsFromDocstore[0],
])
})
@@ -255,7 +255,7 @@ describe('ProjectEditorHandler', function () {
expect(this.result.deletedDocs).to.exist
this.result.deletedDocs.should.deep.equal([
this.project.deletedDocs[0],
- this.deletedDocsFromDocstore[0]
+ this.deletedDocsFromDocstore[0],
])
})
})
@@ -300,7 +300,7 @@ describe('ProjectEditorHandler', function () {
versioning: true,
collaborators: 3,
compileGroup: 'priority',
- compileTimeout: 96
+ compileTimeout: 96,
}
return (this.result = this.handler.buildProjectModelView(
this.project,
@@ -330,7 +330,7 @@ describe('ProjectEditorHandler', function () {
describe('when the owner does not have the trackChanges feature', function () {
beforeEach(function () {
this.owner.features = {
- trackChanges: false
+ trackChanges: false,
}
this.result = this.handler.buildProjectModelView(
this.project,
@@ -347,7 +347,7 @@ describe('ProjectEditorHandler', function () {
describe('when the owner has got the trackChanges feature', function () {
beforeEach(function () {
this.owner.features = {
- trackChanges: true
+ trackChanges: true,
}
})
@@ -374,7 +374,7 @@ describe('ProjectEditorHandler', function () {
[null, false],
[false, false],
[true, true],
- [{ someId: true }, { someId: true }]
+ [{ someId: true }, { someId: true }],
]
CASES.map(genCase)
})
@@ -387,7 +387,7 @@ describe('ProjectEditorHandler', function () {
versioning: true,
collaborators: 3,
compileGroup: 'priority',
- compileTimeout: 22
+ compileTimeout: 22,
}
return (this.result = this.handler.buildOwnerAndMembersViews(
this.members
@@ -398,7 +398,7 @@ describe('ProjectEditorHandler', function () {
return expect(this.result).to.have.all.keys([
'owner',
'ownerFeatures',
- 'members'
+ 'members',
])
})
@@ -432,7 +432,7 @@ describe('ProjectEditorHandler', function () {
return expect(this.result).to.have.all.keys([
'owner',
'ownerFeatures',
- 'members'
+ 'members',
])
})
diff --git a/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js
index 6f8649989c..ecc4ff48bc 100644
--- a/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js
@@ -30,7 +30,7 @@ describe('ProjectEntityHandler', function () {
let Project
this.TpdsUpdateSender = {
addDoc: sinon.stub().callsArg(1),
- addFile: sinon.stub().callsArg(1)
+ addFile: sinon.stub().callsArg(1),
}
this.ProjectModel = Project = (function () {
Project = class Project {
@@ -52,7 +52,7 @@ describe('ProjectEntityHandler', function () {
this.ProjectLocator = { findElement: sinon.stub() }
this.DocumentUpdaterHandler = {
- updateProjectStructure: sinon.stub().yields()
+ updateProjectStructure: sinon.stub().yields(),
}
this.callback = sinon.stub()
@@ -62,12 +62,12 @@ describe('ProjectEntityHandler', function () {
'../../Features/DocumentUpdater/DocumentUpdaterHandler': this
.DocumentUpdaterHandler,
'../../models/Project': {
- Project: this.ProjectModel
+ Project: this.ProjectModel,
},
'./ProjectLocator': this.ProjectLocator,
'./ProjectGetter': (this.ProjectGetter = {}),
- '../ThirdPartyDataStore/TpdsUpdateSender': this.TpdsUpdateSender
- }
+ '../ThirdPartyDataStore/TpdsUpdateSender': this.TpdsUpdateSender,
+ },
}))
})
@@ -78,15 +78,15 @@ describe('ProjectEntityHandler', function () {
docs: [
(this.doc1 = {
name: 'doc1',
- _id: 'doc1_id'
- })
+ _id: 'doc1_id',
+ }),
],
fileRefs: [
(this.file1 = {
rev: 1,
_id: 'file1_id',
- name: 'file1'
- })
+ name: 'file1',
+ }),
],
folders: [
(this.folder1 = {
@@ -94,20 +94,20 @@ describe('ProjectEntityHandler', function () {
docs: [
(this.doc2 = {
name: 'doc2',
- _id: 'doc2_id'
- })
+ _id: 'doc2_id',
+ }),
],
fileRefs: [
(this.file2 = {
rev: 2,
name: 'file2',
- _id: 'file2_id'
- })
+ _id: 'file2_id',
+ }),
],
- folders: []
- })
- ]
- }
+ folders: [],
+ }),
+ ],
+ },
]
this.ProjectGetter.getProjectWithoutDocLines = sinon
.stub()
@@ -120,13 +120,13 @@ describe('ProjectEntityHandler', function () {
{
_id: this.doc1._id,
lines: (this.lines1 = ['one']),
- rev: (this.rev1 = 1)
+ rev: (this.rev1 = 1),
},
{
_id: this.doc2._id,
lines: (this.lines2 = ['two']),
- rev: (this.rev2 = 2)
- }
+ rev: (this.rev2 = 2),
+ },
]
this.DocstoreManager.getAllDocs = sinon
.stub()
@@ -147,14 +147,14 @@ describe('ProjectEntityHandler', function () {
_id: this.doc1._id,
lines: this.lines1,
name: this.doc1.name,
- rev: this.rev1
+ rev: this.rev1,
},
'/folder1/doc2': {
_id: this.doc2._id,
lines: this.lines2,
name: this.doc2.name,
- rev: this.rev2
- }
+ rev: this.rev2,
+ },
})
.should.equal(true)
})
@@ -170,7 +170,7 @@ describe('ProjectEntityHandler', function () {
this.callback
.calledWith(null, {
'/file1': this.file1,
- '/folder1/file2': this.file2
+ '/folder1/file2': this.file2,
})
.should.equal(true)
})
@@ -182,13 +182,13 @@ describe('ProjectEntityHandler', function () {
{
_id: this.doc1._id,
lines: (this.lines1 = ['one']),
- rev: (this.rev1 = 1)
+ rev: (this.rev1 = 1),
},
{
_id: this.doc2._id,
lines: (this.lines2 = ['two']),
- rev: (this.rev2 = 2)
- }
+ rev: (this.rev2 = 2),
+ },
]
this.callback = sinon.stub()
this.ProjectEntityHandler.getAllDocPathsFromProject(
@@ -268,7 +268,7 @@ describe('ProjectEntityHandler', function () {
this.callback
.calledWith(null, {
'/': this.project.rootFolder[0],
- '/folder1': this.folder1
+ '/folder1': this.folder1,
})
.should.equal(true)
})
@@ -287,7 +287,7 @@ describe('ProjectEntityHandler', function () {
this.callback
.calledWith(null, {
'/': this.project.rootFolder[0],
- '/folder1': this.folder1
+ '/folder1': this.folder1,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js
index 71ee778111..f531e6ec55 100644
--- a/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js
@@ -16,58 +16,58 @@ describe('ProjectEntityMongoUpdateHandler', function () {
_id: ObjectId(),
name: 'test-doc.txt',
lines: ['hello', 'world'],
- rev: 1234
+ rev: 1234,
}
this.docPath = {
mongo: 'rootFolder.0.docs.0',
- fileSystem: '/test-doc.txt'
+ fileSystem: '/test-doc.txt',
}
this.file = {
_id: ObjectId(),
name: 'something.jpg',
linkedFileData: { provider: 'url' },
- hash: 'some-hash'
+ hash: 'some-hash',
}
this.filePath = {
fileSystem: '/something.png',
- mongo: 'rootFolder.0.fileRefs.0'
+ mongo: 'rootFolder.0.fileRefs.0',
}
this.subfolder = { _id: ObjectId(), name: 'test-subfolder' }
this.subfolderPath = {
fileSystem: '/test-folder/test-subfolder',
- mongo: 'rootFolder.0.folders.0.folders.0'
+ mongo: 'rootFolder.0.folders.0.folders.0',
}
this.folder = {
_id: ObjectId(),
name: 'test-folder',
- folders: [this.subfolder]
+ folders: [this.subfolder],
}
this.folderPath = {
fileSystem: '/test-folder',
- mongo: 'rootFolder.0.folders.0'
+ mongo: 'rootFolder.0.folders.0',
}
this.rootFolder = {
_id: ObjectId(),
folders: [this.folder],
docs: [this.doc],
- fileRefs: [this.file]
+ fileRefs: [this.file],
}
this.rootFolderPath = {
fileSystem: '/',
- mongo: 'rootFolder.0'
+ mongo: 'rootFolder.0',
}
this.project = {
_id: ObjectId(),
name: 'project name',
- rootFolder: [this.rootFolder]
+ rootFolder: [this.rootFolder],
}
this.Settings = { maxEntitiesPerProject: 100 }
this.CooldownManager = {}
this.LockManager = {
promises: {
- runWithLock: sinon.spy((namespace, id, runner) => runner())
- }
+ runWithLock: sinon.spy((namespace, id, runner) => runner()),
+ },
}
this.FolderModel = sinon.stub()
@@ -75,74 +75,74 @@ describe('ProjectEntityMongoUpdateHandler', function () {
this.ProjectMock = sinon.mock(Project)
this.ProjectEntityHandler = {
promises: {
- getAllEntitiesFromProject: sinon.stub()
- }
+ getAllEntitiesFromProject: sinon.stub(),
+ },
}
this.ProjectLocator = {
promises: {
findElement: sinon.stub().rejects(new Error('not found')),
- findElementByPath: sinon.stub().rejects(new Error('not found'))
- }
+ findElementByPath: sinon.stub().rejects(new Error('not found')),
+ },
}
this.ProjectLocator.promises.findElement
.withArgs({
project: this.project,
element_id: this.rootFolder._id,
- type: 'folder'
+ type: 'folder',
})
.resolves({
element: this.rootFolder,
- path: this.rootFolderPath
+ path: this.rootFolderPath,
})
this.ProjectLocator.promises.findElement
.withArgs({
project: this.project,
element_id: this.folder._id,
- type: 'folder'
+ type: 'folder',
})
.resolves({
element: this.folder,
path: this.folderPath,
- folder: this.rootFolder
+ folder: this.rootFolder,
})
this.ProjectLocator.promises.findElement
.withArgs({
project: this.project,
element_id: this.subfolder._id,
- type: 'folder'
+ type: 'folder',
})
.resolves({
element: this.subfolder,
path: this.subfolderPath,
- folder: this.folder
+ folder: this.folder,
})
this.ProjectLocator.promises.findElement
.withArgs({
project: this.project,
element_id: this.file._id,
- type: 'file'
+ type: 'file',
})
.resolves({
element: this.file,
path: this.filePath,
- folder: this.rootFolder
+ folder: this.rootFolder,
})
this.ProjectLocator.promises.findElement
.withArgs({
project: this.project,
element_id: this.doc._id,
- type: 'doc'
+ type: 'doc',
})
.resolves({
element: this.doc,
path: this.docPath,
- folder: this.rootFolder
+ folder: this.rootFolder,
})
this.ProjectLocator.promises.findElementByPath
.withArgs(
sinon.match({
project: this.project,
- path: '/'
+ path: '/',
})
)
.resolves({ element: this.rootFolder, type: 'folder' })
@@ -150,7 +150,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
.withArgs(
sinon.match({
project: this.project,
- path: '/test-folder'
+ path: '/test-folder',
})
)
.resolves({ element: this.folder, type: 'folder' })
@@ -158,7 +158,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
.withArgs(
sinon.match({
project: this.project,
- path: '/test-folder/test-subfolder'
+ path: '/test-folder/test-subfolder',
})
)
.resolves({ element: this.subfolder, type: 'folder' })
@@ -169,12 +169,12 @@ describe('ProjectEntityMongoUpdateHandler', function () {
.stub()
.withArgs(this.project._id)
.resolves(this.project),
- getProjectWithOnlyFolders: sinon.stub().resolves(this.project)
- }
+ getProjectWithOnlyFolders: sinon.stub().resolves(this.project),
+ },
}
this.FolderStructureBuilder = {
- buildFolderStructure: sinon.stub()
+ buildFolderStructure: sinon.stub(),
}
this.subject = SandboxedModule.require(MODULE_PATH, {
@@ -189,8 +189,8 @@ describe('ProjectEntityMongoUpdateHandler', function () {
'./ProjectEntityHandler': this.ProjectEntityHandler,
'./ProjectLocator': this.ProjectLocator,
'./ProjectGetter': this.ProjectGetter,
- './FolderStructureBuilder': this.FolderStructureBuilder
- }
+ './FolderStructureBuilder': this.FolderStructureBuilder,
+ },
})
})
@@ -215,7 +215,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$push: { 'rootFolder.0.folders.0.docs': doc },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -236,10 +236,10 @@ describe('ProjectEntityMongoUpdateHandler', function () {
result: {
path: {
mongo: 'rootFolder.0.folders.0',
- fileSystem: '/test-folder/other.txt'
- }
+ fileSystem: '/test-folder/other.txt',
+ },
},
- project: this.project
+ project: this.project,
})
})
})
@@ -252,7 +252,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$push: { 'rootFolder.0.folders.0.fileRefs': this.newFile },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -277,10 +277,10 @@ describe('ProjectEntityMongoUpdateHandler', function () {
result: {
path: {
mongo: 'rootFolder.0.folders.0',
- fileSystem: '/test-folder/picture.jpg'
- }
+ fileSystem: '/test-folder/picture.jpg',
+ },
},
- project: this.project
+ project: this.project,
})
})
})
@@ -312,7 +312,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
const folderName = 'New folder'
this.FolderModel.withArgs({ name: folderName }).returns({
_id: ObjectId(),
- name: folderName
+ name: folderName,
})
this.ProjectMock.expects('findOneAndUpdate')
.withArgs(
@@ -320,10 +320,10 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{
$push: {
'rootFolder.0.folders.0.folders': sinon.match({
- name: folderName
- })
+ name: folderName,
+ }),
},
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -346,7 +346,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
_id: ObjectId(),
name: 'some-other-file.png',
linkedFileData: { some: 'data' },
- hash: 'some-hash'
+ hash: 'some-hash',
}
// Add a deleted file record
this.DeletedFileMock.expects('create')
@@ -356,7 +356,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
name: this.file.name,
linkedFileData: this.file.linkedFileData,
hash: this.file.hash,
- deletedAt: sinon.match.date
+ deletedAt: sinon.match.date,
})
.resolves()
// Update the file in place
@@ -368,12 +368,12 @@ describe('ProjectEntityMongoUpdateHandler', function () {
'rootFolder.0.fileRefs.0._id': newFile._id,
'rootFolder.0.fileRefs.0.created': sinon.match.date,
'rootFolder.0.fileRefs.0.linkedFileData': newFile.linkedFileData,
- 'rootFolder.0.fileRefs.0.hash': newFile.hash
+ 'rootFolder.0.fileRefs.0.hash': newFile.hash,
},
$inc: {
version: 1,
- 'rootFolder.0.fileRefs.0.rev': 1
- }
+ 'rootFolder.0.fileRefs.0.rev': 1,
+ },
}
)
.chain('exec')
@@ -443,7 +443,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$push: { 'rootFolder.0.folders': this.newFolder },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -487,10 +487,10 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{
$push: {
'rootFolder.0.folders.0.folders': sinon.match({
- name: 'new-folder'
- })
+ name: 'new-folder',
+ }),
},
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -523,12 +523,12 @@ describe('ProjectEntityMongoUpdateHandler', function () {
this.folder1 = { _id: ObjectId(), name: 'folder1' }
this.folder1Path = {
fileSystem: '/test-folder/folder1',
- mongo: 'rootFolder.0.folders.0.folders.0'
+ mongo: 'rootFolder.0.folders.0.folders.0',
}
this.folder2 = { _id: ObjectId(), name: 'folder2' }
this.folder2Path = {
fileSystem: '/test-folder/folder1/folder2',
- mongo: 'rootFolder.0.folders.0.folders.0.folders.0'
+ mongo: 'rootFolder.0.folders.0.folders.0.folders.0',
}
this.FolderModel.onFirstCall().returns(this.folder1)
this.FolderModel.onSecondCall().returns(this.folder2)
@@ -536,21 +536,21 @@ describe('ProjectEntityMongoUpdateHandler', function () {
.withArgs({
project: this.project,
element_id: this.folder1._id,
- type: 'folder'
+ type: 'folder',
})
.resolves({
element: this.folder1,
- path: this.folder1Path
+ path: this.folder1Path,
})
this.ProjectLocator.promises.findElement
.withArgs({
project: this.project,
element_id: this.folder2._id,
- type: 'folder'
+ type: 'folder',
})
.resolves({
element: this.folder2,
- path: this.folder2Path
+ path: this.folder2Path,
})
this.ProjectMock.expects('findOneAndUpdate')
.withArgs(
@@ -558,10 +558,10 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{
$push: {
'rootFolder.0.folders.0.folders': sinon.match({
- name: 'folder1'
- })
+ name: 'folder1',
+ }),
},
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -572,10 +572,10 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{
$push: {
'rootFolder.0.folders.0.folders.0.folders': sinon.match({
- name: 'folder2'
- })
+ name: 'folder2',
+ }),
},
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -584,12 +584,12 @@ describe('ProjectEntityMongoUpdateHandler', function () {
;[
{
description: 'without a trailing slash',
- path: '/test-folder/folder1/folder2'
+ path: '/test-folder/folder1/folder2',
},
{
description: 'with a trailing slash',
- path: '/test-folder/folder1/folder2/'
- }
+ path: '/test-folder/folder1/folder2/',
+ },
].forEach(({ description, path }) => {
describe(description, function () {
beforeEach(async function () {
@@ -628,7 +628,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
describe('moving a doc into a different folder', function () {
beforeEach(async function () {
this.pathAfterMove = {
- fileSystem: '/somewhere/else.txt'
+ fileSystem: '/somewhere/else.txt',
}
this.oldDocs = ['old-doc']
this.oldFiles = ['old-file']
@@ -647,7 +647,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$push: { 'rootFolder.0.folders.0.docs': this.doc },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -657,7 +657,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$pull: { 'rootFolder.0.docs': { _id: this.doc._id } },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -685,8 +685,8 @@ describe('ProjectEntityMongoUpdateHandler', function () {
newDocs: this.newDocs,
oldFiles: this.oldFiles,
newFiles: this.newFiles,
- newProject: this.project
- }
+ newProject: this.project,
+ },
})
})
})
@@ -725,7 +725,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$pull: { 'rootFolder.0.docs': { _id: this.doc._id } },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -763,7 +763,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$set: { 'rootFolder.0.docs.0.name': this.newName },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -791,8 +791,8 @@ describe('ProjectEntityMongoUpdateHandler', function () {
newDocs: this.newDocs,
oldFiles: this.oldFiles,
newFiles: this.newFiles,
- newProject: this.project
- }
+ newProject: this.project,
+ },
})
})
})
@@ -821,7 +821,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$push: { 'rootFolder.0.folders.0.fileRefs': this.newFile },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -888,7 +888,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
it('should error if element name is too long', async function () {
const file = {
_id: ObjectId(),
- name: 'long-'.repeat(1000) + 'something'
+ name: 'long-'.repeat(1000) + 'something',
}
await expect(
this.subject.promises._putElement(
@@ -903,17 +903,17 @@ describe('ProjectEntityMongoUpdateHandler', function () {
it('should error if the folder name is too long', async function () {
const file = {
_id: ObjectId(),
- name: 'something'
+ name: 'something',
}
this.ProjectLocator.promises.findElement
.withArgs({
project: this.project,
element_id: this.folder._id,
- type: 'folder'
+ type: 'folder',
})
.resolves({
element: this.folder,
- path: { fileSystem: 'subdir/'.repeat(1000) + 'foo' }
+ path: { fileSystem: 'subdir/'.repeat(1000) + 'foo' },
})
await expect(
this.subject.promises._putElement(
@@ -928,7 +928,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
it(`should error if a ${entityType} already exists with the same name`, async function () {
const file = {
_id: ObjectId(),
- name: this[entityType].name
+ name: this[entityType].name,
}
await expect(
this.subject.promises._putElement(
@@ -951,7 +951,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{ _id: this.project._id },
{
$push: { 'rootFolder.0.fileRefs': this.newFile },
- $inc: { version: 1 }
+ $inc: { version: 1 },
}
)
.chain('exec')
@@ -975,7 +975,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
name: this.file.name,
linkedFileData: this.file.linkedFileData,
hash: this.file.hash,
- deletedAt: sinon.match.date
+ deletedAt: sinon.match.date,
})
.resolves()
await this.subject.promises._insertDeletedFileReference(
@@ -1003,7 +1003,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
_id: this.project._id,
'rootFolder.0.folders.0': { $exists: false },
'rootFolder.0.docs.0': { $exists: false },
- 'rootFolder.0.files.0': { $exists: false }
+ 'rootFolder.0.files.0': { $exists: false },
},
{ $set: { rootFolder: [this.mockRootFolder] }, $inc: { version: 1 } },
{ new: true, lean: true, fields: { version: 1 } }
@@ -1051,7 +1051,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{
$pull: { 'rootFolder.0.docs': { _id: this.doc._id } },
$push: { 'rootFolder.0.fileRefs': this.file },
- $inc: { version: 1 }
+ $inc: { version: 1 },
},
{ new: true }
)
@@ -1074,7 +1074,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
{
$pull: { 'rootFolder.0.fileRefs': { _id: this.file._id } },
$push: { 'rootFolder.0.docs': this.doc },
- $inc: { version: 1 }
+ $inc: { version: 1 },
},
{ new: true }
)
diff --git a/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js
index a3ed392bb9..5b19655ce9 100644
--- a/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js
@@ -22,9 +22,9 @@ describe('ProjectEntityUpdateHandler', function () {
name: 'project name',
overleaf: {
history: {
- id: projectHistoryId
- }
- }
+ id: projectHistoryId,
+ },
+ },
}
this.fileUrl = 'filestore.example.com/file'
this.user = { _id: new ObjectId() }
@@ -72,40 +72,40 @@ describe('ProjectEntityUpdateHandler', function () {
getDoc: sinon.stub(),
isDocDeleted: sinon.stub(),
updateDoc: sinon.stub(),
- deleteDoc: sinon.stub()
+ deleteDoc: sinon.stub(),
}
this.DocumentUpdaterHandler = {
flushDocToMongo: sinon.stub().yields(),
updateProjectStructure: sinon.stub().yields(),
setDocument: sinon.stub(),
resyncProjectHistory: sinon.stub(),
- deleteDoc: sinon.stub().yields()
+ deleteDoc: sinon.stub().yields(),
}
this.fs = {
- unlink: sinon.stub().yields()
+ unlink: sinon.stub().yields(),
}
this.LockManager = {
runWithLock: sinon.spy((namespace, id, runner, callback) =>
runner(callback)
- )
+ ),
}
this.ProjectModel = {
- updateOne: sinon.stub()
+ updateOne: sinon.stub(),
}
this.ProjectGetter = {
getProject: sinon.stub(),
- getProjectWithoutDocLines: sinon.stub()
+ getProjectWithoutDocLines: sinon.stub(),
}
this.ProjectLocator = {
findElement: sinon.stub(),
- findElementByPath: sinon.stub()
+ findElementByPath: sinon.stub(),
}
this.ProjectUpdater = {
- markAsUpdated: sinon.stub()
+ markAsUpdated: sinon.stub(),
}
this.ProjectEntityHandler = {
getDocPathByProjectIdAndDocId: sinon.stub(),
- getAllEntitiesFromProject: sinon.stub()
+ getAllEntitiesFromProject: sinon.stub(),
}
this.ProjectEntityMongoUpdateHandler = {
addDoc: sinon.stub(),
@@ -120,7 +120,7 @@ describe('ProjectEntityUpdateHandler', function () {
renameEntity: sinon.stub(),
deleteEntity: sinon.stub(),
replaceDocWithFile: sinon.stub(),
- replaceFileWithDoc: sinon.stub()
+ replaceFileWithDoc: sinon.stub(),
}
this.TpdsUpdateSender = {
addFile: sinon.stub().yields(),
@@ -128,19 +128,19 @@ describe('ProjectEntityUpdateHandler', function () {
deleteEntity: sinon.stub().yields(),
moveEntity: sinon.stub(),
promises: {
- moveEntity: sinon.stub().resolves()
- }
+ moveEntity: sinon.stub().resolves(),
+ },
}
this.FileStoreHandler = {
copyFile: sinon.stub(),
uploadFileFromDisk: sinon.stub(),
- deleteFile: sinon.stub()
+ deleteFile: sinon.stub(),
}
this.FileWriter = {
- writeLinesToDisk: sinon.stub()
+ writeLinesToDisk: sinon.stub(),
}
this.EditorRealTimeController = {
- emitToRoom: sinon.stub()
+ emitToRoom: sinon.stub(),
}
this.ProjectEntityUpdateHandler = SandboxedModule.require(MODULE_PATH, {
requires: {
@@ -162,8 +162,8 @@ describe('ProjectEntityUpdateHandler', function () {
.ProjectEntityMongoUpdateHandler,
'../ThirdPartyDataStore/TpdsUpdateSender': this.TpdsUpdateSender,
'../Editor/EditorRealTimeController': this.EditorRealTimeController,
- '../../infrastructure/FileWriter': this.FileWriter
- }
+ '../../infrastructure/FileWriter': this.FileWriter,
+ },
})
})
@@ -171,7 +171,7 @@ describe('ProjectEntityUpdateHandler', function () {
beforeEach(function () {
this.path = '/somewhere/something.tex'
this.doc = {
- _id: docId
+ _id: docId,
}
this.version = 42
this.ranges = { mock: 'ranges' }
@@ -180,7 +180,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.DocstoreManager.isDocDeleted.yields(null, false)
this.ProjectGetter.getProject.yields(null, this.project)
this.ProjectLocator.findElement.yields(null, this.doc, {
- fileSystem: this.path
+ fileSystem: this.path,
})
this.TpdsUpdateSender.addDoc.yields()
})
@@ -204,7 +204,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.ProjectGetter.getProject
.calledWith(projectId, {
name: true,
- rootFolder: true
+ rootFolder: true,
})
.should.equal(true)
})
@@ -214,7 +214,7 @@ describe('ProjectEntityUpdateHandler', function () {
.calledWith({
project: this.project,
type: 'docs',
- element_id: docId
+ element_id: docId,
})
.should.equal(true)
})
@@ -247,7 +247,7 @@ describe('ProjectEntityUpdateHandler', function () {
project_name: this.project.name,
doc_id: docId,
rev: this.rev,
- path: this.path
+ path: this.path,
})
.should.equal(true)
})
@@ -509,7 +509,7 @@ describe('ProjectEntityUpdateHandler', function () {
name: this.docName,
lines: undefined,
_id: docId,
- rev: 0
+ rev: 0,
})
this.DocstoreManager.updateDoc.yields(null, false, (this.rev = 5))
this.TpdsUpdateSender.addDoc.yields()
@@ -539,13 +539,13 @@ describe('ProjectEntityUpdateHandler', function () {
{
doc: this.newDoc,
path: this.path,
- docLines: this.docLines.join('\n')
- }
+ docLines: this.docLines.join('\n'),
+ },
]
this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(projectId, projectHistoryId, userId, {
newDocs,
- newProject: this.project
+ newProject: this.project,
})
.should.equal(true)
})
@@ -582,7 +582,7 @@ describe('ProjectEntityUpdateHandler', function () {
_id: fileId,
rev: 0,
name: this.fileName,
- linkedFileData: this.linkedFileData
+ linkedFileData: this.linkedFileData,
}
this.FileStoreHandler.uploadFileFromDisk.yields(
null,
@@ -633,7 +633,7 @@ describe('ProjectEntityUpdateHandler', function () {
project_name: this.project.name,
file_id: fileId,
rev: 0,
- path: this.path
+ path: this.path,
})
.should.equal(true)
})
@@ -650,13 +650,13 @@ describe('ProjectEntityUpdateHandler', function () {
{
file: this.newFile,
path: this.path,
- url: this.fileUrl
- }
+ url: this.fileUrl,
+ },
]
this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(projectId, projectHistoryId, userId, {
newFiles,
- newProject: this.project
+ newProject: this.project,
})
.should.equal(true)
})
@@ -670,7 +670,7 @@ describe('ProjectEntityUpdateHandler', function () {
_id: fileId,
rev: 0,
name: this.fileName,
- linkedFileData: this.linkedFileData
+ linkedFileData: this.linkedFileData,
}
this.TpdsUpdateSender.addFile.yields()
this.ProjectEntityMongoUpdateHandler.addFile.yields(
@@ -704,7 +704,7 @@ describe('ProjectEntityUpdateHandler', function () {
_id: newFileId,
name: 'dummy-upload-filename',
rev: 0,
- linkedFileData: this.linkedFileData
+ linkedFileData: this.linkedFileData,
}
this.oldFile = { _id: fileId, rev: 3 }
this.path = '/path/to/file'
@@ -738,7 +738,7 @@ describe('ProjectEntityUpdateHandler', function () {
projectId,
{
name: 'dummy-upload-filename',
- linkedFileData: this.linkedFileData
+ linkedFileData: this.linkedFileData,
},
this.fileSystemPath
)
@@ -758,7 +758,7 @@ describe('ProjectEntityUpdateHandler', function () {
project_name: this.project.name,
file_id: newFileId,
rev: this.oldFile.rev + 1,
- path: this.path
+ path: this.path,
})
.should.equal(true)
})
@@ -774,21 +774,21 @@ describe('ProjectEntityUpdateHandler', function () {
const oldFiles = [
{
file: this.oldFile,
- path: this.path
- }
+ path: this.path,
+ },
]
const newFiles = [
{
file: this.newFile,
path: this.path,
- url: this.newFileUrl
- }
+ url: this.newFileUrl,
+ },
]
this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(projectId, projectHistoryId, userId, {
oldFiles,
newFiles,
- newProject: this.newProject
+ newProject: this.newProject,
})
.should.equal(true)
})
@@ -822,7 +822,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.folder = {
_id: folderId,
docs: [this.existingDoc],
- fileRefs: [this.existingFile]
+ fileRefs: [this.existingFile],
}
this.ProjectLocator.findElement.yields(null, this.folder)
this.DocumentUpdaterHandler.setDocument.yields()
@@ -843,7 +843,7 @@ describe('ProjectEntityUpdateHandler', function () {
.calledWith({
project_id: projectId,
element_id: folderId,
- type: 'folder'
+ type: 'folder',
})
.should.equal(true)
})
@@ -877,7 +877,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.newDoc = { _id: docId }
this.ProjectLocator.findElement.yields(null, this.folder)
this.ProjectEntityUpdateHandler.addDocWithRanges = {
- withoutLock: sinon.stub().yields(null, this.newDoc)
+ withoutLock: sinon.stub().yields(null, this.newDoc),
}
this.ProjectEntityUpdateHandler.upsertDoc(
@@ -896,7 +896,7 @@ describe('ProjectEntityUpdateHandler', function () {
.calledWith({
project_id: projectId,
element_id: folderId,
- type: 'folder'
+ type: 'folder',
})
.should.equal(true)
})
@@ -925,7 +925,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.newDoc = { _id: docId }
this.ProjectLocator.findElement.yields(null, this.folder)
this.ProjectEntityUpdateHandler.addDocWithRanges = {
- withoutLock: sinon.stub().yields(null, this.newDoc)
+ withoutLock: sinon.stub().yields(null, this.newDoc),
}
this.ProjectEntityUpdateHandler.upsertDoc(
@@ -949,7 +949,7 @@ describe('ProjectEntityUpdateHandler', function () {
beforeEach(function () {
this.newProject = {
name: 'new project',
- overleaf: { history: { id: projectHistoryId } }
+ overleaf: { history: { id: projectHistoryId } },
}
this.existingFile = { _id: fileId, name: 'foo.tex', rev: 12 }
this.folder = { _id: folderId, docs: [], fileRefs: [this.existingFile] }
@@ -961,10 +961,10 @@ describe('ProjectEntityUpdateHandler', function () {
.withArgs({
project_id: projectId,
element_id: this.folder._id,
- type: 'folder'
+ type: 'folder',
})
.yields(null, this.folder, {
- fileSystem: this.folderPath
+ fileSystem: this.folderPath,
})
this.DocstoreManager.updateDoc.yields()
this.ProjectEntityMongoUpdateHandler.replaceFileWithDoc.yields(
@@ -1008,7 +1008,7 @@ describe('ProjectEntityUpdateHandler', function () {
doc_id: this.newDoc._id,
path: this.filePath,
project_name: this.newProject.name,
- rev: this.existingFile.rev + 1
+ rev: this.existingFile.rev + 1,
})
})
@@ -1016,22 +1016,22 @@ describe('ProjectEntityUpdateHandler', function () {
const oldFiles = [
{
file: this.existingFile,
- path: this.filePath
- }
+ path: this.filePath,
+ },
]
const newDocs = [
{
doc: sinon.match(this.newDoc),
path: this.filePath,
- docLines: this.docLines.join('\n')
- }
+ docLines: this.docLines.join('\n'),
+ },
]
expect(
this.DocumentUpdaterHandler.updateProjectStructure
).to.have.been.calledWith(projectId, projectHistoryId, userId, {
oldFiles,
newDocs,
- newProject: this.newProject
+ newProject: this.newProject,
})
})
@@ -1083,7 +1083,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.folder = { _id: folderId, fileRefs: [this.existingFile], docs: [] }
this.ProjectLocator.findElement.yields(null, this.folder)
this.ProjectEntityUpdateHandler.replaceFile = {
- mainTask: sinon.stub().yields(null, this.newFile)
+ mainTask: sinon.stub().yields(null, this.newFile),
}
this.ProjectEntityUpdateHandler.upsertFile(
@@ -1120,7 +1120,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.newFile = { _id: fileId }
this.ProjectLocator.findElement.yields(null, this.folder)
this.ProjectEntityUpdateHandler.addFile = {
- mainTask: sinon.stub().yields(null, this.newFile)
+ mainTask: sinon.stub().yields(null, this.newFile),
}
this.ProjectEntityUpdateHandler.upsertFile(
@@ -1139,7 +1139,7 @@ describe('ProjectEntityUpdateHandler', function () {
.calledWith({
project_id: projectId,
element_id: folderId,
- type: 'folder'
+ type: 'folder',
})
.should.equal(true)
})
@@ -1168,7 +1168,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.newFile = { _id: fileId }
this.ProjectLocator.findElement.yields(null, this.folder)
this.ProjectEntityUpdateHandler.addFile = {
- mainTask: sinon.stub().yields(null, this.newFile)
+ mainTask: sinon.stub().yields(null, this.newFile),
}
this.ProjectEntityUpdateHandler.upsertFile(
@@ -1195,20 +1195,20 @@ describe('ProjectEntityUpdateHandler', function () {
this.folder = {
_id: folderId,
fileRefs: [],
- docs: [this.existingDoc]
+ docs: [this.existingDoc],
}
this.ProjectLocator.findElement
.withArgs({
project_id: this.project._id.toString(),
element_id: folderId,
- type: 'folder'
+ type: 'folder',
})
.yields(null, this.folder)
this.ProjectLocator.findElement
.withArgs({
project_id: this.project._id.toString(),
element_id: this.existingDoc._id,
- type: 'doc'
+ type: 'doc',
})
.yields(null, this.existingDoc, { fileSystem: this.path })
@@ -1217,11 +1217,11 @@ describe('ProjectEntityUpdateHandler', function () {
_id: newFileId,
name: 'dummy-upload-filename',
rev: 0,
- linkedFileData: this.linkedFileData
+ linkedFileData: this.linkedFileData,
}
this.newProject = {
name: 'new project',
- overleaf: { history: { id: projectHistoryId } }
+ overleaf: { history: { id: projectHistoryId } },
}
this.FileStoreHandler.uploadFileFromDisk.yields(
null,
@@ -1254,20 +1254,20 @@ describe('ProjectEntityUpdateHandler', function () {
const oldDocs = [
{
doc: this.existingDoc,
- path: this.path
- }
+ path: this.path,
+ },
]
const newFiles = [
{
file: this.newFile,
path: this.path,
- url: this.newFileUrl
- }
+ url: this.newFileUrl,
+ },
]
const updates = {
oldDocs,
newFiles,
- newProject: this.newProject
+ newProject: this.newProject,
}
expect(
this.DocumentUpdaterHandler.updateProjectStructure
@@ -1296,10 +1296,10 @@ describe('ProjectEntityUpdateHandler', function () {
this.doc = { _id: docId }
this.isNewDoc = true
this.ProjectEntityUpdateHandler.mkdirp = {
- withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
+ withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
}
this.ProjectEntityUpdateHandler.upsertDoc = {
- withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc)
+ withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc),
}
this.ProjectEntityUpdateHandler.upsertDocWithPath(
@@ -1352,10 +1352,10 @@ describe('ProjectEntityUpdateHandler', function () {
this.doc = { _id: docId }
this.isNewDoc = true
this.ProjectEntityUpdateHandler.mkdirp = {
- withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
+ withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
}
this.ProjectEntityUpdateHandler.upsertDoc = {
- withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc)
+ withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc),
}
this.ProjectEntityUpdateHandler.upsertDocWithPath(
@@ -1382,10 +1382,10 @@ describe('ProjectEntityUpdateHandler', function () {
this.doc = { _id: docId }
this.isNewDoc = true
this.ProjectEntityUpdateHandler.mkdirp = {
- withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
+ withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
}
this.ProjectEntityUpdateHandler.upsertDoc = {
- withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc)
+ withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc),
}
this.ProjectEntityUpdateHandler.upsertDocWithPath(
@@ -1419,10 +1419,10 @@ describe('ProjectEntityUpdateHandler', function () {
this.newFile
)
this.ProjectEntityUpdateHandler.mkdirp = {
- withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
+ withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
}
this.ProjectEntityUpdateHandler.upsertFile = {
- mainTask: sinon.stub().yields(null, this.file, this.isNewFile)
+ mainTask: sinon.stub().yields(null, this.file, this.isNewFile),
}
this.ProjectEntityUpdateHandler.upsertFileWithPath(
@@ -1476,10 +1476,10 @@ describe('ProjectEntityUpdateHandler', function () {
this.file = { _id: fileId }
this.isNewFile = true
this.ProjectEntityUpdateHandler.mkdirp = {
- withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
+ withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
}
this.ProjectEntityUpdateHandler.upsertFile = {
- mainTask: sinon.stub().yields(null, this.file, this.isNewFile)
+ mainTask: sinon.stub().yields(null, this.file, this.isNewFile),
}
this.ProjectEntityUpdateHandler.upsertFileWithPath(
@@ -1506,10 +1506,10 @@ describe('ProjectEntityUpdateHandler', function () {
this.file = { _id: fileId }
this.isNewFile = true
this.ProjectEntityUpdateHandler.mkdirp = {
- withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
+ withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
}
this.ProjectEntityUpdateHandler.upsertFile = {
- mainTask: sinon.stub().yields(null, this.file, this.isNewFile)
+ mainTask: sinon.stub().yields(null, this.file, this.isNewFile),
}
this.ProjectEntityUpdateHandler.upsertFileWithPath(
@@ -1577,7 +1577,7 @@ describe('ProjectEntityUpdateHandler', function () {
.calledWith({
project_id: projectId,
path: this.path,
- project_name: this.projectBeforeDeletion.name
+ project_name: this.projectBeforeDeletion.name,
})
.should.equal(true)
})
@@ -1593,7 +1593,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.doc = { _id: docId }
this.ProjectLocator.findElementByPath.yields(null, this.doc, 'doc')
this.ProjectEntityUpdateHandler.deleteEntity = {
- withoutLock: sinon.stub().yields()
+ withoutLock: sinon.stub().yields(),
}
this.path = '/path/to/doc.tex'
this.ProjectEntityUpdateHandler.deleteEntityWithPath(
@@ -1753,7 +1753,7 @@ describe('ProjectEntityUpdateHandler', function () {
project_name: this.project_name,
startPath: this.startPath,
endPath: this.endPath,
- rev: this.rev
+ rev: this.rev,
})
.should.equal(true)
})
@@ -1812,7 +1812,7 @@ describe('ProjectEntityUpdateHandler', function () {
project_name: this.project_name,
startPath: this.startPath,
endPath: this.endPath,
- rev: this.rev
+ rev: this.rev,
})
.should.equal(true)
})
@@ -1920,18 +1920,18 @@ describe('ProjectEntityUpdateHandler', function () {
const docs = [
{
doc: {
- _id: docId
+ _id: docId,
},
- path: 'main.tex'
- }
+ path: 'main.tex',
+ },
]
const files = [
{
file: {
- _id: fileId
+ _id: fileId,
},
- path: 'universe.png'
- }
+ path: 'universe.png',
+ },
]
this.ProjectEntityHandler.getAllEntitiesFromProject.yields(
null,
@@ -1962,15 +1962,15 @@ describe('ProjectEntityUpdateHandler', function () {
const docs = [
{
doc: docId,
- path: 'main.tex'
- }
+ path: 'main.tex',
+ },
]
const files = [
{
file: fileId,
path: 'universe.png',
- url: `www.filestore.test/${projectId}/${fileId}`
- }
+ url: `www.filestore.test/${projectId}/${fileId}`,
+ },
]
this.DocumentUpdaterHandler.resyncProjectHistory
.calledWith(projectId, projectHistoryId, docs, files)
@@ -2028,7 +2028,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(projectId, projectHistoryId, userId, {
oldFiles,
- newProject: this.newProject
+ newProject: this.newProject,
})
.should.equal(true)
})
@@ -2062,7 +2062,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(projectId, projectHistoryId, userId, {
oldDocs,
- newProject: this.newProject
+ newProject: this.newProject,
})
.should.equal(true)
})
@@ -2075,14 +2075,14 @@ describe('ProjectEntityUpdateHandler', function () {
{
name: 'subfolder',
fileRefs: [
- (this.file1 = { _id: 'file-id-1', name: 'file-name-1' })
+ (this.file1 = { _id: 'file-id-1', name: 'file-name-1' }),
],
docs: [(this.doc1 = { _id: 'doc-id-1', name: 'doc-name-1' })],
- folders: []
- }
+ folders: [],
+ },
],
fileRefs: [(this.file2 = { _id: 'file-id-2', name: 'file-name-2' })],
- docs: [(this.doc2 = { _id: 'doc-id-2', name: 'doc-name-2' })]
+ docs: [(this.doc2 = { _id: 'doc-id-2', name: 'doc-name-2' })],
}
this.ProjectEntityUpdateHandler._cleanUpDoc = sinon.stub().yields()
@@ -2131,17 +2131,17 @@ describe('ProjectEntityUpdateHandler', function () {
it('should should send one update to the doc updater for all docs and files', function () {
const oldFiles = [
{ file: this.file2, path: '/folder/file-name-2' },
- { file: this.file1, path: '/folder/subfolder/file-name-1' }
+ { file: this.file1, path: '/folder/subfolder/file-name-1' },
]
const oldDocs = [
{ doc: this.doc2, path: '/folder/doc-name-2' },
- { doc: this.doc1, path: '/folder/subfolder/doc-name-1' }
+ { doc: this.doc1, path: '/folder/subfolder/doc-name-1' },
]
this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(projectId, projectHistoryId, userId, {
oldFiles,
oldDocs,
- newProject: this.newProject
+ newProject: this.newProject,
})
.should.equal(true)
})
@@ -2152,7 +2152,7 @@ describe('ProjectEntityUpdateHandler', function () {
beforeEach(function () {
this.doc = {
_id: ObjectId(),
- name: 'test.tex'
+ name: 'test.tex',
}
this.path = '/path/to/doc'
this.ProjectEntityUpdateHandler.unsetRootDoc = sinon.stub().yields()
@@ -2228,14 +2228,14 @@ describe('ProjectEntityUpdateHandler', function () {
.withArgs({
project_id: this.project._id,
element_id: this.doc._id,
- type: 'doc'
+ type: 'doc',
})
.yields(null, this.doc, { fileSystem: this.path })
this.ProjectLocator.findElement
.withArgs({
project_id: this.project._id.toString(),
element_id: this.file._id,
- type: 'file'
+ type: 'file',
})
.yields(null, this.file, this.docPath, this.folder)
this.DocstoreManager.getDoc
@@ -2300,9 +2300,9 @@ describe('ProjectEntityUpdateHandler', function () {
{
oldDocs: [{ doc: this.doc, path: this.path }],
newFiles: [
- { file: this.file, path: this.path, url: this.fileStoreUrl }
+ { file: this.file, path: this.path, url: this.fileStoreUrl },
],
- newProject: this.project
+ newProject: this.project,
}
)
})
diff --git a/services/web/test/unit/src/Project/ProjectGetterTests.js b/services/web/test/unit/src/Project/ProjectGetterTests.js
index c4695c5b49..6f459bf8e4 100644
--- a/services/web/test/unit/src/Project/ProjectGetterTests.js
+++ b/services/web/test/unit/src/Project/ProjectGetterTests.js
@@ -13,51 +13,51 @@ describe('ProjectGetter', function () {
this.userId = new ObjectId()
this.DeletedProject = {
- find: sinon.stub().yields(null, [this.deletedProject])
+ find: sinon.stub().yields(null, [this.deletedProject]),
}
this.Project = {
find: sinon.stub(),
- findOne: sinon.stub().yields(null, this.project)
+ findOne: sinon.stub().yields(null, this.project),
}
this.CollaboratorsGetter = {
getProjectsUserIsMemberOf: sinon.stub().yields(null, {
readAndWrite: [],
readOnly: [],
tokenReadAndWrite: [],
- tokenReadOnly: []
- })
+ tokenReadOnly: [],
+ }),
}
this.LockManager = {
runWithLock: sinon
.stub()
- .callsFake((namespace, id, runner, callback) => runner(callback))
+ .callsFake((namespace, id, runner, callback) => runner(callback)),
}
this.db = {
projects: {
- findOne: sinon.stub().yields(null, this.project)
+ findOne: sinon.stub().yields(null, this.project),
},
- users: {}
+ users: {},
}
this.ProjectEntityMongoUpdateHandler = {
- lockKey: sinon.stub().returnsArg(0)
+ lockKey: sinon.stub().returnsArg(0),
}
this.ProjectGetter = SandboxedModule.require(modulePath, {
requires: {
'../../infrastructure/mongodb': { db: this.db, ObjectId },
'@overleaf/metrics': {
- timeAsyncMethod: sinon.stub()
+ timeAsyncMethod: sinon.stub(),
},
'../../models/Project': {
- Project: this.Project
+ Project: this.Project,
},
'../../models/DeletedProject': {
- DeletedProject: this.DeletedProject
+ DeletedProject: this.DeletedProject,
},
'../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter,
'../../infrastructure/LockManager': this.LockManager,
'./ProjectEntityMongoUpdateHandler': this
- .ProjectEntityMongoUpdateHandler
- }
+ .ProjectEntityMongoUpdateHandler,
+ },
})
})
@@ -89,7 +89,7 @@ describe('ProjectGetter', function () {
'rootFolder.folders.folders.folders.folders.docs.lines': 0,
'rootFolder.folders.folders.folders.folders.folders.docs.lines': 0,
'rootFolder.folders.folders.folders.folders.folders.folders.docs.lines': 0,
- 'rootFolder.folders.folders.folders.folders.folders.folders.folders.docs.lines': 0
+ 'rootFolder.folders.folders.folders.folders.folders.folders.folders.docs.lines': 0,
}
this.ProjectGetter.getProject
@@ -139,7 +139,7 @@ describe('ProjectGetter', function () {
'rootFolder.folders.folders.folders.folders.folders.folders.docs': 0,
'rootFolder.folders.folders.folders.folders.folders.folders.fileRefs': 0,
'rootFolder.folders.folders.folders.folders.folders.folders.folders.docs': 0,
- 'rootFolder.folders.folders.folders.folders.folders.folders.folders.fileRefs': 0
+ 'rootFolder.folders.folders.folders.folders.folders.folders.folders.fileRefs': 0,
}
this.ProjectGetter.getProject
.calledWith(this.project._id, excludes)
@@ -199,7 +199,7 @@ describe('ProjectGetter', function () {
this.db.projects.findOne.lastCall.args[0]._id.toString()
).to.equal(this.projectIdStr)
expect(this.db.projects.findOne.lastCall.args[1]).to.deep.equal({
- projection: this.projection
+ projection: this.projection,
})
})
})
@@ -267,7 +267,7 @@ describe('ProjectGetter', function () {
this.db.projects.findOne.lastCall.args[0]._id.toString()
).to.equal(this.projectIdStr)
expect(this.db.projects.findOne.lastCall.args[1]).to.deep.equal({
- projection: this.projection
+ projection: this.projection,
})
})
})
@@ -295,7 +295,7 @@ describe('ProjectGetter', function () {
readAndWrite: ['mock-rw-projects'],
readOnly: ['mock-ro-projects'],
tokenReadAndWrite: ['mock-token-rw-projects'],
- tokenReadOnly: ['mock-token-ro-projects']
+ tokenReadOnly: ['mock-token-ro-projects'],
})
this.ProjectGetter.findAllUsersProjects(
this.userId,
@@ -311,7 +311,7 @@ describe('ProjectGetter', function () {
readAndWrite: ['mock-rw-projects'],
readOnly: ['mock-ro-projects'],
tokenReadAndWrite: ['mock-token-rw-projects'],
- tokenReadOnly: ['mock-token-ro-projects']
+ tokenReadOnly: ['mock-token-ro-projects'],
})
.should.equal(true)
})
@@ -374,7 +374,7 @@ describe('ProjectGetter', function () {
{ name: 'find me!' },
{ name: 'not me!' },
{ name: 'FIND ME!' },
- { name: 'Find Me!' }
+ { name: 'Find Me!' },
])
this.ProjectGetter.findUsersProjectsByName(
this.userId,
@@ -399,7 +399,7 @@ describe('ProjectGetter', function () {
readAndWrite: [{ name: 'FIND ME!' }],
readOnly: [{ name: 'Find Me!' }],
tokenReadAndWrite: [{ name: 'find ME!' }],
- tokenReadOnly: [{ name: 'FIND me!' }]
+ tokenReadOnly: [{ name: 'FIND me!' }],
})
this.ProjectGetter.findUsersProjectsByName(
this.userId,
@@ -410,7 +410,7 @@ describe('ProjectGetter', function () {
}
expect(projects.map(project => project.name)).to.have.members([
'find me!',
- 'FIND ME!'
+ 'FIND ME!',
])
done()
}
@@ -425,7 +425,7 @@ describe('ProjectGetter', function () {
return done(err)
}
sinon.assert.calledWith(this.DeletedProject.find, {
- 'deleterData.deletedProjectOwnerId': 'giraffe'
+ 'deleterData.deletedProjectOwnerId': 'giraffe',
})
done()
})
diff --git a/services/web/test/unit/src/Project/ProjectHelperTests.js b/services/web/test/unit/src/Project/ProjectHelperTests.js
index 40b2492bae..232ee5811f 100644
--- a/services/web/test/unit/src/Project/ProjectHelperTests.js
+++ b/services/web/test/unit/src/Project/ProjectHelperTests.js
@@ -7,18 +7,18 @@ const MODULE_PATH = '../../../../app/src/Features/Project/ProjectHelper.js'
describe('ProjectHelper', function () {
beforeEach(function () {
this.project = {
- _id: '123213jlkj9kdlsaj'
+ _id: '123213jlkj9kdlsaj',
}
this.user = {
_id: '588f3ddae8ebc1bac07c9fa4',
first_name: 'bjkdsjfk',
- features: {}
+ features: {},
}
this.adminUser = {
_id: 'admin-user-id',
- isAdmin: true
+ isAdmin: true,
}
this.Settings = {
@@ -28,16 +28,16 @@ describe('ProjectHelper', function () {
{
imageName: 'texlive-full:2020.1',
imageDesc: 'TeX Live 2020',
- adminOnly: true
- }
- ]
+ adminOnly: true,
+ },
+ ],
}
this.ProjectHelper = SandboxedModule.require(MODULE_PATH, {
requires: {
mongodb: { ObjectId },
- 'settings-sharelatex': this.Settings
- }
+ 'settings-sharelatex': this.Settings,
+ },
})
})
@@ -46,7 +46,7 @@ describe('ProjectHelper', function () {
it('returns true if user id is found', function () {
this.project.archived = [
ObjectId('588f3ddae8ebc1bac07c9fa4'),
- ObjectId('5c41deb2b4ca500153340809')
+ ObjectId('5c41deb2b4ca500153340809'),
]
expect(
this.ProjectHelper.isArchived(this.project, this.user._id)
@@ -91,7 +91,7 @@ describe('ProjectHelper', function () {
it('returns true if user id is found', function () {
this.project.trashed = [
ObjectId('588f3ddae8ebc1bac07c9fa4'),
- ObjectId('5c41deb2b4ca500153340809')
+ ObjectId('5c41deb2b4ca500153340809'),
]
expect(
this.ProjectHelper.isTrashed(this.project, this.user._id)
@@ -145,11 +145,11 @@ describe('ProjectHelper', function () {
owner_ref: this.user._id,
collaberator_refs: [
ObjectId('4f2cfb341eb5855a5b000f8b'),
- ObjectId('5c45f3bd425ead01488675aa')
+ ObjectId('5c45f3bd425ead01488675aa'),
],
readOnly_refs: [ObjectId('5c92243fcdb09e014aa7d487')],
tokenAccessReadAndWrite_refs: [ObjectId('5c922599cdb09e014aa7d499')],
- tokenAccessReadOnly_refs: []
+ tokenAccessReadOnly_refs: [],
}
const result = this.ProjectHelper.calculateArchivedArray(
@@ -162,7 +162,7 @@ describe('ProjectHelper', function () {
ObjectId('4f2cfb341eb5855a5b000f8b'),
ObjectId('5c45f3bd425ead01488675aa'),
ObjectId('5c92243fcdb09e014aa7d487'),
- ObjectId('5c922599cdb09e014aa7d499')
+ ObjectId('5c922599cdb09e014aa7d499'),
])
})
@@ -173,11 +173,11 @@ describe('ProjectHelper', function () {
collaberator_refs: [
ObjectId('4f2cfb341eb5855a5b000f8b'),
ObjectId('5c45f3bd425ead01488675aa'),
- ObjectId('5c922599cdb09e014aa7d499')
+ ObjectId('5c922599cdb09e014aa7d499'),
],
readOnly_refs: [ObjectId('5c92243fcdb09e014aa7d487')],
tokenAccessReadAndWrite_refs: [ObjectId('5c922599cdb09e014aa7d499')],
- tokenAccessReadOnly_refs: []
+ tokenAccessReadOnly_refs: [],
}
const result = this.ProjectHelper.calculateArchivedArray(
@@ -189,7 +189,7 @@ describe('ProjectHelper', function () {
ObjectId('4f2cfb341eb5855a5b000f8b'),
ObjectId('5c45f3bd425ead01488675aa'),
ObjectId('5c922599cdb09e014aa7d499'),
- ObjectId('5c92243fcdb09e014aa7d487')
+ ObjectId('5c92243fcdb09e014aa7d487'),
])
})
})
@@ -271,7 +271,7 @@ describe('ProjectHelper', function () {
const imageNames = images.map(image => image.imageName)
expect(imageNames).to.deep.equal([
'texlive-full:2018.1',
- 'texlive-full:2019.1'
+ 'texlive-full:2019.1',
])
})
@@ -280,7 +280,7 @@ describe('ProjectHelper', function () {
const imageNames = images.map(image => image.imageName)
expect(imageNames).to.deep.equal([
'texlive-full:2018.1',
- 'texlive-full:2019.1'
+ 'texlive-full:2019.1',
])
})
@@ -290,7 +290,7 @@ describe('ProjectHelper', function () {
expect(imageNames).to.deep.equal([
'texlive-full:2018.1',
'texlive-full:2019.1',
- 'texlive-full:2020.1'
+ 'texlive-full:2020.1',
])
})
})
diff --git a/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js b/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js
index f8c3f6a96c..d24bd1b6d5 100644
--- a/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js
@@ -46,12 +46,12 @@ describe('ProjectHistoryHandler', function () {
requires: {
'settings-sharelatex': (this.Settings = {}),
'../../models/Project': {
- Project: this.ProjectModel
+ Project: this.ProjectModel,
},
'./ProjectDetailsHandler': (this.ProjectDetailsHandler = {}),
'../History/HistoryManager': (this.HistoryManager = {}),
- './ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {})
- }
+ './ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {}),
+ },
}))
})
diff --git a/services/web/test/unit/src/Project/ProjectLocatorTests.js b/services/web/test/unit/src/Project/ProjectLocatorTests.js
index 6681b2e916..d460e74a29 100644
--- a/services/web/test/unit/src/Project/ProjectLocatorTests.js
+++ b/services/web/test/unit/src/Project/ProjectLocatorTests.js
@@ -17,14 +17,14 @@ const secondSubFolder = {
_id: 'dsa3e23',
docs: [subSubDoc],
fileRefs: [subSubFile],
- folders: []
+ folders: [],
}
const subFolder = {
name: 'subFolder',
_id: 'dsadsa93',
folders: [secondSubFolder, null],
docs: [],
- fileRefs: []
+ fileRefs: [],
}
const subFolder1 = { name: 'subFolder1', _id: '123asdjoij' }
@@ -32,7 +32,7 @@ const rootFolder = {
_id: '123sdskd',
docs: [doc1, doc2, null, rootDoc],
fileRefs: [file1],
- folders: [subFolder1, subFolder]
+ folders: [subFolder1, subFolder],
}
project.rootFolder[0] = rootFolder
@@ -44,20 +44,20 @@ describe('ProjectLocator', function () {
callback(null, project)
}
this.ProjectGetter = {
- getProject: sinon.stub().callsArgWith(2, null, project)
+ getProject: sinon.stub().callsArgWith(2, null, project),
}
this.ProjectHelper = {
isArchived: sinon.stub(),
isTrashed: sinon.stub(),
- isArchivedOrTrashed: sinon.stub()
+ isArchivedOrTrashed: sinon.stub(),
}
this.locator = SandboxedModule.require(modulePath, {
requires: {
'../../models/Project': { Project },
'../../models/User': { User: this.User },
'./ProjectGetter': this.ProjectGetter,
- './ProjectHelper': this.ProjectHelper
- }
+ './ProjectHelper': this.ProjectHelper,
+ },
})
})
@@ -143,7 +143,7 @@ describe('ProjectLocator', function () {
{
project_id: project._id,
element_id: secondSubFolder._id,
- type: 'folder'
+ type: 'folder',
},
(err, foundElement, path, parentFolder) => {
if (err != null) {
@@ -183,7 +183,7 @@ describe('ProjectLocator', function () {
{
project_id: project._id,
element_id: subSubFile._id,
- type: 'fileRefs'
+ type: 'fileRefs',
},
(err, foundElement, path, parentFolder) => {
if (err != null) {
@@ -232,15 +232,15 @@ describe('ProjectLocator', function () {
describe('should be able to take actual project as well as id', function () {
const doc3 = {
_id: '123dsdj3',
- name: 'doc3'
+ name: 'doc3',
}
const rootFolder2 = {
_id: '123sddedskd',
- docs: [doc3]
+ docs: [doc3],
}
const project2 = {
_id: '1234566',
- rootFolder: [rootFolder2]
+ rootFolder: [rootFolder2],
}
it('should find doc in project', function (done) {
this.locator.findElement(
@@ -460,20 +460,20 @@ describe('ProjectLocator', function () {
name: '1',
docs: [{ name: 'main.tex', _id: '456' }],
folders: [],
- fileRefs: []
- }
+ fileRefs: [],
+ },
],
docs: [(this.doc = { name: 'main.tex', _id: '456' })],
- fileRefs: []
+ fileRefs: [],
}
this.project = {
rootFolder: [
{
folders: [this.duplicateFolder, this.duplicateFolder],
fileRefs: [],
- docs: []
- }
- ]
+ docs: [],
+ },
+ ],
}
})
@@ -499,9 +499,9 @@ describe('ProjectLocator', function () {
{
folders: [],
fileRefs: [],
- docs: [{ name: 'main.tex' }, null, { name: 'other.tex' }]
- }
- ]
+ docs: [{ name: 'main.tex' }, null, { name: 'other.tex' }],
+ },
+ ],
}
})
diff --git a/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js b/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js
index f6b898bd1f..7a11ba97c9 100644
--- a/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js
@@ -35,15 +35,15 @@ describe('ProjectOptionsHandler', function () {
'settings-sharelatex': {
languages: [
{ name: 'English', code: 'en' },
- { name: 'French', code: 'fr' }
+ { name: 'French', code: 'fr' },
],
imageRoot: 'docker-repo/subdir',
allowedImageNames: [
{ imageName: 'texlive-0000.0', imageDesc: 'test image 0' },
- { imageName: 'texlive-1234.5', imageDesc: 'test image 1' }
- ]
- }
- }
+ { imageName: 'texlive-1234.5', imageDesc: 'test image 1' },
+ ],
+ },
+ },
})
})
diff --git a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js
index 28622bddad..c64f817508 100644
--- a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js
+++ b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js
@@ -24,7 +24,7 @@ describe('ProjectRootDocManager', function () {
'doc-id-1': '/chapter1.tex',
'doc-id-2': '/main.tex',
'doc-id-3': '/nested/chapter1a.tex',
- 'doc-id-4': '/nested/chapter1b.tex'
+ 'doc-id-4': '/nested/chapter1b.tex',
}
this.sl_req_id = 'sl-req-id-123'
this.callback = sinon.stub()
@@ -36,7 +36,7 @@ describe('ProjectRootDocManager', function () {
)
this.fs = {
readFile: sinon.stub().callsArgWith(2, new Error('file not found')),
- stat: sinon.stub().callsArgWith(1, null, { size: 100 })
+ stat: sinon.stub().callsArgWith(1, null, { size: 100 }),
}
return (this.ProjectRootDocManager = SandboxedModule.require(modulePath, {
requires: {
@@ -44,8 +44,8 @@ describe('ProjectRootDocManager', function () {
'./ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {}),
'./ProjectGetter': (this.ProjectGetter = {}),
globby: this.globby,
- fs: this.fs
- }
+ fs: this.fs,
+ },
}))
})
@@ -65,25 +65,25 @@ describe('ProjectRootDocManager', function () {
'something else',
'\\begin{document}',
'Hello world',
- '\\end{document}'
- ]
+ '\\end{document}',
+ ],
},
'/main.tex': {
_id: 'doc-id-2',
lines: [
'different line',
'\\documentclass{article}',
- '\\input{chapter1}'
- ]
+ '\\input{chapter1}',
+ ],
},
'/nested/chapter1a.tex': {
_id: 'doc-id-3',
- lines: ['Hello world']
+ lines: ['Hello world'],
},
'/nested/chapter1b.tex': {
_id: 'doc-id-4',
- lines: ['Hello world']
- }
+ lines: ['Hello world'],
+ },
}
this.ProjectEntityHandler.getAllDocs = sinon
.stub()
@@ -112,12 +112,12 @@ describe('ProjectRootDocManager', function () {
this.docs = {
'/chapter1.tex': {
_id: 'doc-id-1',
- lines: ['\\begin{document}', 'Hello world', '\\end{document}']
+ lines: ['\\begin{document}', 'Hello world', '\\end{document}'],
},
'/main.Rtex': {
_id: 'doc-id-2',
- lines: ['\\documentclass{article}', '\\input{chapter1}']
- }
+ lines: ['\\documentclass{article}', '\\input{chapter1}'],
+ },
}
this.ProjectEntityHandler.getAllDocs = sinon
.stub()
@@ -140,12 +140,12 @@ describe('ProjectRootDocManager', function () {
this.docs = {
'/chapter1.tex': {
_id: 'doc-id-1',
- lines: ['\\begin{document}', 'Hello world', '\\end{document}']
+ lines: ['\\begin{document}', 'Hello world', '\\end{document}'],
},
'/style.bst': {
_id: 'doc-id-2',
- lines: ['%Example: \\documentclass{article}']
- }
+ lines: ['%Example: \\documentclass{article}'],
+ },
}
this.ProjectEntityHandler.getAllDocs = sinon
.stub()
@@ -350,7 +350,7 @@ describe('ProjectRootDocManager', function () {
'doc-id-1': '/chapter1.tex',
'doc-id-2': '/main.tex',
'doc-id-3': '/nested/chapter1a.tex',
- 'doc-id-4': '/nested/chapter1b.tex'
+ 'doc-id-4': '/nested/chapter1b.tex',
}
this.ProjectEntityHandler.getAllDocPathsFromProjectById = sinon
.stub()
diff --git a/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js
index 4a51220bf7..c6193ffbb0 100644
--- a/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js
+++ b/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js
@@ -29,8 +29,8 @@ describe('ProjectUpdateHandler', function () {
this.ProjectModel.updateOne = sinon.stub().callsArg(3)
return (this.handler = SandboxedModule.require(modulePath, {
requires: {
- '../../models/Project': { Project: this.ProjectModel }
- }
+ '../../models/Project': { Project: this.ProjectModel },
+ },
}))
})
@@ -51,11 +51,11 @@ describe('ProjectUpdateHandler', function () {
this.ProjectModel.updateOne,
{
_id: this.project_id,
- lastUpdated: { $lt: this.lastUpdatedAt }
+ lastUpdated: { $lt: this.lastUpdatedAt },
},
{
lastUpdated: this.lastUpdatedAt,
- lastUpdatedBy: this.lastUpdatedBy
+ lastUpdatedBy: this.lastUpdatedBy,
}
)
return done()
@@ -69,11 +69,11 @@ describe('ProjectUpdateHandler', function () {
this.ProjectModel.updateOne,
{
_id: this.project_id,
- lastUpdated: { $lt: this.fakeTime }
+ lastUpdated: { $lt: this.fakeTime },
},
{
lastUpdated: this.fakeTime,
- lastUpdatedBy: null
+ lastUpdatedBy: null,
}
)
return done()
diff --git a/services/web/test/unit/src/Publishers/PublishersGetterTests.js b/services/web/test/unit/src/Publishers/PublishersGetterTests.js
index 7e64542f2b..b003b23bf6 100644
--- a/services/web/test/unit/src/Publishers/PublishersGetterTests.js
+++ b/services/web/test/unit/src/Publishers/PublishersGetterTests.js
@@ -24,7 +24,7 @@ describe('PublishersGetter', function () {
this.publisher = {
_id: 'mock-publsiher-id',
slug: 'ieee',
- fetchV1Data: sinon.stub()
+ fetchV1Data: sinon.stub(),
}
this.PublishersGetter = SandboxedModule.require(modulePath, {
@@ -33,18 +33,18 @@ describe('PublishersGetter', function () {
'../UserMembership/UserMembershipsHandler': (this.UserMembershipsHandler = {
getEntitiesByUser: sinon
.stub()
- .callsArgWith(2, null, [this.publisher])
+ .callsArgWith(2, null, [this.publisher]),
}),
'../UserMembership/UserMembershipEntityConfigs': (this.UserMembershipEntityConfigs = {
publisher: {
modelName: 'Publisher',
canCreate: true,
fields: {
- primaryKey: 'slug'
- }
- }
- })
- }
+ primaryKey: 'slug',
+ },
+ },
+ }),
+ },
})
return (this.userId = '12345abcde')
diff --git a/services/web/test/unit/src/Referal/ReferalAllocatorTests.js b/services/web/test/unit/src/Referal/ReferalAllocatorTests.js
index 4ac90abd48..825e27b532 100644
--- a/services/web/test/unit/src/Referal/ReferalAllocatorTests.js
+++ b/services/web/test/unit/src/Referal/ReferalAllocatorTests.js
@@ -10,11 +10,11 @@ describe('ReferalAllocator', function () {
this.ReferalAllocator = SandboxedModule.require(modulePath, {
requires: {
'../../models/User': {
- User: (this.User = {})
+ User: (this.User = {}),
},
'../Subscription/FeaturesUpdater': (this.FeaturesUpdater = {}),
- 'settings-sharelatex': (this.Settings = {})
- }
+ 'settings-sharelatex': (this.Settings = {}),
+ },
})
this.callback = sinon.stub()
this.referal_id = 'referal-id-123'
@@ -45,15 +45,15 @@ describe('ReferalAllocator', function () {
this.User.updateOne
.calledWith(
{
- referal_id: this.referal_id
+ referal_id: this.referal_id,
},
{
$push: {
- refered_users: this.new_user_id
+ refered_users: this.new_user_id,
},
$inc: {
- refered_user_count: 1
- }
+ refered_user_count: 1,
+ },
}
)
.should.equal(true)
diff --git a/services/web/test/unit/src/Referal/ReferalConnectTests.js b/services/web/test/unit/src/Referal/ReferalConnectTests.js
index 796fb60e00..4008d8730f 100644
--- a/services/web/test/unit/src/Referal/ReferalConnectTests.js
+++ b/services/web/test/unit/src/Referal/ReferalConnectTests.js
@@ -12,7 +12,7 @@ describe('Referal connect middle wear', function () {
it('should take a referal query string and put it on the session if it exists', function (done) {
const req = {
query: { referal: '12345' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_id.should.equal(req.query.referal)
@@ -23,7 +23,7 @@ describe('Referal connect middle wear', function () {
it('should not change the referal_id on the session if not in query', function (done) {
const req = {
query: {},
- session: { referal_id: 'same' }
+ session: { referal_id: 'same' },
}
this.connect.use(req, {}, () => {
req.session.referal_id.should.equal('same')
@@ -34,7 +34,7 @@ describe('Referal connect middle wear', function () {
it('should take a facebook referal query string and put it on the session if it exists', function (done) {
const req = {
query: { fb_ref: '12345' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_id.should.equal(req.query.fb_ref)
@@ -45,7 +45,7 @@ describe('Referal connect middle wear', function () {
it('should map the facebook medium into the session', function (done) {
const req = {
query: { rm: 'fb' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_medium.should.equal('facebook')
@@ -56,7 +56,7 @@ describe('Referal connect middle wear', function () {
it('should map the twitter medium into the session', function (done) {
const req = {
query: { rm: 't' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_medium.should.equal('twitter')
@@ -67,7 +67,7 @@ describe('Referal connect middle wear', function () {
it('should map the google plus medium into the session', function (done) {
const req = {
query: { rm: 'gp' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_medium.should.equal('google_plus')
@@ -78,7 +78,7 @@ describe('Referal connect middle wear', function () {
it('should map the email medium into the session', function (done) {
const req = {
query: { rm: 'e' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_medium.should.equal('email')
@@ -89,7 +89,7 @@ describe('Referal connect middle wear', function () {
it('should map the direct medium into the session', function (done) {
const req = {
query: { rm: 'd' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_medium.should.equal('direct')
@@ -100,7 +100,7 @@ describe('Referal connect middle wear', function () {
it('should map the bonus source into the session', function (done) {
const req = {
query: { rs: 'b' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_source.should.equal('bonus')
@@ -111,7 +111,7 @@ describe('Referal connect middle wear', function () {
it('should map the public share source into the session', function (done) {
const req = {
query: { rs: 'ps' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_source.should.equal('public_share')
@@ -122,7 +122,7 @@ describe('Referal connect middle wear', function () {
it('should map the collaborator invite into the session', function (done) {
const req = {
query: { rs: 'ci' },
- session: {}
+ session: {},
}
this.connect.use(req, {}, () => {
req.session.referal_source.should.equal('collaborator_invite')
diff --git a/services/web/test/unit/src/Referal/ReferalFeaturesTests.js b/services/web/test/unit/src/Referal/ReferalFeaturesTests.js
index 8d1debd016..8b72ffc65a 100644
--- a/services/web/test/unit/src/Referal/ReferalFeaturesTests.js
+++ b/services/web/test/unit/src/Referal/ReferalFeaturesTests.js
@@ -10,10 +10,10 @@ describe('ReferalFeatures', function () {
this.ReferalFeatures = SandboxedModule.require(modulePath, {
requires: {
'../../models/User': {
- User: (this.User = {})
+ User: (this.User = {}),
},
- 'settings-sharelatex': (this.Settings = {})
- }
+ 'settings-sharelatex': (this.Settings = {}),
+ },
})
this.callback = sinon.stub()
this.referal_id = 'referal-id-123'
@@ -29,12 +29,12 @@ describe('ReferalFeatures', function () {
3: {
collaborators: 3,
dropbox: false,
- versioning: false
- }
+ versioning: false,
+ },
}
const stubbedUser = {
refered_user_count: this.refered_user_count,
- features: { collaborators: 1, dropbox: false, versioning: false }
+ features: { collaborators: 1, dropbox: false, versioning: false },
}
this.User.findOne = sinon.stub().callsArgWith(2, null, stubbedUser)
@@ -59,8 +59,8 @@ describe('ReferalFeatures', function () {
1: {
collaborators: 3,
dropbox: false,
- versioning: false
- }
+ versioning: false,
+ },
}
this.User.findOne = sinon
.stub()
diff --git a/services/web/test/unit/src/Referal/ReferalHandlerTests.js b/services/web/test/unit/src/Referal/ReferalHandlerTests.js
index c0d02b71d0..87caead125 100644
--- a/services/web/test/unit/src/Referal/ReferalHandlerTests.js
+++ b/services/web/test/unit/src/Referal/ReferalHandlerTests.js
@@ -12,9 +12,9 @@ describe('Referal handler', function () {
this.handler = SandboxedModule.require(modulePath, {
requires: {
'../../models/User': {
- User: this.User
- }
- }
+ User: this.User,
+ },
+ },
})
this.user_id = '12313'
})
@@ -23,7 +23,7 @@ describe('Referal handler', function () {
it('should get the user from mongo and return the refered users array', function (done) {
const user = {
refered_users: ['1234', '312312', '3213129'],
- refered_user_count: 3
+ refered_user_count: 3,
}
this.User.findById.callsArgWith(2, null, user)
diff --git a/services/web/test/unit/src/References/ReferencesControllerTests.js b/services/web/test/unit/src/References/ReferencesControllerTests.js
index 986289410e..f77597af68 100644
--- a/services/web/test/unit/src/References/ReferencesControllerTests.js
+++ b/services/web/test/unit/src/References/ReferencesControllerTests.js
@@ -24,22 +24,22 @@ describe('ReferencesController', function () {
this.controller = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': (this.settings = {
- apis: { web: { url: 'http://some.url' } }
+ apis: { web: { url: 'http://some.url' } },
}),
'./ReferencesHandler': (this.ReferencesHandler = {
index: sinon.stub(),
- indexAll: sinon.stub()
+ indexAll: sinon.stub(),
}),
'../Editor/EditorRealTimeController': (this.EditorRealTimeController = {
- emitToRoom: sinon.stub()
- })
- }
+ emitToRoom: sinon.stub(),
+ }),
+ },
})
this.req = new MockRequest()
this.req.params.Project_id = this.projectId
this.req.body = {
docIds: (this.docIds = ['aaa', 'bbb']),
- shouldBroadcast: false
+ shouldBroadcast: false,
}
this.res = new MockResponse()
this.res.json = sinon.stub()
@@ -47,7 +47,7 @@ describe('ReferencesController', function () {
this.res.sendStatus = sinon.stub()
return (this.fakeResponseData = {
projectId: this.projectId,
- keys: ['one', 'two', 'three']
+ keys: ['one', 'two', 'three'],
})
})
diff --git a/services/web/test/unit/src/References/ReferencesHandlerTests.js b/services/web/test/unit/src/References/ReferencesHandlerTests.js
index 93d9c0a6e9..0a665cf83a 100644
--- a/services/web/test/unit/src/References/ReferencesHandlerTests.js
+++ b/services/web/test/unit/src/References/ReferencesHandlerTests.js
@@ -25,24 +25,24 @@ describe('ReferencesHandler', function () {
owner_ref: (this.fakeOwner = {
_id: 'some_owner',
features: {
- references: false
- }
+ references: false,
+ },
}),
rootFolder: [
{
docs: [
{ name: 'one.bib', _id: 'aaa' },
- { name: 'two.txt', _id: 'bbb' }
+ { name: 'two.txt', _id: 'bbb' },
],
folders: [
{
docs: [{ name: 'three.bib', _id: 'ccc' }],
fileRefs: [{ name: 'four.bib', _id: 'ghg' }],
- folders: []
- }
- ]
- }
- ]
+ folders: [],
+ },
+ ],
+ },
+ ],
}
this.docIds = ['aaa', 'ccc']
this.handler = SandboxedModule.require(modulePath, {
@@ -51,30 +51,30 @@ describe('ReferencesHandler', function () {
apis: {
references: { url: 'http://some.url/references' },
docstore: { url: 'http://some.url/docstore' },
- filestore: { url: 'http://some.url/filestore' }
- }
+ filestore: { url: 'http://some.url/filestore' },
+ },
}),
request: (this.request = {
get: sinon.stub(),
- post: sinon.stub()
+ post: sinon.stub(),
}),
'../Project/ProjectGetter': (this.ProjectGetter = {
- getProject: sinon.stub().callsArgWith(2, null, this.fakeProject)
+ getProject: sinon.stub().callsArgWith(2, null, this.fakeProject),
}),
'../User/UserGetter': (this.UserGetter = {
- getUser: sinon.stub()
+ getUser: sinon.stub(),
}),
'../DocumentUpdater/DocumentUpdaterHandler': (this.DocumentUpdaterHandler = {
- flushDocToMongo: sinon.stub().callsArgWith(2, null)
+ flushDocToMongo: sinon.stub().callsArgWith(2, null),
}),
'../../infrastructure/Features': (this.Features = {
- hasFeature: sinon.stub().returns(true)
- })
- }
+ hasFeature: sinon.stub().returns(true),
+ }),
+ },
})
return (this.fakeResponseData = {
projectId: this.projectId,
- keys: ['k1', 'k2']
+ keys: ['k1', 'k2'],
})
})
@@ -446,13 +446,13 @@ describe('ReferencesHandler', function () {
{
docs: [
{ name: 'one.bib', _id: 'aaa' },
- { name: 'two.txt', _id: 'bbb' }
+ { name: 'two.txt', _id: 'bbb' },
],
folders: [
- { docs: [{ name: 'three.bib', _id: 'ccc' }], folders: [] }
- ]
- }
- ]
+ { docs: [{ name: 'three.bib', _id: 'ccc' }], folders: [] },
+ ],
+ },
+ ],
}
return (this.expectedIds = ['aaa', 'ccc'])
})
@@ -476,18 +476,18 @@ describe('ReferencesHandler', function () {
{
docs: [
{ name: 'one.bib', _id: 'aaa' },
- { name: 'two.txt', _id: 'bbb' }
+ { name: 'two.txt', _id: 'bbb' },
],
fileRefs: [{ name: 'other.bib', _id: 'ddd' }],
folders: [
{
docs: [{ name: 'three.bib', _id: 'ccc' }],
fileRefs: [{ name: 'four.bib', _id: 'ghg' }],
- folders: []
- }
- ]
- }
- ]
+ folders: [],
+ },
+ ],
+ },
+ ],
}
return (this.expectedIds = ['ddd', 'ghg'])
})
@@ -503,8 +503,8 @@ describe('ReferencesHandler', function () {
this.fakeProject = { owner_ref: (this.owner_ref = 'owner-ref-123') }
this.owner = {
features: {
- references: false
- }
+ references: false,
+ },
}
this.UserGetter.getUser = sinon.stub()
this.UserGetter.getUser
@@ -545,7 +545,7 @@ describe('ReferencesHandler', function () {
beforeEach(function () {
return (this.owner.features = {
referencesSearch: true,
- references: false
+ references: false,
})
})
diff --git a/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js b/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js
index 8553405764..75a6933137 100644
--- a/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js
+++ b/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js
@@ -12,7 +12,7 @@ describe('SamlLogHandler', function () {
beforeEach(function () {
samlLog = {
- save: sinon.stub()
+ save: sinon.stub(),
}
SamlLog = function () {
return samlLog
@@ -20,8 +20,8 @@ describe('SamlLogHandler', function () {
SamlLogModel = { SamlLog }
SamlLogHandler = SandboxedModule.require(modulePath, {
requires: {
- '../../models/SamlLog': SamlLogModel
- }
+ '../../models/SamlLog': SamlLogModel,
+ },
})
data = { foo: true }
diff --git a/services/web/test/unit/src/Security/LoginRateLimiterTests.js b/services/web/test/unit/src/Security/LoginRateLimiterTests.js
index ee8a383d72..74de88afce 100644
--- a/services/web/test/unit/src/Security/LoginRateLimiterTests.js
+++ b/services/web/test/unit/src/Security/LoginRateLimiterTests.js
@@ -23,13 +23,13 @@ describe('LoginRateLimiter', function () {
this.email = 'bob@bob.com'
this.RateLimiter = {
clearRateLimit: sinon.stub(),
- addCount: sinon.stub()
+ addCount: sinon.stub(),
}
return (this.LoginRateLimiter = SandboxedModule.require(modulePath, {
requires: {
- '../../infrastructure/RateLimiter': this.RateLimiter
- }
+ '../../infrastructure/RateLimiter': this.RateLimiter,
+ },
}))
})
diff --git a/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js b/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js
index 553c8ee457..0eda2d1e20 100644
--- a/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js
+++ b/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js
@@ -31,12 +31,12 @@ describe('OneTimeTokenHandler', function () {
requires: {
'settings-sharelatex': this.settings,
crypto: {
- randomBytes: () => this.stubbedToken
+ randomBytes: () => this.stubbedToken,
},
'../../infrastructure/mongodb': {
- db: (this.db = { tokens: {} })
- }
- }
+ db: (this.db = { tokens: {} }),
+ },
+ },
}))
})
@@ -65,7 +65,7 @@ describe('OneTimeTokenHandler', function () {
token: this.stubbedToken,
createdAt: new Date(),
expiresAt: new Date(Date.now() + 60 * 60 * 1000),
- data: 'mock-data-to-store'
+ data: 'mock-data-to-store',
})
.should.equal(true)
})
@@ -94,7 +94,7 @@ describe('OneTimeTokenHandler', function () {
token: this.stubbedToken,
createdAt: new Date(),
expiresAt: new Date(Date.now() + 42 * 1000),
- data: 'mock-data-to-store'
+ data: 'mock-data-to-store',
})
.should.equal(true)
})
@@ -127,10 +127,10 @@ describe('OneTimeTokenHandler', function () {
use: 'password',
token: 'mock-token',
expiresAt: { $gt: new Date() },
- usedAt: { $exists: false }
+ usedAt: { $exists: false },
},
{
- $set: { usedAt: new Date() }
+ $set: { usedAt: new Date() },
}
)
.should.equal(true)
diff --git a/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js b/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js
index 699f93ea16..06dc41161d 100644
--- a/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js
+++ b/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js
@@ -29,7 +29,7 @@ describe('RateLimiterMiddleware', function () {
),
x => x._id
)
- }
+ },
}
this.RateLimiterMiddleware = SandboxedModule.require(modulePath, {
requires: {
@@ -37,14 +37,14 @@ describe('RateLimiterMiddleware', function () {
'../../infrastructure/RateLimiter': (this.RateLimiter = {}),
'./LoginRateLimiter': {},
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
})
this.req = { params: {} }
this.res = {
status: sinon.stub(),
write: sinon.stub(),
- end: sinon.stub()
+ end: sinon.stub(),
}
return (this.next = sinon.stub())
})
@@ -55,11 +55,11 @@ describe('RateLimiterMiddleware', function () {
endpointName: 'test-endpoint',
params: ['project_id', 'doc_id'],
timeInterval: 42,
- maxRequests: 12
+ maxRequests: 12,
})
return (this.req.params = {
project_id: (this.project_id = 'project-id'),
- doc_id: (this.doc_id = 'doc-id')
+ doc_id: (this.doc_id = 'doc-id'),
})
})
@@ -76,7 +76,7 @@ describe('RateLimiterMiddleware', function () {
endpointName: 'test-endpoint',
timeInterval: 42,
throttle: 12,
- subjectName: `${this.project_id}:${this.doc_id}:${this.ip}`
+ subjectName: `${this.project_id}:${this.doc_id}:${this.ip}`,
})
.should.equal(true)
})
@@ -88,8 +88,8 @@ describe('RateLimiterMiddleware', function () {
beforeEach(function () {
this.req.session = {
user: {
- _id: (this.user_id = 'smoke-test-user-id')
- }
+ _id: (this.user_id = 'smoke-test-user-id'),
+ },
}
this.settings.smokeTest = { userId: this.user_id }
this.RateLimiter.addCount = sinon.stub().callsArgWith(1, null, true)
@@ -102,7 +102,7 @@ describe('RateLimiterMiddleware', function () {
endpointName: 'test-endpoint',
timeInterval: 42,
throttle: 12,
- subjectName: `${this.project_id}:${this.doc_id}:${this.user_id}`
+ subjectName: `${this.project_id}:${this.doc_id}:${this.user_id}`,
})
.should.equal(false)
this.RateLimiter.addCount.callCount.should.equal(0)
@@ -117,8 +117,8 @@ describe('RateLimiterMiddleware', function () {
beforeEach(function () {
this.req.session = {
user: {
- _id: (this.user_id = 'user-id')
- }
+ _id: (this.user_id = 'user-id'),
+ },
}
this.RateLimiter.addCount = sinon.stub().callsArgWith(1, null, true)
return this.rateLimiter(this.req, this.res, this.next)
@@ -130,7 +130,7 @@ describe('RateLimiterMiddleware', function () {
endpointName: 'test-endpoint',
timeInterval: 42,
throttle: 12,
- subjectName: `${this.project_id}:${this.doc_id}:${this.user_id}`
+ subjectName: `${this.project_id}:${this.doc_id}:${this.user_id}`,
})
.should.equal(true)
})
@@ -153,7 +153,7 @@ describe('RateLimiterMiddleware', function () {
endpointName: 'test-endpoint',
timeInterval: 42,
throttle: 12,
- subjectName: `${this.project_id}:${this.doc_id}:${this.ip}`
+ subjectName: `${this.project_id}:${this.doc_id}:${this.ip}`,
})
.should.equal(true)
})
@@ -167,8 +167,8 @@ describe('RateLimiterMiddleware', function () {
beforeEach(function () {
this.req.session = {
user: {
- _id: (this.user_id = 'user-id')
- }
+ _id: (this.user_id = 'user-id'),
+ },
}
this.RateLimiter.addCount = sinon.stub().callsArgWith(1, null, false)
return this.rateLimiter(this.req, this.res, this.next)
@@ -190,7 +190,7 @@ describe('RateLimiterMiddleware', function () {
endpointName: 'test-endpoint',
timeInterval: 42,
throttle: 12,
- subjectName: `${this.project_id}:${this.doc_id}:${this.user_id}`
+ subjectName: `${this.project_id}:${this.doc_id}:${this.user_id}`,
},
'rate limit exceeded'
)
diff --git a/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js b/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js
index 6ba74177d4..6154250bf2 100644
--- a/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js
+++ b/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js
@@ -13,13 +13,13 @@ describe('SessionAutostartMiddleware', function () {
beforeEach(function () {
Settings = {
- cookieName: cookieName
+ cookieName: cookieName,
}
SessionAutostartMiddleware = SandboxedModule.require(modulePath, {
requires: {
- 'settings-sharelatex': Settings
- }
+ 'settings-sharelatex': Settings,
+ },
})
middleware = new SessionAutostartMiddleware()
@@ -38,7 +38,7 @@ describe('SessionAutostartMiddleware', function () {
path: excludedRoute,
method: excludedMethod,
signedCookies: {},
- headers: {}
+ headers: {},
}
next = sinon.stub()
})
@@ -72,7 +72,7 @@ describe('SessionAutostartMiddleware', function () {
beforeEach(function () {
req = {
signedCookies: {},
- headers: {}
+ headers: {},
}
next = sinon.stub()
})
diff --git a/services/web/test/unit/src/Security/SessionStoreManagerTests.js b/services/web/test/unit/src/Security/SessionStoreManagerTests.js
index c1ba51891c..a2f48f14aa 100644
--- a/services/web/test/unit/src/Security/SessionStoreManagerTests.js
+++ b/services/web/test/unit/src/Security/SessionStoreManagerTests.js
@@ -7,14 +7,14 @@ describe('SessionStoreManager', function () {
beforeEach(function () {
this.SessionStoreManager = SandboxedModule.require(modulePath, {
requires: {
- '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() })
- }
+ '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }),
+ },
})
this.sessionStore = {
generate: sinon.spy(req => {
req.session = {}
req.session.destroy = sinon.stub().yields()
- })
+ }),
}
})
describe('enableValidationToken', function () {
diff --git a/services/web/test/unit/src/Spelling/SpellingControllerTests.js b/services/web/test/unit/src/Spelling/SpellingControllerTests.js
index 5f2cc33c67..ce18bbb191 100644
--- a/services/web/test/unit/src/Spelling/SpellingControllerTests.js
+++ b/services/web/test/unit/src/Spelling/SpellingControllerTests.js
@@ -19,11 +19,11 @@ describe('SpellingController', function () {
.stub()
.returns({ pipe: this.requestStreamPipe })
this.request = sinon.stub().returns({
- on: this.requestStreamOn
+ on: this.requestStreamOn,
})
this.AuthenticationController = {
- getLoggedInUserId: req => req.session.user._id
+ getLoggedInUserId: req => req.session.user._id,
}
this.controller = SandboxedModule.require(modulePath, {
requires: {
@@ -31,13 +31,13 @@ describe('SpellingController', function () {
'settings-sharelatex': {
languages: [
{ name: 'English', code: 'en' },
- { name: 'French', code: 'fr' }
+ { name: 'French', code: 'fr' },
],
- apis: { spelling: { host: SPELLING_HOST, url: SPELLING_URL } }
+ apis: { spelling: { host: SPELLING_HOST, url: SPELLING_URL } },
},
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
})
this.req = {
url: '/spelling/check',
@@ -45,10 +45,10 @@ describe('SpellingController', function () {
params: {},
session: {
user: {
- _id: userId
- }
+ _id: userId,
+ },
},
- headers: { Host: SPELLING_HOST }
+ headers: { Host: SPELLING_HOST },
}
this.res = {}
@@ -73,7 +73,7 @@ describe('SpellingController', function () {
method: this.req.method,
headers: this.req.headers,
json: this.req.body,
- timeout: TEN_SECONDS
+ timeout: TEN_SECONDS,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Spelling/SpellingHandlerTests.js b/services/web/test/unit/src/Spelling/SpellingHandlerTests.js
index 6f0a8ff534..b00c3d576e 100644
--- a/services/web/test/unit/src/Spelling/SpellingHandlerTests.js
+++ b/services/web/test/unit/src/Spelling/SpellingHandlerTests.js
@@ -24,16 +24,16 @@ describe('SpellingHandler', function () {
.stub()
.yields(null, { statusCode: 200, body: dictionaryString }),
post: sinon.stub().yields(null, { statusCode: 204 }),
- delete: sinon.stub().yields(null, { statusCode: 204 })
+ delete: sinon.stub().yields(null, { statusCode: 204 }),
}
SpellingHandler = SandboxedModule.require(modulePath, {
requires: {
request: request,
'settings-sharelatex': {
- apis: { spelling: { host: SPELLING_HOST, url: SPELLING_URL } }
- }
- }
+ apis: { spelling: { host: SPELLING_HOST, url: SPELLING_URL } },
+ },
+ },
})
})
@@ -42,7 +42,7 @@ describe('SpellingHandler', function () {
SpellingHandler.getUserDictionary(userId, () => {
expect(request.get).to.have.been.calledWith({
url: 'http://spelling.service.test/user/wombat',
- timeout: TIMEOUT
+ timeout: TIMEOUT,
})
done()
})
@@ -71,9 +71,9 @@ describe('SpellingHandler', function () {
expect(request.post).to.have.been.calledWith({
url: 'http://spelling.service.test/user/wombat/unlearn',
json: {
- word: word
+ word: word,
},
- timeout: TIMEOUT
+ timeout: TIMEOUT,
})
done()
})
@@ -100,7 +100,7 @@ describe('SpellingHandler', function () {
SpellingHandler.deleteUserDictionary(userId, () => {
expect(request.delete).to.have.been.calledWith({
url: 'http://spelling.service.test/user/wombat',
- timeout: TIMEOUT
+ timeout: TIMEOUT,
})
done()
})
diff --git a/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js b/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js
index fed0e0a56c..3a04d3c9b9 100644
--- a/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js
+++ b/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js
@@ -19,9 +19,9 @@ describe('FeaturesUpdater', function () {
'../Institutions/InstitutionsFeatures': (this.InstitutionsFeatures = {}),
'../User/UserGetter': (this.UserGetter = {}),
'../../infrastructure/Modules': (this.Modules = {
- hooks: { fire: sinon.stub() }
- })
- }
+ hooks: { fire: sinon.stub() },
+ }),
+ },
})
})
@@ -29,7 +29,7 @@ describe('FeaturesUpdater', function () {
beforeEach(function () {
this.user = {
_id: this.user_id,
- features: {}
+ features: {},
}
this.UserFeaturesUpdater.updateFeatures = sinon
.stub()
@@ -151,7 +151,7 @@ describe('FeaturesUpdater', function () {
beforeEach(function () {
this.user = {
_id: this.user_id,
- features: { dropbox: true }
+ features: { dropbox: true },
}
this.UserGetter.getUser = sinon.stub().yields(null, this.user)
this.FeaturesUpdater._mergeFeatures = sinon
@@ -172,50 +172,50 @@ describe('FeaturesUpdater', function () {
expect(
this.FeaturesUpdater._mergeFeatures(
{
- compileGroup: 'priority'
+ compileGroup: 'priority',
},
{
- compileGroup: 'standard'
+ compileGroup: 'standard',
}
)
).to.deep.equal({
- compileGroup: 'priority'
+ compileGroup: 'priority',
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- compileGroup: 'standard'
+ compileGroup: 'standard',
},
{
- compileGroup: 'priority'
+ compileGroup: 'priority',
}
)
).to.deep.equal({
- compileGroup: 'priority'
+ compileGroup: 'priority',
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- compileGroup: 'priority'
+ compileGroup: 'priority',
},
{
- compileGroup: 'priority'
+ compileGroup: 'priority',
}
)
).to.deep.equal({
- compileGroup: 'priority'
+ compileGroup: 'priority',
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- compileGroup: 'standard'
+ compileGroup: 'standard',
},
{
- compileGroup: 'standard'
+ compileGroup: 'standard',
}
)
).to.deep.equal({
- compileGroup: 'standard'
+ compileGroup: 'standard',
})
})
@@ -223,38 +223,38 @@ describe('FeaturesUpdater', function () {
expect(
this.FeaturesUpdater._mergeFeatures(
{
- collaborators: -1
+ collaborators: -1,
},
{
- collaborators: 10
+ collaborators: 10,
}
)
).to.deep.equal({
- collaborators: -1
+ collaborators: -1,
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- collaborators: 10
+ collaborators: 10,
},
{
- collaborators: -1
+ collaborators: -1,
}
)
).to.deep.equal({
- collaborators: -1
+ collaborators: -1,
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- collaborators: 4
+ collaborators: 4,
},
{
- collaborators: 10
+ collaborators: 10,
}
)
).to.deep.equal({
- collaborators: 10
+ collaborators: 10,
})
})
@@ -262,26 +262,26 @@ describe('FeaturesUpdater', function () {
expect(
this.FeaturesUpdater._mergeFeatures(
{
- compileTimeout: 20
+ compileTimeout: 20,
},
{
- compileTimeout: 10
+ compileTimeout: 10,
}
)
).to.deep.equal({
- compileTimeout: 20
+ compileTimeout: 20,
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- compileTimeout: 10
+ compileTimeout: 10,
},
{
- compileTimeout: 20
+ compileTimeout: 20,
}
)
).to.deep.equal({
- compileTimeout: 20
+ compileTimeout: 20,
})
})
@@ -289,50 +289,50 @@ describe('FeaturesUpdater', function () {
expect(
this.FeaturesUpdater._mergeFeatures(
{
- github: true
+ github: true,
},
{
- github: false
+ github: false,
}
)
).to.deep.equal({
- github: true
+ github: true,
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- github: false
+ github: false,
},
{
- github: true
+ github: true,
}
)
).to.deep.equal({
- github: true
+ github: true,
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- github: true
+ github: true,
},
{
- github: true
+ github: true,
}
)
).to.deep.equal({
- github: true
+ github: true,
})
expect(
this.FeaturesUpdater._mergeFeatures(
{
- github: false
+ github: false,
},
{
- github: false
+ github: false,
}
)
).to.deep.equal({
- github: false
+ github: false,
})
})
})
@@ -344,8 +344,8 @@ describe('FeaturesUpdater', function () {
_id: this.user_id,
email: 'user@example.com',
overleaf: {
- id: this.v1UserId
- }
+ id: this.v1UserId,
+ },
}
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, this.user)
diff --git a/services/web/test/unit/src/Subscription/LimitationsManagerTests.js b/services/web/test/unit/src/Subscription/LimitationsManagerTests.js
index d16feb0e06..9bfa9abaf7 100644
--- a/services/web/test/unit/src/Subscription/LimitationsManagerTests.js
+++ b/services/web/test/unit/src/Subscription/LimitationsManagerTests.js
@@ -30,7 +30,7 @@ describe('LimitationsManager', function () {
} else {
return callback(null, null)
}
- }
+ },
}
this.UserGetter = {
getUser: (user_id, filter, callback) => {
@@ -39,12 +39,12 @@ describe('LimitationsManager', function () {
} else {
return callback(null, null)
}
- }
+ },
}
this.SubscriptionLocator = {
getUsersSubscription: sinon.stub(),
- getSubscription: sinon.stub()
+ getSubscription: sinon.stub(),
}
return (this.LimitationsManager = SandboxedModule.require(modulePath, {
@@ -55,8 +55,8 @@ describe('LimitationsManager', function () {
'settings-sharelatex': (this.Settings = {}),
'../Collaborators/CollaboratorsGetter': (this.CollaboratorsGetter = {}),
'../Collaborators/CollaboratorsInviteHandler': (this.CollaboratorsInviteHandler = {}),
- './V1SubscriptionManager': (this.V1SubscriptionManager = {})
- }
+ './V1SubscriptionManager': (this.V1SubscriptionManager = {}),
+ },
}))
})
@@ -383,7 +383,7 @@ describe('LimitationsManager', function () {
it('should return true if the recurly token is set', function (done) {
this.SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {
- recurlySubscription_id: '1234'
+ recurlySubscription_id: '1234',
})
return this.LimitationsManager.userHasV2Subscription(
this.user,
@@ -626,8 +626,8 @@ describe('LimitationsManager', function () {
membersLimit: 3,
member_ids: ['', ''],
teamInvites: [
- { email: 'bob@example.com', sentAt: new Date(), token: 'hey' }
- ]
+ { email: 'bob@example.com', sentAt: new Date(), token: 'hey' },
+ ],
})
})
diff --git a/services/web/test/unit/src/Subscription/RecurlyClientTests.js b/services/web/test/unit/src/Subscription/RecurlyClientTests.js
index 2ee9b99d4f..a78c0763e1 100644
--- a/services/web/test/unit/src/Subscription/RecurlyClientTests.js
+++ b/services/web/test/unit/src/Subscription/RecurlyClientTests.js
@@ -15,9 +15,9 @@ describe('RecurlyClient', function () {
apis: {
recurly: {
apiKey: 'nonsense',
- privateKey: 'private_nonsense'
- }
- }
+ privateKey: 'private_nonsense',
+ },
+ },
}
this.user = { _id: '123456', email: 'joe@example.com', first_name: 'Joe' }
@@ -30,24 +30,24 @@ describe('RecurlyClient', function () {
if (userId === this.user._id) {
return this.user
}
- })
- }
+ }),
+ },
}
let client
this.client = client = {
- getAccount: sinon.stub()
+ getAccount: sinon.stub(),
}
this.recurly = {
errors: recurly.errors,
Client: function () {
return client
- }
+ },
}
return (this.RecurlyClient = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
requires: {
'settings-sharelatex': this.settings,
@@ -57,10 +57,10 @@ describe('RecurlyClient', function () {
error: sinon.stub(),
warn: sinon.stub(),
log: sinon.stub(),
- debug: sinon.stub()
+ debug: sinon.stub(),
},
- '../User/UserGetter': this.UserGetter
- }
+ '../User/UserGetter': this.UserGetter,
+ },
}))
})
diff --git a/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js b/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js
index 947b64543c..8030c31fa0 100644
--- a/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js
+++ b/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js
@@ -103,7 +103,7 @@ const fixtures = {
' ' +
' a92468579e9c4231a6c0031c4716c01d' +
' 2011-10-25T12:00:00' +
- ''
+ '',
}
const mockApiRequest = function (options, callback) {
@@ -124,20 +124,20 @@ describe('RecurlyWrapper', function () {
name: 'Collaborator',
features: {
collaborators: -1,
- versioning: true
- }
- }
+ versioning: true,
+ },
+ },
],
defaultPlanCode: {
collaborators: 0,
- versioning: false
+ versioning: false,
},
apis: {
recurly: {
apiKey: 'nonsense',
- privateKey: 'private_nonsense'
- }
- }
+ privateKey: 'private_nonsense',
+ },
+ },
}
tk.freeze(Date.now()) // freeze the time for these tests
@@ -147,8 +147,8 @@ describe('RecurlyWrapper', function () {
requires: {
'settings-sharelatex': this.settings,
request: sinon.stub(),
- './Errors': SubscriptionErrors
- }
+ './Errors': SubscriptionErrors,
+ },
}
))
})
@@ -498,7 +498,7 @@ describe('RecurlyWrapper', function () {
beforeEach(function () {
this.user = {
_id: 'some_id',
- email: 'user@example.com'
+ email: 'user@example.com',
}
this.subscriptionDetails = {
currencyCode: 'EUR',
@@ -510,13 +510,13 @@ describe('RecurlyWrapper', function () {
address2: 'addr_two',
country: 'some_country',
state: 'some_state',
- zip: 'some_zip'
- }
+ zip: 'some_zip',
+ },
}
this.subscription = {}
this.recurlyTokenIds = {
billing: 'a-token-id',
- threeDSecureActionResult: 'a-3d-token-id'
+ threeDSecureActionResult: 'a-3d-token-id',
}
return (this.call = callback => {
return this.RecurlyWrapper.createSubscription(
@@ -649,7 +649,7 @@ describe('RecurlyWrapper', function () {
_id: 'some_id',
email: 'user@example.com',
first_name: 'Foo',
- last_name: 'Johnson'
+ last_name: 'Johnson',
}
this.subscriptionDetails = {
currencyCode: 'EUR',
@@ -662,15 +662,15 @@ describe('RecurlyWrapper', function () {
address2: 'addr_two',
country: 'some_country',
state: 'some_state',
- zip: 'some_zip'
+ zip: 'some_zip',
},
ITMCampaign: 'itm-campaign-value',
- ITMContent: 'itm-content-value'
+ ITMContent: 'itm-content-value',
}
this.subscription = {}
this.recurlyTokenIds = {
billing: 'a-token-id',
- threeDSecureActionResult: 'a-3d-token-id'
+ threeDSecureActionResult: 'a-3d-token-id',
}
this.apiRequest = sinon.stub(this.RecurlyWrapper, 'apiRequest')
this.response = { statusCode: 200 }
@@ -859,7 +859,7 @@ describe('RecurlyWrapper', function () {
)
this.user = {
_id: 'some_id',
- email: 'user@example.com'
+ email: 'user@example.com',
}
this.subscriptionDetails = {
currencyCode: 'EUR',
@@ -871,13 +871,13 @@ describe('RecurlyWrapper', function () {
address2: 'addr_two',
country: 'some_country',
state: 'some_state',
- zip: 'some_zip'
- }
+ zip: 'some_zip',
+ },
}
this.subscription = {}
this.recurlyTokenIds = {
billing: 'a-token-id',
- threeDSecureActionResult: 'a-3d-token-id'
+ threeDSecureActionResult: 'a-3d-token-id',
}
// set up data callbacks
@@ -890,14 +890,14 @@ describe('RecurlyWrapper', function () {
subscriptionDetails,
recurlyTokenIds,
userExists: false,
- account: { accountCode: 'xx' }
+ account: { accountCode: 'xx' },
})
this.createAccount.callsArgWith(1, null, {
user,
subscriptionDetails,
recurlyTokenIds,
userExists: false,
- account: { accountCode: 'xx' }
+ account: { accountCode: 'xx' },
})
this.createBillingInfo.callsArgWith(1, null, {
user,
@@ -905,7 +905,7 @@ describe('RecurlyWrapper', function () {
recurlyTokenIds,
userExists: false,
account: { accountCode: 'xx' },
- billingInfo: { token_id: 'abc' }
+ billingInfo: { token_id: 'abc' },
})
this.setAddressAndCompanyBillingInfo.callsArgWith(1, null, {
user,
@@ -913,7 +913,7 @@ describe('RecurlyWrapper', function () {
recurlyTokenIds,
userExists: false,
account: { accountCode: 'xx' },
- billingInfo: { token_id: 'abc' }
+ billingInfo: { token_id: 'abc' },
})
this.createSubscription.callsArgWith(1, null, {
user,
@@ -922,7 +922,7 @@ describe('RecurlyWrapper', function () {
userExists: false,
account: { accountCode: 'xx' },
billingInfo: { token_id: 'abc' },
- subscription: this.subscription
+ subscription: this.subscription,
})
return (this.call = callback => {
@@ -1011,11 +1011,11 @@ describe('RecurlyWrapper', function () {
_id: 'some_id',
email: 'foo@bar.com',
first_name: 'Foo',
- last_name: 'Bar'
+ last_name: 'Bar',
}),
recurlyTokenIds: (this.recurlyTokenIds = {
billing: 'a-token-id',
- threeDSecureActionResult: 'a-3d-token-id'
+ threeDSecureActionResult: 'a-3d-token-id',
}),
subscriptionDetails: (this.subscriptionDetails = {
currencyCode: 'EUR',
@@ -1028,11 +1028,11 @@ describe('RecurlyWrapper', function () {
city: 'some_city',
country: 'some_country',
state: 'some_state',
- zip: 'some_zip'
+ zip: 'some_zip',
},
ITMCampaign: 'itm-campaign-value',
- ITMContent: 'itm-content-value'
- })
+ ITMContent: 'itm-content-value',
+ }),
})
})
@@ -1091,7 +1091,7 @@ describe('RecurlyWrapper', function () {
expect(result.account).to.not.equal(null)
expect(result.account).to.not.equal(undefined)
expect(result.account).to.deep.equal({
- account_code: 'abc'
+ account_code: 'abc',
})
return done()
})
@@ -1150,7 +1150,7 @@ describe('RecurlyWrapper', function () {
describe('when apiRequest produces an error', function () {
beforeEach(function () {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
- statusCode: 500
+ statusCode: 500,
})
})
@@ -1213,7 +1213,7 @@ describe('RecurlyWrapper', function () {
return this.call((err, result) => {
expect(result).to.deep.equal(this.cache)
expect(result.account).to.deep.equal({
- account_code: 'abc'
+ account_code: 'abc',
})
return done()
})
@@ -1295,7 +1295,7 @@ describe('RecurlyWrapper', function () {
describe('when apiRequest produces an error', function () {
beforeEach(function () {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
- statusCode: 500
+ statusCode: 500,
})
})
@@ -1381,7 +1381,7 @@ describe('RecurlyWrapper', function () {
it('should set billingInfo on cache', function (done) {
return this.call((err, result) => {
expect(result.billingInfo).to.deep.equal({
- a: '1'
+ a: '1',
})
return done()
})
@@ -1391,7 +1391,7 @@ describe('RecurlyWrapper', function () {
describe('when apiRequest produces an error', function () {
beforeEach(function () {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
- statusCode: 500
+ statusCode: 500,
})
})
@@ -1495,7 +1495,7 @@ describe('RecurlyWrapper', function () {
it('should set billingInfo on cache', function (done) {
return this.call((err, result) => {
expect(result.billingInfo).to.deep.equal({
- city: 'London'
+ city: 'London',
})
return done()
})
@@ -1505,7 +1505,7 @@ describe('RecurlyWrapper', function () {
describe('when apiRequest produces an error', function () {
beforeEach(function () {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
- statusCode: 500
+ statusCode: 500,
})
})
@@ -1593,7 +1593,7 @@ describe('RecurlyWrapper', function () {
it('should set subscription on cache', function (done) {
return this.call((err, result) => {
expect(result.subscription).to.deep.equal({
- a: '1'
+ a: '1',
})
return done()
})
@@ -1603,7 +1603,7 @@ describe('RecurlyWrapper', function () {
describe('when apiRequest produces an error', function () {
beforeEach(function () {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
- statusCode: 500
+ statusCode: 500,
})
})
@@ -1646,9 +1646,9 @@ describe('RecurlyWrapper', function () {
.calledWith({
url: `accounts/${this.user_id}/subscriptions`,
qs: {
- state: 'active'
+ state: 'active',
},
- expect404: true
+ expect404: true,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js
index 85ae37633a..f72b14b631 100644
--- a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js
+++ b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js
@@ -26,15 +26,15 @@ const mockSubscriptions = {
uuid: 'subscription-123-active',
plan: {
name: 'Gold',
- plan_code: 'gold'
+ plan_code: 'gold',
},
current_period_ends_at: new Date(),
state: 'active',
unit_amount_in_cents: 999,
account: {
- account_code: 'user-123'
- }
- }
+ account_code: 'user-123',
+ },
+ },
}
describe('SubscriptionController', function () {
@@ -42,7 +42,7 @@ describe('SubscriptionController', function () {
this.user = {
email: 'tom@yahoo.com',
_id: 'one',
- signUpDate: new Date('2000-10-01')
+ signUpDate: new Date('2000-10-01'),
}
this.activeRecurlySubscription =
mockSubscriptions['subscription-123-active']
@@ -51,7 +51,7 @@ describe('SubscriptionController', function () {
getLoggedInUser: sinon.stub().callsArgWith(1, null, this.user),
getLoggedInUserId: sinon.stub().returns(this.user._id),
getSessionUser: sinon.stub().returns(this.user),
- isUserLoggedIn: sinon.stub().returns(true)
+ isUserLoggedIn: sinon.stub().returns(true),
}
this.SubscriptionHandler = {
createSubscription: sinon.stub().callsArgWith(3),
@@ -60,7 +60,7 @@ describe('SubscriptionController', function () {
cancelSubscription: sinon.stub().callsArgWith(1),
syncSubscription: sinon.stub().yields(),
attemptPaypalInvoiceCollection: sinon.stub().yields(),
- startFreeTrial: sinon.stub()
+ startFreeTrial: sinon.stub(),
}
this.PlansLocator = { findLocalPlanInSettings: sinon.stub() }
@@ -68,31 +68,31 @@ describe('SubscriptionController', function () {
this.LimitationsManager = {
hasPaidSubscription: sinon.stub(),
userHasV1OrV2Subscription: sinon.stub(),
- userHasV2Subscription: sinon.stub()
+ userHasV2Subscription: sinon.stub(),
}
this.SubscriptionViewModelBuilder = {
buildUsersSubscriptionViewModel: sinon.stub().callsArgWith(1, null, {}),
- buildPlansList: sinon.stub()
+ buildPlansList: sinon.stub(),
}
this.settings = {
coupon_codes: {
upgradeToAnnualPromo: {
student: 'STUDENTCODEHERE',
- collaborator: 'COLLABORATORCODEHERE'
- }
+ collaborator: 'COLLABORATORCODEHERE',
+ },
},
apis: {
recurly: {
- subdomain: 'sl'
- }
+ subdomain: 'sl',
+ },
},
siteUrl: 'http://de.sharelatex.dev:3000',
- gaExperiments: {}
+ gaExperiments: {},
}
this.GeoIpLookup = { getCurrencyCode: sinon.stub() }
this.UserGetter = {
- getUser: sinon.stub().callsArgWith(2, null, this.user)
+ getUser: sinon.stub().callsArgWith(2, null, this.user),
}
this.SubscriptionController = SandboxedModule.require(modulePath, {
requires: {
@@ -106,16 +106,16 @@ describe('SubscriptionController', function () {
'settings-sharelatex': this.settings,
'../User/UserGetter': this.UserGetter,
'./RecurlyWrapper': (this.RecurlyWrapper = {
- updateAccountEmailAddress: sinon.stub().yields()
+ updateAccountEmailAddress: sinon.stub().yields(),
}),
'./FeaturesUpdater': (this.FeaturesUpdater = {}),
'./GroupPlansData': (this.GroupPlansData = {}),
'./V1SubscriptionManager': (this.V1SubscriptionManager = {}),
'../Errors/HttpErrorHandler': (this.HttpErrorHandler = {
- unprocessableEntity: sinon.stub()
+ unprocessableEntity: sinon.stub(),
}),
- './Errors': SubscriptionErrors
- }
+ './Errors': SubscriptionErrors,
+ },
})
this.res = new MockResponse()
@@ -335,11 +335,11 @@ describe('SubscriptionController', function () {
null,
{
personalSubscription: (this.personalSubscription = {
- 'personal-subscription': 'mock'
+ 'personal-subscription': 'mock',
}),
memberGroupSubscriptions: (this.memberGroupSubscriptions = {
- 'group-subscriptions': 'mock'
- })
+ 'group-subscriptions': 'mock',
+ }),
}
)
this.SubscriptionViewModelBuilder.buildPlansList.returns(
@@ -384,16 +384,16 @@ describe('SubscriptionController', function () {
this.res = {
sendStatus() {
return done()
- }
+ },
}
sinon.spy(this.res, 'sendStatus')
this.subscriptionDetails = {
card: '1234',
- cvv: '123'
+ cvv: '123',
}
this.recurlyTokenIds = {
billing: '1234',
- threeDSecureActionResult: '5678'
+ threeDSecureActionResult: '5678',
}
this.req.body.recurly_token_id = this.recurlyTokenIds.billing
this.req.body.recurly_three_d_secure_action_result_token_id = this.recurlyTokenIds.threeDSecureActionResult
@@ -428,7 +428,7 @@ describe('SubscriptionController', function () {
this.SubscriptionHandler.createSubscription.called.should.equal(false)
done()
- }
+ },
})
})
@@ -505,7 +505,7 @@ describe('SubscriptionController', function () {
this.res = {
redirect() {
return done()
- }
+ },
}
sinon.spy(this.res, 'redirect')
this.plan_code = '1234'
@@ -560,7 +560,7 @@ describe('SubscriptionController', function () {
this.res = {
redirect() {
return done()
- }
+ },
}
sinon.spy(this.res, 'redirect')
return this.SubscriptionController.reactivateSubscription(
@@ -587,7 +587,7 @@ describe('SubscriptionController', function () {
this.res = {
redirect() {
return done()
- }
+ },
}
sinon.spy(this.res, 'redirect')
return this.SubscriptionController.cancelSubscription(this.req, this.res)
@@ -615,15 +615,15 @@ describe('SubscriptionController', function () {
body: {
expired_subscription_notification: {
subscription: {
- uuid: this.activeRecurlySubscription.uuid
- }
- }
- }
+ uuid: this.activeRecurlySubscription.uuid,
+ },
+ },
+ },
}
this.res = {
sendStatus() {
return done()
- }
+ },
}
sinon.spy(this.res, 'sendStatus')
return this.SubscriptionController.recurlyCallback(this.req, this.res)
@@ -646,15 +646,15 @@ describe('SubscriptionController', function () {
body: {
billing_info_updated_notification: {
account: {
- account_code: 'mock-account-code'
- }
- }
- }
+ account_code: 'mock-account-code',
+ },
+ },
+ },
}
this.res = {
sendStatus() {
done()
- }
+ },
}
sinon.spy(this.res, 'sendStatus')
this.SubscriptionController.recurlyCallback(this.req, this.res)
@@ -680,15 +680,15 @@ describe('SubscriptionController', function () {
body: {
renewed_subscription_notification: {
subscription: {
- uuid: this.activeRecurlySubscription.uuid
- }
- }
- }
+ uuid: this.activeRecurlySubscription.uuid,
+ },
+ },
+ },
}
this.res = {
sendStatus() {
return done()
- }
+ },
}
sinon.spy(this.res, 'sendStatus')
return this.SubscriptionController.recurlyCallback(this.req, this.res)
diff --git a/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js
index c939113463..0abda17323 100644
--- a/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js
+++ b/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js
@@ -27,23 +27,23 @@ describe('SubscriptionGroupController', function () {
session: {
user: {
_id: this.adminUserId,
- email: this.user_email
- }
+ email: this.user_email,
+ },
},
params: {
- subscriptionId: this.subscriptionId
+ subscriptionId: this.subscriptionId,
},
- query: {}
+ query: {},
}
this.subscription = {
- _id: this.subscriptionId
+ _id: this.subscriptionId,
}
this.GroupHandler = { removeUserFromGroup: sinon.stub().callsArgWith(2) }
this.SubscriptionLocator = {
- getSubscription: sinon.stub().callsArgWith(1, null, this.subscription)
+ getSubscription: sinon.stub().callsArgWith(1, null, this.subscription),
}
this.AuthenticationController = {
@@ -52,7 +52,7 @@ describe('SubscriptionGroupController', function () {
},
getSessionUser(req) {
return req.session.user
- }
+ },
}
return (this.Controller = SandboxedModule.require(modulePath, {
@@ -60,8 +60,8 @@ describe('SubscriptionGroupController', function () {
'./SubscriptionGroupHandler': this.GroupHandler,
'./SubscriptionLocator': this.SubscriptionLocator,
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
}))
})
@@ -77,7 +77,7 @@ describe('SubscriptionGroupController', function () {
.calledWith(this.subscriptionId, userIdToRemove)
.should.equal(true)
return done()
- }
+ },
}
return this.Controller.removeUserFromGroup(this.req, res)
})
@@ -102,7 +102,7 @@ describe('SubscriptionGroupController', function () {
memberUserIdToremove
)
return done()
- }
+ },
}
return this.Controller.removeSelfFromGroup(this.req, res)
})
diff --git a/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js b/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js
index 352ec2117b..8b6a81cfc9 100644
--- a/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js
+++ b/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js
@@ -30,38 +30,38 @@ describe('SubscriptionGroupHandler', function () {
this.subscription = {
admin_id: this.adminUser_id,
manager_ids: [this.adminUser_id],
- _id: this.subscription_id
+ _id: this.subscription_id,
}
this.SubscriptionLocator = {
getUsersSubscription: sinon.stub(),
getSubscriptionByMemberIdAndId: sinon.stub(),
- getSubscription: sinon.stub().callsArgWith(1, null, this.subscription)
+ getSubscription: sinon.stub().callsArgWith(1, null, this.subscription),
}
this.UserCreator = {
getUserOrCreateHoldingAccount: sinon
.stub()
- .callsArgWith(1, null, this.user)
+ .callsArgWith(1, null, this.user),
}
this.SubscriptionUpdater = {
removeUserFromGroup: sinon.stub().callsArgWith(2),
- getSubscription: sinon.stub().callsArgWith(2)
+ getSubscription: sinon.stub().callsArgWith(2),
}
this.TeamInvitesHandler = { createInvite: sinon.stub().callsArgWith(2) }
this.UserGetter = {
getUser: sinon.stub(),
- getUserByAnyEmail: sinon.stub()
+ getUserByAnyEmail: sinon.stub(),
}
this.LimitationsManager = { hasGroupMembersLimitReached: sinon.stub() }
this.OneTimeTokenHandler = {
getValueFromTokenAndExpire: sinon.stub(),
- getNewToken: sinon.stub()
+ getNewToken: sinon.stub(),
}
this.EmailHandler = { sendEmail: sinon.stub() }
@@ -69,20 +69,20 @@ describe('SubscriptionGroupHandler', function () {
this.Subscription = {
updateOne: sinon.stub().yields(),
updateMany: sinon.stub().yields(),
- findOne: sinon.stub().yields()
+ findOne: sinon.stub().yields(),
}
this.settings = { siteUrl: 'http://www.sharelatex.com' }
this.readStub = sinon.stub()
this.NotificationsBuilder = {
- groupPlan: sinon.stub().returns({ read: this.readStub })
+ groupPlan: sinon.stub().returns({ read: this.readStub }),
}
this.UserMembershipViewModel = {
build(email) {
return { email }
- }
+ },
}
return (this.Handler = SandboxedModule.require(modulePath, {
@@ -91,7 +91,7 @@ describe('SubscriptionGroupHandler', function () {
'./SubscriptionUpdater': this.SubscriptionUpdater,
'./SubscriptionLocator': this.SubscriptionLocator,
'../../models/Subscription': {
- Subscription: this.Subscription
+ Subscription: this.Subscription,
},
'../User/UserGetter': this.UserGetter,
'./LimitationsManager': this.LimitationsManager,
@@ -100,8 +100,8 @@ describe('SubscriptionGroupHandler', function () {
'settings-sharelatex': this.settings,
'../Notifications/NotificationsBuilder': this.NotificationsBuilder,
'../UserMembership/UserMembershipViewModel': this
- .UserMembershipViewModel
- }
+ .UserMembershipViewModel,
+ },
}))
})
diff --git a/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js b/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js
index c39d7ddcda..f0119abeea 100644
--- a/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js
+++ b/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js
@@ -8,15 +8,15 @@ const mockRecurlySubscriptions = {
uuid: 'subscription-123-active',
plan: {
name: 'Gold',
- plan_code: 'gold'
+ plan_code: 'gold',
},
current_period_ends_at: new Date(),
state: 'active',
unit_amount_in_cents: 999,
account: {
- account_code: 'user-123'
- }
- }
+ account_code: 'user-123',
+ },
+ },
}
describe('SubscriptionHandler', function () {
@@ -28,21 +28,21 @@ describe('SubscriptionHandler', function () {
name: 'Collaborator',
features: {
collaborators: -1,
- versioning: true
- }
- }
+ versioning: true,
+ },
+ },
],
defaultPlanCode: {
collaborators: 0,
- versioning: false
- }
+ versioning: false,
+ },
}
this.activeRecurlySubscription =
mockRecurlySubscriptions['subscription-123-active']
this.User = {}
this.user = { _id: (this.user_id = 'user_id_here_') }
this.subscription = {
- recurlySubscription_id: this.activeRecurlySubscription.uuid
+ recurlySubscription_id: this.activeRecurlySubscription.uuid,
}
this.RecurlyWrapper = {
getSubscription: sinon
@@ -59,12 +59,12 @@ describe('SubscriptionHandler', function () {
.callsArgWith(3, null, this.activeRecurlySubscription),
getBillingInfo: sinon.stub().yields(),
getAccountPastDueInvoices: sinon.stub().yields(),
- attemptInvoiceCollection: sinon.stub().yields()
+ attemptInvoiceCollection: sinon.stub().yields(),
}
this.SubscriptionUpdater = {
syncSubscription: sinon.stub().yields(),
- startFreeTrial: sinon.stub().callsArgWith(1)
+ startFreeTrial: sinon.stub().callsArgWith(1),
}
this.LimitationsManager = { userHasV2Subscription: sinon.stub() }
@@ -78,13 +78,13 @@ describe('SubscriptionHandler', function () {
'./RecurlyWrapper': this.RecurlyWrapper,
'settings-sharelatex': this.Settings,
'../../models/User': {
- User: this.User
+ User: this.User,
},
'./SubscriptionUpdater': this.SubscriptionUpdater,
'./LimitationsManager': this.LimitationsManager,
'../Email/EmailHandler': this.EmailHandler,
- '../Analytics/AnalyticsManager': this.AnalyticsManager
- }
+ '../Analytics/AnalyticsManager': this.AnalyticsManager,
+ },
})
this.SubscriptionHandler.syncSubscriptionToUser = sinon
@@ -97,7 +97,7 @@ describe('SubscriptionHandler', function () {
this.callback = sinon.stub()
this.subscriptionDetails = {
cvv: '123',
- number: '12345'
+ number: '12345',
}
this.recurlyTokenIds = { billing: '45555666' }
this.SubscriptionHandler.validateNoSubscriptionInRecurly = sinon
@@ -396,7 +396,7 @@ describe('SubscriptionHandler', function () {
describe('for credit card users', function () {
beforeEach(function (done) {
this.RecurlyWrapper.getBillingInfo.yields(null, {
- paypal_billing_agreement_id: null
+ paypal_billing_agreement_id: null,
})
this.SubscriptionHandler.attemptPaypalInvoiceCollection(
this.activeRecurlySubscription.account.account_code,
@@ -419,10 +419,10 @@ describe('SubscriptionHandler', function () {
describe('for paypal users', function () {
beforeEach(function (done) {
this.RecurlyWrapper.getBillingInfo.yields(null, {
- paypal_billing_agreement_id: 'mock-billing-agreement'
+ paypal_billing_agreement_id: 'mock-billing-agreement',
})
this.RecurlyWrapper.getAccountPastDueInvoices.yields(null, [
- { invoice_number: 'mock-invoice-number' }
+ { invoice_number: 'mock-invoice-number' },
])
this.SubscriptionHandler.attemptPaypalInvoiceCollection(
this.activeRecurlySubscription.account.account_code,
diff --git a/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js b/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js
index 4f236e223e..c8079845ee 100644
--- a/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js
+++ b/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js
@@ -23,22 +23,22 @@ describe('Subscription Locator Tests', function () {
this.subscription = { hello: 'world' }
this.Subscription = {
findOne: sinon.stub(),
- find: sinon.stub()
+ find: sinon.stub(),
}
this.DeletedSubscription = {
findOne: sinon.stub().yields(),
- find: sinon.stub().yields()
+ find: sinon.stub().yields(),
}
return (this.SubscriptionLocator = SandboxedModule.require(modulePath, {
requires: {
'./GroupPlansData': {},
'../../models/Subscription': {
- Subscription: this.Subscription
+ Subscription: this.Subscription,
},
'../../models/DeletedSubscription': {
- DeletedSubscription: this.DeletedSubscription
- }
- }
+ DeletedSubscription: this.DeletedSubscription,
+ },
+ },
}))
})
diff --git a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js
index db734da1a4..182313a4b1 100644
--- a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js
+++ b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js
@@ -10,8 +10,8 @@ describe('SubscriptionUpdater', function () {
this.recurlySubscription = {
uuid: '1238uoijdasjhd',
plan: {
- plan_code: 'kjhsakjds'
- }
+ plan_code: 'kjhsakjds',
+ },
}
this.adminUser = { _id: (this.adminuser_id = '5208dd34438843e2db000007') }
this.otherUserId = '5208dd34438842e2db000005'
@@ -22,7 +22,7 @@ describe('SubscriptionUpdater', function () {
manager_ids: [this.adminUser._id],
member_ids: [],
save: sinon.stub().callsArgWith(0),
- planCode: 'student_or_something'
+ planCode: 'student_or_something',
}
this.user_id = this.adminuser_id
@@ -32,7 +32,7 @@ describe('SubscriptionUpdater', function () {
manager_ids: [this.adminUser._id],
member_ids: this.allUserIds,
save: sinon.stub().callsArgWith(0),
- planCode: 'group_subscription'
+ planCode: 'group_subscription',
}
this.updateStub = sinon.stub().callsArgWith(2, null)
@@ -58,12 +58,12 @@ describe('SubscriptionUpdater', function () {
this.SubscriptionLocator = {
getUsersSubscription: sinon.stub(),
getGroupSubscriptionMemberOf: sinon.stub(),
- getMemberSubscriptions: sinon.stub().yields(null, [])
+ getMemberSubscriptions: sinon.stub().yields(null, []),
}
this.Settings = {
defaultPlanCode: 'personal',
- defaultFeatures: { default: 'features' }
+ defaultFeatures: { default: 'features' },
}
this.UserFeaturesUpdater = { updateFeatures: sinon.stub().yields() }
@@ -75,22 +75,22 @@ describe('SubscriptionUpdater', function () {
const users = memberIds.map(id => ({ _id: id }))
callback(null, users)
},
- getUser: sinon.stub()
+ getUser: sinon.stub(),
}
this.ReferalFeatures = { getBonusFeatures: sinon.stub().callsArgWith(1) }
this.Modules = { hooks: { fire: sinon.stub().callsArgWith(2, null, null) } }
this.FeaturesUpdater = {
- refreshFeatures: sinon.stub().yields()
+ refreshFeatures: sinon.stub().yields(),
}
this.DeletedSubscription = {
- findOneAndUpdate: sinon.stub().yields()
+ findOneAndUpdate: sinon.stub().yields(),
}
this.SubscriptionUpdater = SandboxedModule.require(modulePath, {
requires: {
mongodb: { ObjectId },
'../../models/Subscription': {
- Subscription: this.SubscriptionModel
+ Subscription: this.SubscriptionModel,
},
'./UserFeaturesUpdater': this.UserFeaturesUpdater,
'./SubscriptionLocator': this.SubscriptionLocator,
@@ -100,9 +100,9 @@ describe('SubscriptionUpdater', function () {
'../../infrastructure/mongodb': { db: {}, ObjectId },
'./FeaturesUpdater': this.FeaturesUpdater,
'../../models/DeletedSubscription': {
- DeletedSubscription: this.DeletedSubscription
- }
- }
+ DeletedSubscription: this.DeletedSubscription,
+ },
+ },
})
})
@@ -118,11 +118,11 @@ describe('SubscriptionUpdater', function () {
}
const query = {
_id: ObjectId(this.subscription._id),
- customAccount: true
+ customAccount: true,
}
const update = {
$set: { admin_id: ObjectId(this.otherUserId) },
- $addToSet: { manager_ids: ObjectId(this.otherUserId) }
+ $addToSet: { manager_ids: ObjectId(this.otherUserId) },
}
this.SubscriptionModel.updateOne.should.have.been.calledOnce
this.SubscriptionModel.updateOne.should.have.been.calledWith(
@@ -144,13 +144,13 @@ describe('SubscriptionUpdater', function () {
}
const query = {
_id: ObjectId(this.subscription._id),
- customAccount: true
+ customAccount: true,
}
const update = {
$set: {
admin_id: ObjectId(this.otherUserId),
- manager_ids: [ObjectId(this.otherUserId)]
- }
+ manager_ids: [ObjectId(this.otherUserId)],
+ },
}
this.SubscriptionModel.updateOne.should.have.been.calledOnce
this.SubscriptionModel.updateOne.should.have.been.calledWith(
@@ -317,7 +317,7 @@ describe('SubscriptionUpdater', function () {
this.subscription.membersLimit.should.equal(5)
this.subscription.groupPlan.should.equal(true)
this.subscription.member_ids.should.deep.equal([
- this.subscription.admin_id
+ this.subscription.admin_id,
])
done()
}
@@ -348,7 +348,7 @@ describe('SubscriptionUpdater', function () {
.returns({
groupPlan: true,
membersLimit: 5,
- membersLimitAddOn: this.membersLimitAddOn
+ membersLimitAddOn: this.membersLimitAddOn,
})
})
@@ -378,7 +378,7 @@ describe('SubscriptionUpdater', function () {
describe('when the recurlySubscription has non-matching add ons', function () {
beforeEach(function () {
this.recurlySubscription.subscription_add_ons = [
- { add_on_code: 'add_on_99', quantity: 3 }
+ { add_on_code: 'add_on_99', quantity: 3 },
]
})
expectMembersLimit(5)
@@ -387,7 +387,7 @@ describe('SubscriptionUpdater', function () {
describe('when the recurlySubscription has a matching add on', function () {
beforeEach(function () {
this.recurlySubscription.subscription_add_ons = [
- { add_on_code: this.membersLimitAddOn, quantity: 10 }
+ { add_on_code: this.membersLimitAddOn, quantity: 10 },
]
})
expectMembersLimit(15)
@@ -398,7 +398,7 @@ describe('SubscriptionUpdater', function () {
beforeEach(function () {
this.recurlySubscription.subscription_add_ons = [
{ add_on_code: this.membersLimitAddOn, quantity: 10 },
- { add_on_code: this.membersLimitAddOn, quantity: 3 }
+ { add_on_code: this.membersLimitAddOn, quantity: 3 },
]
})
expectMembersLimit(18)
@@ -451,7 +451,7 @@ describe('SubscriptionUpdater', function () {
() => {
const searchOps = { _id: this.subscription._id }
const insertOperation = {
- $addToSet: { member_ids: { $each: [this.otherUserId] } }
+ $addToSet: { member_ids: { $each: [this.otherUserId] } },
}
this.updateStub
.calledWith(searchOps, insertOperation)
@@ -530,7 +530,7 @@ describe('SubscriptionUpdater', function () {
_id: ObjectId().toString(),
mock: 'subscription',
admin_id: ObjectId(),
- member_ids: [ObjectId(), ObjectId(), ObjectId()]
+ member_ids: [ObjectId(), ObjectId(), ObjectId()],
}
this.SubscriptionLocator.getSubscription = sinon
.stub()
diff --git a/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js b/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js
index a0d4b80aa1..ded01ad6d2 100644
--- a/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js
+++ b/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js
@@ -14,14 +14,14 @@ describe('TeamInvitesHandler', function () {
first_name: 'Daenerys',
last_name: 'Targaryen',
email: 'daenerys@example.com',
- emails: [{ email: 'daenerys@example.com' }]
+ emails: [{ email: 'daenerys@example.com' }],
}
this.token = 'aaaaaaaaaaaaaaaaaaaaaa'
this.teamInvite = {
email: 'jorah@example.com',
- token: this.token
+ token: this.token,
}
this.subscription = {
@@ -31,34 +31,34 @@ describe('TeamInvitesHandler', function () {
groupPlan: true,
member_ids: [],
teamInvites: [this.teamInvite],
- save: sinon.stub().yields(null)
+ save: sinon.stub().yields(null),
}
this.SubscriptionLocator = {
getUsersSubscription: sinon.stub(),
- getSubscription: sinon.stub().yields(null, this.subscription)
+ getSubscription: sinon.stub().yields(null, this.subscription),
}
this.UserGetter = {
getUser: sinon.stub().yields(),
- getUserByAnyEmail: sinon.stub().yields()
+ getUserByAnyEmail: sinon.stub().yields(),
}
this.SubscriptionUpdater = {
- addUserToGroup: sinon.stub().yields()
+ addUserToGroup: sinon.stub().yields(),
}
this.LimitationsManager = {
- teamHasReachedMemberLimit: sinon.stub().returns(false)
+ teamHasReachedMemberLimit: sinon.stub().returns(false),
}
this.Subscription = {
findOne: sinon.stub().yields(),
- updateOne: sinon.stub().yields()
+ updateOne: sinon.stub().yields(),
}
this.EmailHandler = {
- sendEmail: sinon.stub().yields(null)
+ sendEmail: sinon.stub().yields(null),
}
this.newToken = 'bbbbbbbbb'
@@ -66,7 +66,7 @@ describe('TeamInvitesHandler', function () {
this.crypto = {
randomBytes: () => {
return { toString: sinon.stub().returns(this.newToken) }
- }
+ },
}
this.UserGetter.getUser
@@ -93,8 +93,8 @@ describe('TeamInvitesHandler', function () {
'./SubscriptionLocator': this.SubscriptionLocator,
'./SubscriptionUpdater': this.SubscriptionUpdater,
'./LimitationsManager': this.LimitationsManager,
- '../Email/EmailHandler': this.EmailHandler
- }
+ '../Email/EmailHandler': this.EmailHandler,
+ },
})
})
@@ -156,7 +156,7 @@ describe('TeamInvitesHandler', function () {
sinon.match({
to: 'john.snow@example.com',
inviter: this.manager,
- acceptInviteUrl: `http://example.com/subscription/invites/${this.newToken}/`
+ acceptInviteUrl: `http://example.com/subscription/invites/${this.newToken}/`,
})
)
.should.equal(true)
@@ -261,7 +261,7 @@ describe('TeamInvitesHandler', function () {
id: '123456789',
first_name: 'Tyrion',
last_name: 'Lannister',
- email: 'tyrion@example.com'
+ email: 'tyrion@example.com',
}
this.UserGetter.getUserByAnyEmail
@@ -271,7 +271,7 @@ describe('TeamInvitesHandler', function () {
this.subscription.teamInvites.push({
email: 'john.snow@example.com',
token: 'dddddddd',
- inviterName: 'Daenerys Targaryen (daenerys@example.com)'
+ inviterName: 'Daenerys Targaryen (daenerys@example.com)',
})
})
@@ -327,7 +327,7 @@ describe('TeamInvitesHandler', function () {
beforeEach(function () {
this.subscription.invited_emails = [
'eddard@example.com',
- 'robert@example.com'
+ 'robert@example.com',
]
this.TeamInvitesHandler.createInvite = sinon.stub().yields(null)
this.SubscriptionLocator.getGroupsWithEmailInvite = sinon
@@ -390,7 +390,7 @@ describe('TeamInvitesHandler', function () {
const member = {
id: '1a2b',
_id: '1a2b',
- email: 'tyrion@example.com'
+ email: 'tyrion@example.com',
}
this.subscription.member_ids = [member.id]
diff --git a/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js b/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js
index f932c5f54e..3307ac1333 100644
--- a/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js
+++ b/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js
@@ -24,9 +24,9 @@ describe('UserFeaturesUpdater', function () {
return (this.UserFeaturesUpdater = SandboxedModule.require(modulePath, {
requires: {
'../../models/User': {
- User: this.User
- }
- }
+ User: this.User,
+ },
+ },
}))
})
@@ -40,7 +40,7 @@ describe('UserFeaturesUpdater', function () {
(err, features) => {
const update = {
'features.versioning': true,
- 'features.collaborators': 10
+ 'features.collaborators': 10,
}
this.User.updateOne
.calledWith({ _id: user_id }, update)
diff --git a/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js b/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js
index dd2eb27180..b9ce29aca1 100644
--- a/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js
+++ b/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js
@@ -31,17 +31,17 @@ describe('V1SubscriptionManager', function () {
apis: {
v1: {
host: (this.host = 'http://overleaf.example.com'),
- url: 'v1.url'
- }
+ url: 'v1.url',
+ },
},
v1GrandfatheredFeaturesUidCutoff: 10,
v1GrandfatheredFeatures: {
github: true,
- mendeley: true
- }
+ mendeley: true,
+ },
}),
- request: (this.request = sinon.stub())
- }
+ request: (this.request = sinon.stub()),
+ },
})
this.userId = 'abcd'
this.v1UserId = 42
@@ -49,8 +49,8 @@ describe('V1SubscriptionManager', function () {
_id: this.userId,
email: 'user@example.com',
overleaf: {
- id: this.v1UserId
- }
+ id: this.v1UserId,
+ },
})
})
@@ -58,7 +58,7 @@ describe('V1SubscriptionManager', function () {
beforeEach(function () {
this.responseBody = {
id: 32,
- plan_name: 'pro'
+ plan_name: 'pro',
}
this.V1SubscriptionManager._v1Request = sinon
.stub()
@@ -126,7 +126,7 @@ describe('V1SubscriptionManager', function () {
this.V1SubscriptionManager.getGrandfatheredFeaturesForV1User(1)
).to.eql({
github: true,
- mendeley: true
+ mendeley: true,
})
return done()
})
@@ -149,7 +149,7 @@ describe('V1SubscriptionManager', function () {
{
url() {
return '/foo'
- }
+ },
},
cb
)
@@ -180,7 +180,7 @@ describe('V1SubscriptionManager', function () {
{
url() {
return '/foo'
- }
+ },
},
cb
)
@@ -211,7 +211,7 @@ describe('V1SubscriptionManager', function () {
{
url() {
return '/foo'
- }
+ },
},
cb
)
@@ -238,7 +238,7 @@ describe('V1SubscriptionManager', function () {
{
url() {
return '/foo'
- }
+ },
},
cb
)
@@ -279,7 +279,7 @@ describe('V1SubscriptionManager', function () {
{
url() {
return '/foo'
- }
+ },
},
cb
)
@@ -306,7 +306,7 @@ describe('V1SubscriptionManager', function () {
{
url() {
return '/foo'
- }
+ },
},
cb
)
diff --git a/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js b/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js
index 794889f0c0..cd98273ab3 100644
--- a/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js
+++ b/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js
@@ -22,12 +22,12 @@ describe('SystemMessageManager', function () {
beforeEach(function () {
this.messages = ['messages-stub']
this.SystemMessage = {
- find: sinon.stub().yields(null, this.messages)
+ find: sinon.stub().yields(null, this.messages),
}
this.SystemMessageManager = SandboxedModule.require(modulePath, {
requires: {
- '../../models/SystemMessage': { SystemMessage: this.SystemMessage }
- }
+ '../../models/SystemMessage': { SystemMessage: this.SystemMessage },
+ },
})
return (this.callback = sinon.stub())
})
diff --git a/services/web/test/unit/src/Tags/TagsControllerTests.js b/services/web/test/unit/src/Tags/TagsControllerTests.js
index 73acb2da90..5a7accf292 100644
--- a/services/web/test/unit/src/Tags/TagsControllerTests.js
+++ b/services/web/test/unit/src/Tags/TagsControllerTests.js
@@ -30,29 +30,29 @@ describe('TagsController', function () {
removeProjectFromTag: sinon.stub().callsArgWith(3),
deleteTag: sinon.stub().callsArg(2),
renameTag: sinon.stub().callsArg(3),
- createTag: sinon.stub()
+ createTag: sinon.stub(),
}
this.AuthenticationController = {
getLoggedInUserId: req => {
return req.session.user._id
- }
+ },
}
this.controller = SandboxedModule.require(modulePath, {
requires: {
'./TagsHandler': this.handler,
'../Authentication/AuthenticationController': this
- .AuthenticationController
- }
+ .AuthenticationController,
+ },
})
this.req = {
params: {
- projectId
+ projectId,
},
session: {
user: {
- _id: userId
- }
- }
+ _id: userId,
+ },
+ },
}
this.res = {}
@@ -70,7 +70,7 @@ describe('TagsController', function () {
body.should.equal(allTags)
this.handler.getAllTags.calledWith(userId).should.equal(true)
return done()
- }
+ },
})
})
})
diff --git a/services/web/test/unit/src/Tags/TagsHandlerTests.js b/services/web/test/unit/src/Tags/TagsHandlerTests.js
index 26223ef676..df9356bb99 100644
--- a/services/web/test/unit/src/Tags/TagsHandlerTests.js
+++ b/services/web/test/unit/src/Tags/TagsHandlerTests.js
@@ -23,8 +23,8 @@ describe('TagsHandler', function () {
this.TagsHandler = SandboxedModule.require(modulePath, {
requires: {
'../../infrastructure/mongodb': this.mongodb,
- '../../models/Tag': { Tag: Tag }
- }
+ '../../models/Tag': { Tag: Tag },
+ },
})
})
@@ -170,10 +170,10 @@ describe('TagsHandler', function () {
.withArgs(
{
_id: this.tagId,
- user_id: this.userId
+ user_id: this.userId,
},
{
- $pull: { project_ids: this.projectId }
+ $pull: { project_ids: this.projectId },
}
)
.yields()
@@ -197,10 +197,10 @@ describe('TagsHandler', function () {
.once()
.withArgs(
{
- user_id: this.userId
+ user_id: this.userId,
},
{
- $pull: { project_ids: this.projectId }
+ $pull: { project_ids: this.projectId },
}
)
.yields()
diff --git a/services/web/test/unit/src/Templates/TemplatesControllerTests.js b/services/web/test/unit/src/Templates/TemplatesControllerTests.js
index b14d8151ee..dd43000941 100644
--- a/services/web/test/unit/src/Templates/TemplatesControllerTests.js
+++ b/services/web/test/unit/src/Templates/TemplatesControllerTests.js
@@ -25,12 +25,12 @@ describe('TemplatesController', function () {
requires: {
'../Project/ProjectHelper': ProjectHelper,
'../Authentication/AuthenticationController': (this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.user_id)
+ getLoggedInUserId: sinon.stub().returns(this.user_id),
}),
'./TemplatesManager': (this.TemplatesManager = {
- createProjectFromV1Template: sinon.stub()
- })
- }
+ createProjectFromV1Template: sinon.stub(),
+ }),
+ },
})
this.next = sinon.stub()
this.req = {
@@ -40,14 +40,14 @@ describe('TemplatesController', function () {
mainFile: 'main-file',
templateId: 'template-id',
templateName: 'template-name',
- templateVersionId: 'template-version-id'
+ templateVersionId: 'template-version-id',
},
session: {
templateData: 'template-data',
user: {
- _id: this.user_id
- }
- }
+ _id: this.user_id,
+ },
+ },
}
return (this.res = { redirect: sinon.stub() })
})
diff --git a/services/web/test/unit/src/Templates/TemplatesManagerTests.js b/services/web/test/unit/src/Templates/TemplatesManagerTests.js
index 92c52ab61b..7320498ffd 100644
--- a/services/web/test/unit/src/Templates/TemplatesManagerTests.js
+++ b/services/web/test/unit/src/Templates/TemplatesManagerTests.js
@@ -33,31 +33,31 @@ describe('TemplatesManager', function () {
pipe() {},
on() {},
response: {
- statusCode: 200
- }
+ statusCode: 200,
+ },
})
this.fs = {
unlink: sinon.stub(),
- createWriteStream: sinon.stub().returns({ on: sinon.stub().yields() })
+ createWriteStream: sinon.stub().returns({ on: sinon.stub().yields() }),
}
this.ProjectUploadManager = {
createProjectFromZipArchiveWithName: sinon
.stub()
- .callsArgWith(4, null, { _id: this.project_id })
+ .callsArgWith(4, null, { _id: this.project_id }),
}
this.dumpFolder = 'dump/path'
this.ProjectOptionsHandler = {
setCompiler: sinon.stub().callsArgWith(2),
setImageName: sinon.stub().callsArgWith(2),
- setBrandVariationId: sinon.stub().callsArgWith(2)
+ setBrandVariationId: sinon.stub().callsArgWith(2),
}
this.uuid = '1234'
this.ProjectRootDocManager = {
- setRootDocFromName: sinon.stub().callsArgWith(2)
+ setRootDocFromName: sinon.stub().callsArgWith(2),
}
this.ProjectDetailsHandler = {
getProjectDescription: sinon.stub(),
- fixProjectName: sinon.stub().returns(this.templateName)
+ fixProjectName: sinon.stub().returns(this.templateName),
}
this.Project = { updateOne: sinon.stub().callsArgWith(3, null) }
this.FileWriter = { ensureDumpFolderExists: sinon.stub().callsArg(0) }
@@ -69,32 +69,32 @@ describe('TemplatesManager', function () {
'../Project/ProjectRootDocManager': this.ProjectRootDocManager,
'../Project/ProjectDetailsHandler': this.ProjectDetailsHandler,
'../Authentication/AuthenticationController': (this.AuthenticationController = {
- getLoggedInUserId: sinon.stub()
+ getLoggedInUserId: sinon.stub(),
}),
'../../infrastructure/FileWriter': this.FileWriter,
'settings-sharelatex': {
path: {
- dumpFolder: this.dumpFolder
+ dumpFolder: this.dumpFolder,
},
siteUrl: (this.siteUrl = 'http://localhost:3000'),
apis: {
v1: {
url: (this.v1Url = 'http://overleaf.com'),
user: 'sharelatex',
- pass: 'password'
- }
+ pass: 'password',
+ },
},
overleaf: {
- host: this.v1Url
- }
+ host: this.v1Url,
+ },
},
uuid: {
- v4: () => this.uuid
+ v4: () => this.uuid,
},
request: this.request,
fs: this.fs,
- '../../models/Project': { Project: this.Project }
- }
+ '../../models/Project': { Project: this.Project },
+ },
})
return (this.zipUrl =
'%2Ftemplates%2F52fb86a81ae1e566597a25f6%2Fv%2F4%2Fzip&templateName=Moderncv%20Banking&compiler=pdflatex')
@@ -135,7 +135,7 @@ describe('TemplatesManager', function () {
this.dumpPath,
{
fromV1TemplateId: this.templateId,
- fromV1TemplateVersionId: this.templateVersionId
+ fromV1TemplateVersionId: this.templateVersionId,
}
)
})
@@ -168,7 +168,7 @@ describe('TemplatesManager', function () {
{ _id: this.project_id },
{
fromV1TemplateId: this.templateId,
- fromV1TemplateVersionId: this.templateVersionId
+ fromV1TemplateVersionId: this.templateVersionId,
}
)
})
diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js
index a623c71dc0..293300f8a6 100644
--- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js
+++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js
@@ -10,27 +10,27 @@ describe('TpdsController', function () {
beforeEach(function () {
this.TpdsUpdateHandler = {}
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns('user-id')
+ getLoggedInUserId: sinon.stub().returns('user-id'),
}
this.TpdsQueueManager = {
promises: {
- getQueues: sinon.stub().returns('queues')
- }
+ getQueues: sinon.stub().returns('queues'),
+ },
}
this.TpdsController = SandboxedModule.require(modulePath, {
requires: {
'./TpdsUpdateHandler': this.TpdsUpdateHandler,
'./UpdateMerger': (this.UpdateMerger = {}),
'../Notifications/NotificationsBuilder': (this.NotificationsBuilder = {
- tpdsFileLimit: sinon.stub().returns({ create: sinon.stub() })
+ tpdsFileLimit: sinon.stub().returns({ create: sinon.stub() }),
}),
'../Authentication/AuthenticationController': this
.AuthenticationController,
'./TpdsQueueManager': this.TpdsQueueManager,
'@overleaf/metrics': {
- inc() {}
- }
- }
+ inc() {},
+ },
+ },
})
this.user_id = 'dsad29jlkjas'
@@ -43,11 +43,11 @@ describe('TpdsController', function () {
pause() {},
params: { 0: path, user_id: this.user_id },
session: {
- destroy() {}
+ destroy() {},
},
headers: {
- 'x-sl-update-source': (this.source = 'dropbox')
- }
+ 'x-sl-update-source': (this.source = 'dropbox'),
+ },
}
this.TpdsUpdateHandler.newUpdate = sinon.stub().callsArg(5)
const res = {
@@ -62,7 +62,7 @@ describe('TpdsController', function () {
)
.should.equal(true)
done()
- }
+ },
}
this.TpdsController.mergeUpdate(req, res)
})
@@ -73,17 +73,17 @@ describe('TpdsController', function () {
pause() {},
params: { 0: path, user_id: this.user_id },
session: {
- destroy() {}
+ destroy() {},
},
headers: {
- 'x-sl-update-source': (this.source = 'dropbox')
- }
+ 'x-sl-update-source': (this.source = 'dropbox'),
+ },
}
this.TpdsUpdateHandler.newUpdate = sinon
.stub()
.callsArgWith(5, 'update-receiver-error')
const res = {
- sendStatus: sinon.stub()
+ sendStatus: sinon.stub(),
}
this.TpdsController.mergeUpdate(req, res)
res.sendStatus.calledWith(500).should.equal(true)
@@ -95,17 +95,17 @@ describe('TpdsController', function () {
pause() {},
params: { 0: path, user_id: this.user_id, projectName: 'projectName' },
session: {
- destroy() {}
+ destroy() {},
},
headers: {
- 'x-sl-update-source': (this.source = 'dropbox')
- }
+ 'x-sl-update-source': (this.source = 'dropbox'),
+ },
}
this.TpdsUpdateHandler.newUpdate = sinon
.stub()
.callsArgWith(5, { message: 'project_has_too_many_files' })
const res = {
- sendStatus: sinon.stub()
+ sendStatus: sinon.stub(),
}
this.TpdsController.mergeUpdate(req, res)
res.sendStatus.calledWith(400).should.equal(true)
@@ -120,17 +120,17 @@ describe('TpdsController', function () {
pause() {},
params: { 0: path, user_id: this.user_id },
session: {
- destroy() {}
+ destroy() {},
},
headers: {
- 'x-sl-update-source': (this.source = 'dropbox')
- }
+ 'x-sl-update-source': (this.source = 'dropbox'),
+ },
}
this.TpdsUpdateHandler.newUpdate = sinon
.stub()
.callsArgWith(5, new Errors.TooManyRequestsError('project on cooldown'))
const res = {
- sendStatus: sinon.stub()
+ sendStatus: sinon.stub(),
}
this.TpdsController.mergeUpdate(req, res)
res.sendStatus.calledWith(429).should.equal(true)
@@ -143,11 +143,11 @@ describe('TpdsController', function () {
const req = {
params: { 0: path, user_id: this.user_id },
session: {
- destroy() {}
+ destroy() {},
},
headers: {
- 'x-sl-update-source': (this.source = 'dropbox')
- }
+ 'x-sl-update-source': (this.source = 'dropbox'),
+ },
}
this.TpdsUpdateHandler.deleteUpdate = sinon.stub().callsArg(4)
const res = {
@@ -156,7 +156,7 @@ describe('TpdsController', function () {
.calledWith(this.user_id, 'projectName', '/here.txt', this.source)
.should.equal(true)
done()
- }
+ },
}
this.TpdsController.deleteUpdate(req, res)
})
@@ -196,14 +196,14 @@ describe('TpdsController', function () {
this.req = {
params: {
0: (this.path = 'chapters/main.tex'),
- project_id: (this.project_id = 'project-id-123')
+ project_id: (this.project_id = 'project-id-123'),
},
session: {
- destroy: sinon.stub()
+ destroy: sinon.stub(),
},
headers: {
- 'x-sl-update-source': (this.source = 'github')
- }
+ 'x-sl-update-source': (this.source = 'github'),
+ },
}
this.res = { sendStatus: sinon.stub() }
@@ -233,14 +233,14 @@ describe('TpdsController', function () {
this.req = {
params: {
0: (this.path = 'chapters/main.tex'),
- project_id: (this.project_id = 'project-id-123')
+ project_id: (this.project_id = 'project-id-123'),
},
session: {
- destroy: sinon.stub()
+ destroy: sinon.stub(),
},
headers: {
- 'x-sl-update-source': (this.source = 'github')
- }
+ 'x-sl-update-source': (this.source = 'github'),
+ },
}
this.res = { sendStatus: sinon.stub() }
diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js
index 838b34fa18..bcdec7f9ff 100644
--- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js
+++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js
@@ -12,21 +12,21 @@ describe('TpdsProjectFlusher', function () {
this.project = { _id: ObjectId() }
this.docs = {
'/doc/one': { _id: 'mock-doc-1', lines: ['one'], rev: 5 },
- '/doc/two': { _id: 'mock-doc-2', lines: ['two'], rev: 6 }
+ '/doc/two': { _id: 'mock-doc-2', lines: ['two'], rev: 6 },
}
this.files = {
'/file/one': { _id: 'mock-file-1', rev: 7 },
- '/file/two': { _id: 'mock-file-2', rev: 8 }
+ '/file/two': { _id: 'mock-file-2', rev: 8 },
}
this.DocumentUpdaterHandler = {
promises: {
- flushProjectToMongo: sinon.stub().resolves()
- }
+ flushProjectToMongo: sinon.stub().resolves(),
+ },
}
this.ProjectGetter = {
promises: {
- getProject: sinon.stub().resolves(this.project)
- }
+ getProject: sinon.stub().resolves(this.project),
+ },
}
this.ProjectEntityHandler = {
promises: {
@@ -34,14 +34,14 @@ describe('TpdsProjectFlusher', function () {
getAllFiles: sinon
.stub()
.withArgs(this.project._id)
- .resolves(this.files)
- }
+ .resolves(this.files),
+ },
}
this.TpdsUpdateSender = {
promises: {
addDoc: sinon.stub().resolves(),
- addFile: sinon.stub().resolves()
- }
+ addFile: sinon.stub().resolves(),
+ },
}
this.ProjectMock = sinon.mock(Project)
@@ -52,8 +52,8 @@ describe('TpdsProjectFlusher', function () {
'../Project/ProjectGetter': this.ProjectGetter,
'../Project/ProjectEntityHandler': this.ProjectEntityHandler,
'../../models/Project': { Project },
- './TpdsUpdateSender': this.TpdsUpdateSender
- }
+ './TpdsUpdateSender': this.TpdsUpdateSender,
+ },
})
})
@@ -83,7 +83,7 @@ describe('TpdsProjectFlusher', function () {
doc_id: doc._id,
project_name: this.project.name,
rev: doc.rev,
- path
+ path,
}
)
}
@@ -98,7 +98,7 @@ describe('TpdsProjectFlusher', function () {
file_id: file._id,
project_name: this.project.name,
rev: file.rev,
- path
+ path,
})
}
})
@@ -111,7 +111,7 @@ describe('TpdsProjectFlusher', function () {
.withArgs(
{
_id: this.project._id,
- deferredTpdsFlushCounter: { $lte: 2 }
+ deferredTpdsFlushCounter: { $lte: 2 },
},
{ $set: { deferredTpdsFlushCounter: 0 } }
)
@@ -133,7 +133,7 @@ describe('TpdsProjectFlusher', function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
- _id: this.project._id
+ _id: this.project._id,
},
{ $inc: { deferredTpdsFlushCounter: 1 } }
)
@@ -184,7 +184,7 @@ describe('TpdsProjectFlusher', function () {
.withArgs(
{
_id: this.project._id,
- deferredTpdsFlushCounter: { $lte: counterValue }
+ deferredTpdsFlushCounter: { $lte: counterValue },
},
{ $set: { deferredTpdsFlushCounter: 0 } }
)
@@ -210,7 +210,7 @@ describe('TpdsProjectFlusher', function () {
doc_id: doc._id,
project_name: this.project.name,
rev: doc.rev,
- path
+ path,
})
}
})
@@ -224,7 +224,7 @@ describe('TpdsProjectFlusher', function () {
file_id: file._id,
project_name: this.project.name,
rev: file.rev,
- path
+ path,
})
}
})
diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js
index 56c8c9a269..0c08a1576f 100644
--- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js
+++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js
@@ -24,13 +24,13 @@ describe('TpdsUpdateHandler', function () {
archived1: {
_id: new ObjectId(),
name: this.projectName,
- archived: [this.userId]
+ archived: [this.userId],
},
archived2: {
_id: new ObjectId(),
name: this.projectName,
- archived: [this.userId]
- }
+ archived: [this.userId],
+ },
}
this.userId = new ObjectId()
this.source = 'dropbox'
@@ -38,31 +38,31 @@ describe('TpdsUpdateHandler', function () {
this.update = {}
this.CooldownManager = {
- isProjectOnCooldown: sinon.stub().yields(null, false)
+ isProjectOnCooldown: sinon.stub().yields(null, false),
}
this.FileTypeManager = {
- shouldIgnore: sinon.stub().yields(null, false)
+ shouldIgnore: sinon.stub().yields(null, false),
}
this.Modules = {
- hooks: { fire: sinon.stub().yields() }
+ hooks: { fire: sinon.stub().yields() },
}
this.notification = {
- create: sinon.stub().yields()
+ create: sinon.stub().yields(),
}
this.NotificationsBuilder = {
- dropboxDuplicateProjectNames: sinon.stub().returns(this.notification)
+ dropboxDuplicateProjectNames: sinon.stub().returns(this.notification),
}
this.ProjectCreationHandler = {
- createBlankProject: sinon.stub().yields(null, this.projects.active1)
+ createBlankProject: sinon.stub().yields(null, this.projects.active1),
}
this.ProjectDeleter = {
- markAsDeletedByExternalSource: sinon.stub().yields()
+ markAsDeletedByExternalSource: sinon.stub().yields(),
}
this.ProjectGetter = {
- findUsersProjectsByName: sinon.stub()
+ findUsersProjectsByName: sinon.stub(),
}
this.ProjectHelper = {
- isArchivedOrTrashed: sinon.stub().returns(false)
+ isArchivedOrTrashed: sinon.stub().returns(false),
}
this.ProjectHelper.isArchivedOrTrashed
.withArgs(this.projects.archived1, this.userId)
@@ -73,7 +73,7 @@ describe('TpdsUpdateHandler', function () {
this.RootDocManager = { setRootDocAutomatically: sinon.stub() }
this.UpdateMerger = {
deleteUpdate: sinon.stub().yields(),
- mergeUpdate: sinon.stub().yields()
+ mergeUpdate: sinon.stub().yields(),
}
this.TpdsUpdateHandler = SandboxedModule.require(MODULE_PATH, {
@@ -87,8 +87,8 @@ describe('TpdsUpdateHandler', function () {
'../Project/ProjectGetter': this.ProjectGetter,
'../Project/ProjectHelper': this.ProjectHelper,
'../Project/ProjectRootDocManager': this.RootDocManager,
- './UpdateMerger': this.UpdateMerger
- }
+ './UpdateMerger': this.UpdateMerger,
+ },
})
})
diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js
index b46471628a..ca3672b462 100644
--- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js
+++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js
@@ -24,14 +24,14 @@ const filestoreUrl = 'filestore.sharelatex.com'
describe('TpdsUpdateSender', function () {
beforeEach(function () {
this.fakeUser = {
- _id: '12390i'
+ _id: '12390i',
}
this.requestQueuer = function (queue, meth, opts, callback) {}
const memberIds = [userId, collaberatorRef, readOnlyRef]
this.CollaboratorsGetter = {
promises: {
- getInvitedMemberIds: sinon.stub().resolves(memberIds)
- }
+ getInvitedMemberIds: sinon.stub().resolves(memberIds),
+ },
}
this.docstoreUrl = 'docstore.sharelatex.env'
this.request = sinon.stub().resolves()
@@ -41,12 +41,12 @@ describe('TpdsUpdateSender', function () {
apis: {
thirdPartyDataStore: { url: thirdPartyDataStoreApiUrl },
filestore: {
- url: filestoreUrl
+ url: filestoreUrl,
},
docstore: {
- pubUrl: this.docstoreUrl
- }
- }
+ pubUrl: this.docstoreUrl,
+ },
+ },
}
const getUsers = sinon.stub().resolves(
memberIds.slice(1).map(userId => {
@@ -54,7 +54,7 @@ describe('TpdsUpdateSender', function () {
})
)
this.UserGetter = {
- promises: { getUsers }
+ promises: { getUsers },
}
this.updateSender = SandboxedModule.require(modulePath, {
requires: {
@@ -64,9 +64,9 @@ describe('TpdsUpdateSender', function () {
'../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter,
'../User/UserGetter.js': this.UserGetter,
'@overleaf/metrics': {
- inc() {}
- }
- }
+ inc() {},
+ },
+ },
})
})
@@ -105,13 +105,13 @@ describe('TpdsUpdateSender', function () {
project_id: projectId,
file_id: fileId,
path,
- project_name: projectName
+ project_name: projectName,
})
const {
group: group0,
job: job0,
- method: method0
+ method: method0,
} = this.request.firstCall.args[0].json
group0.should.equal(userId)
method0.should.equal('pipeStreamFrom')
@@ -141,9 +141,9 @@ describe('TpdsUpdateSender', function () {
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
{
_id: {
- $in: [collaberatorRef, readOnlyRef]
+ $in: [collaberatorRef, readOnlyRef],
},
- 'dropbox.access_token.uid': { $ne: null }
+ 'dropbox.access_token.uid': { $ne: null },
},
{ _id: 1 }
)
@@ -159,13 +159,13 @@ describe('TpdsUpdateSender', function () {
doc_id: docId,
path,
docLines: lines,
- project_name: projectName
+ project_name: projectName,
})
const {
group: group0,
job: job0,
- method: method0
+ method: method0,
} = this.request.firstCall.args[0].json
group0.should.equal(userId)
@@ -193,9 +193,9 @@ describe('TpdsUpdateSender', function () {
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
{
_id: {
- $in: [collaberatorRef, readOnlyRef]
+ $in: [collaberatorRef, readOnlyRef],
},
- 'dropbox.access_token.uid': { $ne: null }
+ 'dropbox.access_token.uid': { $ne: null },
},
{ _id: 1 }
)
@@ -207,13 +207,13 @@ describe('TpdsUpdateSender', function () {
await this.updateSender.promises.deleteEntity({
project_id: projectId,
path,
- project_name: projectName
+ project_name: projectName,
})
const {
group: group0,
job: job0,
- method: method0
+ method: method0,
} = this.request.firstCall.args[0].json
group0.should.equal(userId)
@@ -238,9 +238,9 @@ describe('TpdsUpdateSender', function () {
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
{
_id: {
- $in: [collaberatorRef, readOnlyRef]
+ $in: [collaberatorRef, readOnlyRef],
},
- 'dropbox.access_token.uid': { $ne: null }
+ 'dropbox.access_token.uid': { $ne: null },
},
{ _id: 1 }
)
@@ -254,13 +254,13 @@ describe('TpdsUpdateSender', function () {
project_id: projectId,
startPath,
endPath,
- project_name: projectName
+ project_name: projectName,
})
const {
group: group0,
job: job0,
- method: method0
+ method: method0,
} = this.request.firstCall.args[0].json
group0.should.equal(userId)
@@ -286,9 +286,9 @@ describe('TpdsUpdateSender', function () {
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
{
_id: {
- $in: [collaberatorRef, readOnlyRef]
+ $in: [collaberatorRef, readOnlyRef],
},
- 'dropbox.access_token.uid': { $ne: null }
+ 'dropbox.access_token.uid': { $ne: null },
},
{ _id: 1 }
)
@@ -301,13 +301,13 @@ describe('TpdsUpdateSender', function () {
await this.updateSender.promises.moveEntity({
project_id: projectId,
project_name: oldProjectName,
- newProjectName
+ newProjectName,
})
const {
group: group0,
job: job0,
- method: method0
+ method: method0,
} = this.request.firstCall.args[0].json
group0.should.equal(userId)
@@ -333,9 +333,9 @@ describe('TpdsUpdateSender', function () {
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
{
_id: {
- $in: [collaberatorRef, readOnlyRef]
+ $in: [collaberatorRef, readOnlyRef],
},
- 'dropbox.access_token.uid': { $ne: null }
+ 'dropbox.access_token.uid': { $ne: null },
},
{ _id: 1 }
)
@@ -347,7 +347,7 @@ describe('TpdsUpdateSender', function () {
const {
group: group0,
job: job0,
- method: method0
+ method: method0,
} = this.request.firstCall.args[0].json
group0.should.equal(`poll-dropbox:${userId}`)
diff --git a/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js
index b9f18be50b..a6462dc248 100644
--- a/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js
+++ b/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js
@@ -15,8 +15,8 @@ describe('UpdateMerger :', function () {
'../Uploads/FileTypeManager': (this.FileTypeManager = {}),
'../../infrastructure/FileWriter': (this.FileWriter = {}),
'../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}),
- 'settings-sharelatex': { path: { dumpPath: 'dump_here' } }
- }
+ 'settings-sharelatex': { path: { dumpPath: 'dump_here' } },
+ },
})
this.project_id = 'project_id_here'
this.user_id = 'mock-user-id'
diff --git a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js
index aa3cfae4d5..fc7bc5b0d5 100644
--- a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js
+++ b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js
@@ -29,7 +29,7 @@ describe('TokenAccessHandler', function () {
this.project = {
_id: this.projectId,
publicAccesLevel: 'tokenBased',
- owner_ref: ObjectId()
+ owner_ref: ObjectId(),
}
this.userId = ObjectId()
this.req = {}
@@ -40,13 +40,13 @@ describe('TokenAccessHandler', function () {
'settings-sharelatex': (this.settings = {}),
'../User/UserGetter': (this.UserGetter = {}),
'../V1/V1Api': (this.V1Api = {
- request: sinon.stub()
+ request: sinon.stub(),
}),
crypto: (this.Crypto = require('crypto')),
'../Analytics/AnalyticsManager': (this.Analytics = {
- recordEvent: sinon.stub()
- })
- }
+ recordEvent: sinon.stub(),
+ }),
+ },
}))
})
@@ -58,7 +58,7 @@ describe('TokenAccessHandler', function () {
'54325aaaaaa': 'readAndWrite',
'54325aaaaaabbbbbb': 'readAndWrite',
'': null,
- abc123def: null
+ abc123def: null,
}
for (var token of Object.keys(specs)) {
expect(this.TokenAccessHandler.getTokenType(token)).to.equal(
@@ -93,7 +93,7 @@ describe('TokenAccessHandler', function () {
this.token = '1234abcdefabcdef'
this.project.tokens = {
readAndWrite: this.token,
- readAndWritePrefix: '1234'
+ readAndWritePrefix: '1234',
}
this.Project.findOne = sinon.stub().callsArgWith(2, null, this.project)
})
@@ -132,7 +132,7 @@ describe('TokenAccessHandler', function () {
expect(this.Project.updateOne.callCount).to.equal(1)
expect(
this.Project.updateOne.calledWith({
- _id: this.projectId
+ _id: this.projectId,
})
).to.equal(true)
expect(
@@ -193,7 +193,7 @@ describe('TokenAccessHandler', function () {
expect(this.Project.updateOne.callCount).to.equal(1)
expect(
this.Project.updateOne.calledWith({
- _id: this.projectId
+ _id: this.projectId,
})
).to.equal(true)
expect(
@@ -521,8 +521,8 @@ describe('TokenAccessHandler', function () {
tokens: {
readAndWrite: 'rw',
readOnly: 'ro',
- readAndWritePrefix: 'pre'
- }
+ readAndWritePrefix: 'pre',
+ },
})
})
@@ -564,7 +564,7 @@ describe('TokenAccessHandler', function () {
expect(this.V1Api.request.called).to.equal(false)
return expect(
this.callback.calledWith(null, {
- allow: true
+ allow: true,
})
).to.equal(true)
})
@@ -589,7 +589,7 @@ describe('TokenAccessHandler', function () {
it('should return response body', function () {
expect(
this.V1Api.request.calledWith({
- url: `/api/v1/sharelatex/docs/${this.token}/is_published`
+ url: `/api/v1/sharelatex/docs/${this.token}/is_published`,
})
).to.equal(true)
return expect(this.callback.calledWith(null, 'mock-data')).to.equal(
@@ -634,7 +634,7 @@ describe('TokenAccessHandler', function () {
return expect(
this.callback.calledWith(null, {
exists: true,
- exported: false
+ exported: false,
})
).to.equal(true)
})
@@ -648,7 +648,7 @@ describe('TokenAccessHandler', function () {
describe('on UserGetter.getUser success', function () {
beforeEach(function () {
this.UserGetter.getUser = sinon.stub().yields(null, {
- overleaf: { id: 1 }
+ overleaf: { id: 1 },
})
return this.TokenAccessHandler.getV1DocInfo(
this.token,
@@ -684,7 +684,7 @@ describe('TokenAccessHandler', function () {
beforeEach(function () {
this.v1UserId = 1
this.UserGetter.getUser = sinon.stub().yields(null, {
- overleaf: { id: this.v1UserId }
+ overleaf: { id: this.v1UserId },
})
this.V1Api.request = sinon
.stub()
@@ -699,7 +699,7 @@ describe('TokenAccessHandler', function () {
it('should return response body', function () {
expect(
this.V1Api.request.calledWith({
- url: `/api/v1/sharelatex/users/${this.v1UserId}/docs/${this.token}/info`
+ url: `/api/v1/sharelatex/users/${this.v1UserId}/docs/${this.token}/info`,
})
).to.equal(true)
return expect(this.callback.calledWith(null, 'mock-data')).to.equal(
@@ -711,7 +711,7 @@ describe('TokenAccessHandler', function () {
describe('on V1Api.request error', function () {
beforeEach(function () {
this.UserGetter.getUser = sinon.stub().yields(null, {
- overleaf: { id: 1 }
+ overleaf: { id: 1 },
})
this.V1Api.request = sinon.stub().callsArgWith(1, 'error')
return this.TokenAccessHandler.getV1DocInfo(
diff --git a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js
index 7cbc61afb8..39ca0441c6 100644
--- a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js
+++ b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js
@@ -31,7 +31,7 @@ describe('ArchiveManager', function () {
}
Timer.initClass()
return Timer
- })())
+ })()),
}
this.zipfile = new events.EventEmitter()
this.zipfile.readEntry = sinon.stub()
@@ -41,13 +41,13 @@ describe('ArchiveManager', function () {
requires: {
'settings-sharelatex': {},
yauzl: (this.yauzl = {
- open: sinon.stub().callsArgWith(2, null, this.zipfile)
+ open: sinon.stub().callsArgWith(2, null, this.zipfile),
}),
'@overleaf/metrics': this.metrics,
fs: (this.fs = {}),
'fs-extra': (this.fse = {}),
- './ArchiveErrors': ArchiveErrors
- }
+ './ArchiveErrors': ArchiveErrors,
+ },
})
return (this.callback = sinon.stub())
})
@@ -283,10 +283,10 @@ describe('ArchiveManager', function () {
it('should read the file entry with its original path', function () {
this.zipfile.openReadStream.should.be.calledWith({
- fileName: 'wombat\\foo.tex'
+ fileName: 'wombat\\foo.tex',
})
return this.zipfile.openReadStream.should.be.calledWith({
- fileName: 'potato\\bar.tex'
+ fileName: 'potato\\bar.tex',
})
})
@@ -518,7 +518,7 @@ describe('ArchiveManager', function () {
this.fs.stat.callsArgWith(1, null, {
isDirectory() {
return false
- }
+ },
})
return this.ArchiveManager.findTopLevelDirectory(
this.directory,
@@ -543,7 +543,7 @@ describe('ArchiveManager', function () {
this.fs.stat.callsArgWith(1, null, {
isDirectory() {
return true
- }
+ },
})
return this.ArchiveManager.findTopLevelDirectory(
this.directory,
diff --git a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js
index c17e8291a1..041d672c2a 100644
--- a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js
+++ b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js
@@ -20,13 +20,13 @@ describe('FileSystemImportManager', function () {
addFile: sinon.stub().resolves(),
upsertDoc: sinon.stub().resolves(),
upsertFile: sinon.stub().resolves(),
- addFolder: sinon.stub().resolves({ _id: this.newFolderId })
- }
+ addFolder: sinon.stub().resolves({ _id: this.newFolderId }),
+ },
}
this.FileSystemImportManager = SandboxedModule.require(MODULE_PATH, {
requires: {
- '../Editor/EditorController': this.EditorController
- }
+ '../Editor/EditorController': this.EditorController,
+ },
})
})
@@ -38,20 +38,20 @@ describe('FileSystemImportManager', function () {
'link-to-main.tex': mockFs.symlink({ path: 'import-test/main.tex' }),
'.DS_Store': 'Should be ignored',
images: {
- 'cat.jpg': Buffer.from([1, 2, 3, 4])
+ 'cat.jpg': Buffer.from([1, 2, 3, 4]),
},
'line-endings': {
'unix.txt': 'one\ntwo\nthree',
'mac.txt': 'uno\rdos\rtres',
'windows.txt': 'ein\r\nzwei\r\ndrei',
- 'mixed.txt': 'uno\rdue\r\ntre\nquattro'
+ 'mixed.txt': 'uno\rdue\r\ntre\nquattro',
},
encodings: {
'utf16le.txt': Buffer.from('\ufeffétonnant!', 'utf16le'),
- 'latin1.txt': Buffer.from('tétanisant!', 'latin1')
- }
+ 'latin1.txt': Buffer.from('tétanisant!', 'latin1'),
+ },
},
- symlink: mockFs.symlink({ path: 'import-test' })
+ symlink: mockFs.symlink({ path: 'import-test' }),
})
this.entries = await this.FileSystemImportManager.promises.importDir(
'import-test'
@@ -67,7 +67,7 @@ describe('FileSystemImportManager', function () {
expect(this.entries).to.deep.include({
type: 'doc',
projectPath: '/main.tex',
- lines: ['My thesis']
+ lines: ['My thesis'],
})
})
@@ -83,7 +83,7 @@ describe('FileSystemImportManager', function () {
expect(this.entries).to.deep.include({
type: 'file',
projectPath: '/images/cat.jpg',
- fsPath: 'import-test/images/cat.jpg'
+ fsPath: 'import-test/images/cat.jpg',
})
})
@@ -91,22 +91,22 @@ describe('FileSystemImportManager', function () {
expect(this.entries).to.deep.include({
type: 'doc',
projectPath: '/line-endings/unix.txt',
- lines: ['one', 'two', 'three']
+ lines: ['one', 'two', 'three'],
})
expect(this.entries).to.deep.include({
type: 'doc',
projectPath: '/line-endings/mac.txt',
- lines: ['uno', 'dos', 'tres']
+ lines: ['uno', 'dos', 'tres'],
})
expect(this.entries).to.deep.include({
type: 'doc',
projectPath: '/line-endings/windows.txt',
- lines: ['ein', 'zwei', 'drei']
+ lines: ['ein', 'zwei', 'drei'],
})
expect(this.entries).to.deep.include({
type: 'doc',
projectPath: '/line-endings/mixed.txt',
- lines: ['uno', 'due', 'tre', 'quattro']
+ lines: ['uno', 'due', 'tre', 'quattro'],
})
})
@@ -114,7 +114,7 @@ describe('FileSystemImportManager', function () {
expect(this.entries).to.deep.include({
type: 'doc',
projectPath: '/encodings/latin1.txt',
- lines: ['tétanisant!']
+ lines: ['tétanisant!'],
})
})
@@ -122,7 +122,7 @@ describe('FileSystemImportManager', function () {
expect(this.entries).to.deep.include({
type: 'doc',
projectPath: '/encodings/utf16le.txt',
- lines: ['\ufeffétonnant!']
+ lines: ['\ufeffétonnant!'],
})
})
@@ -140,10 +140,10 @@ describe('FileSystemImportManager', function () {
to: {
folder: {
'doc.tex': 'one\ntwo\nthree',
- 'image.jpg': Buffer.from([1, 2, 3, 4])
- }
- }
- }
+ 'image.jpg': Buffer.from([1, 2, 3, 4]),
+ },
+ },
+ },
})
await this.FileSystemImportManager.promises.addEntity(
@@ -253,14 +253,14 @@ describe('FileSystemImportManager', function () {
for (const [lineEndingDescription, lineEnding] of [
['Unix', '\n'],
['Mac', '\r'],
- ['Windows', '\r\n']
+ ['Windows', '\r\n'],
]) {
describe(`with text file (${lineEndingDescription} line endings)`, function () {
beforeEach(function () {
mockFs({
path: {
- to: { 'uploaded-file': `one${lineEnding}two${lineEnding}three` }
- }
+ to: { 'uploaded-file': `one${lineEnding}two${lineEnding}three` },
+ },
})
})
@@ -321,7 +321,7 @@ describe('FileSystemImportManager', function () {
describe('with symlink', function () {
beforeEach(function () {
mockFs({
- path: { to: { symlink: mockFs.symlink({ path: '/etc/passwd' }) } }
+ path: { to: { symlink: mockFs.symlink({ path: '/etc/passwd' }) } },
})
})
diff --git a/services/web/test/unit/src/Uploads/FileTypeManagerTests.js b/services/web/test/unit/src/Uploads/FileTypeManagerTests.js
index 72517600e8..144cb60099 100644
--- a/services/web/test/unit/src/Uploads/FileTypeManagerTests.js
+++ b/services/web/test/unit/src/Uploads/FileTypeManagerTests.js
@@ -10,12 +10,12 @@ describe('FileTypeManager', function () {
this.isUtf8 = sinon.spy(isUtf8)
this.stats = {
isDirectory: sinon.stub().returns(false),
- size: 100
+ size: 100,
}
const fileContents = 'Ich bin eine kleine Teekanne, kurz und kräftig.'
this.fs = {
stat: sinon.stub().yields(null, this.stats),
- readFile: sinon.stub()
+ readFile: sinon.stub(),
}
this.fs.readFile
.withArgs('utf8.tex')
@@ -44,8 +44,8 @@ describe('FileTypeManager', function () {
requires: {
fs: this.fs,
'utf-8-validate': this.isUtf8,
- 'settings-sharelatex': Settings
- }
+ 'settings-sharelatex': Settings,
+ },
})
})
@@ -87,7 +87,7 @@ describe('FileTypeManager', function () {
'file.bbx',
'file.cbx',
'file.m',
- 'file.TEX'
+ 'file.TEX',
]
TEXT_FILENAMES.forEach(filename => {
it(`should classify ${filename} as text`, function (done) {
diff --git a/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js b/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js
index 1f06df3e5e..532b86379f 100644
--- a/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js
+++ b/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js
@@ -35,10 +35,10 @@ describe('ProjectUploadController', function () {
}
Timer.initClass()
return Timer
- })())
+ })()),
}
this.AuthenticationController = {
- getLoggedInUserId: sinon.stub().returns(this.user_id)
+ getLoggedInUserId: sinon.stub().returns(this.user_id),
}
return (this.ProjectUploadController = SandboxedModule.require(modulePath, {
@@ -51,8 +51,8 @@ describe('ProjectUploadController', function () {
'../Authentication/AuthenticationController': this
.AuthenticationController,
'./ArchiveErrors': ArchiveErrors,
- fs: (this.fs = {})
- }
+ fs: (this.fs = {}),
+ },
}))
})
@@ -62,12 +62,12 @@ describe('ProjectUploadController', function () {
this.name = 'filename.zip'
this.req.file = {
path: this.path,
- originalname: this.name
+ originalname: this.name,
}
this.req.session = {
user: {
- _id: this.user_id
- }
+ _id: this.user_id,
+ },
}
this.project = { _id: (this.project_id = 'project-id-123') }
@@ -103,7 +103,7 @@ describe('ProjectUploadController', function () {
it('should return a successful response to the FileUploader client', function () {
return expect(this.res.body).to.deep.equal({
success: true,
- project_id: this.project_id
+ project_id: this.project_id,
})
})
@@ -146,7 +146,7 @@ describe('ProjectUploadController', function () {
it('should return the reported error to the FileUploader client', function () {
expect(JSON.parse(this.res.body)).to.deep.equal({
success: false,
- error: 'zip_contents_too_large'
+ error: 'zip_contents_too_large',
})
})
@@ -164,12 +164,12 @@ describe('ProjectUploadController', function () {
this.name = 'filename.png'
this.req.file = {
path: this.path,
- originalname: this.name
+ originalname: this.name,
}
this.req.session = {
user: {
- _id: this.user_id
- }
+ _id: this.user_id,
+ },
}
this.req.params = { Project_id: this.project_id }
this.req.query = { folder_id: this.folder_id }
@@ -180,7 +180,7 @@ describe('ProjectUploadController', function () {
beforeEach(function () {
this.entity = {
_id: '1234',
- type: 'file'
+ type: 'file',
}
this.FileSystemImportManager.addEntity = sinon
.stub()
@@ -204,7 +204,7 @@ describe('ProjectUploadController', function () {
return expect(this.res.body).to.deep.equal({
success: true,
entity_id: this.entity._id,
- entity_type: 'file'
+ entity_type: 'file',
})
})
@@ -227,7 +227,7 @@ describe('ProjectUploadController', function () {
it('should return an unsuccessful response to the FileUploader client', function () {
return expect(this.res.body).to.deep.equal({
- success: false
+ success: false,
})
})
})
@@ -243,7 +243,7 @@ describe('ProjectUploadController', function () {
it('should return an unsuccessful response to the FileUploader client', function () {
return expect(this.res.body).to.deep.equal({
success: false,
- error: 'project_has_too_many_files'
+ error: 'project_has_too_many_files',
})
})
})
@@ -256,7 +256,7 @@ describe('ProjectUploadController', function () {
it('should return a a non success response', function () {
return expect(this.res.body).to.deep.equal({
- success: false
+ success: false,
})
})
})
diff --git a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js
index 2abe4b45c0..125236937c 100644
--- a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js
+++ b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js
@@ -22,17 +22,17 @@ describe('ProjectUploadManager', function () {
this.project = {
_id: new ObjectId(),
rootFolder: [{ _id: this.rootFolderId }],
- overleaf: { history: { id: 12345 } }
+ overleaf: { history: { id: 12345 } },
}
this.doc = {
_id: new ObjectId(),
- name: 'main.tex'
+ name: 'main.tex',
}
this.docFsPath = '/path/to/doc'
this.docLines = ['My thesis', 'by A. U. Thor']
this.file = {
_id: new ObjectId(),
- name: 'image.png'
+ name: 'image.png',
}
this.fileFsPath = '/path/to/file'
@@ -42,27 +42,27 @@ describe('ProjectUploadManager', function () {
{
type: 'doc',
projectPath: '/main.tex',
- lines: this.docLines
+ lines: this.docLines,
},
{
type: 'file',
projectPath: `/${this.file.name}`,
- fsPath: this.fileFsPath
- }
+ fsPath: this.fileFsPath,
+ },
]
this.docEntries = [
{
doc: this.doc,
path: `/${this.doc.name}`,
- docLines: this.docLines.join('\n')
- }
+ docLines: this.docLines.join('\n'),
+ },
]
this.fileEntries = [
- { file: this.file, path: `/${this.file.name}`, url: this.fileStoreUrl }
+ { file: this.file, path: `/${this.file.name}`, url: this.fileStoreUrl },
]
this.fs = {
- remove: sinon.stub().resolves()
+ remove: sinon.stub().resolves(),
}
this.ArchiveManager = {
promises: {
@@ -70,50 +70,50 @@ describe('ProjectUploadManager', function () {
findTopLevelDirectory: sinon
.stub()
.withArgs(this.extractedZipPath)
- .resolves(this.topLevelDestination)
- }
+ .resolves(this.topLevelDestination),
+ },
}
this.Doc = sinon.stub().returns(this.doc)
this.DocstoreManager = {
promises: {
- updateDoc: sinon.stub().resolves()
- }
+ updateDoc: sinon.stub().resolves(),
+ },
}
this.DocumentHelper = {
getTitleFromTexContent: sinon
.stub()
.withArgs(this.mainContent)
- .returns(this.projectName)
+ .returns(this.projectName),
}
this.DocumentUpdaterHandler = {
promises: {
- updateProjectStructure: sinon.stub().resolves()
- }
+ updateProjectStructure: sinon.stub().resolves(),
+ },
}
this.FileStoreHandler = {
promises: {
uploadFileFromDisk: sinon
.stub()
- .resolves({ fileRef: this.file, url: this.fileStoreUrl })
- }
+ .resolves({ fileRef: this.file, url: this.fileStoreUrl }),
+ },
}
this.FileSystemImportManager = {
promises: {
importDir: sinon
.stub()
.withArgs(this.topLevelDestination)
- .resolves(this.importEntries)
- }
+ .resolves(this.importEntries),
+ },
}
this.ProjectCreationHandler = {
promises: {
- createBlankProject: sinon.stub().resolves(this.project)
- }
+ createBlankProject: sinon.stub().resolves(this.project),
+ },
}
this.ProjectEntityMongoUpdateHandler = {
promises: {
- createNewFolderStructure: sinon.stub().resolves(this.newProjectVersion)
- }
+ createNewFolderStructure: sinon.stub().resolves(this.newProjectVersion),
+ },
}
this.ProjectRootDocManager = {
promises: {
@@ -121,8 +121,8 @@ describe('ProjectUploadManager', function () {
findRootDocFileFromDirectory: sinon
.stub()
.resolves({ path: 'main.tex', content: this.mainContent }),
- setRootDocFromName: sinon.stub().resolves()
- }
+ setRootDocFromName: sinon.stub().resolves(),
+ },
}
this.ProjectDetailsHandler = {
fixProjectName: sinon
@@ -130,18 +130,18 @@ describe('ProjectUploadManager', function () {
.withArgs(this.projectName)
.returns(this.fixedProjectName),
promises: {
- generateUniqueName: sinon.stub().resolves(this.uniqueProjectName)
- }
+ generateUniqueName: sinon.stub().resolves(this.uniqueProjectName),
+ },
}
this.ProjectDeleter = {
promises: {
- deleteProject: sinon.stub().resolves()
- }
+ deleteProject: sinon.stub().resolves(),
+ },
}
this.TpdsProjectFlusher = {
promises: {
- flushProjectToTpds: sinon.stub().resolves()
- }
+ flushProjectToTpds: sinon.stub().resolves(),
+ },
}
this.ProjectUploadManager = SandboxedModule.require(MODULE_PATH, {
@@ -161,8 +161,8 @@ describe('ProjectUploadManager', function () {
'../Project/ProjectRootDocManager': this.ProjectRootDocManager,
'../Project/ProjectDetailsHandler': this.ProjectDetailsHandler,
'../Project/ProjectDeleter': this.ProjectDeleter,
- '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher
- }
+ '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher,
+ },
})
})
@@ -210,7 +210,7 @@ describe('ProjectUploadManager', function () {
{
newDocs: this.docEntries,
newFiles: this.fileEntries,
- newProject: { version: this.newProjectVersion }
+ newProject: { version: this.newProjectVersion },
}
)
})
@@ -297,7 +297,7 @@ describe('ProjectUploadManager', function () {
{
newDocs: this.docEntries,
newFiles: this.fileEntries,
- newProject: { version: this.newProjectVersion }
+ newProject: { version: this.newProjectVersion },
}
)
})
diff --git a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js b/services/web/test/unit/src/User/SAMLIdentityManagerTests.js
index 969169e87b..82ef0b16c5 100644
--- a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js
+++ b/services/web/test/unit/src/User/SAMLIdentityManagerTests.js
@@ -14,86 +14,86 @@ describe('SAMLIdentityManager', function () {
_id: this.userId,
email: 'not-linked@overleaf.com',
emails: [{ email: 'not-linked@overleaf.com' }],
- samlIdentifiers: []
+ samlIdentifiers: [],
}
this.auditLog = {
initiatorId: this.userId,
- ipAddress: '0:0:0:0'
+ ipAddress: '0:0:0:0',
}
this.userAlreadyLinked = {
_id: '6005c7a012cbcaf771f4a106',
email: 'linked@overleaf.com',
emails: [{ email: 'linked@overleaf.com', samlProviderId: '1' }],
- samlIdentifiers: [{ externalUserId: 'linked-id', providerId: '1' }]
+ samlIdentifiers: [{ externalUserId: 'linked-id', providerId: '1' }],
}
this.userEmailExists = {
_id: '6005c7a012cbcaf771f4a107',
email: 'exists@overleaf.com',
emails: [{ email: 'exists@overleaf.com' }],
- samlIdentifiers: []
+ samlIdentifiers: [],
}
this.institution = {
- name: 'Overleaf University'
+ name: 'Overleaf University',
}
this.InstitutionsAPI = {
promises: {
addEntitlement: sinon.stub().resolves(),
- removeEntitlement: sinon.stub().resolves()
- }
+ removeEntitlement: sinon.stub().resolves(),
+ },
}
this.SAMLIdentityManager = SandboxedModule.require(modulePath, {
requires: {
'../Email/EmailHandler': (this.EmailHandler = {
- sendEmail: sinon.stub().yields()
+ sendEmail: sinon.stub().yields(),
}),
'../Notifications/NotificationsBuilder': (this.NotificationsBuilder = {
promises: {
redundantPersonalSubscription: sinon
.stub()
- .returns({ create: sinon.stub().resolves() })
- }
+ .returns({ create: sinon.stub().resolves() }),
+ },
}),
'../Subscription/SubscriptionLocator': (this.SubscriptionLocator = {
promises: {
- getUserIndividualSubscription: sinon.stub().resolves()
- }
+ getUserIndividualSubscription: sinon.stub().resolves(),
+ },
}),
'../../models/User': {
User: (this.User = {
findOneAndUpdate: sinon.stub().returns({
- exec: sinon.stub().resolves(this.user)
+ exec: sinon.stub().resolves(this.user),
}),
findOne: sinon.stub().returns({
- exec: sinon.stub().resolves()
+ exec: sinon.stub().resolves(),
}),
updateOne: sinon.stub().returns({
- exec: sinon.stub().resolves()
- })
- })
+ exec: sinon.stub().resolves(),
+ }),
+ }),
},
'../User/UserAuditLogHandler': (this.UserAuditLogHandler = {
promises: {
- addEntry: sinon.stub().resolves()
- }
+ addEntry: sinon.stub().resolves(),
+ },
}),
'../User/UserGetter': (this.UserGetter = {
getUser: sinon.stub(),
promises: {
getUser: sinon.stub().resolves(this.user),
getUserByAnyEmail: sinon.stub().resolves(),
- getUserFullEmails: sinon.stub().resolves()
- }
+ getUserFullEmails: sinon.stub().resolves(),
+ },
}),
'../User/UserUpdater': (this.UserUpdater = {
addEmailAddress: sinon.stub(),
promises: {
addEmailAddress: sinon.stub().resolves(),
confirmEmail: sinon.stub().resolves(),
- updateUser: sinon.stub().resolves()
- }
+ updateUser: sinon.stub().resolves(),
+ },
}),
- '../Institutions/InstitutionsAPI': this.InstitutionsAPI
- }
+ '../Institutions/InstitutionsAPI': this.InstitutionsAPI,
+ },
})
})
@@ -154,7 +154,7 @@ describe('SAMLIdentityManager', function () {
true,
{
intiatorId: '6005c75b12cbcaf771f4a105',
- ip: '0:0:0:0'
+ ip: '0:0:0:0',
}
)
} catch (e) {
@@ -171,8 +171,8 @@ describe('SAMLIdentityManager', function () {
this.UserGetter.promises.getUserByAnyEmail.resolves(this.user)
this.UserGetter.promises.getUserFullEmails.resolves([
{
- email: 'not-affiliated@overleaf.com'
- }
+ email: 'not-affiliated@overleaf.com',
+ },
])
})
@@ -188,7 +188,7 @@ describe('SAMLIdentityManager', function () {
true,
{
intiatorId: 'user-id-1',
- ip: '0:0:0:0'
+ ip: '0:0:0:0',
}
)
} catch (e) {
@@ -206,8 +206,8 @@ describe('SAMLIdentityManager', function () {
this.UserGetter.promises.getUserFullEmails.resolves([
{
email: 'affiliated@overleaf.com',
- affiliation: { institution: { id: '987' } }
- }
+ affiliation: { institution: { id: '987' } },
+ },
])
})
@@ -223,7 +223,7 @@ describe('SAMLIdentityManager', function () {
true,
{
intiatorId: 'user-id-1',
- ip: '0:0:0:0'
+ ip: '0:0:0:0',
}
)
} catch (e) {
@@ -256,7 +256,7 @@ describe('SAMLIdentityManager', function () {
true,
{
intiatorId: '6005c75b12cbcaf771f4a105',
- ip: '0:0:0:0'
+ ip: '0:0:0:0',
}
)
} catch (e) {
@@ -286,7 +286,7 @@ describe('SAMLIdentityManager', function () {
true,
{
intiatorId: '6005c75b12cbcaf771f4a105',
- ip: '0:0:0:0'
+ ip: '0:0:0:0',
}
)
} catch (e) {
@@ -296,7 +296,7 @@ describe('SAMLIdentityManager', function () {
this.UserGetter.promises.getUser
).to.have.been.calledWithMatch({
_id: ObjectId('6005c75b12cbcaf771f4a105'),
- 'samlIdentifiers.providerId': '123456'
+ 'samlIdentifiers.providerId': '123456',
})
expect(error).to.be.instanceof(Errors.SAMLAlreadyLinkedError)
expect(this.User.findOneAndUpdate).to.not.have.been.called
@@ -318,7 +318,7 @@ describe('SAMLIdentityManager', function () {
undefined,
{
intiatorId: '6005c75b12cbcaf771f4a105',
- ipAddress: '0:0:0:0'
+ ipAddress: '0:0:0:0',
}
)
} catch (e) {
@@ -342,7 +342,7 @@ describe('SAMLIdentityManager', function () {
it('should update the user audit log', function () {
const auditLog = {
intiatorId: '6005c75b12cbcaf771f4a105',
- ip: '0:0:0:0'
+ ip: '0:0:0:0',
}
this.SAMLIdentityManager.linkAccounts(
this.user._id,
@@ -363,7 +363,7 @@ describe('SAMLIdentityManager', function () {
{
institutionEmail: this.user.email,
providerId: '1',
- providerName: 'Overleaf University'
+ providerName: 'Overleaf University',
}
)
}
@@ -380,7 +380,7 @@ describe('SAMLIdentityManager', function () {
undefined,
{
intiatorId: '6005c75b12cbcaf771f4a105',
- ipAddress: '0:0:0:0'
+ ipAddress: '0:0:0:0',
},
() => {
expect(this.User.updateOne).to.have.been.called
@@ -417,7 +417,7 @@ describe('SAMLIdentityManager', function () {
{
institutionEmail: linkedEmail,
providerId: '1',
- providerName: 'Overleaf University'
+ providerName: 'Overleaf University',
}
)
})
@@ -431,14 +431,14 @@ describe('SAMLIdentityManager', function () {
this.auditLog
)
const query = {
- _id: this.user._id
+ _id: this.user._id,
}
const update = {
$pull: {
samlIdentifiers: {
- providerId: '1'
- }
- }
+ providerId: '1',
+ },
+ },
}
expect(this.User.updateOne).to.have.been.calledOnce.and.calledWithMatch(
query,
@@ -542,7 +542,7 @@ describe('SAMLIdentityManager', function () {
beforeEach(function () {
this.SubscriptionLocator.promises.getUserIndividualSubscription.resolves(
{
- planCode: 'professional'
+ planCode: 'professional',
}
)
})
diff --git a/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js b/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js
index 317bbceea2..6b10faf381 100644
--- a/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js
+++ b/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js
@@ -9,7 +9,7 @@ describe('ThirdPartyIdentityManager', function () {
this.userId = 'a1b2c3'
this.user = {
_id: this.userId,
- email: 'example@overleaf.com'
+ email: 'example@overleaf.com',
}
this.externalUserId = 'id789'
this.externalData = {}
@@ -17,28 +17,28 @@ describe('ThirdPartyIdentityManager', function () {
this.ThirdPartyIdentityManager = SandboxedModule.require(modulePath, {
requires: {
'../../../../app/src/Features/User/UserAuditLogHandler': (this.UserAuditLogHandler = {
- addEntry: sinon.stub().yields()
+ addEntry: sinon.stub().yields(),
}),
'../../../../app/src/Features/Email/EmailHandler': (this.EmailHandler = {
- sendEmail: sinon.stub().yields()
+ sendEmail: sinon.stub().yields(),
}),
'../../../../app/src/models/User': {
User: (this.User = {
findOneAndUpdate: sinon.stub().yields(undefined, this.user),
- findOne: sinon.stub().yields(undefined, undefined)
- })
+ findOne: sinon.stub().yields(undefined, undefined),
+ }),
},
'settings-sharelatex': {
oauthProviders: {
google: {
- name: 'Google'
+ name: 'Google',
},
orcid: {
- name: 'Orcid'
- }
- }
- }
- }
+ name: 'Orcid',
+ },
+ },
+ },
+ },
})
})
describe('getUser', function () {
@@ -51,7 +51,7 @@ describe('ThirdPartyIdentityManager', function () {
expect(error.message).to.equal('invalid SSO arguments')
expect(error.info).to.deep.equal({
externalUserId: undefined,
- providerId: undefined
+ providerId: undefined,
})
done()
}
@@ -113,7 +113,7 @@ describe('ThirdPartyIdentityManager', function () {
this.auditLog.initiatorId,
this.auditLog.ipAddress,
{
- providerId: 'google'
+ providerId: 'google',
}
)
})
@@ -151,7 +151,7 @@ describe('ThirdPartyIdentityManager', function () {
expect(this.logger.error.lastCall).to.be.calledWithExactly(
{
err: anError,
- userId: this.userId
+ userId: this.userId,
},
'could not send security alert email when Google account linked'
)
@@ -187,7 +187,7 @@ describe('ThirdPartyIdentityManager', function () {
this.auditLog.initiatorId,
this.auditLog.ipAddress,
{
- providerId: 'orcid'
+ providerId: 'orcid',
}
)
})
@@ -222,7 +222,7 @@ describe('ThirdPartyIdentityManager', function () {
expect(this.logger.error.lastCall).to.be.calledWithExactly(
{
err: anError,
- userId: this.userId
+ userId: this.userId,
},
'could not send security alert email when Google account no longer linked'
)
diff --git a/services/web/test/unit/src/User/UserAuditLogHandlerTests.js b/services/web/test/unit/src/User/UserAuditLogHandlerTests.js
index d37ab18337..a2c6c95d5a 100644
--- a/services/web/test/unit/src/User/UserAuditLogHandlerTests.js
+++ b/services/web/test/unit/src/User/UserAuditLogHandlerTests.js
@@ -17,17 +17,17 @@ describe('UserAuditLogHandler', function () {
sessions: [
{
ip_address: '0:0:0:0',
- session_created: '2020-07-15T16:07:57.652Z'
- }
- ]
+ session_created: '2020-07-15T16:07:57.652Z',
+ },
+ ],
},
- ip: '0:0:0:0'
+ ip: '0:0:0:0',
}
this.UserMock = sinon.mock(User)
this.UserAuditLogHandler = SandboxedModule.require(MODULE_PATH, {
requires: {
- '../../models/User': { User }
- }
+ '../../models/User': { User },
+ },
})
})
diff --git a/services/web/test/unit/src/User/UserControllerTests.js b/services/web/test/unit/src/User/UserControllerTests.js
index 7c1a57e437..7ce628a735 100644
--- a/services/web/test/unit/src/User/UserControllerTests.js
+++ b/services/web/test/unit/src/User/UserControllerTests.js
@@ -13,7 +13,7 @@ describe('UserController', function () {
_id: this.user_id,
email: 'email@overleaf.com',
save: sinon.stub().callsArgWith(0),
- ace: {}
+ ace: {},
}
this.req = {
@@ -22,22 +22,22 @@ describe('UserController', function () {
destroy() {},
user: {
_id: this.user_id,
- email: 'old@something.com'
- }
+ email: 'old@something.com',
+ },
},
sessionID: '123',
body: {},
i18n: {
- translate: text => text
+ translate: text => text,
},
ip: '0:0:0:0',
- query: {}
+ query: {},
}
this.UserDeleter = { deleteUser: sinon.stub().yields() }
this.UserGetter = {
getUser: sinon.stub().callsArgWith(1, null, this.user),
- promises: { getUser: sinon.stub().resolves(this.user) }
+ promises: { getUser: sinon.stub().resolves(this.user) },
}
this.User = { findById: sinon.stub().callsArgWith(1, null, this.user) }
this.NewsLetterManager = { unsubscribe: sinon.stub().callsArgWith(1) }
@@ -46,22 +46,22 @@ describe('UserController', function () {
establishUserSession: sinon.stub().callsArg(2),
getLoggedInUserId: sinon.stub().returns(this.user._id),
getSessionUser: sinon.stub().returns(this.req.session.user),
- setInSessionUser: sinon.stub()
+ setInSessionUser: sinon.stub(),
}
this.AuthenticationManager = {
authenticate: sinon.stub(),
validatePassword: sinon.stub(),
promises: {
authenticate: sinon.stub(),
- setUserPassword: sinon.stub()
- }
+ setUserPassword: sinon.stub(),
+ },
}
this.UserUpdater = {
changeEmailAddress: sinon.stub(),
promises: {
confirmEmail: sinon.stub().resolves(),
- addAffiliationForNewUser: sinon.stub().resolves()
- }
+ addAffiliationForNewUser: sinon.stub().resolves(),
+ },
}
this.settings = { siteUrl: 'sharelatex.example.com' }
this.UserHandler = { populateTeamInvites: sinon.stub().callsArgWith(1) }
@@ -71,18 +71,18 @@ describe('UserController', function () {
revokeAllUserSessions: sinon.stub().callsArgWith(2, null),
promises: {
getAllUserSessions: sinon.stub().resolves(),
- revokeAllUserSessions: sinon.stub().resolves()
- }
+ revokeAllUserSessions: sinon.stub().resolves(),
+ },
}
this.HttpErrorHandler = {
badRequest: sinon.stub(),
conflict: sinon.stub(),
unprocessableEntity: sinon.stub(),
- legacyInternal: sinon.stub()
+ legacyInternal: sinon.stub(),
}
this.UrlHelper = {
- getSafeRedirectPath: sinon.stub()
+ getSafeRedirectPath: sinon.stub(),
}
this.UrlHelper.getSafeRedirectPath
.withArgs('https://evil.com')
@@ -96,7 +96,7 @@ describe('UserController', function () {
'./UserDeleter': this.UserDeleter,
'./UserUpdater': this.UserUpdater,
'../../models/User': {
- User: this.User
+ User: this.User,
},
'../Newsletter/NewsletterManager': this.NewsLetterManager,
'./UserRegistrationHandler': this.UserRegistrationHandler,
@@ -104,33 +104,33 @@ describe('UserController', function () {
.AuthenticationController,
'../Authentication/AuthenticationManager': this.AuthenticationManager,
'../../infrastructure/Features': (this.Features = {
- hasFeature: sinon.stub()
+ hasFeature: sinon.stub(),
}),
'./UserAuditLogHandler': (this.UserAuditLogHandler = {
promises: {
- addEntry: sinon.stub().resolves()
- }
+ addEntry: sinon.stub().resolves(),
+ },
}),
'./UserHandler': this.UserHandler,
'./UserSessionsManager': this.UserSessionsManager,
'../Errors/HttpErrorHandler': this.HttpErrorHandler,
'settings-sharelatex': this.settings,
'@overleaf/metrics': {
- inc() {}
+ inc() {},
},
'@overleaf/o-error': OError,
'../Email/EmailHandler': (this.EmailHandler = {
sendEmail: sinon.stub(),
- promises: { sendEmail: sinon.stub().resolves() }
- })
- }
+ promises: { sendEmail: sinon.stub().resolves() },
+ }),
+ },
})
this.res = {
send: sinon.stub(),
status: sinon.stub(),
sendStatus: sinon.stub(),
- json: sinon.stub()
+ json: sinon.stub(),
}
this.res.status.returns(this.res)
this.next = sinon.stub()
@@ -254,7 +254,7 @@ describe('UserController', function () {
expect(res).to.exist
expect(message).to.equal('error while deleting user account')
expect(info).to.deep.equal({
- error: 'SubscriptionAdminDeletionError'
+ error: 'SubscriptionAdminDeletionError',
})
done()
}
@@ -401,7 +401,7 @@ describe('UserController', function () {
.calledWith(this.req, {
email: this.newEmail,
first_name: undefined,
- last_name: undefined
+ last_name: undefined,
})
.should.equal(true)
done()
@@ -550,7 +550,7 @@ describe('UserController', function () {
this.res.json
.calledWith({
email: this.email,
- setNewPasswordUrl: this.url
+ setNewPasswordUrl: this.url,
})
.should.equal(true)
})
@@ -583,7 +583,7 @@ describe('UserController', function () {
const expectedArg = {
to: this.user.email,
actionDescribed: `active sessions were cleared on your account ${this.user.email}`,
- action: 'active sessions cleared'
+ action: 'active sessions cleared',
}
const emailCall = this.EmailHandler.promises.sendEmail.lastCall
expect(emailCall.args[0]).to.equal('securityAlert')
@@ -640,7 +640,7 @@ describe('UserController', function () {
const loggerCall = this.logger.error.getCall(0)
expect(loggerCall.args[0]).to.deep.equal({
error: anError,
- userId: this.user_id
+ userId: this.user_id,
})
expect(loggerCall.args[1]).to.contain(
'could not send security alert email when sessions cleared'
@@ -660,7 +660,7 @@ describe('UserController', function () {
this.AuthenticationManager.promises.setUserPassword.resolves()
this.req.body = {
newPassword1: 'newpass',
- newPassword2: 'newpass'
+ newPassword2: 'newpass',
}
})
it('should set the new password if they do match', function (done) {
@@ -695,7 +695,7 @@ describe('UserController', function () {
const expectedArg = {
to: this.user.email,
actionDescribed: `your password has been changed on your account ${this.user.email}`,
- action: 'password changed'
+ action: 'password changed',
}
const emailCall = this.EmailHandler.sendEmail.lastCall
expect(emailCall.args[0]).to.equal('securityAlert')
@@ -732,7 +732,7 @@ describe('UserController', function () {
this.AuthenticationManager.promises.authenticate.resolves({})
this.req.body = {
newPassword1: '1',
- newPassword2: '2'
+ newPassword2: '2',
}
this.HttpErrorHandler.badRequest.callsFake(() => {
expect(this.HttpErrorHandler.badRequest).to.have.been.calledWith(
@@ -758,7 +758,7 @@ describe('UserController', function () {
this.AuthenticationManager.promises.authenticate.resolves({})
this.req.body = {
newPassword1: 'newpass',
- newPassword2: 'newpass'
+ newPassword2: 'newpass',
}
this.HttpErrorHandler.badRequest.callsFake(() => {
expect(this.HttpErrorHandler.badRequest).to.have.been.calledWith(
@@ -781,7 +781,7 @@ describe('UserController', function () {
this.AuthenticationManager.promises.setUserPassword.resolves()
this.req.body = {
newPassword1: 'newpass',
- newPassword2: 'newpass'
+ newPassword2: 'newpass',
}
this.UserController.changePassword(this.req, this.res, error => {
@@ -801,7 +801,7 @@ describe('UserController', function () {
this.AuthenticationManager.promises.setUserPassword.resolves()
this.req.body = {
newPassword1: 'newpass',
- newPassword2: 'newpass'
+ newPassword2: 'newpass',
}
this.EmailHandler.sendEmail.yields(anError)
})
@@ -812,7 +812,7 @@ describe('UserController', function () {
expect(this.logger.error).to.have.been.calledWithExactly(
{
error: anError,
- userId: this.user_id
+ userId: this.user_id,
},
'could not send security alert email when password changed'
)
@@ -868,8 +868,8 @@ describe('UserController', function () {
this.user.email = email
this.user.emails = [
{
- email
- }
+ email,
+ },
]
this.Features.hasFeature.withArgs('affiliations').returns(true)
this.req.query.ensureAffiliation = true
@@ -900,8 +900,8 @@ describe('UserController', function () {
this.user.emails = [
{
email: emailFlagged,
- affiliationUnchecked: true
- }
+ affiliationUnchecked: true,
+ },
]
this.Features.hasFeature.withArgs('affiliations').returns(true)
this.req.query.ensureAffiliation = true
@@ -932,8 +932,8 @@ describe('UserController', function () {
{
email: emailFlagged,
affiliationUnchecked: true,
- samlProviderId: '123'
- }
+ samlProviderId: '123',
+ },
]
this.Features.hasFeature.withArgs('affiliations').returns(true)
this.req.query.ensureAffiliation = true
@@ -964,8 +964,8 @@ describe('UserController', function () {
this.user.emails = [
{
email: emailFlagged,
- affiliationUnchecked: true
- }
+ affiliationUnchecked: true,
+ },
]
this.Features.hasFeature.withArgs('affiliations').returns(true)
this.req.query.ensureAffiliation = true
diff --git a/services/web/test/unit/src/User/UserCreatorTests.js b/services/web/test/unit/src/User/UserCreatorTests.js
index 9059911203..b902a62125 100644
--- a/services/web/test/unit/src/User/UserCreatorTests.js
+++ b/services/web/test/unit/src/User/UserCreatorTests.js
@@ -17,37 +17,37 @@ describe('UserCreator', function () {
this.UserCreator = SandboxedModule.require(modulePath, {
requires: {
'../../models/User': {
- User: this.UserModel
+ User: this.UserModel,
},
'@overleaf/metrics': { timeAsyncMethod() {} },
'../../infrastructure/Features': (this.Features = {
- hasFeature: sinon.stub().returns(false)
+ hasFeature: sinon.stub().returns(false),
}),
'./UserDeleter': (this.UserDeleter = {
promises: {
- deleteNewUser: sinon.stub().resolves()
- }
+ deleteNewUser: sinon.stub().resolves(),
+ },
}),
'./UserGetter': (this.UserGetter = {
promises: {
- getUser: sinon.stub().resolves(this.user)
- }
+ getUser: sinon.stub().resolves(this.user),
+ },
}),
'./UserUpdater': (this.UserUpdater = {
promises: {
addAffiliationForNewUser: sinon
.stub()
.resolves({ n: 1, nModified: 1, ok: 1 }),
- updateUser: sinon.stub().resolves()
- }
+ updateUser: sinon.stub().resolves(),
+ },
}),
'../Analytics/AnalyticsManager': (this.Analytics = {
- recordEvent: sinon.stub()
+ recordEvent: sinon.stub(),
}),
'./UserOnboardingEmailManager': (this.UserOnboardingEmailManager = {
- scheduleOnboardingEmail: sinon.stub()
- })
- }
+ scheduleOnboardingEmail: sinon.stub(),
+ }),
+ },
})
this.email = 'bob.oswald@gmail.com'
@@ -58,7 +58,7 @@ describe('UserCreator', function () {
it('should take the opts and put them in the model', async function () {
const user = await this.UserCreator.promises.createNewUser({
email: this.email,
- holdingAccount: true
+ holdingAccount: true,
})
assert.equal(user.email, this.email)
assert.equal(user.holdingAccount, true)
@@ -69,7 +69,7 @@ describe('UserCreator', function () {
const user = await this.UserCreator.promises.createNewUser({
email: this.email,
holdingAccount: true,
- first_name: ''
+ first_name: '',
})
assert.equal(user.email, this.email)
assert.equal(user.holdingAccount, true)
@@ -80,7 +80,7 @@ describe('UserCreator', function () {
const user = await this.UserCreator.promises.createNewUser({
email: this.email,
holdingAccount: true,
- first_name: 'fiiirstname'
+ first_name: 'fiiirstname',
})
assert.equal(user.email, this.email)
assert.equal(user.holdingAccount, true)
@@ -91,7 +91,7 @@ describe('UserCreator', function () {
const user = await this.UserCreator.promises.createNewUser({
email: this.email,
holdingAccount: true,
- last_name: 'lastNammmmeee'
+ last_name: 'lastNammmmeee',
})
assert.equal(user.email, this.email)
assert.equal(user.holdingAccount, true)
@@ -100,7 +100,7 @@ describe('UserCreator', function () {
it('should set emails attribute', async function () {
const user = await this.UserCreator.promises.createNewUser({
- email: this.email
+ email: this.email,
})
user.email.should.equal(this.email)
user.emails.length.should.equal(1)
@@ -218,7 +218,7 @@ describe('UserCreator', function () {
it('should take the opts and put them in the model', async function () {
const opts = {
email: this.email,
- holdingAccount: true
+ holdingAccount: true,
}
const user = await this.UserCreator.promises.createNewUser(opts)
assert.equal(user.email, this.email)
@@ -255,7 +255,7 @@ describe('UserCreator', function () {
it('should include SAML provider ID with email', async function () {
const attributes = {
email: this.email,
- samlIdentifiers: [{ email: this.email, providerId: '1' }]
+ samlIdentifiers: [{ email: this.email, providerId: '1' }],
}
const user = await this.UserCreator.promises.createNewUser(attributes)
assert.equal(user.emails[0].samlProviderId, '1')
@@ -263,7 +263,7 @@ describe('UserCreator', function () {
it('should fire an analytics event on registration', async function () {
const user = await this.UserCreator.promises.createNewUser({
- email: this.email
+ email: this.email,
})
assert.equal(user.email, this.email)
sinon.assert.calledWith(
@@ -275,7 +275,7 @@ describe('UserCreator', function () {
it('should schedule an onboarding email on registration', async function () {
const user = await this.UserCreator.promises.createNewUser({
- email: this.email
+ email: this.email,
})
assert.equal(user.email, this.email)
sinon.assert.calledWith(
diff --git a/services/web/test/unit/src/User/UserDeleterTests.js b/services/web/test/unit/src/User/UserDeleterTests.js
index 3da498ab8e..584d0b6ede 100644
--- a/services/web/test/unit/src/User/UserDeleterTests.js
+++ b/services/web/test/unit/src/User/UserDeleterTests.js
@@ -27,61 +27,61 @@ describe('UserDeleter', function () {
signUpDate: Date.now() + 2000,
loginCount: 10,
overleaf: {
- id: 1234
+ id: 1234,
},
refered_users: ['wombat', 'potato'],
refered_user_count: 2,
- referal_id: ['giraffe']
+ referal_id: ['giraffe'],
})
)
this.user = this.mockedUser.object
this.NewsletterManager = {
promises: {
- unsubscribe: sinon.stub().resolves()
- }
+ unsubscribe: sinon.stub().resolves(),
+ },
}
this.ProjectDeleter = {
promises: {
- deleteUsersProjects: sinon.stub().resolves()
- }
+ deleteUsersProjects: sinon.stub().resolves(),
+ },
}
this.SubscriptionHandler = {
promises: {
- cancelSubscription: sinon.stub().resolves()
- }
+ cancelSubscription: sinon.stub().resolves(),
+ },
}
this.SubscriptionUpdater = {
promises: {
- removeUserFromAllGroups: sinon.stub().resolves()
- }
+ removeUserFromAllGroups: sinon.stub().resolves(),
+ },
}
this.SubscriptionLocator = {
promises: {
- getUsersSubscription: sinon.stub().resolves()
- }
+ getUsersSubscription: sinon.stub().resolves(),
+ },
}
this.UserMembershipsHandler = {
promises: {
- removeUserFromAllEntities: sinon.stub().resolves()
- }
+ removeUserFromAllEntities: sinon.stub().resolves(),
+ },
}
this.UserSessionsManager = {
promises: {
- revokeAllUserSessions: sinon.stub().resolves()
- }
+ revokeAllUserSessions: sinon.stub().resolves(),
+ },
}
this.InstitutionsApi = {
promises: {
- deleteAffiliations: sinon.stub().resolves()
- }
+ deleteAffiliations: sinon.stub().resolves(),
+ },
}
this.UserDeleter = SandboxedModule.require(modulePath, {
@@ -95,8 +95,8 @@ describe('UserDeleter', function () {
'../Subscription/SubscriptionLocator': this.SubscriptionLocator,
'../UserMembership/UserMembershipsHandler': this.UserMembershipsHandler,
'../Project/ProjectDeleter': this.ProjectDeleter,
- '../Institutions/InstitutionsAPI': this.InstitutionsApi
- }
+ '../Institutions/InstitutionsAPI': this.InstitutionsApi,
+ },
})
})
@@ -129,8 +129,8 @@ describe('UserDeleter', function () {
deletedUserReferralId: this.user.referal_id,
deletedUserReferredUsers: this.user.refered_users,
deletedUserReferredUserCount: this.user.refered_user_count,
- deletedUserOverleafId: this.user.overleaf.id
- }
+ deletedUserOverleafId: this.user.overleaf.id,
+ },
}
})
@@ -210,7 +210,7 @@ describe('UserDeleter', function () {
it('rejects if the user is a subscription admin', async function () {
this.SubscriptionLocator.promises.getUsersSubscription.rejects({
- _id: 'some-subscription'
+ _id: 'some-subscription',
})
await expect(this.UserDeleter.promises.deleteUser(this.userId)).to
.be.rejected
@@ -280,7 +280,7 @@ describe('UserDeleter', function () {
it('should add the deleted user id and ip address to the deletedUser', async function () {
await this.UserDeleter.promises.deleteUser(this.userId, {
deleterUser: { _id: this.deleterId },
- ipAddress: this.ipAddress
+ ipAddress: this.ipAddress,
})
this.DeletedUserMock.verify()
})
@@ -291,7 +291,7 @@ describe('UserDeleter', function () {
this.userId,
{
deleterUser: { _id: this.deleterId },
- ipAddress: this.ipAddress
+ ipAddress: this.ipAddress,
},
err => {
expect(err).not.to.exist
@@ -308,7 +308,7 @@ describe('UserDeleter', function () {
describe('when the user cannot be deleted because they are a subscription admin', function () {
beforeEach(function () {
this.SubscriptionLocator.promises.getUsersSubscription.resolves({
- _id: 'some-subscription'
+ _id: 'some-subscription',
})
})
@@ -347,7 +347,7 @@ describe('UserDeleter', function () {
it('should return custom error when user is group admin', async function () {
this.SubscriptionLocator.promises.getUsersSubscription.resolves({
- _id: '123abc'
+ _id: '123abc',
})
let error
try {
@@ -383,30 +383,30 @@ describe('UserDeleter', function () {
{
user: { _id: userId1 },
deleterData: { deletedUserId: userId1 },
- save: sinon.stub().resolves()
+ save: sinon.stub().resolves(),
},
{
user: { _id: userId2 },
deleterData: { deletedUserId: userId2 },
- save: sinon.stub().resolves()
- }
+ save: sinon.stub().resolves(),
+ },
]
this.DeletedUserMock.expects('find')
.withArgs({
'deleterData.deletedAt': {
- $lt: new Date(moment().subtract(90, 'days'))
+ $lt: new Date(moment().subtract(90, 'days')),
},
user: {
- $ne: null
- }
+ $ne: null,
+ },
})
.chain('exec')
.resolves(this.deletedUsers)
for (const deletedUser of this.deletedUsers) {
this.DeletedUserMock.expects('findOne')
.withArgs({
- 'deleterData.deletedUserId': deletedUser.deleterData.deletedUserId
+ 'deleterData.deletedUserId': deletedUser.deleterData.deletedUserId,
})
.chain('exec')
.resolves(deletedUser)
@@ -429,8 +429,8 @@ describe('UserDeleter', function () {
user: this.user,
deleterData: {
deleterIpAddress: '1.1.1.1',
- deletedUserId: this.userId
- }
+ deletedUserId: this.userId,
+ },
})
)
this.deletedUser = this.mockedDeletedUser.object
diff --git a/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js b/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js
index c7f4e292ca..c6e906a1f3 100644
--- a/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js
+++ b/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js
@@ -27,21 +27,21 @@ describe('UserEmailsConfirmationHandler', function () {
this.UserEmailsConfirmationHandler = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': (this.settings = {
- siteUrl: 'emails.example.com'
+ siteUrl: 'emails.example.com',
}),
'../Security/OneTimeTokenHandler': (this.OneTimeTokenHandler = {}),
'./UserUpdater': (this.UserUpdater = {}),
'./UserGetter': (this.UserGetter = {
- getUser: sinon.stub().yields(null, this.mockUser)
+ getUser: sinon.stub().yields(null, this.mockUser),
}),
'../Email/EmailHandler': (this.EmailHandler = {}),
- '../Helpers/EmailHelper': EmailHelper
- }
+ '../Helpers/EmailHelper': EmailHelper,
+ },
})
this.mockUser = {
_id: 'mock-user-id',
email: 'mock@example.com',
- emails: [{ email: 'mock@example.com' }]
+ emails: [{ email: 'mock@example.com' }],
}
this.user_id = this.mockUser._id
this.email = this.mockUser.email
@@ -81,7 +81,7 @@ describe('UserEmailsConfirmationHandler', function () {
to: this.email,
confirmEmailUrl:
'emails.example.com/user/emails/confirm?token=new-token',
- sendingUser_id: this.user_id
+ sendingUser_id: this.user_id,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/User/UserEmailsControllerTests.js b/services/web/test/unit/src/User/UserEmailsControllerTests.js
index 94f85fd858..93cc68d0d8 100644
--- a/services/web/test/unit/src/User/UserEmailsControllerTests.js
+++ b/services/web/test/unit/src/User/UserEmailsControllerTests.js
@@ -20,19 +20,19 @@ describe('UserEmailsController', function () {
getUserFullEmails: sinon.stub(),
getUserByAnyEmail: sinon.stub(),
promises: {
- getUser: sinon.stub().resolves(this.user)
- }
+ getUser: sinon.stub().resolves(this.user),
+ },
}
this.AuthenticationController = {
getSessionUser: sinon.stub().returns(this.user),
getLoggedInUserId: sinon.stub().returns(this.user._id),
- setInSessionUser: sinon.stub()
+ setInSessionUser: sinon.stub(),
}
this.Features = {
- hasFeature: sinon.stub()
+ hasFeature: sinon.stub(),
}
this.UserSessionsManager = {
- revokeAllUserSessions: sinon.stub().yields()
+ revokeAllUserSessions: sinon.stub().yields(),
}
this.UserUpdater = {
addEmailAddress: sinon.stub(),
@@ -40,13 +40,13 @@ describe('UserEmailsController', function () {
setDefaultEmailAddress: sinon.stub(),
updateV1AndSetDefaultEmailAddress: sinon.stub(),
promises: {
- addEmailAddress: sinon.stub().resolves()
- }
+ addEmailAddress: sinon.stub().resolves(),
+ },
}
this.EmailHelper = { parseEmail: sinon.stub() }
this.endorseAffiliation = sinon.stub().yields()
this.InstitutionsAPI = {
- endorseAffiliation: this.endorseAffiliation
+ endorseAffiliation: this.endorseAffiliation,
}
this.HttpErrorHandler = { conflict: sinon.stub() }
this.UserEmailsController = SandboxedModule.require(modulePath, {
@@ -59,19 +59,19 @@ describe('UserEmailsController', function () {
'./UserUpdater': this.UserUpdater,
'../Email/EmailHandler': (this.EmailHandler = {
promises: {
- sendEmail: sinon.stub().resolves()
- }
+ sendEmail: sinon.stub().resolves(),
+ },
}),
'../Helpers/EmailHelper': this.EmailHelper,
'./UserEmailsConfirmationHandler': (this.UserEmailsConfirmationHandler = {
sendReconfirmationEmail: sinon.stub(),
promises: {
- sendConfirmationEmail: sinon.stub().resolves()
- }
+ sendConfirmationEmail: sinon.stub().resolves(),
+ },
}),
'../Institutions/InstitutionsAPI': this.InstitutionsAPI,
- '../Errors/HttpErrorHandler': this.HttpErrorHandler
- }
+ '../Errors/HttpErrorHandler': this.HttpErrorHandler,
+ },
})
})
@@ -87,7 +87,7 @@ describe('UserEmailsController', function () {
assert.deepEqual(response, fullEmails)
assertCalledWith(this.UserGetter.getUserFullEmails, this.user._id)
done()
- }
+ },
})
})
})
@@ -99,7 +99,7 @@ describe('UserEmailsController', function () {
email: this.newEmail,
university: { name: 'University Name' },
department: 'Department',
- role: 'Role'
+ role: 'Role',
}
this.EmailHelper.parseEmail.returns(this.newEmail)
this.UserEmailsConfirmationHandler.sendConfirmationEmail = sinon
@@ -113,7 +113,7 @@ describe('UserEmailsController', function () {
const addCall = this.UserUpdater.promises.addEmailAddress.lastCall
expect(addCall.args[3]).to.deep.equal({
initiatorId: this.user._id,
- ipAddress: this.req.ip
+ ipAddress: this.req.ip,
})
done()
})
@@ -141,7 +141,7 @@ describe('UserEmailsController', function () {
affiliationOptions.role.should.equal(this.req.body.role)
done()
- }
+ },
},
this.next
)
@@ -176,7 +176,7 @@ describe('UserEmailsController', function () {
this.newEmail
)
done()
- }
+ },
},
this.next
)
@@ -191,7 +191,7 @@ describe('UserEmailsController', function () {
code.should.equal(422)
assertNotCalled(this.UserUpdater.promises.addEmailAddress)
done()
- }
+ },
},
this.next
)
@@ -252,7 +252,7 @@ describe('UserEmailsController', function () {
this.email
)
done()
- }
+ },
})
})
@@ -264,7 +264,7 @@ describe('UserEmailsController', function () {
code.should.equal(422)
assertNotCalled(this.UserUpdater.removeEmailAddress)
done()
- }
+ },
})
})
})
@@ -295,7 +295,7 @@ describe('UserEmailsController', function () {
this.email
)
done()
- }
+ },
})
})
@@ -307,7 +307,7 @@ describe('UserEmailsController', function () {
code.should.equal(422)
assertNotCalled(this.UserUpdater.setDefaultEmailAddress)
done()
- }
+ },
})
})
@@ -370,7 +370,7 @@ describe('UserEmailsController', function () {
'Department'
)
done()
- }
+ },
})
})
})
@@ -382,7 +382,7 @@ describe('UserEmailsController', function () {
.yields()
this.res = {
sendStatus: sinon.stub(),
- json: sinon.stub()
+ json: sinon.stub(),
}
this.res.status = sinon.stub().returns(this.res)
this.next = sinon.stub()
@@ -429,7 +429,7 @@ describe('UserEmailsController', function () {
this.res.status.calledWith(404).should.equal(true)
this.res.json
.calledWith({
- message: this.req.i18n.translate('confirmation_token_invalid')
+ message: this.req.i18n.translate('confirmation_token_invalid'),
})
.should.equal(true)
})
@@ -440,13 +440,13 @@ describe('UserEmailsController', function () {
beforeEach(function () {
this.EmailHelper.parseEmail.returnsArg(0)
this.UserGetter.getUserByAnyEmail.yields(undefined, {
- _id: this.user._id
+ _id: this.user._id,
})
this.req = {
- body: {}
+ body: {},
}
this.res = {
- sendStatus: sinon.stub()
+ sendStatus: sinon.stub(),
}
this.next = sinon.stub()
this.UserEmailsConfirmationHandler.sendConfirmationEmail = sinon
@@ -457,8 +457,8 @@ describe('UserEmailsController', function () {
it('should send the email', function (done) {
this.req = {
body: {
- email: 'test@example.com'
- }
+ email: 'test@example.com',
+ },
}
this.UserEmailsController.sendReconfirmation(
this.req,
@@ -472,7 +472,7 @@ describe('UserEmailsController', function () {
it('should return 422 if email not valid', function (done) {
this.req = {
- body: {}
+ body: {},
}
this.UserEmailsController.resendConfirmation(
this.req,
@@ -487,14 +487,14 @@ describe('UserEmailsController', function () {
describe('email on another user account', function () {
beforeEach(function () {
this.UserGetter.getUserByAnyEmail.yields(undefined, {
- _id: 'another-user-id'
+ _id: 'another-user-id',
})
})
it('should return 422', function (done) {
this.req = {
body: {
- email: 'test@example.com'
- }
+ email: 'test@example.com',
+ },
}
this.UserEmailsController.resendConfirmation(
this.req,
@@ -513,15 +513,15 @@ describe('UserEmailsController', function () {
beforeEach(function () {
this.res.sendStatus = sinon.stub()
this.UserGetter.getUserByAnyEmail.yields(undefined, {
- _id: this.user._id
+ _id: this.user._id,
})
this.EmailHelper.parseEmail.returnsArg(0)
})
it('should send the email', function (done) {
this.req = {
body: {
- email: 'test@example.com'
- }
+ email: 'test@example.com',
+ },
}
this.UserEmailsController.sendReconfirmation(
this.req,
@@ -534,7 +534,7 @@ describe('UserEmailsController', function () {
})
it('should return 400 if email not valid', function (done) {
this.req = {
- body: {}
+ body: {},
}
this.UserEmailsController.sendReconfirmation(
this.req,
@@ -549,14 +549,14 @@ describe('UserEmailsController', function () {
describe('email on another user account', function () {
beforeEach(function () {
this.UserGetter.getUserByAnyEmail.yields(undefined, {
- _id: 'another-user-id'
+ _id: 'another-user-id',
})
})
it('should return 422', function (done) {
this.req = {
body: {
- email: 'test@example.com'
- }
+ email: 'test@example.com',
+ },
}
this.UserEmailsController.sendReconfirmation(
this.req,
diff --git a/services/web/test/unit/src/User/UserGetterTests.js b/services/web/test/unit/src/User/UserGetterTests.js
index 03bd01c5bf..7285e4b21a 100644
--- a/services/web/test/unit/src/User/UserGetterTests.js
+++ b/services/web/test/unit/src/User/UserGetterTests.js
@@ -12,7 +12,7 @@ const { expect } = require('chai')
const Errors = require('../../../../app/src/Features/Errors/Errors')
const {
normalizeQuery,
- normalizeMultiQuery
+ normalizeMultiQuery,
} = require('../../../../app/src/Features/Helpers/Mongo')
describe('UserGetter', function () {
@@ -24,10 +24,10 @@ describe('UserGetter', function () {
{
email: 'email1@foo.bar',
reversedHostname: 'rab.oof',
- confirmedAt: new Date()
+ confirmedAt: new Date(),
},
- { email: 'email2@foo.bar', reversedHostname: 'rab.oof' }
- ]
+ { email: 'email2@foo.bar', reversedHostname: 'rab.oof' },
+ ],
}
this.findOne = sinon.stub().callsArgWith(2, null, this.fakeUser)
this.findToArrayStub = sinon.stub().yields(null, [this.fakeUser])
@@ -36,10 +36,10 @@ describe('UserGetter', function () {
db: {
users: {
findOne: this.findOne,
- find: this.find
- }
+ find: this.find,
+ },
},
- ObjectId
+ ObjectId,
}
this.getUserAffiliations = sinon.stub().resolves([])
@@ -48,20 +48,20 @@ describe('UserGetter', function () {
'../Helpers/Mongo': { normalizeQuery, normalizeMultiQuery },
'../../infrastructure/mongodb': this.Mongo,
'@overleaf/metrics': {
- timeAsyncMethod: sinon.stub()
+ timeAsyncMethod: sinon.stub(),
},
'settings-sharelatex': (this.settings = {
- reconfirmNotificationDays: 14
+ reconfirmNotificationDays: 14,
}),
'../Institutions/InstitutionsAPI': {
promises: {
- getUserAffiliations: this.getUserAffiliations
- }
+ getUserAffiliations: this.getUserAffiliations,
+ },
},
'../../infrastructure/Features': {
- hasFeature: sinon.stub().returns(true)
- }
- }
+ hasFeature: sinon.stub().returns(true),
+ },
+ },
})
})
@@ -140,14 +140,14 @@ describe('UserGetter', function () {
reversedHostname: 'rab.oof',
confirmedAt: this.fakeUser.emails[0].confirmedAt,
emailHasInstitutionLicence: false,
- default: false
+ default: false,
},
{
email: 'email2@foo.bar',
reversedHostname: 'rab.oof',
emailHasInstitutionLicence: false,
- default: true
- }
+ default: true,
+ },
])
done()
}
@@ -166,10 +166,10 @@ describe('UserGetter', function () {
institution: {
name: 'University Name',
isUniversity: true,
- confirmed: true
+ confirmed: true,
},
- portal: undefined
- }
+ portal: undefined,
+ },
]
this.getUserAffiliations.resolves(affiliationsData)
this.UserGetter.getUserFullEmails(
@@ -192,15 +192,15 @@ describe('UserGetter', function () {
licence: affiliationsData[0].licence,
inReconfirmNotificationPeriod: false,
pastReconfirmDate: false,
- portal: undefined
- }
+ portal: undefined,
+ },
},
{
email: 'email2@foo.bar',
reversedHostname: 'rab.oof',
emailHasInstitutionLicence: false,
- default: true
- }
+ default: true,
+ },
])
done()
}
@@ -209,7 +209,7 @@ describe('UserGetter', function () {
it('should merge SAML identifier', function (done) {
const fakeSamlIdentifiers = [
- { providerId: 'saml_id', exteranlUserId: 'whatever' }
+ { providerId: 'saml_id', exteranlUserId: 'whatever' },
]
const fakeUserWithSaml = this.fakeUser
fakeUserWithSaml.emails[0].samlProviderId = 'saml_id'
@@ -228,14 +228,14 @@ describe('UserGetter', function () {
default: false,
emailHasInstitutionLicence: false,
samlProviderId: 'saml_id',
- samlIdentifier: fakeSamlIdentifiers[0]
+ samlIdentifier: fakeSamlIdentifiers[0],
},
{
email: 'email2@foo.bar',
reversedHostname: 'rab.oof',
emailHasInstitutionLicence: false,
- default: true
- }
+ default: true,
+ },
])
done()
}
@@ -245,7 +245,7 @@ describe('UserGetter', function () {
it('should get user when it has no emails field', function (done) {
this.fakeUser = {
_id: '12390i',
- email: 'email2@foo.bar'
+ email: 'email2@foo.bar',
}
this.UserGetter.promises.getUser = sinon.stub().resolves(this.fakeUser)
const projection = { email: 1, emails: 1, samlIdentifiers: 1 }
@@ -272,7 +272,7 @@ describe('UserGetter', function () {
confirmed: true,
ssoBeta: false,
ssoEnabled: false,
- maxConfirmationMonths: 12
+ maxConfirmationMonths: 12,
}
const institutionSSO = {
id: 2,
@@ -281,7 +281,7 @@ describe('UserGetter', function () {
confirmed: true,
ssoBeta: false,
ssoEnabled: true,
- maxConfirmationMonths: 12
+ maxConfirmationMonths: 12,
}
describe('non-SSO institutions', function () {
const email1 = 'leonard@example-affiliation.com'
@@ -293,7 +293,7 @@ describe('UserGetter', function () {
department: 'Medicine',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
+ institution: institutionNonSSO,
},
{
email: email2,
@@ -301,8 +301,8 @@ describe('UserGetter', function () {
department: 'Medicine',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
- }
+ institution: institutionNonSSO,
+ },
]
it('should flag inReconfirmNotificationPeriod for all affiliations in period', function (done) {
const user = {
@@ -318,7 +318,7 @@ describe('UserGetter', function () {
'months'
)
.toDate(),
- default: true
+ default: true,
},
{
email: email2,
@@ -328,9 +328,9 @@ describe('UserGetter', function () {
institutionNonSSO.maxConfirmationMonths + 1,
'months'
)
- .toDate()
- }
- ]
+ .toDate(),
+ },
+ ],
}
this.getUserAffiliations.resolves(affiliationsData)
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
@@ -361,14 +361,14 @@ describe('UserGetter', function () {
email: email1,
reversedHostname: 'moc.noitailiffa-elpmaxe',
confirmedAt: new Date(),
- default: true
+ default: true,
},
{
email: email2,
reversedHostname: 'moc.noitailiffa-elpmaxe',
- confirmedAt: aboutToBeWithinPeriod
- }
- ]
+ confirmedAt: aboutToBeWithinPeriod,
+ },
+ ],
}
this.getUserAffiliations.resolves(affiliationsData)
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
@@ -401,7 +401,7 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionSSO
+ institution: institutionSSO,
},
{
email: email2,
@@ -409,7 +409,7 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionSSO
+ institution: institutionSSO,
},
{
email: email3,
@@ -417,8 +417,8 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionSSO
- }
+ institution: institutionSSO,
+ },
]
const user = {
@@ -430,28 +430,28 @@ describe('UserGetter', function () {
reversedHostname: 'rab.oss',
confirmedAt: new Date('2019-09-24'),
reconfirmedAt: new Date('2019-09-24'),
- default: true
+ default: true,
},
{
email: email2,
reversedHostname: 'rab.oss',
confirmedAt: new Date('2019-09-24'),
reconfirmedAt: new Date('2019-09-24'),
- samlProviderId: institutionSSO.id
+ samlProviderId: institutionSSO.id,
},
{
email: email3,
reversedHostname: 'rab.oss',
confirmedAt: new Date('2019-09-24'),
- reconfirmedAt: new Date('2019-09-24')
- }
+ reconfirmedAt: new Date('2019-09-24'),
+ },
],
samlIdentifiers: [
{
providerId: institutionSSO.id,
- externalUserId: 'abc123'
- }
- ]
+ externalUserId: 'abc123',
+ },
+ ],
}
this.getUserAffiliations.resolves(affiliationsData)
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
@@ -488,7 +488,7 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionSSO
+ institution: institutionSSO,
},
{
email: email2,
@@ -496,7 +496,7 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionSSO
+ institution: institutionSSO,
},
{
email: email3,
@@ -504,7 +504,7 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
+ institution: institutionNonSSO,
},
{
email: email4,
@@ -512,8 +512,8 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
- }
+ institution: institutionNonSSO,
+ },
]
const user = {
_id: '12390i',
@@ -523,31 +523,31 @@ describe('UserGetter', function () {
email: email1,
reversedHostname: 'rab.oss',
confirmedAt: '2019-09-24T20:25:08.503Z',
- default: true
+ default: true,
},
{
email: email2,
reversedHostname: 'rab.oss',
confirmedAt: new Date('2019-09-24T20:25:08.503Z'),
- samlProviderId: institutionSSO.id
+ samlProviderId: institutionSSO.id,
},
{
email: email3,
reversedHostname: 'rab.oof',
- confirmedAt: new Date('2019-10-24T20:25:08.503Z')
+ confirmedAt: new Date('2019-10-24T20:25:08.503Z'),
},
{
email: email4,
reversedHostname: 'rab.oof',
- confirmedAt: new Date('2019-09-24T20:25:08.503Z')
- }
+ confirmedAt: new Date('2019-09-24T20:25:08.503Z'),
+ },
],
samlIdentifiers: [
{
providerId: institutionSSO.id,
- externalUserId: 'abc123'
- }
- ]
+ externalUserId: 'abc123',
+ },
+ ],
}
this.getUserAffiliations.resolves(affiliationsData)
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
@@ -586,7 +586,7 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
+ institution: institutionNonSSO,
},
{
email: email2,
@@ -594,7 +594,7 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
+ institution: institutionNonSSO,
},
{
email: email3,
@@ -602,8 +602,8 @@ describe('UserGetter', function () {
department: 'Maths',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
- }
+ institution: institutionNonSSO,
+ },
]
const user = {
_id: '12390i',
@@ -620,7 +620,7 @@ describe('UserGetter', function () {
institutionSSO.maxConfirmationMonths * 3,
'months'
),
- default: true
+ default: true,
},
{
email: email2,
@@ -632,7 +632,7 @@ describe('UserGetter', function () {
reconfirmedAt: moment().subtract(
institutionSSO.maxConfirmationMonths * 2,
'months'
- )
+ ),
},
{
email: email3,
@@ -644,9 +644,9 @@ describe('UserGetter', function () {
reconfirmedAt: moment().subtract(
institutionSSO.maxConfirmationMonths * 4,
'months'
- )
- }
- ]
+ ),
+ },
+ ],
}
this.getUserAffiliations.resolves(affiliationsData)
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
@@ -683,8 +683,8 @@ describe('UserGetter', function () {
department: 'Medicine',
inferred: false,
licence: 'pro_plus',
- institution: institutionNonSSO
- }
+ institution: institutionNonSSO,
+ },
]
const user = {
_id: '12390i',
@@ -693,9 +693,9 @@ describe('UserGetter', function () {
{
email,
confirmedAt,
- default: true
- }
- ]
+ default: true,
+ },
+ ],
}
this.getUserAffiliations.resolves(affiliationsData)
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
@@ -725,16 +725,16 @@ describe('UserGetter', function () {
const affiliationsData = [
{
email: email1,
- institution: institutionSSO
+ institution: institutionSSO,
},
{
email: email2,
- institution: institutionNonSSO
+ institution: institutionNonSSO,
},
{
email: email3,
- institution: institutionNonSSO
- }
+ institution: institutionNonSSO,
+ },
]
const user = {
_id: '12390i',
@@ -744,23 +744,23 @@ describe('UserGetter', function () {
email: email1,
confirmedAt: confirmedAtAboutToExpire,
default: true,
- samlProviderId: institutionSSO.id
+ samlProviderId: institutionSSO.id,
},
{
email: email2,
- confirmedAt: new Date('2019-09-24T20:25:08.503Z')
+ confirmedAt: new Date('2019-09-24T20:25:08.503Z'),
},
{
email: email3,
- confirmedAt: new Date('2019-10-24T20:25:08.503Z')
- }
+ confirmedAt: new Date('2019-10-24T20:25:08.503Z'),
+ },
],
samlIdentifiers: [
{
providerId: institutionSSO.id,
- externalUserId: 'abc123'
- }
- ]
+ externalUserId: 'abc123',
+ },
+ ],
}
this.settings.reconfirmNotificationDays = undefined
this.getUserAffiliations.resolves(affiliationsData)
@@ -823,7 +823,7 @@ describe('UserGetter', function () {
const email = 'hello@world.com'
const expectedQuery = {
emails: { $exists: true },
- 'emails.email': email
+ 'emails.email': email,
}
const projection = { emails: 1 }
this.UserGetter.getUserByAnyEmail(
@@ -843,7 +843,7 @@ describe('UserGetter', function () {
it('query contains $exists:true so partial index is used', function (done) {
const expectedQuery = {
emails: { $exists: true },
- 'emails.email': ''
+ 'emails.email': '',
}
this.UserGetter.getUserByAnyEmail('', {}, (error, user) => {
expect(error).to.not.exist
@@ -876,7 +876,7 @@ describe('UserGetter', function () {
const hostname = 'bar.foo'
const expectedQuery = {
emails: { $exists: true },
- 'emails.reversedHostname': hostname.split('').reverse().join('')
+ 'emails.reversedHostname': hostname.split('').reverse().join(''),
}
const projection = { emails: 1 }
this.UserGetter.getUsersByHostname(
@@ -905,9 +905,9 @@ describe('UserGetter', function () {
$exists: true,
$elemMatch: {
email: { $in: emails },
- confirmedAt: { $exists: true }
- }
- }
+ confirmedAt: { $exists: true },
+ },
+ },
},
{ projection: {} }
)
@@ -920,7 +920,7 @@ describe('UserGetter', function () {
it('should find users by list of v1 ids', function (done) {
const v1Ids = [501]
const expectedQuery = {
- 'overleaf.id': { $in: v1Ids }
+ 'overleaf.id': { $in: v1Ids },
}
const projection = { emails: 1 }
this.UserGetter.getUsersByV1Ids(v1Ids, projection, (error, users) => {
diff --git a/services/web/test/unit/src/User/UserHandlerTests.js b/services/web/test/unit/src/User/UserHandlerTests.js
index ddd54e6550..d215c57f07 100644
--- a/services/web/test/unit/src/User/UserHandlerTests.js
+++ b/services/web/test/unit/src/User/UserHandlerTests.js
@@ -7,17 +7,17 @@ describe('UserHandler', function () {
this.user = {
_id: '12390i',
email: 'bob@bob.com',
- remove: sinon.stub().callsArgWith(0)
+ remove: sinon.stub().callsArgWith(0),
}
this.TeamInvitesHandler = {
- createTeamInvitesForLegacyInvitedEmail: sinon.stub().yields()
+ createTeamInvitesForLegacyInvitedEmail: sinon.stub().yields(),
}
this.UserHandler = SandboxedModule.require(modulePath, {
requires: {
- '../Subscription/TeamInvitesHandler': this.TeamInvitesHandler
- }
+ '../Subscription/TeamInvitesHandler': this.TeamInvitesHandler,
+ },
})
})
diff --git a/services/web/test/unit/src/User/UserInfoControllerTests.js b/services/web/test/unit/src/User/UserInfoControllerTests.js
index e34c773fe5..65b40cbb8a 100644
--- a/services/web/test/unit/src/User/UserInfoControllerTests.js
+++ b/services/web/test/unit/src/User/UserInfoControllerTests.js
@@ -26,7 +26,7 @@ describe('UserInfoController', function () {
this.sanitizer = {
escape(v) {
return v
- }
+ },
}
sinon.spy(this.sanitizer, 'escape')
this.UserGetter = {}
@@ -39,9 +39,9 @@ describe('UserInfoController', function () {
'./UserDeleter': this.UserDeleter,
sanitizer: this.sanitizer,
'../Authentication/AuthenticationController': (this.AuthenticationController = {
- getLoggedInUserId: sinon.stub()
- })
- }
+ getLoggedInUserId: sinon.stub(),
+ }),
+ },
})
this.req = new MockRequest()
@@ -110,8 +110,8 @@ describe('UserInfoController', function () {
this.user = {
_id: ObjectId(),
overleaf: {
- id: this.user_id
- }
+ id: this.user_id,
+ },
}
this.req.params = { user_id: this.user_id.toString() }
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, this.user)
@@ -180,13 +180,13 @@ describe('UserInfoController', function () {
_id: ObjectId(),
first_name: 'Douglas',
last_name: 'Adams',
- email: 'doug@sharelatex.com'
+ email: 'doug@sharelatex.com',
}
this.formattedInfo = {
id: this.user._id.toString(),
first_name: this.user.first_name,
last_name: this.user.last_name,
- email: this.user.email
+ email: this.user.email,
}
this.UserInfoController.formatPersonalInfo = sinon
.stub()
@@ -218,7 +218,7 @@ describe('UserInfoController', function () {
password: 'should-not-get-included',
signUpDate: new Date(),
role: 'student',
- institution: 'sheffield'
+ institution: 'sheffield',
}
return expect(
this.UserInfoController.formatPersonalInfo(this.user)
@@ -229,7 +229,7 @@ describe('UserInfoController', function () {
email: this.user.email,
signUpDate: this.user.signUpDate,
role: this.user.role,
- institution: this.user.institution
+ institution: this.user.institution,
})
})
})
diff --git a/services/web/test/unit/src/User/UserOnboardingEmailManagerTests.js b/services/web/test/unit/src/User/UserOnboardingEmailManagerTests.js
index 9e1f8933ba..0776b0eb9e 100644
--- a/services/web/test/unit/src/User/UserOnboardingEmailManagerTests.js
+++ b/services/web/test/unit/src/User/UserOnboardingEmailManagerTests.js
@@ -15,50 +15,50 @@ describe('UserOnboardingEmailManager', function () {
add: sinon.stub().resolves(),
process: callback => {
this.queueProcessFunction = callback
- }
+ },
}
const self = this
this.Queues = {
getOnboardingEmailsQueue: () => {
return self.onboardingEmailsQueue
- }
+ },
}
this.UserGetter = {
promises: {
getUser: sinon.stub().resolves({
_id: this.fakeUserId,
- email: this.fakeUserEmail
- })
- }
+ email: this.fakeUserEmail,
+ }),
+ },
}
this.EmailHandler = {
promises: {
- sendEmail: sinon.stub().resolves()
- }
+ sendEmail: sinon.stub().resolves(),
+ },
}
this.UserUpdater = {
promises: {
- updateUser: sinon.stub().resolves()
- }
+ updateUser: sinon.stub().resolves(),
+ },
}
this.request = sinon.stub().yields()
this.UserOnboardingEmailManager = SandboxedModule.require(MODULE_PATH, {
globals: {
- console: console
+ console: console,
},
requires: {
'../../infrastructure/Queues': this.Queues,
'../Email/EmailHandler': this.EmailHandler,
'./UserGetter': this.UserGetter,
- './UserUpdater': this.UserUpdater
- }
+ './UserUpdater': this.UserUpdater,
+ },
})
})
describe('schedule email', function () {
it('should schedule delayed job on queue', function () {
this.UserOnboardingEmailManager.scheduleOnboardingEmail({
- _id: this.fakeUserId
+ _id: this.fakeUserId,
})
sinon.assert.calledWith(
this.onboardingEmailsQueue.add,
@@ -78,14 +78,14 @@ describe('UserOnboardingEmailManager', function () {
this.EmailHandler.promises.sendEmail,
'userOnboardingEmail',
{
- to: this.fakeUserEmail
+ to: this.fakeUserEmail,
}
)
sinon.assert.calledWith(
this.UserUpdater.promises.updateUser,
this.fakeUserId,
{
- $set: { onboardingEmailSentAt: sinon.match.date }
+ $set: { onboardingEmailSentAt: sinon.match.date },
}
)
})
diff --git a/services/web/test/unit/src/User/UserPagesControllerTests.js b/services/web/test/unit/src/User/UserPagesControllerTests.js
index 86d14d359a..a09c8a0987 100644
--- a/services/web/test/unit/src/User/UserPagesControllerTests.js
+++ b/services/web/test/unit/src/User/UserPagesControllerTests.js
@@ -27,9 +27,9 @@ describe('UserPagesController', function () {
v1: {
url: 'some.host',
user: 'one',
- pass: 'two'
- }
- }
+ pass: 'two',
+ },
+ },
}
this.user = {
_id: (this.user_id = 'kwjewkl'),
@@ -38,9 +38,9 @@ describe('UserPagesController', function () {
thirdPartyIdentifiers: [
{
providerId: 'google',
- externalUserId: 'testId'
- }
- ]
+ externalUserId: 'testId',
+ },
+ ],
}
this.UserGetter = { getUser: sinon.stub() }
@@ -51,7 +51,7 @@ describe('UserPagesController', function () {
getLoggedInUserId: sinon.stub().returns(this.user._id),
getSessionUser: sinon.stub().returns(this.user),
_getRedirectFromSession: sinon.stub(),
- setRedirectInSession: sinon.stub()
+ setRedirectInSession: sinon.stub(),
}
this.UserPagesController = SandboxedModule.require(modulePath, {
requires: {
@@ -61,14 +61,14 @@ describe('UserPagesController', function () {
'../Errors/ErrorController': this.ErrorController,
'../Authentication/AuthenticationController': this
.AuthenticationController,
- request: (this.request = sinon.stub())
- }
+ request: (this.request = sinon.stub()),
+ },
})
this.req = {
query: {},
session: {
- user: this.user
- }
+ user: this.user,
+ },
}
return (this.res = {})
})
@@ -232,7 +232,7 @@ describe('UserPagesController', function () {
it('should restructure thirdPartyIdentifiers data for template use', function (done) {
const expectedResult = {
- google: 'testId'
+ google: 'testId',
}
this.res.render = (page, opts) => {
expect(opts.thirdPartyIds).to.include(expectedResult)
diff --git a/services/web/test/unit/src/User/UserRegistrationHandlerTests.js b/services/web/test/unit/src/User/UserRegistrationHandlerTests.js
index 2ea25598e7..ca316117f0 100644
--- a/services/web/test/unit/src/User/UserRegistrationHandlerTests.js
+++ b/services/web/test/unit/src/User/UserRegistrationHandlerTests.js
@@ -28,12 +28,12 @@ describe('UserRegistrationHandler', function () {
this.User = { updateOne: sinon.stub().callsArgWith(2) }
this.UserGetter = { getUserByAnyEmail: sinon.stub() }
this.UserCreator = {
- createNewUser: sinon.stub().callsArgWith(2, null, this.user)
+ createNewUser: sinon.stub().callsArgWith(2, null, this.user),
}
this.AuthenticationManager = {
validateEmail: sinon.stub().returns(null),
validatePassword: sinon.stub().returns(null),
- setUserPassword: sinon.stub().callsArgWith(2)
+ setUserPassword: sinon.stub().callsArgWith(2),
}
this.NewsLetterManager = { subscribe: sinon.stub().callsArgWith(1) }
this.EmailHandler = { sendEmail: sinon.stub().callsArgWith(2) }
@@ -49,18 +49,18 @@ describe('UserRegistrationHandler', function () {
'../Email/EmailHandler': this.EmailHandler,
'../Security/OneTimeTokenHandler': this.OneTimeTokenHandler,
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
- recordEvent: sinon.stub()
+ recordEvent: sinon.stub(),
}),
'settings-sharelatex': (this.settings = {
- siteUrl: 'http://sl.example.com'
+ siteUrl: 'http://sl.example.com',
}),
- '../Helpers/EmailHelper': EmailHelper
- }
+ '../Helpers/EmailHelper': EmailHelper,
+ },
})
return (this.passingRequest = {
email: 'something@email.com',
- password: '123'
+ password: '123',
})
})
@@ -75,7 +75,7 @@ describe('UserRegistrationHandler', function () {
describe('failing email validation', function () {
beforeEach(function () {
return this.AuthenticationManager.validateEmail.returns({
- message: 'email not set'
+ message: 'email not set',
})
})
@@ -90,7 +90,7 @@ describe('UserRegistrationHandler', function () {
describe('failing password validation', function () {
beforeEach(function () {
return this.AuthenticationManager.validatePassword.returns({
- message: 'password is too short'
+ message: 'password is too short',
})
})
@@ -173,7 +173,7 @@ describe('UserRegistrationHandler', function () {
email: this.passingRequest.email,
holdingAccount: false,
first_name: this.passingRequest.first_name,
- last_name: this.passingRequest.last_name
+ last_name: this.passingRequest.last_name,
})
.should.equal(true)
return done()
@@ -249,7 +249,7 @@ describe('UserRegistrationHandler', function () {
this.crypto.randomBytes = sinon.stub().returns({
toString: () => {
return (this.password = 'mock-password')
- }
+ },
})
this.OneTimeTokenHandler.getNewToken.yields(
null,
@@ -273,7 +273,7 @@ describe('UserRegistrationHandler', function () {
return this.handler.registerNewUser
.calledWith({
email: this.email,
- password: this.password
+ password: this.password,
})
.should.equal(true)
})
@@ -281,7 +281,7 @@ describe('UserRegistrationHandler', function () {
it('should generate a new password reset token', function () {
const data = {
user_id: this.user._id.toString(),
- email: this.user.email
+ email: this.user.email,
}
return this.OneTimeTokenHandler.getNewToken
.calledWith('password', data, { expiresIn: 7 * 24 * 60 * 60 })
@@ -292,7 +292,7 @@ describe('UserRegistrationHandler', function () {
return this.EmailHandler.sendEmail
.calledWith('registered', {
to: this.user.email,
- setNewPasswordUrl: `${this.settings.siteUrl}/user/activate?token=${this.token}&user_id=${this.user_id}`
+ setNewPasswordUrl: `${this.settings.siteUrl}/user/activate?token=${this.token}&user_id=${this.user_id}`,
})
.should.equal(true)
})
diff --git a/services/web/test/unit/src/User/UserSessionsManagerTests.js b/services/web/test/unit/src/User/UserSessionsManagerTests.js
index d4265de440..56b4511079 100644
--- a/services/web/test/unit/src/User/UserSessionsManagerTests.js
+++ b/services/web/test/unit/src/User/UserSessionsManagerTests.js
@@ -20,7 +20,7 @@ describe('UserSessionsManager', function () {
beforeEach(function () {
this.user = {
_id: 'abcd',
- email: 'user@example.com'
+ email: 'user@example.com',
}
this.sessionId = 'some_session_id'
@@ -33,7 +33,7 @@ describe('UserSessionsManager', function () {
srem: sinon.stub(),
smembers: sinon.stub(),
mget: sinon.stub(),
- pexpire: sinon.stub()
+ pexpire: sinon.stub(),
}
this.rclient.multi.returns(this.rclient)
this.rclient.get.returns(this.rclient)
@@ -46,18 +46,18 @@ describe('UserSessionsManager', function () {
this.UserSessionsRedis = {
client: () => this.rclient,
- sessionSetKey: user => `UserSessions:{${user._id}}`
+ sessionSetKey: user => `UserSessions:{${user._id}}`,
}
this.settings = {
redis: {
- web: {}
- }
+ web: {},
+ },
}
return (this.UserSessionsManager = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': this.settings,
- './UserSessionsRedis': this.UserSessionsRedis
- }
+ './UserSessionsRedis': this.UserSessionsRedis,
+ },
}))
})
@@ -432,7 +432,7 @@ describe('UserSessionsManager', function () {
expect(this.rclient.srem.firstCall.args[1]).to.deep.equal([
'sess:one',
'sess:three',
- 'sess:four'
+ 'sess:four',
])
return done()
})
@@ -579,7 +579,7 @@ describe('UserSessionsManager', function () {
this.sessionKeys = ['sess:one', 'sess:two', 'sess:three']
this.sessions = [
'{"user": {"ip_address": "a", "session_created": "b"}}',
- '{"passport": {"user": {"ip_address": "c", "session_created": "d"}}}'
+ '{"passport": {"user": {"ip_address": "c", "session_created": "d"}}}',
]
this.exclude = ['two']
this.rclient.smembers.callsArgWith(1, null, this.sessionKeys)
@@ -607,7 +607,7 @@ describe('UserSessionsManager', function () {
return this.call((err, sessions) => {
expect(sessions).to.deep.equal([
{ ip_address: 'a', session_created: 'b' },
- { ip_address: 'c', session_created: 'd' }
+ { ip_address: 'c', session_created: 'd' },
])
return done()
})
diff --git a/services/web/test/unit/src/User/UserUpdaterTests.js b/services/web/test/unit/src/User/UserUpdaterTests.js
index b0e4707d60..93e2dc5fdb 100644
--- a/services/web/test/unit/src/User/UserUpdaterTests.js
+++ b/services/web/test/unit/src/User/UserUpdaterTests.js
@@ -16,57 +16,57 @@ describe('UserUpdater', function () {
db: {},
ObjectId(id) {
return id
- }
+ },
}
this.UserGetter = {
getUserEmail: sinon.stub(),
getUserByAnyEmail: sinon.stub(),
promises: {
ensureUniqueEmailAddress: sinon.stub(),
- getUser: sinon.stub()
- }
+ getUser: sinon.stub(),
+ },
}
this.addAffiliation = sinon.stub().yields()
this.removeAffiliation = sinon.stub().callsArgWith(2, null)
this.refreshFeatures = sinon.stub().yields()
this.NewsletterManager = {
promises: {
- changeEmail: sinon.stub()
- }
+ changeEmail: sinon.stub(),
+ },
}
this.RecurlyWrapper = {
promises: {
- updateAccountEmailAddress: sinon.stub()
- }
+ updateAccountEmailAddress: sinon.stub(),
+ },
}
this.UserUpdater = SandboxedModule.require(modulePath, {
requires: {
'../Helpers/Mongo': { normalizeQuery },
'../../infrastructure/mongodb': this.mongodb,
'@overleaf/metrics': {
- timeAsyncMethod: sinon.stub()
+ timeAsyncMethod: sinon.stub(),
},
'./UserGetter': this.UserGetter,
'../Institutions/InstitutionsAPI': (this.InstitutionsAPI = {
addAffiliation: this.addAffiliation,
removeAffiliation: this.removeAffiliation,
promises: {
- addAffiliation: sinon.stub()
- }
+ addAffiliation: sinon.stub(),
+ },
}),
'../Email/EmailHandler': (this.EmailHandler = {
promises: {
- sendEmail: sinon.stub()
- }
+ sendEmail: sinon.stub(),
+ },
}),
'../../infrastructure/Features': (this.Features = {
- hasFeature: sinon.stub().returns(false)
+ hasFeature: sinon.stub().returns(false),
}),
'../Subscription/FeaturesUpdater': (this.FeaturesUpdater = {
refreshFeatures: this.refreshFeatures,
promises: {
- refreshFeatures: sinon.stub().resolves()
- }
+ refreshFeatures: sinon.stub().resolves(),
+ },
}),
'settings-sharelatex': (this.settings = {}),
request: (this.request = {}),
@@ -74,10 +74,10 @@ describe('UserUpdater', function () {
'../Subscription/RecurlyWrapper': this.RecurlyWrapper,
'./UserAuditLogHandler': (this.UserAuditLogHandler = {
promises: {
- addEntry: sinon.stub().resolves()
- }
- })
- }
+ addEntry: sinon.stub().resolves(),
+ },
+ }),
+ },
})
this.stubbedUserEmail = 'hello@world.com'
@@ -87,9 +87,9 @@ describe('UserUpdater', function () {
email: this.stubbedUserEmail,
emails: [
{
- email: this.stubbedUserEmail
- }
- ]
+ email: this.stubbedUserEmail,
+ },
+ ],
}
this.newEmail = 'bob@bob.com'
this.callback = sinon.stub()
@@ -141,7 +141,7 @@ describe('UserUpdater', function () {
beforeEach(function () {
this.auditLog = {
initiatorId: 'abc123',
- ipAddress: '0:0:0:0'
+ ipAddress: '0:0:0:0',
}
this.UserGetter.getUserEmail.callsArgWith(1, null, this.stubbedUser.email)
this.UserUpdater.addEmailAddress = sinon.stub().callsArgWith(4)
@@ -232,9 +232,9 @@ describe('UserUpdater', function () {
emails: {
email: this.newEmail,
createdAt: sinon.match.date,
- reversedHostname
- }
- }
+ reversedHostname,
+ },
+ },
})
.should.equal(true)
done()
@@ -246,7 +246,7 @@ describe('UserUpdater', function () {
const affiliationOptions = {
university: { id: 1 },
role: 'Prof',
- department: 'Math'
+ department: 'Math',
}
this.UserUpdater.addEmailAddress(
this.stubbedUser._id,
@@ -313,7 +313,7 @@ describe('UserUpdater', function () {
expect(args[2]).to.equal(this.stubbedUser._id)
expect(args[3]).to.equal(this.ip)
expect(args[4]).to.deep.equal({
- newSecondaryEmail: this.newEmail
+ newSecondaryEmail: this.newEmail,
})
done()
}
@@ -449,13 +449,13 @@ describe('UserUpdater', function () {
beforeEach(function () {
this.auditLog = {
initiatorId: this.stubbedUser,
- ipAddress: '0:0:0:0'
+ ipAddress: '0:0:0:0',
}
this.stubbedUser.emails = [
{
email: this.newEmail,
- confirmedAt: new Date()
- }
+ confirmedAt: new Date(),
+ },
]
this.UserGetter.promises.getUser.resolves(this.stubbedUser)
this.NewsletterManager.promises.changeEmail.callsArgWith(2, null)
@@ -566,7 +566,7 @@ describe('UserUpdater', function () {
this.auditLog.ipAddress,
{
newPrimaryEmail: this.newEmail,
- oldPrimaryEmail: this.stubbedUser.email
+ oldPrimaryEmail: this.stubbedUser.email,
}
)
done()
@@ -595,8 +595,8 @@ describe('UserUpdater', function () {
this.stubbedUser.emails = [
{
email: this.newEmail,
- confirmedAt: null
- }
+ confirmedAt: null,
+ },
]
this.UserUpdater.promises.updateUser = sinon.stub()
})
@@ -691,7 +691,7 @@ describe('UserUpdater', function () {
const loggerCall = this.logger.error.firstCall
expect(loggerCall.args[0]).to.deep.equal({
error: anError,
- userId: this.stubbedUser._id
+ userId: this.stubbedUser._id,
})
expect(loggerCall.args[1]).to.contain(
'could not send security alert email when primary email changed'
@@ -720,15 +720,15 @@ describe('UserUpdater', function () {
.calledWith(
{
_id: this.stubbedUser._id,
- 'emails.email': this.stubbedUserEmail
+ 'emails.email': this.stubbedUserEmail,
},
{
$set: {
- 'emails.$.reconfirmedAt': new Date()
+ 'emails.$.reconfirmedAt': new Date(),
},
$min: {
- 'emails.$.confirmedAt': new Date()
- }
+ 'emails.$.confirmedAt': new Date(),
+ },
}
)
.should.equal(true)
diff --git a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js
index 80f4cf0c72..50fdc22a27 100644
--- a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js
+++ b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js
@@ -30,7 +30,7 @@ describe('UserMembershipController', function () {
this.newUser = { _id: 'mock-new-user-id', email: 'new-user-email@foo.bar' }
this.subscription = {
_id: 'mock-subscription-id',
- fetchV1Data: callback => callback(null, this.subscription)
+ fetchV1Data: callback => callback(null, this.subscription),
}
this.institution = {
_id: 'mock-institution-id',
@@ -39,31 +39,31 @@ describe('UserMembershipController', function () {
const institution = Object.assign({}, this.institution)
institution.name = 'Test Institution Name'
return callback(null, institution)
- }
+ },
}
this.users = [
{
_id: 'mock-member-id-1',
email: 'mock-email-1@foo.com',
- last_logged_in_at: '2020-08-09T12:43:11.467Z'
+ last_logged_in_at: '2020-08-09T12:43:11.467Z',
},
{
_id: 'mock-member-id-2',
email: 'mock-email-2@foo.com',
- last_logged_in_at: '2020-05-20T10:41:11.407Z'
- }
+ last_logged_in_at: '2020-05-20T10:41:11.407Z',
+ },
]
this.AuthenticationController = {
getSessionUser: sinon.stub().returns(this.user),
- getLoggedInUserId: sinon.stub().returns(this.user._id)
+ getLoggedInUserId: sinon.stub().returns(this.user._id),
}
this.UserMembershipHandler = {
getEntity: sinon.stub().yields(null, this.subscription),
createEntity: sinon.stub().yields(null, this.institution),
getUsers: sinon.stub().yields(null, this.users),
addUser: sinon.stub().yields(null, this.newUser),
- removeUser: sinon.stub().yields(null)
+ removeUser: sinon.stub().yields(null),
}
return (this.UserMembershipController = SandboxedModule.require(
modulePath,
@@ -71,8 +71,8 @@ describe('UserMembershipController', function () {
requires: {
'../Authentication/AuthenticationController': this
.AuthenticationController,
- './UserMembershipHandler': this.UserMembershipHandler
- }
+ './UserMembershipHandler': this.UserMembershipHandler,
+ },
}
))
})
@@ -92,7 +92,7 @@ describe('UserMembershipController', function () {
{ modelName: 'Subscription' }
)
return done()
- }
+ },
})
})
@@ -107,7 +107,7 @@ describe('UserMembershipController', function () {
`/manage/groups/${this.subscription._id}/invites`
)
return done()
- }
+ },
})
})
@@ -123,7 +123,7 @@ describe('UserMembershipController', function () {
)
expect(viewParams.paths.exportMembers).to.be.undefined
return done()
- }
+ },
})
})
@@ -138,7 +138,7 @@ describe('UserMembershipController', function () {
expect(viewParams.translations.title).to.equal('institution_account')
expect(viewParams.paths.exportMembers).to.be.undefined
return done()
- }
+ },
})
})
})
@@ -160,7 +160,7 @@ describe('UserMembershipController', function () {
this.newUser.email
)
return done()
- }
+ },
})
})
@@ -169,7 +169,7 @@ describe('UserMembershipController', function () {
json: payload => {
payload.user.should.equal(this.newUser)
return done()
- }
+ },
})
})
@@ -189,8 +189,8 @@ describe('UserMembershipController', function () {
json: payload => {
expect(payload.error.code).to.equal('user_already_added')
return done()
- }
- })
+ },
+ }),
})
})
@@ -201,8 +201,8 @@ describe('UserMembershipController', function () {
json: payload => {
expect(payload.error.code).to.equal('user_not_found')
return done()
- }
- })
+ },
+ }),
})
})
@@ -213,8 +213,8 @@ describe('UserMembershipController', function () {
json: payload => {
expect(payload.error.code).to.equal('invalid_email')
return done()
- }
- })
+ },
+ }),
})
})
})
@@ -236,7 +236,7 @@ describe('UserMembershipController', function () {
this.newUser._id
)
return done()
- }
+ },
})
})
@@ -256,8 +256,8 @@ describe('UserMembershipController', function () {
json: payload => {
expect(payload.error.code).to.equal('managers_cannot_remove_self')
return done()
- }
- })
+ },
+ }),
})
})
@@ -268,8 +268,8 @@ describe('UserMembershipController', function () {
json: payload => {
expect(payload.error.code).to.equal('managers_cannot_remove_admin')
return done()
- }
- })
+ },
+ }),
})
})
})
@@ -325,7 +325,7 @@ describe('UserMembershipController', function () {
expect(data.entityName).to.eq('publisher')
expect(data.entityId).to.eq('abc')
return done()
- }
+ },
})
})
})
@@ -347,7 +347,7 @@ describe('UserMembershipController', function () {
{ modelName: 'Institution' }
)
return done()
- }
+ },
})
})
})
diff --git a/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js
index 6f93e7def7..a47d57ed75 100644
--- a/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js
+++ b/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js
@@ -35,35 +35,35 @@ describe('UserMembershipHandler', function () {
manager_ids: [ObjectId()],
invited_emails: ['mock-email-1@foo.com'],
teamInvites: [{ email: 'mock-email-1@bar.com' }],
- update: sinon.stub().yields(null)
+ update: sinon.stub().yields(null),
}
this.institution = {
_id: 'mock-institution-id',
v1Id: 123,
managerIds: [ObjectId(), ObjectId(), ObjectId()],
- updateOne: sinon.stub().yields(null)
+ updateOne: sinon.stub().yields(null),
}
this.publisher = {
_id: 'mock-publisher-id',
slug: 'slug',
managerIds: [ObjectId(), ObjectId()],
- updateOne: sinon.stub().yields(null)
+ updateOne: sinon.stub().yields(null),
}
this.UserMembershipViewModel = {
buildAsync: sinon.stub().yields(null, { _id: 'mock-member-id' }),
- build: sinon.stub().returns(this.newUser)
+ build: sinon.stub().returns(this.newUser),
}
this.UserGetter = {
- getUserByAnyEmail: sinon.stub().yields(null, this.newUser)
+ getUserByAnyEmail: sinon.stub().yields(null, this.newUser),
}
this.Institution = { findOne: sinon.stub().yields(null, this.institution) }
this.Subscription = {
- findOne: sinon.stub().yields(null, this.subscription)
+ findOne: sinon.stub().yields(null, this.subscription),
}
this.Publisher = {
findOne: sinon.stub().yields(null, this.publisher),
- create: sinon.stub().yields(null, this.publisher)
+ create: sinon.stub().yields(null, this.publisher),
}
return (this.UserMembershipHandler = SandboxedModule.require(modulePath, {
requires: {
@@ -71,15 +71,15 @@ describe('UserMembershipHandler', function () {
'./UserMembershipViewModel': this.UserMembershipViewModel,
'../User/UserGetter': this.UserGetter,
'../../models/Institution': {
- Institution: this.Institution
+ Institution: this.Institution,
},
'../../models/Subscription': {
- Subscription: this.Subscription
+ Subscription: this.Subscription,
},
'../../models/Publisher': {
- Publisher: this.Publisher
- }
- }
+ Publisher: this.Publisher,
+ },
+ },
}))
})
@@ -219,7 +219,7 @@ describe('UserMembershipHandler', function () {
this.email,
(error, user) => {
assertCalledWith(this.institution.updateOne, {
- $addToSet: { managerIds: this.newUser._id }
+ $addToSet: { managerIds: this.newUser._id },
})
return done()
}
@@ -250,7 +250,7 @@ describe('UserMembershipHandler', function () {
(error, user) => {
const { lastCall } = this.institution.updateOne
assertCalledWith(this.institution.updateOne, {
- $pull: { managerIds: this.newUser._id }
+ $pull: { managerIds: this.newUser._id },
})
return done()
}
diff --git a/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js b/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js
index fece8b9c43..39d073b1f2 100644
--- a/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js
+++ b/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js
@@ -20,7 +20,7 @@ const modulePath =
const SandboxedModule = require('sandboxed-module')
const {
isObjectIdInstance,
- normalizeQuery
+ normalizeQuery,
} = require('../../../../app/src/Features/Helpers/Mongo')
describe('UserMembershipViewModel', function () {
@@ -30,15 +30,15 @@ describe('UserMembershipViewModel', function () {
requires: {
mongodb: { ObjectId },
'../Helpers/Mongo': { isObjectIdInstance, normalizeQuery },
- '../User/UserGetter': this.UserGetter
- }
+ '../User/UserGetter': this.UserGetter,
+ },
})
this.email = 'mock-email@bar.com'
this.user = {
_id: 'mock-user-id',
email: 'mock-email@baz.com',
first_name: 'Name',
- lastLoggedIn: '2020-05-20T10:41:11.407Z'
+ lastLoggedIn: '2020-05-20T10:41:11.407Z',
}
})
@@ -51,7 +51,7 @@ describe('UserMembershipViewModel', function () {
last_logged_in_at: null,
first_name: null,
last_name: null,
- _id: null
+ _id: null,
})
})
diff --git a/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js
index 946d260701..448a2febd5 100644
--- a/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js
+++ b/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js
@@ -27,15 +27,15 @@ describe('UserMembershipsHandler', function () {
return (this.UserMembershipsHandler = SandboxedModule.require(modulePath, {
requires: {
'../../models/Institution': {
- Institution: this.Institution
+ Institution: this.Institution,
},
'../../models/Subscription': {
- Subscription: this.Subscription
+ Subscription: this.Subscription,
},
'../../models/Publisher': {
- Publisher: this.Publisher
- }
- }
+ Publisher: this.Publisher,
+ },
+ },
}))
})
diff --git a/services/web/test/unit/src/helpers/MockModel.js b/services/web/test/unit/src/helpers/MockModel.js
index ab6a75570b..a8d0f8110c 100644
--- a/services/web/test/unit/src/helpers/MockModel.js
+++ b/services/web/test/unit/src/helpers/MockModel.js
@@ -20,7 +20,7 @@ module.exports = (modelName, requires = {}) => {
requires['../infrastructure/Mongoose'] = {
createConnection: () => {
return {
- model: () => {}
+ model: () => {},
}
},
model: (modelName, schema) => {
@@ -28,11 +28,11 @@ module.exports = (modelName, requires = {}) => {
model[modelName] = mongoose.model(modelName, schema)
},
Schema: mongoose.Schema,
- Types: mongoose.Types
+ Types: mongoose.Types,
}
SandboxedModule.require('../../../../app/src/models/' + modelName, {
- requires: requires
+ requires: requires,
})
return model
diff --git a/services/web/test/unit/src/helpers/MockRequest.js b/services/web/test/unit/src/helpers/MockRequest.js
index c270feb401..89c2cedd40 100644
--- a/services/web/test/unit/src/helpers/MockRequest.js
+++ b/services/web/test/unit/src/helpers/MockRequest.js
@@ -18,7 +18,7 @@ class MockRequest {
this.prototype.i18n = {
translate(str) {
return str
- }
+ },
}
this.prototype.route = { path: '' }
this.prototype.accepts = () => {}
diff --git a/services/web/test/unit/src/helpers/models/DeletedProject.js b/services/web/test/unit/src/helpers/models/DeletedProject.js
index 6c53392faa..f3537bcb43 100644
--- a/services/web/test/unit/src/helpers/models/DeletedProject.js
+++ b/services/web/test/unit/src/helpers/models/DeletedProject.js
@@ -1,5 +1,5 @@
const mockModel = require('../MockModel')
module.exports = mockModel('DeletedProject', {
- './Project': require('./Project')
+ './Project': require('./Project'),
})
diff --git a/services/web/test/unit/src/helpers/models/DeletedUser.js b/services/web/test/unit/src/helpers/models/DeletedUser.js
index 2425e76447..92d932c784 100644
--- a/services/web/test/unit/src/helpers/models/DeletedUser.js
+++ b/services/web/test/unit/src/helpers/models/DeletedUser.js
@@ -1,5 +1,5 @@
const mockModel = require('../MockModel')
module.exports = mockModel('DeletedUser', {
- './User': require('./User')
+ './User': require('./User'),
})
diff --git a/services/web/test/unit/src/helpers/models/Folder.js b/services/web/test/unit/src/helpers/models/Folder.js
index e6e40007df..3abf588ff9 100644
--- a/services/web/test/unit/src/helpers/models/Folder.js
+++ b/services/web/test/unit/src/helpers/models/Folder.js
@@ -2,5 +2,5 @@ const mockModel = require('../MockModel')
module.exports = mockModel('Folder', {
'./Doc': require('./Doc'),
- './File': require('./File')
+ './File': require('./File'),
})
diff --git a/services/web/test/unit/src/helpers/models/Project.js b/services/web/test/unit/src/helpers/models/Project.js
index e12f163331..508db37d85 100644
--- a/services/web/test/unit/src/helpers/models/Project.js
+++ b/services/web/test/unit/src/helpers/models/Project.js
@@ -1,5 +1,5 @@
const mockModel = require('../MockModel')
module.exports = mockModel('Project', {
- './Folder': require('./Folder')
+ './Folder': require('./Folder'),
})
diff --git a/services/web/test/unit/src/helpers/models/User.js b/services/web/test/unit/src/helpers/models/User.js
index 66c1287603..7190fd6640 100644
--- a/services/web/test/unit/src/helpers/models/User.js
+++ b/services/web/test/unit/src/helpers/models/User.js
@@ -1,5 +1,5 @@
const mockModel = require('../MockModel')
module.exports = mockModel('User', {
- './Project': require('./Project')
+ './Project': require('./Project'),
})
diff --git a/services/web/test/unit/src/infrastructure/CsrfTests.js b/services/web/test/unit/src/infrastructure/CsrfTests.js
index d51977b29b..45371a0e2f 100644
--- a/services/web/test/unit/src/infrastructure/CsrfTests.js
+++ b/services/web/test/unit/src/infrastructure/CsrfTests.js
@@ -22,15 +22,15 @@ describe('Csrf', function () {
.callsArgWith(2, (this.err = { code: 'EBADCSRFTOKEN' }))
this.Csrf = SandboxedModule.require(modulePath, {
requires: {
- csurf: sinon.stub().returns(this.csurf_csrf)
- }
+ csurf: sinon.stub().returns(this.csurf_csrf),
+ },
})
this.csrf = new this.Csrf()
this.next = sinon.stub()
this.path = '/foo/bar'
this.req = {
path: this.path,
- method: 'POST'
+ method: 'POST',
}
return (this.res = {})
})
@@ -97,7 +97,7 @@ describe('Csrf', function () {
let err
this.Csrf = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
requires: {
csurf: (this.csurf = sinon
@@ -106,8 +106,8 @@ describe('Csrf', function () {
(this.csurf_csrf = sinon
.stub()
.callsArgWith(2, (err = { code: 'EOTHER' })))
- ))
- }
+ )),
+ },
})
this.csrf = new this.Csrf()
this.csrf.disableDefaultCsrfProtection(this.path, 'POST')
@@ -131,13 +131,13 @@ describe('Csrf', function () {
it('calls the callback without an error', function () {
this.Csrf = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
requires: {
csurf: (this.csurf = sinon
.stub()
- .returns((this.csurf_csrf = sinon.stub().callsArg(2))))
- }
+ .returns((this.csurf_csrf = sinon.stub().callsArg(2)))),
+ },
})
this.cb = sinon.stub()
this.Csrf.validateRequest(this.req, this.cb)
@@ -159,13 +159,13 @@ describe('Csrf', function () {
it('calls the callback with `true`', function () {
this.Csrf = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
requires: {
csurf: (this.csurf = sinon
.stub()
- .returns((this.csurf_csrf = sinon.stub().callsArg(2))))
- }
+ .returns((this.csurf_csrf = sinon.stub().callsArg(2)))),
+ },
})
this.cb = sinon.stub()
this.Csrf.validateToken('goodtoken', {}, this.cb)
@@ -177,13 +177,13 @@ describe('Csrf', function () {
it('calls the callback with an error', function () {
this.Csrf = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
requires: {
csurf: (this.csurf = sinon
.stub()
- .returns((this.csurf_csrf = sinon.stub().callsArg(2))))
- }
+ .returns((this.csurf_csrf = sinon.stub().callsArg(2)))),
+ },
})
this.cb = sinon.stub()
this.Csrf.validateToken(null, {}, error => {
diff --git a/services/web/test/unit/src/infrastructure/FeaturesTests.js b/services/web/test/unit/src/infrastructure/FeaturesTests.js
index f770a45d84..3b93b09d9f 100644
--- a/services/web/test/unit/src/infrastructure/FeaturesTests.js
+++ b/services/web/test/unit/src/infrastructure/FeaturesTests.js
@@ -6,8 +6,8 @@ describe('Features', function () {
beforeEach(function () {
this.Features = SandboxedModule.require(modulePath, {
requires: {
- 'settings-sharelatex': (this.settings = {})
- }
+ 'settings-sharelatex': (this.settings = {}),
+ },
})
})
describe('externalAuthenticationSystemUsed', function () {
@@ -89,14 +89,14 @@ describe('Features', function () {
beforeEach(function () {
this.settings.apis = {
linkedUrlProxy: {
- url: 'https://www.overleaf.com'
+ url: 'https://www.overleaf.com',
},
references: {
- url: 'https://www.overleaf.com'
+ url: 'https://www.overleaf.com',
},
v1: {
- url: 'https://www.overleaf.com'
- }
+ url: 'https://www.overleaf.com',
+ },
}
})
it('should return true', function () {
diff --git a/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js b/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js
index 7da836977b..501ad8c58a 100644
--- a/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js
+++ b/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js
@@ -26,16 +26,16 @@ describe('GeoIpLookup', function () {
this.settings = {
apis: {
geoIpLookup: {
- url: 'http://lookup.com'
- }
- }
+ url: 'http://lookup.com',
+ },
+ },
}
this.request = { get: sinon.stub() }
this.GeoIpLookup = SandboxedModule.require(modulePath, {
requires: {
request: this.request,
- 'settings-sharelatex': this.settings
- }
+ 'settings-sharelatex': this.settings,
+ },
})
this.ipAddress = '123.456.789.123'
@@ -50,7 +50,7 @@ describe('GeoIpLookup', function () {
latitude: 51.0,
longitude: -0.0493,
metro_code: '',
- area_code: ''
+ area_code: '',
})
})
@@ -65,7 +65,7 @@ describe('GeoIpLookup', function () {
.calledWith({
url: this.settings.apis.geoIpLookup.url + '/' + this.ipAddress,
timeout: 1000,
- json: true
+ json: true,
})
.should.equal(true)
return done()
@@ -90,7 +90,7 @@ describe('GeoIpLookup', function () {
.calledWith({
url: this.settings.apis.geoIpLookup.url + '/' + this.ipAddress,
timeout: 1000,
- json: true
+ json: true,
})
.should.equal(true)
return done()
diff --git a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js
index 34355e8dfa..14146b6fb2 100644
--- a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js
+++ b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js
@@ -30,18 +30,18 @@ describe('LockManager - releasing the lock', function () {
maxTestInterval: 1000,
maxLockWaitTime: 10000,
redisLockExpiry: 30,
- slowExecutionThreshold: 5000
- }
+ slowExecutionThreshold: 5000,
+ },
},
'@overleaf/metrics': {},
'./RedisWrapper': {
client() {
return {
auth() {},
- eval: deleteStub
+ eval: deleteStub,
}
- }
- }
+ },
+ },
}
const LockManager = SandboxedModule.require(modulePath, { requires: mocks })
diff --git a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js
index e971461d48..f7c3efad5a 100644
--- a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js
+++ b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js
@@ -28,7 +28,7 @@ describe('LockManager - getting the lock', function () {
'./RedisWrapper': {
client() {
return { auth() {} }
- }
+ },
},
'settings-sharelatex': {
redis: {},
@@ -37,14 +37,14 @@ describe('LockManager - getting the lock', function () {
maxTestInterval: 1000,
maxLockWaitTime: 10000,
redisLockExpiry: 30,
- slowExecutionThreshold: 5000
- }
+ slowExecutionThreshold: 5000,
+ },
},
'@overleaf/metrics': {
inc() {},
- gauge() {}
- }
- }
+ gauge() {},
+ },
+ },
})
this.callback = sinon.stub()
diff --git a/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js b/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js
index 2d12411409..95940784a4 100644
--- a/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js
+++ b/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js
@@ -26,9 +26,9 @@ describe('LockManager - trying the lock', function () {
client: () => {
return {
auth() {},
- set: (this.set = sinon.stub())
+ set: (this.set = sinon.stub()),
}
- }
+ },
},
'settings-sharelatex': {
redis: {},
@@ -37,13 +37,13 @@ describe('LockManager - trying the lock', function () {
maxTestInterval: 1000,
maxLockWaitTime: 10000,
redisLockExpiry: 30,
- slowExecutionThreshold: 5000
- }
+ slowExecutionThreshold: 5000,
+ },
},
'@overleaf/metrics': {
- inc() {}
- }
- }
+ inc() {},
+ },
+ },
})
this.callback = sinon.stub()
this.key = 'lock:web:lockName:project-id}'
diff --git a/services/web/test/unit/src/infrastructure/ProxyManagerTests.js b/services/web/test/unit/src/infrastructure/ProxyManagerTests.js
index 98e626d45c..f8f03851c3 100644
--- a/services/web/test/unit/src/infrastructure/ProxyManagerTests.js
+++ b/services/web/test/unit/src/infrastructure/ProxyManagerTests.js
@@ -23,13 +23,13 @@ describe('ProxyManager', function () {
this.settings = { proxyUrls: {} }
this.request = sinon.stub().returns({
on() {},
- pipe() {}
+ pipe() {},
})
this.proxyManager = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': this.settings,
- request: this.request
- }
+ request: this.request,
+ },
})
this.proxyPath = '/foo/bar'
this.req = new MockRequest()
@@ -42,7 +42,7 @@ describe('ProxyManager', function () {
this.router = { get: sinon.stub() }
this.settings.proxyUrls = {
'/foo/bar': '',
- '/foo/:id': ''
+ '/foo/:id': '',
}
this.proxyManager.apply(this.router)
sinon.assert.calledTwice(this.router.get)
@@ -53,11 +53,11 @@ describe('ProxyManager', function () {
it('applies methods other than get', function () {
this.router = {
post: sinon.stub(),
- put: sinon.stub()
+ put: sinon.stub(),
}
this.settings.proxyUrls = {
'/foo/bar': { options: { method: 'post' } },
- '/foo/:id': { options: { method: 'put' } }
+ '/foo/:id': { options: { method: 'put' } },
}
this.proxyManager.apply(this.router)
sinon.assert.calledOnce(this.router.post)
@@ -125,7 +125,7 @@ describe('ProxyManager', function () {
baseUrl: 'api.v1',
path(params) {
return `/resource/${params.id}`
- }
+ },
}
this.settings.proxyUrls['/res/:id'] = target
this.req.url = '/res/123'
@@ -139,14 +139,14 @@ describe('ProxyManager', function () {
const target = {
baseUrl: 'api.v1',
path: '/foo',
- options: { foo: 'bar' }
+ options: { foo: 'bar' },
}
this.req.url = '/foo'
this.req.route.path = '/foo'
this.proxyManager.createProxy(target)(this.req, this.res, this.next)
return assertCalledWith(this.request, {
foo: 'bar',
- url: 'api.v1/foo'
+ url: 'api.v1/foo',
})
})
@@ -158,9 +158,9 @@ describe('ProxyManager', function () {
this.proxyManager.createProxy(target)(this.req, this.res, this.next)
return assertCalledWith(this.request, {
headers: {
- Cookie: 'cookie'
+ Cookie: 'cookie',
},
- url: 'api.v1/foo'
+ url: 'api.v1/foo',
})
})
@@ -168,7 +168,7 @@ describe('ProxyManager', function () {
const target = {
baseUrl: 'api.v1',
path: '/foo',
- options: { method: 'post' }
+ options: { method: 'post' },
}
this.req.url = '/foo'
this.req.route.path = '/foo'
@@ -176,10 +176,10 @@ describe('ProxyManager', function () {
this.proxyManager.createProxy(target)(this.req, this.res, this.next)
return assertCalledWith(this.request, {
form: {
- foo: 'bar'
+ foo: 'bar',
},
method: 'post',
- url: 'api.v1/foo'
+ url: 'api.v1/foo',
})
})
@@ -187,7 +187,7 @@ describe('ProxyManager', function () {
const target = {
baseUrl: 'api.v1',
path: '/foo',
- options: { method: 'put' }
+ options: { method: 'put' },
}
this.req.url = '/foo'
this.req.route.path = '/foo'
@@ -195,10 +195,10 @@ describe('ProxyManager', function () {
this.proxyManager.createProxy(target)(this.req, this.res, this.next)
return assertCalledWith(this.request, {
form: {
- foo: 'bar'
+ foo: 'bar',
},
method: 'put',
- url: 'api.v1/foo'
+ url: 'api.v1/foo',
})
})
})
diff --git a/services/web/test/unit/src/infrastructure/RateLimterTests.js b/services/web/test/unit/src/infrastructure/RateLimterTests.js
index f965935c8a..ca078e875b 100644
--- a/services/web/test/unit/src/infrastructure/RateLimterTests.js
+++ b/services/web/test/unit/src/infrastructure/RateLimterTests.js
@@ -23,15 +23,15 @@ describe('RateLimiter', function () {
web: {
port: '1234',
host: 'somewhere',
- password: 'password'
- }
- }
+ password: 'password',
+ },
+ },
}
this.rclient = {
incr: sinon.stub(),
get: sinon.stub(),
expire: sinon.stub(),
- exec: sinon.stub()
+ exec: sinon.stub(),
}
this.rclient.multi = sinon.stub().returns(this.rclient)
this.RedisWrapper = { client: sinon.stub().returns(this.rclient) }
@@ -44,14 +44,14 @@ describe('RateLimiter', function () {
this.requires = {
'settings-sharelatex': this.settings,
'@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }),
- './RedisWrapper': this.RedisWrapper
+ './RedisWrapper': this.RedisWrapper,
}
this.details = {
endpointName: this.endpointName,
subjectName: this.subject,
throttle: this.throttleLimit,
- timeInterval: this.timeInterval
+ timeInterval: this.timeInterval,
}
return (this.key = `RateLimiter:${this.endpointName}:{${this.subject}}`)
})
@@ -62,7 +62,7 @@ describe('RateLimiter', function () {
return sinon.stub().callsArgWith(1, null, 0, 22)
}
return (this.limiter = SandboxedModule.require(modulePath, {
- requires: this.requires
+ requires: this.requires,
}))
})
@@ -98,9 +98,9 @@ describe('RateLimiter', function () {
}
return (this.limiter = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
- requires: this.requires
+ requires: this.requires,
}))
})
@@ -123,7 +123,7 @@ describe('RateLimiter', function () {
{ endpointName: this.endpointName },
(err, should) => {
sinon.assert.calledWith(this.Metrics.inc, `rate-limit-hit`, 1, {
- path: this.endpointName
+ path: this.endpointName,
})
return done()
}
@@ -138,9 +138,9 @@ describe('RateLimiter', function () {
}
return (this.limiter = SandboxedModule.require(modulePath, {
globals: {
- console: console
+ console: console,
},
- requires: this.requires
+ requires: this.requires,
}))
})
diff --git a/services/web/test/unit/src/infrastructure/TranslationsTests.js b/services/web/test/unit/src/infrastructure/TranslationsTests.js
index 22d8ef8d71..9e85394af6 100644
--- a/services/web/test/unit/src/infrastructure/TranslationsTests.js
+++ b/services/web/test/unit/src/infrastructure/TranslationsTests.js
@@ -20,23 +20,23 @@ describe('Translations', function () {
subdomainLang: {
www: { lngCode: 'en', url: 'https://www.sharelatex.com' },
fr: { lngCode: 'fr', url: 'https://fr.sharelatex.com' },
- da: { lngCode: 'da', url: 'https://da.sharelatex.com' }
- }
- }
- }
- }
+ da: { lngCode: 'da', url: 'https://da.sharelatex.com' },
+ },
+ },
+ },
+ },
})
req = {
url: '/',
headers: {
- 'accept-language': ''
- }
+ 'accept-language': '',
+ },
}
res = {
locals: {},
getHeader: () => {},
- setHeader: () => {}
+ setHeader: () => {},
}
})
@@ -62,7 +62,7 @@ describe('Translations', function () {
it('works', function () {
expect(
req.i18n.t('please_confirm_email', {
- emailAddress: 'foo@example.com'
+ emailAddress: 'foo@example.com',
})
).to.equal(
'Please confirm your email foo@example.com by clicking on the link in the confirmation email '
@@ -75,7 +75,7 @@ describe('Translations', function () {
expect(
req.i18n.t('faq_how_does_free_trial_works_answer', {
appName: 'Overleaf',
- len: '5'
+ len: '5',
})
).to.equal(
'You get full access to your chosen Overleaf plan during your 5-day free trial. There is no obligation to continue beyond the trial. Your card will be charged at the end of your 5 day trial unless you cancel before then. You can cancel via your subscription settings.'
@@ -85,7 +85,7 @@ describe('Translations', function () {
it('disables escaping', function () {
expect(
req.i18n.t('admin_user_created_message', {
- link: 'http://google.com'
+ link: 'http://google.com',
})
).to.equal(
'Created admin user, Log in here to continue'
diff --git a/services/web/test/unit/src/util/promisesTests.js b/services/web/test/unit/src/util/promisesTests.js
index d38cb20308..cecfa395cf 100644
--- a/services/web/test/unit/src/util/promisesTests.js
+++ b/services/web/test/unit/src/util/promisesTests.js
@@ -1,7 +1,7 @@
const { expect } = require('chai')
const {
promisifyAll,
- callbackifyMultiResult
+ callbackifyMultiResult,
} = require('../../../../app/src/util/promises')
describe('promisifyAll', function () {
@@ -14,7 +14,7 @@ describe('promisifyAll', function () {
},
asyncDouble(x, callback) {
this.asyncAdd(x, x, callback)
- }
+ },
}
this.promisified = promisifyAll(this.module)
})
@@ -46,7 +46,7 @@ describe('promisifyAll', function () {
},
syncAdd(a, b) {
return a + b
- }
+ },
}
this.promisified = promisifyAll(this.module, { without: 'syncAdd' })
})
@@ -69,10 +69,10 @@ describe('promisifyAll', function () {
},
asyncArithmetic(a, b, callback) {
callback(null, a + b, a * b)
- }
+ },
}
this.promisified = promisifyAll(this.module, {
- multiResult: { asyncArithmetic: ['sum', 'product'] }
+ multiResult: { asyncArithmetic: ['sum', 'product'] },
})
})
@@ -95,7 +95,7 @@ describe('callbackifyMultiResult', function () {
}
const callbackified = callbackifyMultiResult(asyncArithmetic, [
'sum',
- 'product'
+ 'product',
])
callbackified(3, 11, (err, sum, product) => {
if (err != null) {
@@ -113,7 +113,7 @@ describe('callbackifyMultiResult', function () {
}
const callbackified = callbackifyMultiResult(asyncBomb, [
'explosives',
- 'dynamite'
+ 'dynamite',
])
callbackified(err => {
expect(err).to.exist
diff --git a/services/web/transform/o-error/transform.js b/services/web/transform/o-error/transform.js
index 82e695b309..e78e401325 100644
--- a/services/web/transform/o-error/transform.js
+++ b/services/web/transform/o-error/transform.js
@@ -72,8 +72,8 @@ function functionBodyProcessor(j, path) {
j(path)
.find(j.CallExpression, {
callee: {
- object: { name: 'logger' }
- }
+ object: { name: 'logger' },
+ },
})
.filter(path => expressionIsLoggingError(path))
.replaceWith(path => {
diff --git a/services/web/webpack.config.dev.js b/services/web/webpack.config.dev.js
index 46b2ed97fb..ced39fca67 100644
--- a/services/web/webpack.config.dev.js
+++ b/services/web/webpack.config.dev.js
@@ -13,8 +13,8 @@ module.exports = merge(base, {
// Extract CSS to a separate file (rather than inlining to a