Quellcode durchsuchen

Merge pull request #167 from overleaf/em-upgrade-node-12

Reintroduce Node 12 and metrics upgrades
Simon Detheridge vor 5 Jahren
Ursprung
Commit
2d44a54c6c
44 geänderte Dateien mit 638 neuen und 415 gelöschten Zeilen
  1. 3 0
      services/document-updater/.mocharc.json
  2. 1 1
      services/document-updater/.nvmrc
  3. 1 1
      services/document-updater/Dockerfile
  4. 4 2
      services/document-updater/Makefile
  5. 6 2
      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. 557 243
      services/document-updater/package-lock.json
  9. 4 4
      services/document-updater/package.json
  10. 1 3
      services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js
  11. 0 2
      services/document-updater/test/acceptance/js/ApplyingUpdatesToProjectStructureTests.js
  12. 0 3
      services/document-updater/test/acceptance/js/DeletingADocumentTests.js
  13. 0 2
      services/document-updater/test/acceptance/js/DeletingAProjectTests.js
  14. 0 2
      services/document-updater/test/acceptance/js/FlushingAProjectTests.js
  15. 1 3
      services/document-updater/test/acceptance/js/FlushingDocsTests.js
  16. 1 3
      services/document-updater/test/acceptance/js/GettingADocumentTests.js
  17. 1 3
      services/document-updater/test/acceptance/js/GettingProjectDocsTests.js
  18. 1 3
      services/document-updater/test/acceptance/js/RangesTests.js
  19. 0 2
      services/document-updater/test/acceptance/js/SettingADocumentTests.js
  20. 37 0
      services/document-updater/test/setup.js
  21. 1 3
      services/document-updater/test/unit/js/DiffCodec/DiffCodecTests.js
  22. 0 7
      services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js
  23. 0 9
      services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js
  24. 0 6
      services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js
  25. 1 4
      services/document-updater/test/unit/js/HistoryRedisManager/HistoryRedisManagerTests.js
  26. 0 1
      services/document-updater/test/unit/js/HttpController/HttpControllerTests.js
  27. 0 1
      services/document-updater/test/unit/js/LockManager/CheckingTheLock.js
  28. 0 4
      services/document-updater/test/unit/js/LockManager/ReleasingTheLock.js
  29. 0 3
      services/document-updater/test/unit/js/LockManager/getLockTests.js
  30. 0 3
      services/document-updater/test/unit/js/LockManager/tryLockTests.js
  31. 0 7
      services/document-updater/test/unit/js/PersistenceManager/PersistenceManagerTests.js
  32. 2 10
      services/document-updater/test/unit/js/ProjectHistoryRedisManager/ProjectHistoryRedisManagerTests.js
  33. 0 6
      services/document-updater/test/unit/js/ProjectManager/flushAndDeleteProjectTests.js
  34. 0 6
      services/document-updater/test/unit/js/ProjectManager/flushProjectTests.js
  35. 0 6
      services/document-updater/test/unit/js/ProjectManager/getProjectDocsTests.js
  36. 0 6
      services/document-updater/test/unit/js/ProjectManager/updateProjectTests.js
  37. 2 17
      services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js
  38. 1 4
      services/document-updater/test/unit/js/RateLimitManager/RateLimitManager.js
  39. 0 3
      services/document-updater/test/unit/js/RealTimeRedisManager/RealTimeRedisManagerTests.js
  40. 8 16
      services/document-updater/test/unit/js/RedisManager/RedisManagerTests.js
  41. 0 1
      services/document-updater/test/unit/js/ShareJS/TextTransformTests.js
  42. 1 3
      services/document-updater/test/unit/js/ShareJsDB/ShareJsDBTests.js
  43. 0 3
      services/document-updater/test/unit/js/ShareJsUpdateManager/ShareJsUpdateManagerTests.js
  44. 0 3
      services/document-updater/test/unit/js/UpdateManager/UpdateManagerTests.js

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

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

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

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

+ 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:10.23.1 as base
+FROM node:12.21.0 as base
 
 WORKDIR /app
 

+ 4 - 2
services/document-updater/Makefile

@@ -21,8 +21,10 @@ 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 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
 
 format:
 	$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format

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

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

+ 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=10.23.1
+--node-version=12.21.0
 --public-repo=True
---script-version=3.4.0
+--script-version=3.7.0

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

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

Datei-Diff unterdrückt, da er zu groß ist
+ 557 - 243
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.4.1",
+    "@overleaf/metrics": "^3.5.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": "^5.0.1",
+    "mocha": "^8.3.2",
     "prettier": "^2.0.0",
     "prettier-eslint-cli": "^5.0.0",
-    "sandboxed-module": "~0.2.0",
+    "sandboxed-module": "^2.0.4",
     "sinon": "^9.0.2",
     "timekeeper": "^2.0.0"
   }

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

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

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

@@ -1,6 +1,4 @@
 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

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

@@ -11,9 +11,6 @@
  * 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')

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

@@ -12,8 +12,6 @@
  * 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')

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

@@ -12,8 +12,6 @@
  * 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')

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

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

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

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

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

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

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

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

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

@@ -1,6 +1,4 @@
 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(

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

@@ -0,0 +1,37 @@
+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()
+  }
+}

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

@@ -11,9 +11,7 @@
  * 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 { expect } = chai
+const { expect } = require('chai')
 const modulePath = '../../../../app/js/DiffCodec.js'
 const SandboxedModule = require('sandboxed-module')
 

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

@@ -12,8 +12,6 @@
  * 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')
@@ -25,11 +23,6 @@ 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: {}

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

@@ -13,8 +13,6 @@
  * 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')
@@ -33,11 +31,6 @@ 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 {
@@ -220,7 +213,6 @@ 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,
@@ -236,7 +228,6 @@ 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 () {

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

@@ -11,7 +11,6 @@
  */
 const SandboxedModule = require('sandboxed-module')
 const sinon = require('sinon')
-require('chai').should()
 const modulePath = require('path').join(
   __dirname,
   '../../../../app/js/HistoryManager'
@@ -33,11 +32,6 @@ 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 = {}),

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

@@ -12,8 +12,6 @@
  * 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')
@@ -41,8 +39,7 @@ describe('HistoryRedisManager', function () {
               }
             })
           }
-        },
-        'logger-sharelatex': { log() {} }
+        }
       }
     })
     this.doc_id = 'doc-id-123'

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

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

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

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

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

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

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

@@ -15,8 +15,6 @@
  * 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')
 
@@ -25,7 +23,6 @@ describe('LockManager - getting the lock', function () {
     let Profiler
     this.LockManager = SandboxedModule.require(modulePath, {
       requires: {
-        'logger-sharelatex': { log() {} },
         '@overleaf/redis-wrapper': {
           createClient: () => {
             return { auth() {} }

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

@@ -12,8 +12,6 @@
  * 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')
 
@@ -22,7 +20,6 @@ describe('LockManager - trying the lock', function () {
     let Profiler
     this.LockManager = SandboxedModule.require(modulePath, {
       requires: {
-        'logger-sharelatex': { log() {} },
         '@overleaf/redis-wrapper': {
           createClient: () => {
             return {

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

@@ -11,8 +11,6 @@
  * 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')
@@ -38,11 +36,6 @@ describe('PersistenceManager', function () {
           })()),
           inc: sinon.stub()
         }),
-        'logger-sharelatex': (this.logger = {
-          log: sinon.stub(),
-          err: sinon.stub(),
-          error: sinon.stub()
-        }),
         './Errors': Errors
       }
     })

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

@@ -12,8 +12,6 @@
  * 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')
@@ -47,13 +45,7 @@ describe('ProjectHistoryRedisManager', function () {
           '@overleaf/redis-wrapper': {
             createClient: () => this.rclient
           },
-          'logger-sharelatex': {
-            log() {}
-          },
           './Metrics': (this.metrics = { summary: sinon.stub() })
-        },
-        globals: {
-          JSON: (this.JSON = JSON)
         }
       }
     ))
@@ -136,7 +128,7 @@ describe('ProjectHistoryRedisManager', function () {
       return this.ProjectHistoryRedisManager.queueOps
         .calledWithExactly(
           this.project_id,
-          this.JSON.stringify(update),
+          JSON.stringify(update),
           this.callback
         )
         .should.equal(true)
@@ -184,7 +176,7 @@ describe('ProjectHistoryRedisManager', function () {
       return this.ProjectHistoryRedisManager.queueOps
         .calledWithExactly(
           this.project_id,
-          this.JSON.stringify(update),
+          JSON.stringify(update),
           this.callback
         )
         .should.equal(true)

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

@@ -13,8 +13,6 @@
  * 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,10 +24,6 @@ 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)
         }),

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

@@ -15,8 +15,6 @@
  * 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')
 
@@ -28,10 +26,6 @@ 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 () {

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

@@ -11,8 +11,6 @@
  * 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')
@@ -25,10 +23,6 @@ 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 () {

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

@@ -22,17 +22,11 @@ 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
       }

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

@@ -13,23 +13,13 @@
  * 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 { expect } = chai
+const { expect } = require('chai')
 const modulePath = '../../../../app/js/RangesManager.js'
 const SandboxedModule = require('sandboxed-module')
 
 describe('RangesManager', function () {
   beforeEach(function () {
-    this.RangesManager = SandboxedModule.require(modulePath, {
-      requires: {
-        'logger-sharelatex': (this.logger = {
-          error: sinon.stub(),
-          log: sinon.stub(),
-          warn: sinon.stub()
-        })
-      }
-    })
+    this.RangesManager = SandboxedModule.require(modulePath)
 
     this.doc_id = 'doc-id-123'
     this.project_id = 'project-id-123'
@@ -368,11 +358,6 @@ 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'
           ))

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

@@ -11,9 +11,7 @@
  * 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 { expect } = chai
+const { expect } = require('chai')
 const modulePath = '../../../../app/js/RateLimitManager.js'
 const SandboxedModule = require('sandboxed-module')
 
@@ -22,7 +20,6 @@ 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 () {

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

@@ -11,8 +11,6 @@
  * 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')
@@ -45,7 +43,6 @@ describe('RealTimeRedisManager', function () {
             }
           }
         },
-        'logger-sharelatex': { log() {} },
         crypto: (this.crypto = {
           randomBytes: sinon
             .stub()

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

@@ -12,8 +12,6 @@
  * 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')
@@ -28,11 +26,6 @@ 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 } },
@@ -122,9 +115,6 @@ describe('RedisManager', function () {
           })
         }),
         './Errors': Errors
-      },
-      globals: {
-        JSON: (this.JSON = JSON)
       }
     })
 
@@ -924,8 +914,9 @@ describe('RedisManager', function () {
         this.RedisManager.getDocVersion
           .withArgs(this.doc_id)
           .yields(null, this.version - this.ops.length)
-        this._stringify = JSON.stringify
-        this.JSON.stringify = () => '["bad bytes! \u0000 <- here"]'
+        this.stringifyStub = sinon
+          .stub(JSON, 'stringify')
+          .callsFake(() => '["bad bytes! \u0000 <- here"]')
         return this.RedisManager.updateDocument(
           this.project_id,
           this.doc_id,
@@ -939,7 +930,7 @@ describe('RedisManager', function () {
       })
 
       afterEach(function () {
-        return (this.JSON.stringify = this._stringify)
+        this.stringifyStub.restore()
       })
 
       it('should log an error', function () {
@@ -1127,8 +1118,9 @@ describe('RedisManager', function () {
 
     describe('with null bytes in the serialized doc lines', function () {
       beforeEach(function () {
-        this._stringify = JSON.stringify
-        this.JSON.stringify = () => '["bad bytes! \u0000 <- here"]'
+        this.stringifyStub = sinon
+          .stub(JSON, 'stringify')
+          .callsFake(() => '["bad bytes! \u0000 <- here"]')
         return this.RedisManager.putDocInMemory(
           this.project_id,
           this.doc_id,
@@ -1142,7 +1134,7 @@ describe('RedisManager', function () {
       })
 
       afterEach(function () {
-        return (this.JSON.stringify = this._stringify)
+        this.stringifyStub.restore()
       })
 
       it('should log an error', function () {

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

@@ -14,7 +14,6 @@
  * 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 () {

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

@@ -11,9 +11,7 @@
  * 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 { expect } = chai
+const { expect } = require('chai')
 const modulePath = '../../../../app/js/ShareJsDB.js'
 const SandboxedModule = require('sandboxed-module')
 const Errors = require('../../../../app/js/Errors')

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

@@ -10,8 +10,6 @@
  * 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')
@@ -35,7 +33,6 @@ describe('ShareJsUpdateManager', function () {
             return (this.rclient = { auth() {} })
           }
         },
-        'logger-sharelatex': (this.logger = { log: sinon.stub() }),
         './RealTimeRedisManager': (this.RealTimeRedisManager = {}),
         './Metrics': (this.metrics = { inc: sinon.stub() })
       },

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

@@ -12,8 +12,6 @@
  * 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')
 
@@ -31,7 +29,6 @@ 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 {

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.