Просмотр исходного кода

Merge pull request #4799 from overleaf/hb-eslint-rules

Re-enable some eslint rules

GitOrigin-RevId: 16153adb839bb61784bb40fbc8e43da281fe090d
Hugh O'Brien 4 лет назад
Родитель
Сommit
f7900b474b
26 измененных файлов с 136 добавлено и 82 удалено
  1. 4 6
      services/web/.eslintrc
  2. 4 1
      services/web/app/src/Features/Notifications/NotificationsController.js
  3. 4 0
      services/web/app/src/Features/Project/ProjectController.js
  4. 6 4
      services/web/app/src/Features/Project/ProjectCreationHandler.js
  5. 0 6
      services/web/app/src/Features/Security/OneTimeTokenHandler.js
  6. 2 5
      services/web/app/src/Features/StaticPages/HomeController.js
  7. 0 21
      services/web/app/src/Features/Subscription/LimitationsManager.js
  8. 3 0
      services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.js
  9. 0 8
      services/web/app/src/Features/V1/V1Handler.js
  10. 1 1
      services/web/app/src/infrastructure/Modules.js
  11. 2 0
      services/web/frontend/js/features/file-view/components/file-view-header.js
  12. 1 0
      services/web/frontend/js/features/preview/components/preview-error.js
  13. 1 1
      services/web/frontend/js/features/preview/components/preview-logs-pane-entry.js
  14. 1 1
      services/web/frontend/js/ide/human-readable-logs/HumanReadableLogsRules.js
  15. 1 1
      services/web/frontend/js/main/affiliations/controllers/UserAffiliationsReconfirmController.js
  16. 4 0
      services/web/frontend/js/main/learn.js
  17. 1 1
      services/web/frontend/stories/icon.stories.js
  18. 6 4
      services/web/scripts/create_project.js
  19. 2 1
      services/web/scripts/translations/download.js
  20. 2 1
      services/web/scripts/translations/transformLocales.js
  21. 4 1
      services/web/scripts/translations/upload.js
  22. 38 5
      services/web/test/acceptance/src/ProjectDuplicateNameTests.js
  23. 13 14
      services/web/test/acceptance/src/RegistrationTests.js
  24. 23 0
      services/web/test/unit/src/Subscription/LimitationsManagerTests.js
  25. 3 0
      services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js
  26. 10 0
      services/web/test/unit/src/infrastructure/GeoIpLookupTest.js

+ 4 - 6
services/web/.eslintrc

@@ -47,9 +47,7 @@
     "import/no-extraneous-dependencies": "error",
     "import/no-extraneous-dependencies": "error",
 
 
     "node/no-callback-literal": "off",
     "node/no-callback-literal": "off",
-    "node/no-deprecated-api": "off",
-    "node/handle-callback-err": "off",
-    "node/no-path-concat": "off"
+    "node/no-deprecated-api": "off"
   },
   },
   "overrides": [
   "overrides": [
     // NOTE: changing paths may require updating them in the Makefile too.
     // NOTE: changing paths may require updating them in the Makefile too.
@@ -118,6 +116,9 @@
         "ExposedSettings": true
         "ExposedSettings": true
       },
       },
       "rules": {
       "rules": {
+        "react/jsx-no-target-blank": ["error", {
+          "allowReferrer": true
+        }],
         // Prevent usage of legacy string refs
         // Prevent usage of legacy string refs
         "react/no-string-refs": "error",
         "react/no-string-refs": "error",
 
 
@@ -127,9 +128,6 @@
           "children": "never"
           "children": "never"
         }],
         }],
 
 
-        // Allow target="_blank" in JSX
-        "react/jsx-no-target-blank": "off",
-
         // Don't import React for JSX; the JSX runtime is added by a Babel plugin
         // Don't import React for JSX; the JSX runtime is added by a Babel plugin
         "react/react-in-jsx-scope": "off",
         "react/react-in-jsx-scope": "off",
         "react/jsx-uses-react": "off",
         "react/jsx-uses-react": "off",

+ 4 - 1
services/web/app/src/Features/Notifications/NotificationsController.js

@@ -3,11 +3,14 @@ const SessionManager = require('../Authentication/SessionManager')
 const _ = require('underscore')
 const _ = require('underscore')
 
 
 module.exports = {
 module.exports = {
-  getAllUnreadNotifications(req, res) {
+  getAllUnreadNotifications(req, res, next) {
     const userId = SessionManager.getLoggedInUserId(req.session)
     const userId = SessionManager.getLoggedInUserId(req.session)
     NotificationsHandler.getUserNotifications(
     NotificationsHandler.getUserNotifications(
       userId,
       userId,
       function (err, unreadNotifications) {
       function (err, unreadNotifications) {
+        if (err) {
+          return next(err)
+        }
         unreadNotifications = _.map(
         unreadNotifications = _.map(
           unreadNotifications,
           unreadNotifications,
           function (notification) {
           function (notification) {

+ 4 - 0
services/web/app/src/Features/Project/ProjectController.js

@@ -428,6 +428,10 @@ const ProjectController = {
               'allInReconfirmNotificationPeriodsForUser',
               'allInReconfirmNotificationPeriodsForUser',
               fullEmails,
               fullEmails,
               (error, results) => {
               (error, results) => {
+                if (error != null) {
+                  return cb(error)
+                }
+
                 // Module.hooks.fire accepts multiple methods
                 // Module.hooks.fire accepts multiple methods
                 // and does async.series
                 // and does async.series
                 const allInReconfirmNotificationPeriods =
                 const allInReconfirmNotificationPeriods =

+ 6 - 4
services/web/app/src/Features/Project/ProjectCreationHandler.js

@@ -103,8 +103,9 @@ async function _addExampleProjectFiles(ownerId, projectName, project) {
     ownerId
     ownerId
   )
   )
 
 
-  const frogPath = path.resolve(
-    __dirname + '/../../../templates/project_files/example-project/frog.jpg'
+  const frogPath = path.join(
+    __dirname,
+    '/../../../templates/project_files/example-project/frog.jpg'
   )
   )
   await ProjectEntityUpdateHandler.promises.addFile(
   await ProjectEntityUpdateHandler.promises.addFile(
     project._id,
     project._id,
@@ -175,8 +176,9 @@ async function _createRootDoc(project, ownerId, docLines) {
 async function _buildTemplate(templateName, userId, projectName) {
 async function _buildTemplate(templateName, userId, projectName) {
   const user = await User.findById(userId, 'first_name last_name')
   const user = await User.findById(userId, 'first_name last_name')
 
 
-  const templatePath = path.resolve(
-    __dirname + `/../../../templates/project_files/${templateName}`
+  const templatePath = path.join(
+    __dirname,
+    `/../../../templates/project_files/${templateName}`
   )
   )
   const template = fs.readFileSync(templatePath)
   const template = fs.readFileSync(templatePath)
   const data = {
   const data = {

+ 0 - 6
services/web/app/src/Features/Security/OneTimeTokenHandler.js

@@ -11,9 +11,6 @@ const OneTimeTokenHandler = {
     if (!options) {
     if (!options) {
       options = {}
       options = {}
     }
     }
-    if (!callback) {
-      callback = function (error, data) {}
-    }
     if (typeof options === 'function') {
     if (typeof options === 'function') {
       callback = options
       callback = options
       options = {}
       options = {}
@@ -40,9 +37,6 @@ const OneTimeTokenHandler = {
   },
   },
 
 
   getValueFromTokenAndExpire(use, token, callback) {
   getValueFromTokenAndExpire(use, token, callback) {
-    if (!callback) {
-      callback = function (error, data) {}
-    }
     const now = new Date()
     const now = new Date()
     db.tokens.findOneAndUpdate(
     db.tokens.findOneAndUpdate(
       {
       {

+ 2 - 5
services/web/app/src/Features/StaticPages/HomeController.js

@@ -1,7 +1,6 @@
 /* eslint-disable
 /* eslint-disable
     node/handle-callback-err,
     node/handle-callback-err,
     max-len,
     max-len,
-    no-path-concat,
     no-unused-vars,
     no-unused-vars,
     node/no-deprecated-api,
     node/no-deprecated-api,
 */
 */
@@ -23,7 +22,7 @@ const ErrorController = require('../Errors/ErrorController')
 const SessionManager = require('../Authentication/SessionManager')
 const SessionManager = require('../Authentication/SessionManager')
 
 
 const homepageExists = fs.existsSync(
 const homepageExists = fs.existsSync(
-  Path.resolve(__dirname + '/../../../views/external/home/v2.pug')
+  Path.join(__dirname, '/../../../views/external/home/v2.pug')
 )
 )
 
 
 module.exports = HomeController = {
 module.exports = HomeController = {
@@ -52,9 +51,7 @@ module.exports = HomeController = {
       if (next == null) {
       if (next == null) {
         next = function (error) {}
         next = function (error) {}
       }
       }
-      const path = Path.resolve(
-        __dirname + `/../../../views/external/${page}.pug`
-      )
+      const path = Path.join(__dirname, `/../../../views/external/${page}.pug`)
       return fs.exists(path, function (exists) {
       return fs.exists(path, function (exists) {
         // No error in this callback - old method in Node.js!
         // No error in this callback - old method in Node.js!
         if (exists) {
         if (exists) {

+ 0 - 21
services/web/app/src/Features/Subscription/LimitationsManager.js

@@ -38,9 +38,6 @@ const LimitationsManager = {
   },
   },
 
 
   canAddXCollaborators(projectId, numberOfNewCollaborators, callback) {
   canAddXCollaborators(projectId, numberOfNewCollaborators, callback) {
-    if (!callback) {
-      callback = function (error, allowed) {}
-    }
     this.allowedNumberOfCollaboratorsInProject(
     this.allowedNumberOfCollaboratorsInProject(
       projectId,
       projectId,
       (error, allowedNumber) => {
       (error, allowedNumber) => {
@@ -77,9 +74,6 @@ const LimitationsManager = {
   },
   },
 
 
   hasPaidSubscription(user, callback) {
   hasPaidSubscription(user, callback) {
-    if (!callback) {
-      callback = function (err, hasSubscriptionOrIsMember) {}
-    }
     this.userHasV2Subscription(user, (err, hasSubscription, subscription) => {
     this.userHasV2Subscription(user, (err, hasSubscription, subscription) => {
       if (err) {
       if (err) {
         return callback(err)
         return callback(err)
@@ -112,9 +106,6 @@ const LimitationsManager = {
   },
   },
 
 
   userHasV2Subscription(user, callback) {
   userHasV2Subscription(user, callback) {
-    if (!callback) {
-      callback = function (err, hasSubscription, subscription) {}
-    }
     SubscriptionLocator.getUsersSubscription(
     SubscriptionLocator.getUsersSubscription(
       user._id,
       user._id,
       function (err, subscription) {
       function (err, subscription) {
@@ -136,9 +127,6 @@ const LimitationsManager = {
   },
   },
 
 
   userHasV1OrV2Subscription(user, callback) {
   userHasV1OrV2Subscription(user, callback) {
-    if (!callback) {
-      callback = function (err, hasSubscription) {}
-    }
     this.userHasV2Subscription(user, (err, hasV2Subscription) => {
     this.userHasV2Subscription(user, (err, hasV2Subscription) => {
       if (err) {
       if (err) {
         return callback(err)
         return callback(err)
@@ -159,9 +147,6 @@ const LimitationsManager = {
   },
   },
 
 
   userIsMemberOfGroupSubscription(user, callback) {
   userIsMemberOfGroupSubscription(user, callback) {
-    if (!callback) {
-      callback = function (error, isMember, subscriptions) {}
-    }
     SubscriptionLocator.getMemberSubscriptions(
     SubscriptionLocator.getMemberSubscriptions(
       user._id,
       user._id,
       function (err, subscriptions) {
       function (err, subscriptions) {
@@ -177,9 +162,6 @@ const LimitationsManager = {
   },
   },
 
 
   userHasV1Subscription(user, callback) {
   userHasV1Subscription(user, callback) {
-    if (!callback) {
-      callback = function (error, hasV1Subscription) {}
-    }
     V1SubscriptionManager.getSubscriptionsFromV1(
     V1SubscriptionManager.getSubscriptionsFromV1(
       user._id,
       user._id,
       function (err, v1Subscription) {
       function (err, v1Subscription) {
@@ -201,9 +183,6 @@ const LimitationsManager = {
   },
   },
 
 
   hasGroupMembersLimitReached(subscriptionId, callback) {
   hasGroupMembersLimitReached(subscriptionId, callback) {
-    if (!callback) {
-      callback = function (err, limitReached, subscription) {}
-    }
     SubscriptionLocator.getSubscription(
     SubscriptionLocator.getSubscription(
       subscriptionId,
       subscriptionId,
       function (err, subscription) {
       function (err, subscription) {

+ 3 - 0
services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.js

@@ -33,6 +33,9 @@ function newUpdate(userId, projectName, path, updateRequest, source, callback) {
           )
           )
         }
         }
         FileTypeManager.shouldIgnore(path, (err, shouldIgnore) => {
         FileTypeManager.shouldIgnore(path, (err, shouldIgnore) => {
+          if (err) {
+            return callback(err)
+          }
           if (shouldIgnore) {
           if (shouldIgnore) {
             return callback()
             return callback()
           }
           }

+ 0 - 8
services/web/app/src/Features/V1/V1Handler.js

@@ -1,6 +1,5 @@
 /* eslint-disable
 /* eslint-disable
     camelcase,
     camelcase,
-    node/handle-callback-err,
     max-len,
     max-len,
     no-unused-vars,
     no-unused-vars,
 */
 */
@@ -21,9 +20,6 @@ const logger = require('logger-sharelatex')
 
 
 module.exports = V1Handler = {
 module.exports = V1Handler = {
   authWithV1(email, password, callback) {
   authWithV1(email, password, callback) {
-    if (callback == null) {
-      callback = function (err, isValid, v1Profile) {}
-    }
     return V1Api.request(
     return V1Api.request(
       {
       {
         method: 'POST',
         method: 'POST',
@@ -64,10 +60,6 @@ module.exports = V1Handler = {
   },
   },
 
 
   doPasswordReset(v1_user_id, password, callback) {
   doPasswordReset(v1_user_id, password, callback) {
-    if (callback == null) {
-      callback = function (err, created) {}
-    }
-
     return V1Api.request(
     return V1Api.request(
       {
       {
         method: 'POST',
         method: 'POST',

+ 1 - 1
services/web/app/src/infrastructure/Modules.js

@@ -5,7 +5,7 @@ const async = require('async')
 const { promisify } = require('util')
 const { promisify } = require('util')
 const Settings = require('@overleaf/settings')
 const Settings = require('@overleaf/settings')
 
 
-const MODULE_BASE_PATH = Path.resolve(__dirname + '/../../../modules')
+const MODULE_BASE_PATH = Path.join(__dirname, '/../../../modules')
 
 
 const _modules = []
 const _modules = []
 const _hooks = {}
 const _hooks = {}

+ 2 - 0
services/web/frontend/js/features/file-view/components/file-view-header.js

@@ -213,6 +213,7 @@ function ProjectFilePathProvider({ file }) {
                 <a
                 <a
                   href={`/project/${file.linkedFileData.source_project_id}`}
                   href={`/project/${file.linkedFileData.source_project_id}`}
                   target="_blank"
                   target="_blank"
+                  rel="noopener"
                 />,
                 />,
               ]
               ]
         }
         }
@@ -252,6 +253,7 @@ function ProjectOutputFileProvider({ file }) {
                 <a
                 <a
                   href={`/project/${file.linkedFileData.source_project_id}`}
                   href={`/project/${file.linkedFileData.source_project_id}`}
                   target="_blank"
                   target="_blank"
+                  rel="noopener"
                 />,
                 />,
               ]
               ]
         }
         }

+ 1 - 0
services/web/frontend/js/features/preview/components/preview-error.js

@@ -47,6 +47,7 @@ function PreviewError({ name }) {
           <a
           <a
             href="https://www.overleaf.com/learn/how-to/Why_do_I_keep_getting_the_compile_timeout_error_message%3F"
             href="https://www.overleaf.com/learn/how-to/Why_do_I_keep_getting_the_compile_timeout_error_message%3F"
             target="_blank"
             target="_blank"
+            rel="noopener"
           >
           >
             {t('learn_how_to_make_documents_compile_quickly')}
             {t('learn_how_to_make_documents_compile_quickly')}
           </a>
           </a>

+ 1 - 1
services/web/frontend/js/features/preview/components/preview-logs-pane-entry.js

@@ -224,7 +224,7 @@ function PreviewLogEntryContent({
       ) : null}
       ) : null}
       {extraInfoURL ? (
       {extraInfoURL ? (
         <div className="log-entry-content-link">
         <div className="log-entry-content-link">
-          <a href={extraInfoURL} target="_blank">
+          <a href={extraInfoURL} target="_blank" rel="noopener">
             {t('log_hint_extra_info')}
             {t('log_hint_extra_info')}
           </a>
           </a>
         </div>
         </div>

+ 1 - 1
services/web/frontend/js/ide/human-readable-logs/HumanReadableLogsRules.js

@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
 function WikiLink({ url, children, skipPlainRendering }) {
 function WikiLink({ url, children, skipPlainRendering }) {
   if (window.wikiEnabled) {
   if (window.wikiEnabled) {
     return (
     return (
-      <a href={url} target="_blank">
+      <a href={url} target="_blank" rel="noopener">
         {children}
         {children}
       </a>
       </a>
     )
     )

+ 1 - 1
services/web/frontend/js/main/affiliations/controllers/UserAffiliationsReconfirmController.js

@@ -38,7 +38,7 @@ export default App.controller(
         .then(() => {
         .then(() => {
           $scope.reconfirm[email].reconfirmationSent = true
           $scope.reconfirm[email].reconfirmationSent = true
         })
         })
-        .catch(error => {
+        .catch(_ => {
           $scope.ui.hasError = true
           $scope.ui.hasError = true
         })
         })
         .finally(() => ($scope.ui.isMakingRequest = false))
         .finally(() => ($scope.ui.isMakingRequest = false))

+ 4 - 0
services/web/frontend/js/main/learn.js

@@ -81,6 +81,10 @@ App.controller(
           hitsPerPage: $scope.config_hits_per_page,
           hitsPerPage: $scope.config_hits_per_page,
         },
         },
         function (err, response) {
         function (err, response) {
+          if (err) {
+            $scope.searchError = err
+          }
+
           $scope.processingSearch = false
           $scope.processingSearch = false
           if (response.hits.length === 0) {
           if (response.hits.length === 0) {
             updateHits([])
             updateHits([])

+ 1 - 1
services/web/frontend/stories/icon.stories.js

@@ -8,7 +8,7 @@ export const Type = args => {
         <a
         <a
           href="https://fontawesome.com/v4.7.0/icons/"
           href="https://fontawesome.com/v4.7.0/icons/"
           target="_blank"
           target="_blank"
-          rel="noopener"
+          rel="noopener noreferrer"
         >
         >
           Font Awesome icons
           Font Awesome icons
         </a>
         </a>

+ 6 - 4
services/web/scripts/create_project.js

@@ -65,8 +65,9 @@ async function _addDefaultExampleProjectFiles(ownerId, projectName, project) {
     ownerId
     ownerId
   )
   )
 
 
-  const frogPath = path.resolve(
-    __dirname + '/../app/templates/project_files/example-project/frog.jpg'
+  const frogPath = path.join(
+    __dirname,
+    '/../app/templates/project_files/example-project/frog.jpg'
   )
   )
   await ProjectEntityUpdateHandler.promises.addFile(
   await ProjectEntityUpdateHandler.promises.addFile(
     project._id,
     project._id,
@@ -81,8 +82,9 @@ async function _addDefaultExampleProjectFiles(ownerId, projectName, project) {
 async function _buildTemplate(templateName, userId, projectName) {
 async function _buildTemplate(templateName, userId, projectName) {
   const user = await User.findById(userId, 'first_name last_name')
   const user = await User.findById(userId, 'first_name last_name')
 
 
-  const templatePath = path.resolve(
-    __dirname + `/../app/templates/project_files/${templateName}`
+  const templatePath = path.join(
+    __dirname,
+    `/../app/templates/project_files/${templateName}`
   )
   )
   const template = fs.readFileSync(templatePath)
   const template = fs.readFileSync(templatePath)
   const data = {
   const data = {

+ 2 - 1
services/web/scripts/translations/download.js

@@ -1,3 +1,4 @@
+const path = require('path')
 const { promises: fs } = require('fs')
 const { promises: fs } = require('fs')
 const oneSky = require('@brainly/onesky-utils')
 const oneSky = require('@brainly/onesky-utils')
 const sanitizeHtml = require('sanitize-html')
 const sanitizeHtml = require('sanitize-html')
@@ -35,7 +36,7 @@ async function run() {
       }
       }
 
 
       await fs.writeFile(
       await fs.writeFile(
-        `${__dirname}/../../locales/${code}.json`,
+        path.join(__dirname, `/../../locales/${code}.json`),
         JSON.stringify(lang.translation, null, 2) + '\n'
         JSON.stringify(lang.translation, null, 2) + '\n'
       )
       )
     }
     }

+ 2 - 1
services/web/scripts/translations/transformLocales.js

@@ -1,3 +1,4 @@
+const Path = require('path')
 const fs = require('fs')
 const fs = require('fs')
 
 
 const LANGUAGES = [
 const LANGUAGES = [
@@ -38,7 +39,7 @@ function transformLocales(mapping, transformLocale) {
     })
     })
 
 
     fs.writeFileSync(
     fs.writeFileSync(
-      `${__dirname}/../../locales/${language}.json`,
+      Path.join(__dirname, `/../../locales/${language}.json`),
       JSON.stringify(translatedLocales, null, 2) + '\n'
       JSON.stringify(translatedLocales, null, 2) + '\n'
     )
     )
   })
   })

+ 4 - 1
services/web/scripts/translations/upload.js

@@ -1,3 +1,4 @@
+const Path = require('path')
 const { promises: fs } = require('fs')
 const { promises: fs } = require('fs')
 const { promisify } = require('util')
 const { promisify } = require('util')
 const oneSky = require('@brainly/onesky-utils')
 const oneSky = require('@brainly/onesky-utils')
@@ -12,7 +13,9 @@ async function uploadLocales() {
       fileName: 'en-US.json',
       fileName: 'en-US.json',
       language: 'en-GB',
       language: 'en-GB',
       format: 'HIERARCHICAL_JSON',
       format: 'HIERARCHICAL_JSON',
-      content: await fs.readFile(`${__dirname}/../../locales/en.json`),
+      content: await fs.readFile(
+        Path.join(__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
     })
     })
   )
   )

+ 38 - 5
services/web/test/acceptance/src/ProjectDuplicateNameTests.js

@@ -30,11 +30,10 @@ describe('ProjectDuplicateNames', function () {
         'example-project',
         'example-project',
         { template: 'example' },
         { template: 'example' },
         (error, projectId) => {
         (error, projectId) => {
-          if (error) {
-            throw error
-          }
+          expect(error).to.not.exist
           this.example_project_id = projectId
           this.example_project_id = projectId
           this.owner.getProject(projectId, (error, project) => {
           this.owner.getProject(projectId, (error, project) => {
+            expect(error).to.not.exist
             this.project = project
             this.project = project
             this.mainTexDoc = _.find(
             this.mainTexDoc = _.find(
               project.rootFolder[0].docs,
               project.rootFolder[0].docs,
@@ -59,6 +58,7 @@ describe('ProjectDuplicateNames', function () {
                 },
                 },
               },
               },
               (err, res, body) => {
               (err, res, body) => {
+                expect(err).to.not.exist
                 this.testFolderId = body._id
                 this.testFolderId = body._id
                 done()
                 done()
               }
               }
@@ -95,6 +95,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -117,6 +118,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -141,6 +143,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -163,6 +166,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -187,7 +191,7 @@ describe('ProjectDuplicateNames', function () {
               formData: {
               formData: {
                 qqfile: {
                 qqfile: {
                   value: fs.createReadStream(
                   value: fs.createReadStream(
-                    Path.resolve(__dirname + '/../files/1pixel.png')
+                    Path.join(__dirname, '/../files/1pixel.png')
                   ),
                   ),
                   options: {
                   options: {
                     filename: 'frog.jpg',
                     filename: 'frog.jpg',
@@ -197,6 +201,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.body = body
               this.body = body
               // update the image id because we have replaced the file
               // update the image id because we have replaced the file
               this.imageFile._id = this.body.entity_id
               this.imageFile._id = this.body.entity_id
@@ -224,6 +229,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -246,6 +252,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -270,7 +277,7 @@ describe('ProjectDuplicateNames', function () {
               formData: {
               formData: {
                 qqfile: {
                 qqfile: {
                   value: fs.createReadStream(
                   value: fs.createReadStream(
-                    Path.resolve(__dirname + '/../files/1pixel.png')
+                    Path.join(__dirname, '/../files/1pixel.png')
                   ),
                   ),
                   options: {
                   options: {
                     filename: 'testfolder',
                     filename: 'testfolder',
@@ -280,6 +287,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.body = body
               this.body = body
               done()
               done()
             }
             }
@@ -303,6 +311,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -324,6 +333,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -345,6 +355,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -368,6 +379,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -389,6 +401,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -410,6 +423,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -433,6 +447,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -454,6 +469,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -475,6 +491,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -498,6 +515,9 @@ describe('ProjectDuplicateNames', function () {
             },
             },
           },
           },
           (err, res, body) => {
           (err, res, body) => {
+            if (err) {
+              throw err
+            }
             this.owner.request.post(
             this.owner.request.post(
               {
               {
                 uri: `/project/${this.example_project_id}/doc`,
                 uri: `/project/${this.example_project_id}/doc`,
@@ -507,6 +527,9 @@ describe('ProjectDuplicateNames', function () {
                 },
                 },
               },
               },
               (err, res, body) => {
               (err, res, body) => {
+                if (err) {
+                  throw err
+                }
                 this.owner.request.post(
                 this.owner.request.post(
                   {
                   {
                     uri: `/project/${this.example_project_id}/folder`,
                     uri: `/project/${this.example_project_id}/folder`,
@@ -516,6 +539,9 @@ describe('ProjectDuplicateNames', function () {
                     },
                     },
                   },
                   },
                   (err, res, body) => {
                   (err, res, body) => {
+                    if (err) {
+                      throw err
+                    }
                     this.subFolderId = body._id
                     this.subFolderId = body._id
                     this.owner.request.post(
                     this.owner.request.post(
                       {
                       {
@@ -526,6 +552,9 @@ describe('ProjectDuplicateNames', function () {
                         },
                         },
                       },
                       },
                       (err, res, body) => {
                       (err, res, body) => {
+                        if (err) {
+                          throw err
+                        }
                         this.otherFolderId = body._id
                         this.otherFolderId = body._id
                         done()
                         done()
                       }
                       }
@@ -548,6 +577,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -569,6 +599,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -590,6 +621,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }
@@ -611,6 +643,7 @@ describe('ProjectDuplicateNames', function () {
               },
               },
             },
             },
             (err, res, body) => {
             (err, res, body) => {
+              expect(err).to.not.exist
               this.res = res
               this.res = res
               done()
               done()
             }
             }

+ 13 - 14
services/web/test/acceptance/src/RegistrationTests.js

@@ -1,7 +1,3 @@
-/* eslint-disable
-    handle-callback-err
-*/
-
 const { expect } = require('chai')
 const { expect } = require('chai')
 const async = require('async')
 const async = require('async')
 const metrics = require('./helpers/metrics')
 const metrics = require('./helpers/metrics')
@@ -13,9 +9,6 @@ const Features = require('../../../app/src/infrastructure/Features')
 // Expectations
 // Expectations
 const expectProjectAccess = function (user, projectId, callback) {
 const expectProjectAccess = function (user, projectId, callback) {
   // should have access to project
   // should have access to project
-  if (callback == null) {
-    callback = function (err, result) {}
-  }
   user.openProject(projectId, err => {
   user.openProject(projectId, err => {
     expect(err).to.be.oneOf([null, undefined])
     expect(err).to.be.oneOf([null, undefined])
     return callback()
     return callback()
@@ -24,9 +17,6 @@ const expectProjectAccess = function (user, projectId, callback) {
 
 
 const expectNoProjectAccess = function (user, projectId, callback) {
 const expectNoProjectAccess = function (user, projectId, callback) {
   // should not have access to project page
   // should not have access to project page
-  if (callback == null) {
-    callback = function (err, result) {}
-  }
   user.openProject(projectId, err => {
   user.openProject(projectId, err => {
     expect(err).to.be.instanceof(Error)
     expect(err).to.be.instanceof(Error)
     return callback()
     return callback()
@@ -40,9 +30,6 @@ const tryLoginThroughRegistrationForm = function (
   password,
   password,
   callback
   callback
 ) {
 ) {
-  if (callback == null) {
-    callback = function (err, response, body) {}
-  }
   user.getCsrfToken(err => {
   user.getCsrfToken(err => {
     if (err != null) {
     if (err != null) {
       return callback(err)
       return callback(err)
@@ -234,7 +221,9 @@ describe('Registration', function () {
 
 
     it('should register with the csrf token', function (done) {
     it('should register with the csrf token', function (done) {
       this.user.request.get('/login', (err, res, body) => {
       this.user.request.get('/login', (err, res, body) => {
+        expect(err).to.not.exist
         this.user.getCsrfToken(error => {
         this.user.getCsrfToken(error => {
+          expect(error).to.not.exist
           this.user.request.post(
           this.user.request.post(
             {
             {
               url: '/register',
               url: '/register',
@@ -247,7 +236,7 @@ describe('Registration', function () {
               },
               },
             },
             },
             (error, response, body) => {
             (error, response, body) => {
-              expect(err != null).to.equal(false)
+              expect(error).to.not.exist
               expect(response.statusCode).to.equal(200)
               expect(response.statusCode).to.equal(200)
               return done()
               return done()
             }
             }
@@ -258,7 +247,9 @@ describe('Registration', function () {
 
 
     it('should fail with no csrf token', function (done) {
     it('should fail with no csrf token', function (done) {
       this.user.request.get('/login', (err, res, body) => {
       this.user.request.get('/login', (err, res, body) => {
+        expect(err).to.not.exist
         this.user.getCsrfToken(error => {
         this.user.getCsrfToken(error => {
+          expect(error).to.not.exist
           this.user.request.post(
           this.user.request.post(
             {
             {
               url: '/register',
               url: '/register',
@@ -271,6 +262,7 @@ describe('Registration', function () {
               },
               },
             },
             },
             (error, response, body) => {
             (error, response, body) => {
+              expect(error).to.not.exist
               expect(response.statusCode).to.equal(403)
               expect(response.statusCode).to.equal(403)
               return done()
               return done()
             }
             }
@@ -281,9 +273,12 @@ describe('Registration', function () {
 
 
     it('should fail with a stale csrf token', function (done) {
     it('should fail with a stale csrf token', function (done) {
       this.user.request.get('/login', (err, res, body) => {
       this.user.request.get('/login', (err, res, body) => {
+        expect(err).to.not.exist
         this.user.getCsrfToken(error => {
         this.user.getCsrfToken(error => {
+          expect(error).to.not.exist
           const oldCsrfToken = this.user.csrfToken
           const oldCsrfToken = this.user.csrfToken
           this.user.logout(err => {
           this.user.logout(err => {
+            expect(err).to.not.exist
             this.user.request.post(
             this.user.request.post(
               {
               {
                 url: '/register',
                 url: '/register',
@@ -296,6 +291,7 @@ describe('Registration', function () {
                 },
                 },
               },
               },
               (error, response, body) => {
               (error, response, body) => {
+                expect(error).to.not.exist
                 expect(response.statusCode).to.equal(403)
                 expect(response.statusCode).to.equal(403)
                 return done()
                 return done()
               }
               }
@@ -359,9 +355,11 @@ describe('Registration', function () {
       it('should not allow sign in with secondary email', function (done) {
       it('should not allow sign in with secondary email', function (done) {
         const secondaryEmail = 'acceptance-test-secondary@example.com'
         const secondaryEmail = 'acceptance-test-secondary@example.com'
         this.user1.addEmail(secondaryEmail, err => {
         this.user1.addEmail(secondaryEmail, err => {
+          expect(err).to.not.exist
           this.user1.loginWith(secondaryEmail, err => {
           this.user1.loginWith(secondaryEmail, err => {
             expect(err != null).to.equal(false)
             expect(err != null).to.equal(false)
             this.user1.isLoggedIn((err, isLoggedIn) => {
             this.user1.isLoggedIn((err, isLoggedIn) => {
+              expect(err).to.not.exist
               expect(isLoggedIn).to.equal(false)
               expect(isLoggedIn).to.equal(false)
               return done()
               return done()
             })
             })
@@ -396,6 +394,7 @@ describe('Registration', function () {
                 this.user1.email,
                 this.user1.email,
                 'totally_not_the_right_password',
                 'totally_not_the_right_password',
                 (err, response, body) => {
                 (err, response, body) => {
+                  expect(err).to.not.exist
                   expect(body.redir != null).to.equal(false)
                   expect(body.redir != null).to.equal(false)
                   expect(body.message != null).to.equal(true)
                   expect(body.message != null).to.equal(true)
                   expect(body.message).to.have.all.keys('type', 'text')
                   expect(body.message).to.have.all.keys('type', 'text')

+ 23 - 0
services/web/test/unit/src/Subscription/LimitationsManagerTests.js

@@ -1,4 +1,5 @@
 const SandboxedModule = require('sandboxed-module')
 const SandboxedModule = require('sandboxed-module')
+const assert = require('assert')
 const sinon = require('sinon')
 const sinon = require('sinon')
 const modulePath = require('path').join(
 const modulePath = require('path').join(
   __dirname,
   __dirname,
@@ -374,6 +375,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV2Subscription(
       this.LimitationsManager.userHasV2Subscription(
         this.user,
         this.user,
         (err, hasSubscription) => {
         (err, hasSubscription) => {
+          assert.equal(err, null)
           hasSubscription.should.equal(true)
           hasSubscription.should.equal(true)
           done()
           done()
         }
         }
@@ -386,6 +388,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV2Subscription(
       this.LimitationsManager.userHasV2Subscription(
         this.user,
         this.user,
         (err, hasSubscription) => {
         (err, hasSubscription) => {
+          assert.equal(err, null)
           hasSubscription.should.equal(false)
           hasSubscription.should.equal(false)
           done()
           done()
         }
         }
@@ -397,6 +400,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV2Subscription(
       this.LimitationsManager.userHasV2Subscription(
         this.user,
         this.user,
         (err, hasSubscription) => {
         (err, hasSubscription) => {
+          assert.equal(err, null)
           hasSubscription.should.equal(false)
           hasSubscription.should.equal(false)
           done()
           done()
         }
         }
@@ -413,6 +417,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV2Subscription(
       this.LimitationsManager.userHasV2Subscription(
         this.user,
         this.user,
         (err, hasSubOrIsGroupMember, subscription) => {
         (err, hasSubOrIsGroupMember, subscription) => {
+          assert.equal(err, null)
           subscription.should.deep.equal(stubbedSubscription)
           subscription.should.deep.equal(stubbedSubscription)
           done()
           done()
         }
         }
@@ -433,6 +438,7 @@ describe('LimitationsManager', function () {
         this.LimitationsManager.userHasV2Subscription(
         this.LimitationsManager.userHasV2Subscription(
           this.user,
           this.user,
           (err, hasSubscription, subscription) => {
           (err, hasSubscription, subscription) => {
+            assert.equal(err, null)
             hasSubscription.should.equal(true)
             hasSubscription.should.equal(true)
             done()
             done()
           }
           }
@@ -443,6 +449,7 @@ describe('LimitationsManager', function () {
         this.LimitationsManager.userHasV2Subscription(
         this.LimitationsManager.userHasV2Subscription(
           this.user,
           this.user,
           (err, hasSubscription, subscription) => {
           (err, hasSubscription, subscription) => {
+            assert.equal(err, null)
             subscription.should.deep.equal(this.fakeSubscription)
             subscription.should.deep.equal(this.fakeSubscription)
             done()
             done()
           }
           }
@@ -461,6 +468,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userIsMemberOfGroupSubscription(
       this.LimitationsManager.userIsMemberOfGroupSubscription(
         this.user,
         this.user,
         (err, isMember) => {
         (err, isMember) => {
+          assert.equal(err, null)
           isMember.should.equal(false)
           isMember.should.equal(false)
           done()
           done()
         }
         }
@@ -477,6 +485,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userIsMemberOfGroupSubscription(
       this.LimitationsManager.userIsMemberOfGroupSubscription(
         this.user,
         this.user,
         (err, isMember, retSubscriptions) => {
         (err, isMember, retSubscriptions) => {
+          assert.equal(err, null)
           isMember.should.equal(true)
           isMember.should.equal(true)
           retSubscriptions.should.equal(subscriptions)
           retSubscriptions.should.equal(subscriptions)
           done()
           done()
@@ -505,6 +514,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.hasPaidSubscription(
       this.LimitationsManager.hasPaidSubscription(
         this.user,
         this.user,
         (err, hasSubOrIsGroupMember) => {
         (err, hasSubOrIsGroupMember) => {
+          assert.equal(err, null)
           hasSubOrIsGroupMember.should.equal(true)
           hasSubOrIsGroupMember.should.equal(true)
           done()
           done()
         }
         }
@@ -518,6 +528,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.hasPaidSubscription(
       this.LimitationsManager.hasPaidSubscription(
         this.user,
         this.user,
         (err, hasSubOrIsGroupMember) => {
         (err, hasSubOrIsGroupMember) => {
+          assert.equal(err, null)
           hasSubOrIsGroupMember.should.equal(true)
           hasSubOrIsGroupMember.should.equal(true)
           done()
           done()
         }
         }
@@ -531,6 +542,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.hasPaidSubscription(
       this.LimitationsManager.hasPaidSubscription(
         this.user,
         this.user,
         (err, hasSubOrIsGroupMember) => {
         (err, hasSubOrIsGroupMember) => {
+          assert.equal(err, null)
           hasSubOrIsGroupMember.should.equal(true)
           hasSubOrIsGroupMember.should.equal(true)
           done()
           done()
         }
         }
@@ -541,6 +553,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.hasPaidSubscription(
       this.LimitationsManager.hasPaidSubscription(
         this.user,
         this.user,
         (err, hasSubOrIsGroupMember) => {
         (err, hasSubOrIsGroupMember) => {
+          assert.equal(err, null)
           hasSubOrIsGroupMember.should.equal(false)
           hasSubOrIsGroupMember.should.equal(false)
           done()
           done()
         }
         }
@@ -551,6 +564,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasSubscriptionOrIsGroupMember(
       this.LimitationsManager.userHasSubscriptionOrIsGroupMember(
         this.user,
         this.user,
         (err, hasSubOrIsGroupMember) => {
         (err, hasSubOrIsGroupMember) => {
+          assert.equal(err, null)
           hasSubOrIsGroupMember.should.equal(false)
           hasSubOrIsGroupMember.should.equal(false)
           done()
           done()
         }
         }
@@ -575,6 +589,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV1OrV2Subscription(
       this.LimitationsManager.userHasV1OrV2Subscription(
         this.user,
         this.user,
         (err, hasSub) => {
         (err, hasSub) => {
+          assert.equal(err, null)
           hasSub.should.equal(true)
           hasSub.should.equal(true)
           done()
           done()
         }
         }
@@ -588,6 +603,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV1OrV2Subscription(
       this.LimitationsManager.userHasV1OrV2Subscription(
         this.user,
         this.user,
         (err, hasSub) => {
         (err, hasSub) => {
+          assert.equal(err, null)
           hasSub.should.equal(true)
           hasSub.should.equal(true)
           done()
           done()
         }
         }
@@ -598,6 +614,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV1OrV2Subscription(
       this.LimitationsManager.userHasV1OrV2Subscription(
         this.user,
         this.user,
         (err, hasSub) => {
         (err, hasSub) => {
+          assert.equal(err, null)
           hasSub.should.equal(false)
           hasSub.should.equal(false)
           done()
           done()
         }
         }
@@ -626,6 +643,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.hasGroupMembersLimitReached(
       this.LimitationsManager.hasGroupMembersLimitReached(
         this.subscriptionId,
         this.subscriptionId,
         (err, limitReached) => {
         (err, limitReached) => {
+          assert.equal(err, null)
           limitReached.should.equal(true)
           limitReached.should.equal(true)
           done()
           done()
         }
         }
@@ -642,6 +660,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.hasGroupMembersLimitReached(
       this.LimitationsManager.hasGroupMembersLimitReached(
         this.subscriptionId,
         this.subscriptionId,
         (err, limitReached) => {
         (err, limitReached) => {
+          assert.equal(err, null)
           limitReached.should.equal(false)
           limitReached.should.equal(false)
           done()
           done()
         }
         }
@@ -658,6 +677,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.hasGroupMembersLimitReached(
       this.LimitationsManager.hasGroupMembersLimitReached(
         this.subscriptionId,
         this.subscriptionId,
         (err, limitReached) => {
         (err, limitReached) => {
+          assert.equal(err, null)
           limitReached.should.equal(true)
           limitReached.should.equal(true)
           done()
           done()
         }
         }
@@ -673,6 +693,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV1Subscription(
       this.LimitationsManager.userHasV1Subscription(
         this.user,
         this.user,
         (error, result) => {
         (error, result) => {
+          assert.equal(error, null)
           this.V1SubscriptionManager.getSubscriptionsFromV1
           this.V1SubscriptionManager.getSubscriptionsFromV1
             .calledWith(this.userId)
             .calledWith(this.userId)
             .should.equal(true)
             .should.equal(true)
@@ -689,6 +710,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV1Subscription(
       this.LimitationsManager.userHasV1Subscription(
         this.user,
         this.user,
         (error, result) => {
         (error, result) => {
+          assert.equal(error, null)
           this.V1SubscriptionManager.getSubscriptionsFromV1
           this.V1SubscriptionManager.getSubscriptionsFromV1
             .calledWith(this.userId)
             .calledWith(this.userId)
             .should.equal(true)
             .should.equal(true)
@@ -705,6 +727,7 @@ describe('LimitationsManager', function () {
       this.LimitationsManager.userHasV1Subscription(
       this.LimitationsManager.userHasV1Subscription(
         this.user,
         this.user,
         (error, result) => {
         (error, result) => {
+          assert.equal(error, null)
           this.V1SubscriptionManager.getSubscriptionsFromV1
           this.V1SubscriptionManager.getSubscriptionsFromV1
             .calledWith(this.userId)
             .calledWith(this.userId)
             .should.equal(true)
             .should.equal(true)

+ 3 - 0
services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js

@@ -1,5 +1,6 @@
 const SandboxedModule = require('sandboxed-module')
 const SandboxedModule = require('sandboxed-module')
 const { expect } = require('chai')
 const { expect } = require('chai')
+const assert = require('assert')
 const sinon = require('sinon')
 const sinon = require('sinon')
 const modulePath =
 const modulePath =
   '../../../../app/src/Features/Subscription/UserFeaturesUpdater'
   '../../../../app/src/Features/Subscription/UserFeaturesUpdater'
@@ -46,6 +47,7 @@ describe('UserFeaturesUpdater', function () {
         (err, features) => {
         (err, features) => {
           const updateArgs = this.User.findByIdAndUpdate.lastCall.args
           const updateArgs = this.User.findByIdAndUpdate.lastCall.args
           expect(updateArgs[0]).to.deep.equal(userId)
           expect(updateArgs[0]).to.deep.equal(userId)
+          assert.equal(err, null)
           expect(Object.keys(updateArgs[1]).length).to.equal(3)
           expect(Object.keys(updateArgs[1]).length).to.equal(3)
           expect(updateArgs[1]['features.versioning']).to.equal(
           expect(updateArgs[1]['features.versioning']).to.equal(
             update.versioning
             update.versioning
@@ -69,6 +71,7 @@ describe('UserFeaturesUpdater', function () {
         userId,
         userId,
         update,
         update,
         (err, featuresChanged) => {
         (err, featuresChanged) => {
+          assert.equal(err, null)
           const updateArgs = this.User.findByIdAndUpdate.lastCall.args
           const updateArgs = this.User.findByIdAndUpdate.lastCall.args
           expect(updateArgs[0]).to.equal(userId)
           expect(updateArgs[0]).to.equal(userId)
           expect(Object.keys(updateArgs[1]).length).to.equal(2)
           expect(Object.keys(updateArgs[1]).length).to.equal(2)

+ 10 - 0
services/web/test/unit/src/infrastructure/GeoIpLookupTest.js

@@ -61,6 +61,7 @@ describe('GeoIpLookup', function () {
     describe('callback', function () {
     describe('callback', function () {
       it('should request the details using the ip', function (done) {
       it('should request the details using the ip', function (done) {
         this.GeoIpLookup.getDetails(this.ipAddress, err => {
         this.GeoIpLookup.getDetails(this.ipAddress, err => {
+          assert.equal(err, null)
           this.request.get
           this.request.get
             .calledWith({
             .calledWith({
               url: this.settings.apis.geoIpLookup.url + '/' + this.ipAddress,
               url: this.settings.apis.geoIpLookup.url + '/' + this.ipAddress,
@@ -74,6 +75,7 @@ describe('GeoIpLookup', function () {
 
 
       it('should return the ip details', function (done) {
       it('should return the ip details', function (done) {
         this.GeoIpLookup.getDetails(this.ipAddress, (err, returnedDetails) => {
         this.GeoIpLookup.getDetails(this.ipAddress, (err, returnedDetails) => {
+          assert.equal(err, null)
           assert.deepEqual(returnedDetails, this.stubbedResponse)
           assert.deepEqual(returnedDetails, this.stubbedResponse)
           done()
           done()
         })
         })
@@ -83,6 +85,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getDetails(
         this.GeoIpLookup.getDetails(
           ` ${this.ipAddress} 123.123.123.123 234.234.234.234`,
           ` ${this.ipAddress} 123.123.123.123 234.234.234.234`,
           err => {
           err => {
+            assert.equal(err, null)
             this.request.get
             this.request.get
               .calledWith({
               .calledWith({
                 url: this.settings.apis.geoIpLookup.url + '/' + this.ipAddress,
                 url: this.settings.apis.geoIpLookup.url + '/' + this.ipAddress,
@@ -137,6 +140,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getCurrencyCode(
         this.GeoIpLookup.getCurrencyCode(
           this.ipAddress,
           this.ipAddress,
           (err, currencyCode) => {
           (err, currencyCode) => {
+            assert.equal(err, null)
             currencyCode.should.equal('GBP')
             currencyCode.should.equal('GBP')
             done()
             done()
           }
           }
@@ -149,6 +153,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getCurrencyCode(
         this.GeoIpLookup.getCurrencyCode(
           this.ipAddress,
           this.ipAddress,
           (err, currencyCode) => {
           (err, currencyCode) => {
+            assert.equal(err, null)
             currencyCode.should.equal('GBP')
             currencyCode.should.equal('GBP')
             done()
             done()
           }
           }
@@ -161,6 +166,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getCurrencyCode(
         this.GeoIpLookup.getCurrencyCode(
           this.ipAddress,
           this.ipAddress,
           (err, currencyCode) => {
           (err, currencyCode) => {
+            assert.equal(err, null)
             currencyCode.should.equal('USD')
             currencyCode.should.equal('USD')
             done()
             done()
           }
           }
@@ -173,6 +179,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getCurrencyCode(
         this.GeoIpLookup.getCurrencyCode(
           this.ipAddress,
           this.ipAddress,
           (err, currencyCode) => {
           (err, currencyCode) => {
+            assert.equal(err, null)
             currencyCode.should.equal('EUR')
             currencyCode.should.equal('EUR')
             done()
             done()
           }
           }
@@ -184,6 +191,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getCurrencyCode(
         this.GeoIpLookup.getCurrencyCode(
           this.ipAddress,
           this.ipAddress,
           (err, currencyCode) => {
           (err, currencyCode) => {
+            assert.equal(err, null)
             currencyCode.should.equal('USD')
             currencyCode.should.equal('USD')
             done()
             done()
           }
           }
@@ -195,6 +203,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getCurrencyCode(
         this.GeoIpLookup.getCurrencyCode(
           this.ipAddress,
           this.ipAddress,
           (err, currencyCode) => {
           (err, currencyCode) => {
+            assert.equal(err, null)
             currencyCode.should.equal('USD')
             currencyCode.should.equal('USD')
             done()
             done()
           }
           }
@@ -207,6 +216,7 @@ describe('GeoIpLookup', function () {
         this.GeoIpLookup.getCurrencyCode(
         this.GeoIpLookup.getCurrencyCode(
           this.ipAddress,
           this.ipAddress,
           (err, currencyCode) => {
           (err, currencyCode) => {
+            assert.equal(err, null)
             currencyCode.should.equal('USD')
             currencyCode.should.equal('USD')
             done()
             done()
           }
           }