|
@@ -21,6 +21,7 @@ const modulePath = require('path').join(
|
|
|
describe('EditorRealTimeController', function() {
|
|
describe('EditorRealTimeController', function() {
|
|
|
beforeEach(function() {
|
|
beforeEach(function() {
|
|
|
this.rclient = { publish: sinon.stub() }
|
|
this.rclient = { publish: sinon.stub() }
|
|
|
|
|
+ this.Metrics = { summary: sinon.stub() }
|
|
|
this.EditorRealTimeController = SandboxedModule.require(modulePath, {
|
|
this.EditorRealTimeController = SandboxedModule.require(modulePath, {
|
|
|
globals: {
|
|
globals: {
|
|
|
console: console
|
|
console: console
|
|
@@ -33,6 +34,7 @@ describe('EditorRealTimeController', function() {
|
|
|
io: (this.io = {})
|
|
io: (this.io = {})
|
|
|
},
|
|
},
|
|
|
'settings-sharelatex': { redis: {} },
|
|
'settings-sharelatex': { redis: {} },
|
|
|
|
|
+ 'metrics-sharelatex': this.Metrics,
|
|
|
crypto: (this.crypto = {
|
|
crypto: (this.crypto = {
|
|
|
randomBytes: sinon
|
|
randomBytes: sinon
|
|
|
.stub()
|
|
.stub()
|
|
@@ -71,6 +73,20 @@ describe('EditorRealTimeController', function() {
|
|
|
)
|
|
)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ it('should track the payload size', function() {
|
|
|
|
|
+ this.Metrics.summary
|
|
|
|
|
+ .calledWith(
|
|
|
|
|
+ 'redis.publish.editor-events',
|
|
|
|
|
+ JSON.stringify({
|
|
|
|
|
+ room_id: this.room_id,
|
|
|
|
|
+ message: this.message,
|
|
|
|
|
+ payload: this.payload,
|
|
|
|
|
+ _id: this.message_id
|
|
|
|
|
+ }).length
|
|
|
|
|
+ )
|
|
|
|
|
+ .should.equal(true)
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('emitToAll', function() {
|
|
describe('emitToAll', function() {
|