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

Reintroduce Node 12 and metrics upgrades
This commit is contained in:
Simon Detheridge 2021-04-06 11:40:00 +01:00 committed by GitHub
commit 2d44a54c6c
44 changed files with 1248 additions and 588 deletions

View file

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

View file

@ -1 +1 @@
10.23.1 12.21.0

View file

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

View file

@ -21,8 +21,10 @@ DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
clean: clean:
docker rmi ci/$(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 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: format:
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format $(DOCKER_COMPOSE) run --rm test_unit npm run --silent format

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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()
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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