Browse Source

Merge pull request #164 from overleaf/em-revert-node-upgrade

Revert Node upgrade
Eric Mc Sween 5 years ago
parent
commit
2588c9b87b
44 changed files with 410 additions and 633 deletions
  1. 0 3
      services/document-updater/.mocharc.json
  2. 1 1
      services/document-updater/.nvmrc
  3. 1 1
      services/document-updater/Dockerfile
  4. 2 4
      services/document-updater/Makefile
  5. 2 6
      services/document-updater/app/js/RangesTracker.js
  6. 2 2
      services/document-updater/buildscript.txt
  7. 2 2
      services/document-updater/docker-compose.yml
  8. 238 552
      services/document-updater/package-lock.json
  9. 4 4
      services/document-updater/package.json
  10. 3 1
      services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js
  11. 2 0
      services/document-updater/test/acceptance/js/ApplyingUpdatesToProjectStructureTests.js
  12. 3 0
      services/document-updater/test/acceptance/js/DeletingADocumentTests.js
  13. 2 0
      services/document-updater/test/acceptance/js/DeletingAProjectTests.js
  14. 2 0
      services/document-updater/test/acceptance/js/FlushingAProjectTests.js
  15. 3 1
      services/document-updater/test/acceptance/js/FlushingDocsTests.js
  16. 3 1
      services/document-updater/test/acceptance/js/GettingADocumentTests.js
  17. 3 1
      services/document-updater/test/acceptance/js/GettingProjectDocsTests.js
  18. 3 1
      services/document-updater/test/acceptance/js/RangesTests.js
  19. 2 0
      services/document-updater/test/acceptance/js/SettingADocumentTests.js
  20. 0 37
      services/document-updater/test/setup.js
  21. 3 1
      services/document-updater/test/unit/js/DiffCodec/DiffCodecTests.js
  22. 7 0
      services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js
  23. 9 0
      services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js
  24. 6 0
      services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js
  25. 4 1
      services/document-updater/test/unit/js/HistoryRedisManager/HistoryRedisManagerTests.js
  26. 1 0
      services/document-updater/test/unit/js/HttpController/HttpControllerTests.js
  27. 1 0
      services/document-updater/test/unit/js/LockManager/CheckingTheLock.js
  28. 4 0
      services/document-updater/test/unit/js/LockManager/ReleasingTheLock.js
  29. 3 0
      services/document-updater/test/unit/js/LockManager/getLockTests.js
  30. 3 0
      services/document-updater/test/unit/js/LockManager/tryLockTests.js
  31. 7 0
      services/document-updater/test/unit/js/PersistenceManager/PersistenceManagerTests.js
  32. 10 2
      services/document-updater/test/unit/js/ProjectHistoryRedisManager/ProjectHistoryRedisManagerTests.js
  33. 6 0
      services/document-updater/test/unit/js/ProjectManager/flushAndDeleteProjectTests.js
  34. 6 0
      services/document-updater/test/unit/js/ProjectManager/flushProjectTests.js
  35. 6 0
      services/document-updater/test/unit/js/ProjectManager/getProjectDocsTests.js
  36. 6 0
      services/document-updater/test/unit/js/ProjectManager/updateProjectTests.js
  37. 17 2
      services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js
  38. 4 1
      services/document-updater/test/unit/js/RateLimitManager/RateLimitManager.js
  39. 3 0
      services/document-updater/test/unit/js/RealTimeRedisManager/RealTimeRedisManagerTests.js
  40. 16 8
      services/document-updater/test/unit/js/RedisManager/RedisManagerTests.js
  41. 1 0
      services/document-updater/test/unit/js/ShareJS/TextTransformTests.js
  42. 3 1
      services/document-updater/test/unit/js/ShareJsDB/ShareJsDBTests.js
  43. 3 0
      services/document-updater/test/unit/js/ShareJsUpdateManager/ShareJsUpdateManagerTests.js
  44. 3 0
      services/document-updater/test/unit/js/UpdateManager/UpdateManagerTests.js

+ 0 - 3
services/document-updater/.mocharc.json

@@ -1,3 +0,0 @@
-{
-  "require": "test/setup.js"
-}

+ 1 - 1
services/document-updater/.nvmrc

@@ -1 +1 @@
-12.21.0
+10.23.1

+ 1 - 1
services/document-updater/Dockerfile

@@ -2,7 +2,7 @@
 # Instead run bin/update_build_scripts from
 # https://github.com/sharelatex/sharelatex-dev-environment
 
-FROM node:12.21.0 as base
+FROM node:10.23.1 as base
 
 WORKDIR /app
 

+ 2 - 4
services/document-updater/Makefile

@@ -21,10 +21,8 @@ DOCKER_COMPOSE_TEST_UNIT = \
 	COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
 
 clean:
-	-docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
-	-docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
-	-$(DOCKER_COMPOSE_TEST_UNIT) down --rmi local
-	-$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down --rmi local
+	docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
+	docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
 
 format:
 	$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format

+ 2 - 6
services/document-updater/app/js/RangesTracker.js

@@ -706,10 +706,8 @@ const load = function () {
           return result
         } else if (c1.op.i != null && c2.op.d != null) {
           return 1
-        } else if (c1.op.d != null && c2.op.i != null) {
-          return -1
         } else {
-          return 0
+          return -1
         }
       })
 
@@ -730,10 +728,8 @@ const load = function () {
           return result
         } else if (a.i != null && b.d != null) {
           return 1
-        } else if (a.d != null && b.i != null) {
-          return -1
         } else {
-          return 0
+          return -1
         }
       })
 

+ 2 - 2
services/document-updater/buildscript.txt

@@ -3,6 +3,6 @@ document-updater
 --docker-repos=gcr.io/overleaf-ops
 --env-add=
 --env-pass-through=
---node-version=12.21.0
+--node-version=10.23.1
 --public-repo=True
---script-version=3.7.0
+--script-version=3.4.0

+ 2 - 2
services/document-updater/docker-compose.yml

@@ -6,7 +6,7 @@ version: "2.3"
 
 services:
   test_unit:
-    image: node:12.21.0
+    image: node:10.23.1
     volumes:
       - .:/app
     working_dir: /app
@@ -18,7 +18,7 @@ services:
     user: node
 
   test_acceptance:
-    image: node:12.21.0
+    image: node:10.23.1
     volumes:
       - .:/app
     working_dir: /app

File diff suppressed because it is too large
+ 238 - 552
services/document-updater/package-lock.json


+ 4 - 4
services/document-updater/package.json

@@ -18,7 +18,7 @@
     "format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write"
   },
   "dependencies": {
-    "@overleaf/metrics": "^3.5.1",
+    "@overleaf/metrics": "^3.4.1",
     "@overleaf/o-error": "^3.1.0",
     "@overleaf/redis-wrapper": "^2.0.0",
     "async": "^2.5.0",
@@ -36,8 +36,8 @@
   "devDependencies": {
     "babel-eslint": "^10.1.0",
     "chai": "^3.5.0",
+    "chai-spies": "^0.7.1",
     "cluster-key-slot": "^1.0.5",
-    "coffee-script": "^1.12.7",
     "eslint": "^6.8.0",
     "eslint-config-prettier": "^6.10.0",
     "eslint-config-standard": "^14.1.0",
@@ -53,10 +53,10 @@
     "eslint-plugin-promise": "^4.2.1",
     "eslint-plugin-react": "^7.19.0",
     "eslint-plugin-standard": "^4.0.1",
-    "mocha": "^8.3.2",
+    "mocha": "^5.0.1",
     "prettier": "^2.0.0",
     "prettier-eslint-cli": "^5.0.0",
-    "sandboxed-module": "^2.0.4",
+    "sandboxed-module": "~0.2.0",
     "sinon": "^9.0.2",
     "timekeeper": "^2.0.0"
   }

+ 3 - 1
services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js

@@ -12,7 +12,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+chai.should()
+const { expect } = chai
 const async = require('async')
 const Settings = require('settings-sharelatex')
 const rclient_history = require('@overleaf/redis-wrapper').createClient(

+ 2 - 0
services/document-updater/test/acceptance/js/ApplyingUpdatesToProjectStructureTests.js

@@ -1,4 +1,6 @@
 const sinon = require('sinon')
+const chai = require('chai')
+chai.should()
 const Settings = require('settings-sharelatex')
 const rclientProjectHistory = require('@overleaf/redis-wrapper').createClient(
   Settings.redis.project_history

+ 3 - 0
services/document-updater/test/acceptance/js/DeletingADocumentTests.js

@@ -11,6 +11,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+chai.should()
+
 const MockTrackChangesApi = require('./helpers/MockTrackChangesApi')
 const MockProjectHistoryApi = require('./helpers/MockProjectHistoryApi')
 const MockWebApi = require('./helpers/MockWebApi')

+ 2 - 0
services/document-updater/test/acceptance/js/DeletingAProjectTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+chai.should()
 const async = require('async')
 
 const MockTrackChangesApi = require('./helpers/MockTrackChangesApi')

+ 2 - 0
services/document-updater/test/acceptance/js/FlushingAProjectTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+chai.should()
 const async = require('async')
 
 const MockWebApi = require('./helpers/MockWebApi')

+ 3 - 1
services/document-updater/test/acceptance/js/FlushingDocsTests.js

@@ -14,7 +14,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+chai.should()
+const { expect } = chai
 const async = require('async')
 
 const MockWebApi = require('./helpers/MockWebApi')

+ 3 - 1
services/document-updater/test/acceptance/js/GettingADocumentTests.js

@@ -12,7 +12,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+chai.should()
+const { expect } = chai
 
 const MockWebApi = require('./helpers/MockWebApi')
 const DocUpdaterClient = require('./helpers/DocUpdaterClient')

+ 3 - 1
services/document-updater/test/acceptance/js/GettingProjectDocsTests.js

@@ -12,7 +12,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+chai.should()
+const { expect } = chai
 
 const MockWebApi = require('./helpers/MockWebApi')
 const DocUpdaterClient = require('./helpers/DocUpdaterClient')

+ 3 - 1
services/document-updater/test/acceptance/js/RangesTests.js

@@ -12,7 +12,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+chai.should()
+const { expect } = chai
 const async = require('async')
 
 const { db, ObjectId } = require('../../../app/js/mongodb')

+ 2 - 0
services/document-updater/test/acceptance/js/SettingADocumentTests.js

@@ -1,4 +1,6 @@
 const sinon = require('sinon')
+const chai = require('chai')
+chai.should()
 const { expect } = require('chai')
 const Settings = require('settings-sharelatex')
 const docUpdaterRedis = require('@overleaf/redis-wrapper').createClient(

+ 0 - 37
services/document-updater/test/setup.js

@@ -1,37 +0,0 @@
-const chai = require('chai')
-const SandboxedModule = require('sandboxed-module')
-const sinon = require('sinon')
-
-// Chai configuration
-chai.should()
-
-// Global stubs
-const sandbox = sinon.createSandbox()
-const stubs = {
-  logger: {
-    debug: sandbox.stub(),
-    log: sandbox.stub(),
-    warn: sandbox.stub(),
-    err: sandbox.stub(),
-    error: sandbox.stub()
-  }
-}
-
-// SandboxedModule configuration
-SandboxedModule.configure({
-  requires: {
-    'logger-sharelatex': stubs.logger
-  },
-  globals: { Buffer, JSON, Math, console, process }
-})
-
-// Mocha hooks
-exports.mochaHooks = {
-  beforeEach() {
-    this.logger = stubs.logger
-  },
-
-  afterEach() {
-    sandbox.reset()
-  }
-}

+ 3 - 1
services/document-updater/test/unit/js/DiffCodec/DiffCodecTests.js

@@ -11,7 +11,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+const should = chai.should()
+const { expect } = chai
 const modulePath = '../../../../app/js/DiffCodec.js'
 const SandboxedModule = require('sandboxed-module')
 

+ 7 - 0
services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/DispatchManager.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors.js')
@@ -23,6 +25,11 @@ describe('DispatchManager', function () {
     this.DispatchManager = SandboxedModule.require(modulePath, {
       requires: {
         './UpdateManager': (this.UpdateManager = {}),
+        'logger-sharelatex': (this.logger = {
+          log: sinon.stub(),
+          error: sinon.stub(),
+          warn: sinon.stub()
+        }),
         'settings-sharelatex': (this.settings = {
           redis: {
             documentupdater: {}

+ 9 - 0
services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js

@@ -13,6 +13,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/DocumentManager.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors')
@@ -31,6 +33,11 @@ describe('DocumentManager', function () {
           flushDocChangesAsync: sinon.stub(),
           flushProjectChangesAsync: sinon.stub()
         }),
+        'logger-sharelatex': (this.logger = {
+          log: sinon.stub(),
+          warn: sinon.stub()
+        }),
+        './DocOpsManager': (this.DocOpsManager = {}),
         './Metrics': (this.Metrics = {
           Timer: (Timer = (function () {
             Timer = class Timer {
@@ -213,6 +220,7 @@ describe('DocumentManager', function () {
           .stub()
           .callsArgWith(2, null, null, null, null)
         this.PersistenceManager.setDoc = sinon.stub().yields()
+        this.DocOpsManager.flushDocOpsToMongo = sinon.stub().callsArgWith(2)
         return this.DocumentManager.flushDocIfLoaded(
           this.project_id,
           this.doc_id,
@@ -228,6 +236,7 @@ describe('DocumentManager', function () {
 
       it('should not write anything to the persistence layer', function () {
         this.PersistenceManager.setDoc.called.should.equal(false)
+        return this.DocOpsManager.flushDocOpsToMongo.called.should.equal(false)
       })
 
       it('should call the callback without error', function () {

+ 6 - 0
services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js

@@ -11,6 +11,7 @@
  */
 const SandboxedModule = require('sandboxed-module')
 const sinon = require('sinon')
+require('chai').should()
 const modulePath = require('path').join(
   __dirname,
   '../../../../app/js/HistoryManager'
@@ -32,6 +33,11 @@ describe('HistoryManager', function () {
             }
           }
         }),
+        'logger-sharelatex': (this.logger = {
+          log: sinon.stub(),
+          error: sinon.stub(),
+          debug: sinon.stub()
+        }),
         './DocumentManager': (this.DocumentManager = {}),
         './HistoryRedisManager': (this.HistoryRedisManager = {}),
         './RedisManager': (this.RedisManager = {}),

+ 4 - 1
services/document-updater/test/unit/js/HistoryRedisManager/HistoryRedisManagerTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/HistoryRedisManager.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors')
@@ -39,7 +41,8 @@ describe('HistoryRedisManager', function () {
               }
             })
           }
-        }
+        },
+        'logger-sharelatex': { log() {} }
       }
     })
     this.doc_id = 'doc-id-123'

+ 1 - 0
services/document-updater/test/unit/js/HttpController/HttpControllerTests.js

@@ -12,6 +12,7 @@ describe('HttpController', function () {
           flushProjectChangesAsync: sinon.stub()
         }),
         './ProjectManager': (this.ProjectManager = {}),
+        'logger-sharelatex': (this.logger = { log: sinon.stub() }),
         './ProjectFlusher': { flushAllProjects() {} },
         './DeleteQueueManager': (this.DeleteQueueManager = {}),
         './Metrics': (this.Metrics = {}),

+ 1 - 0
services/document-updater/test/unit/js/LockManager/CheckingTheLock.js

@@ -25,6 +25,7 @@ describe('LockManager - checking the lock', function () {
   const existsStub = sinon.stub()
 
   const mocks = {
+    'logger-sharelatex': { log() {} },
     '@overleaf/redis-wrapper': {
       createClient() {
         return {

+ 4 - 0
services/document-updater/test/unit/js/LockManager/ReleasingTheLock.js

@@ -27,6 +27,10 @@ describe('LockManager - releasing the lock', function () {
       eval: sinon.stub()
     }
     const mocks = {
+      'logger-sharelatex': {
+        log() {},
+        error() {}
+      },
       '@overleaf/redis-wrapper': {
         createClient: () => this.client
       },

+ 3 - 0
services/document-updater/test/unit/js/LockManager/getLockTests.js

@@ -15,6 +15,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/LockManager.js'
 const SandboxedModule = require('sandboxed-module')
 
@@ -23,6 +25,7 @@ describe('LockManager - getting the lock', function () {
     let Profiler
     this.LockManager = SandboxedModule.require(modulePath, {
       requires: {
+        'logger-sharelatex': { log() {} },
         '@overleaf/redis-wrapper': {
           createClient: () => {
             return { auth() {} }

+ 3 - 0
services/document-updater/test/unit/js/LockManager/tryLockTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/LockManager.js'
 const SandboxedModule = require('sandboxed-module')
 
@@ -20,6 +22,7 @@ describe('LockManager - trying the lock', function () {
     let Profiler
     this.LockManager = SandboxedModule.require(modulePath, {
       requires: {
+        'logger-sharelatex': { log() {} },
         '@overleaf/redis-wrapper': {
           createClient: () => {
             return {

+ 7 - 0
services/document-updater/test/unit/js/PersistenceManager/PersistenceManagerTests.js

@@ -11,6 +11,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/PersistenceManager.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors')
@@ -36,6 +38,11 @@ describe('PersistenceManager', function () {
           })()),
           inc: sinon.stub()
         }),
+        'logger-sharelatex': (this.logger = {
+          log: sinon.stub(),
+          err: sinon.stub(),
+          error: sinon.stub()
+        }),
         './Errors': Errors
       }
     })

+ 10 - 2
services/document-updater/test/unit/js/ProjectHistoryRedisManager/ProjectHistoryRedisManagerTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/ProjectHistoryRedisManager.js'
 const SandboxedModule = require('sandboxed-module')
 const tk = require('timekeeper')
@@ -45,7 +47,13 @@ describe('ProjectHistoryRedisManager', function () {
           '@overleaf/redis-wrapper': {
             createClient: () => this.rclient
           },
+          'logger-sharelatex': {
+            log() {}
+          },
           './Metrics': (this.metrics = { summary: sinon.stub() })
+        },
+        globals: {
+          JSON: (this.JSON = JSON)
         }
       }
     ))
@@ -128,7 +136,7 @@ describe('ProjectHistoryRedisManager', function () {
       return this.ProjectHistoryRedisManager.queueOps
         .calledWithExactly(
           this.project_id,
-          JSON.stringify(update),
+          this.JSON.stringify(update),
           this.callback
         )
         .should.equal(true)
@@ -176,7 +184,7 @@ describe('ProjectHistoryRedisManager', function () {
       return this.ProjectHistoryRedisManager.queueOps
         .calledWithExactly(
           this.project_id,
-          JSON.stringify(update),
+          this.JSON.stringify(update),
           this.callback
         )
         .should.equal(true)

+ 6 - 0
services/document-updater/test/unit/js/ProjectManager/flushAndDeleteProjectTests.js

@@ -13,6 +13,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/ProjectManager.js'
 const SandboxedModule = require('sandboxed-module')
 
@@ -24,6 +26,10 @@ describe('ProjectManager - flushAndDeleteProject', function () {
         './RedisManager': (this.RedisManager = {}),
         './ProjectHistoryRedisManager': (this.ProjectHistoryRedisManager = {}),
         './DocumentManager': (this.DocumentManager = {}),
+        'logger-sharelatex': (this.logger = {
+          log: sinon.stub(),
+          error: sinon.stub()
+        }),
         './HistoryManager': (this.HistoryManager = {
           flushProjectChanges: sinon.stub().callsArg(2)
         }),

+ 6 - 0
services/document-updater/test/unit/js/ProjectManager/flushProjectTests.js

@@ -15,6 +15,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/ProjectManager.js'
 const SandboxedModule = require('sandboxed-module')
 
@@ -26,6 +28,10 @@ describe('ProjectManager - flushProject', function () {
         './RedisManager': (this.RedisManager = {}),
         './ProjectHistoryRedisManager': (this.ProjectHistoryRedisManager = {}),
         './DocumentManager': (this.DocumentManager = {}),
+        'logger-sharelatex': (this.logger = {
+          log: sinon.stub(),
+          error: sinon.stub()
+        }),
         './HistoryManager': (this.HistoryManager = {}),
         './Metrics': (this.Metrics = {
           Timer: (Timer = (function () {

+ 6 - 0
services/document-updater/test/unit/js/ProjectManager/getProjectDocsTests.js

@@ -11,6 +11,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/ProjectManager.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors.js')
@@ -23,6 +25,10 @@ describe('ProjectManager - getProjectDocsAndFlushIfOld', function () {
         './RedisManager': (this.RedisManager = {}),
         './ProjectHistoryRedisManager': (this.ProjectHistoryRedisManager = {}),
         './DocumentManager': (this.DocumentManager = {}),
+        'logger-sharelatex': (this.logger = {
+          log: sinon.stub(),
+          error: sinon.stub()
+        }),
         './HistoryManager': (this.HistoryManager = {}),
         './Metrics': (this.Metrics = {
           Timer: (Timer = (function () {

+ 6 - 0
services/document-updater/test/unit/js/ProjectManager/updateProjectTests.js

@@ -22,11 +22,17 @@ describe('ProjectManager', function () {
     }
     this.Metrics.Timer.prototype.done = sinon.stub()
 
+    this.logger = {
+      log: sinon.stub(),
+      error: sinon.stub()
+    }
+
     this.ProjectManager = SandboxedModule.require(modulePath, {
       requires: {
         './RedisManager': this.RedisManager,
         './ProjectHistoryRedisManager': this.ProjectHistoryRedisManager,
         './DocumentManager': this.DocumentManager,
+        'logger-sharelatex': this.logger,
         './HistoryManager': this.HistoryManager,
         './Metrics': this.Metrics
       }

+ 17 - 2
services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js

@@ -13,13 +13,23 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+const should = chai.should()
+const { expect } = chai
 const modulePath = '../../../../app/js/RangesManager.js'
 const SandboxedModule = require('sandboxed-module')
 
 describe('RangesManager', function () {
   beforeEach(function () {
-    this.RangesManager = SandboxedModule.require(modulePath)
+    this.RangesManager = SandboxedModule.require(modulePath, {
+      requires: {
+        'logger-sharelatex': (this.logger = {
+          error: sinon.stub(),
+          log: sinon.stub(),
+          warn: sinon.stub()
+        })
+      }
+    })
 
     this.doc_id = 'doc-id-123'
     this.project_id = 'project-id-123'
@@ -358,6 +368,11 @@ describe('RangesManager', function () {
     beforeEach(function () {
       this.RangesManager = SandboxedModule.require(modulePath, {
         requires: {
+          'logger-sharelatex': (this.logger = {
+            error: sinon.stub(),
+            log: sinon.stub(),
+            warn: sinon.stub()
+          }),
           './RangesTracker': (this.RangesTracker = SandboxedModule.require(
             '../../../../app/js/RangesTracker.js'
           ))

+ 4 - 1
services/document-updater/test/unit/js/RateLimitManager/RateLimitManager.js

@@ -11,7 +11,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+const should = chai.should()
+const { expect } = chai
 const modulePath = '../../../../app/js/RateLimitManager.js'
 const SandboxedModule = require('sandboxed-module')
 
@@ -20,6 +22,7 @@ describe('RateLimitManager', function () {
     let Timer
     this.RateLimitManager = SandboxedModule.require(modulePath, {
       requires: {
+        'logger-sharelatex': (this.logger = { log: sinon.stub() }),
         'settings-sharelatex': (this.settings = {}),
         './Metrics': (this.Metrics = {
           Timer: (Timer = (function () {

+ 3 - 0
services/document-updater/test/unit/js/RealTimeRedisManager/RealTimeRedisManagerTests.js

@@ -11,6 +11,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/RealTimeRedisManager.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors')
@@ -43,6 +45,7 @@ describe('RealTimeRedisManager', function () {
             }
           }
         },
+        'logger-sharelatex': { log() {} },
         crypto: (this.crypto = {
           randomBytes: sinon
             .stub()

+ 16 - 8
services/document-updater/test/unit/js/RedisManager/RedisManagerTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/RedisManager.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors')
@@ -26,6 +28,11 @@ describe('RedisManager', function () {
     tk.freeze(new Date())
     this.RedisManager = SandboxedModule.require(modulePath, {
       requires: {
+        'logger-sharelatex': (this.logger = {
+          error: sinon.stub(),
+          log: sinon.stub(),
+          warn: sinon.stub()
+        }),
         './ProjectHistoryRedisManager': (this.ProjectHistoryRedisManager = {}),
         'settings-sharelatex': (this.settings = {
           documentupdater: { logHashErrors: { write: true, read: true } },
@@ -115,6 +122,9 @@ describe('RedisManager', function () {
           })
         }),
         './Errors': Errors
+      },
+      globals: {
+        JSON: (this.JSON = JSON)
       }
     })
 
@@ -914,9 +924,8 @@ describe('RedisManager', function () {
         this.RedisManager.getDocVersion
           .withArgs(this.doc_id)
           .yields(null, this.version - this.ops.length)
-        this.stringifyStub = sinon
-          .stub(JSON, 'stringify')
-          .callsFake(() => '["bad bytes! \u0000 <- here"]')
+        this._stringify = JSON.stringify
+        this.JSON.stringify = () => '["bad bytes! \u0000 <- here"]'
         return this.RedisManager.updateDocument(
           this.project_id,
           this.doc_id,
@@ -930,7 +939,7 @@ describe('RedisManager', function () {
       })
 
       afterEach(function () {
-        this.stringifyStub.restore()
+        return (this.JSON.stringify = this._stringify)
       })
 
       it('should log an error', function () {
@@ -1118,9 +1127,8 @@ describe('RedisManager', function () {
 
     describe('with null bytes in the serialized doc lines', function () {
       beforeEach(function () {
-        this.stringifyStub = sinon
-          .stub(JSON, 'stringify')
-          .callsFake(() => '["bad bytes! \u0000 <- here"]')
+        this._stringify = JSON.stringify
+        this.JSON.stringify = () => '["bad bytes! \u0000 <- here"]'
         return this.RedisManager.putDocInMemory(
           this.project_id,
           this.doc_id,
@@ -1134,7 +1142,7 @@ describe('RedisManager', function () {
       })
 
       afterEach(function () {
-        this.stringifyStub.restore()
+        return (this.JSON.stringify = this._stringify)
       })
 
       it('should log an error', function () {

+ 1 - 0
services/document-updater/test/unit/js/ShareJS/TextTransformTests.js

@@ -14,6 +14,7 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const text = require('../../../../app/js/sharejs/types/text')
+require('chai').should()
 const RangesTracker = require('../../../../app/js/RangesTracker')
 
 describe('ShareJS text type', function () {

+ 3 - 1
services/document-updater/test/unit/js/ShareJsDB/ShareJsDBTests.js

@@ -11,7 +11,9 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
-const { expect } = require('chai')
+const chai = require('chai')
+const should = chai.should()
+const { expect } = chai
 const modulePath = '../../../../app/js/ShareJsDB.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors')

+ 3 - 0
services/document-updater/test/unit/js/ShareJsUpdateManager/ShareJsUpdateManagerTests.js

@@ -10,6 +10,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/ShareJsUpdateManager.js'
 const SandboxedModule = require('sandboxed-module')
 const crypto = require('crypto')
@@ -33,6 +35,7 @@ describe('ShareJsUpdateManager', function () {
             return (this.rclient = { auth() {} })
           }
         },
+        'logger-sharelatex': (this.logger = { log: sinon.stub() }),
         './RealTimeRedisManager': (this.RealTimeRedisManager = {}),
         './Metrics': (this.metrics = { inc: sinon.stub() })
       },

+ 3 - 0
services/document-updater/test/unit/js/UpdateManager/UpdateManagerTests.js

@@ -12,6 +12,8 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 const sinon = require('sinon')
+const chai = require('chai')
+const should = chai.should()
 const modulePath = '../../../../app/js/UpdateManager.js'
 const SandboxedModule = require('sandboxed-module')
 
@@ -29,6 +31,7 @@ describe('UpdateManager', function () {
         './RealTimeRedisManager': (this.RealTimeRedisManager = {}),
         './ShareJsUpdateManager': (this.ShareJsUpdateManager = {}),
         './HistoryManager': (this.HistoryManager = {}),
+        'logger-sharelatex': (this.logger = { log: sinon.stub() }),
         './Metrics': (this.Metrics = {
           Timer: (Timer = (function () {
             Timer = class Timer {

Some files were not shown because too many files changed in this diff