Merge pull request #12211 from overleaf/em-camel-case-real-time

Camel case variables in real-time

GitOrigin-RevId: 0a35d2e39d54c258bed017ea4dcdbf9a19a2a9b1
This commit is contained in:
Eric Mc Sween
2023-03-21 09:05:37 +00:00
committed by Copybot
parent 5ae698ec6c
commit d9e0215aee
35 changed files with 528 additions and 587 deletions
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -68,9 +67,9 @@ describe('applyOtUpdate', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -80,8 +79,8 @@ describe('applyOtUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -120,8 +119,8 @@ describe('applyOtUpdate', function () {
it('should push the doc into the pending updates list', function (done) {
getPendingUpdatesList((error, ...rest) => {
if (error) return done(error)
const [doc_id] = Array.from(rest[0])
doc_id.should.equal(`${this.project_id}:${this.doc_id}`)
const [docId] = Array.from(rest[0])
docId.should.equal(`${this.project_id}:${this.doc_id}`)
return done()
})
return null
@@ -187,9 +186,9 @@ describe('applyOtUpdate', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -199,8 +198,8 @@ describe('applyOtUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -284,9 +283,9 @@ describe('applyOtUpdate', function () {
{
privilegeLevel: 'readOnly',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -296,8 +295,8 @@ describe('applyOtUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -374,9 +373,9 @@ describe('applyOtUpdate', function () {
{
privilegeLevel: 'readOnly',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -386,8 +385,8 @@ describe('applyOtUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -426,8 +425,8 @@ describe('applyOtUpdate', function () {
it('should push the doc into the pending updates list', function (done) {
getPendingUpdatesList((error, ...rest) => {
if (error) return done(error)
const [doc_id] = Array.from(rest[0])
doc_id.should.equal(`${this.project_id}:${this.doc_id}`)
const [docId] = Array.from(rest[0])
docId.should.equal(`${this.project_id}:${this.doc_id}`)
return done()
})
return null
@@ -487,9 +486,9 @@ describe('applyOtUpdate', function () {
{
privilegeLevel: 'readOnly',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -499,8 +498,8 @@ describe('applyOtUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -574,9 +573,9 @@ describe('applyOtUpdate', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -586,8 +585,8 @@ describe('applyOtUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -30,10 +29,10 @@ describe('clientTracking', function () {
privilegeLevel: 'owner',
project: { name: 'Test Project' },
},
(error, { user_id, project_id }) => {
(error, { user_id: userId, project_id: projectId }) => {
if (error) return done(error)
this.user_id = user_id
this.project_id = project_id
this.user_id = userId
this.project_id = projectId
return cb()
}
)
@@ -43,8 +42,8 @@ describe('clientTracking', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -155,10 +154,10 @@ describe('clientTracking', function () {
project: { name: 'Test Project' },
publicAccess: 'readAndWrite',
},
(error, { user_id, project_id }) => {
(error, { user_id: userId, project_id: projectId }) => {
if (error) return done(error)
this.user_id = user_id
this.project_id = project_id
this.user_id = userId
this.project_id = projectId
return cb()
}
)
@@ -168,8 +167,8 @@ describe('clientTracking', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -1,6 +1,3 @@
/* eslint-disable
camelcase,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
@@ -35,9 +32,9 @@ describe('DrainManagerTests', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return done()
}
)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -34,8 +33,8 @@ describe('EarlyDisconnect', function () {
// slow down web-api requests to force the race condition
let joinProject
this.actualWebAPIjoinProject = joinProject = MockWebServer.joinProject
return (MockWebServer.joinProject = (project_id, user_id, cb) =>
setTimeout(() => joinProject(project_id, user_id, cb), 300))
return (MockWebServer.joinProject = (projectId, userId, cb) =>
setTimeout(() => joinProject(projectId, userId, cb), 300))
})
after(function () {
@@ -53,9 +52,9 @@ describe('EarlyDisconnect', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -114,9 +113,9 @@ describe('EarlyDisconnect', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -144,8 +143,8 @@ describe('EarlyDisconnect', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -202,9 +201,9 @@ describe('EarlyDisconnect', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -232,8 +231,8 @@ describe('EarlyDisconnect', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -1,6 +1,3 @@
/* eslint-disable
camelcase,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
@@ -20,10 +17,10 @@ const FixturesManager = require('./helpers/FixturesManager')
describe('HttpControllerTests', function () {
describe('without a user', function () {
return it('should return 404 for the client view', function (done) {
const client_id = 'not-existing'
const clientId = 'not-existing'
return request.get(
{
url: `/clients/${client_id}`,
url: `/clients/${clientId}`,
json: true,
},
(error, response, data) => {
@@ -46,9 +43,9 @@ describe('HttpControllerTests', function () {
{
privilegeLevel: 'owner',
},
(error, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(error, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(error)
}
)
@@ -58,8 +55,8 @@ describe('HttpControllerTests', function () {
return FixturesManager.setUpDoc(
this.project_id,
{},
(error, { doc_id }) => {
this.doc_id = doc_id
(error, { doc_id: docId }) => {
this.doc_id = docId
return cb(error)
}
)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -35,9 +34,9 @@ describe('joinDoc', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -52,8 +51,8 @@ describe('joinDoc', function () {
ops: this.ops,
ranges: this.ranges,
},
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -123,9 +122,9 @@ describe('joinDoc', function () {
{
privilegeLevel: 'readOnly',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -140,8 +139,8 @@ describe('joinDoc', function () {
ops: this.ops,
ranges: this.ranges,
},
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -211,9 +210,9 @@ describe('joinDoc', function () {
{
privilegeLevel: 'owner',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -228,8 +227,8 @@ describe('joinDoc', function () {
ops: this.ops,
ranges: this.ranges,
},
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -303,9 +302,9 @@ describe('joinDoc', function () {
{
privilegeLevel: 'owner',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -320,8 +319,8 @@ describe('joinDoc', function () {
ops: this.ops,
ranges: this.ranges,
},
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -389,9 +388,9 @@ describe('joinDoc', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -406,8 +405,8 @@ describe('joinDoc', function () {
ops: this.ops,
ranges: this.ranges,
},
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -479,9 +478,9 @@ describe('joinDoc', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -496,8 +495,8 @@ describe('joinDoc', function () {
ops: this.ops,
ranges: this.ranges,
},
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -570,9 +569,9 @@ describe('joinDoc', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -587,8 +586,8 @@ describe('joinDoc', function () {
ops: this.ops,
ranges: this.ranges,
},
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -1,6 +1,3 @@
/* eslint-disable
camelcase,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
@@ -30,9 +27,9 @@ describe('joinProject', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -127,9 +124,9 @@ describe('joinProject', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -189,9 +186,9 @@ describe('joinProject', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
cb(e)
}
)
@@ -251,9 +248,9 @@ describe('joinProject', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
cb(e)
}
)
@@ -346,9 +343,9 @@ describe('joinProject', function () {
name: 'Other Project',
},
},
(e, { project_id, user_id }) => {
this.other_project_id = project_id
this.other_user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.other_project_id = projectId
this.other_user_id = userId
return cb(e)
}
)
@@ -363,9 +360,9 @@ describe('joinProject', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
no-unused-vars,
*/
@@ -48,9 +47,9 @@ describe('leaveDoc', function () {
{
privilegeLevel: 'readAndWrite',
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -60,8 +59,8 @@ describe('leaveDoc', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-throw-literal,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -37,9 +36,9 @@ describe('leaveProject', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -93,8 +92,8 @@ describe('leaveProject', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -184,9 +183,9 @@ describe('leaveProject', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -214,8 +213,8 @@ describe('leaveProject', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -44,9 +44,7 @@ There is additional meta-data that UserItems and SessionItems may use to skip
UserItem: { hasOwnProject: true, setup(cb) { cb(null, { project_id, ... }) }}
SessionItem: { needsOwnProject: true }
*/
/* eslint-disable
camelcase,
*/
const { expect } = require('chai')
const async = require('async')
@@ -58,11 +56,11 @@ const Keys = settings.redis.documentupdater.key_schema
const redis = require('@overleaf/redis-wrapper')
const rclient = redis.createClient(settings.redis.pubsub)
function getPendingUpdates(doc_id, cb) {
rclient.lrange(Keys.pendingUpdates({ doc_id }), 0, 10, cb)
function getPendingUpdates(docId, cb) {
rclient.lrange(Keys.pendingUpdates({ doc_id: docId }), 0, 10, cb)
}
function cleanupPreviousUpdates(doc_id, cb) {
rclient.del(Keys.pendingUpdates({ doc_id }), cb)
function cleanupPreviousUpdates(docId, cb) {
rclient.del(Keys.pendingUpdates({ doc_id: docId }), cb)
}
describe('MatrixTests', function () {
@@ -72,10 +70,10 @@ describe('MatrixTests', function () {
before(function setupPrivateProject(done) {
FixturesManager.setUpEditorSession(
{ privilegeLevel: 'owner' },
(err, { project_id, doc_id }) => {
(err, { project_id: projectId, doc_id: docId }) => {
if (err) return done(err)
privateProjectId = project_id
privateDocId = doc_id
privateProjectId = projectId
privateDocId = docId
privateClient = RealTimeClient.connect()
privateClient.on('connectionAccepted', () => {
privateClient.emit(
@@ -96,9 +94,9 @@ describe('MatrixTests', function () {
{
publicAccess: 'readAndWrite',
},
(err, { project_id, doc_id }) => {
readWriteProjectId = project_id
readWriteDocId = doc_id
(err, { project_id: projectId, doc_id: docId }) => {
readWriteProjectId = projectId
readWriteDocId = docId
done(err)
}
)
@@ -118,11 +116,11 @@ describe('MatrixTests', function () {
registered: {
setup(cb) {
const user_id = FixturesManager.getRandomId()
const userId = FixturesManager.getRandomId()
RealTimeClient.setSession(
{
user: {
_id: user_id,
_id: userId,
first_name: 'Joe',
last_name: 'Bloggs',
},
@@ -130,7 +128,7 @@ describe('MatrixTests', function () {
err => {
if (err) return cb(err)
cb(null, {
user_id,
user_id: userId,
client: RealTimeClient.connect(),
})
}
@@ -142,12 +140,12 @@ describe('MatrixTests', function () {
setup(cb) {
FixturesManager.setUpEditorSession(
{ privilegeLevel: 'owner' },
(err, { project_id, user_id, doc_id }) => {
(err, { project_id: projectId, user_id: userId, doc_id: docId }) => {
if (err) return cb(err)
cb(null, {
user_id,
project_id,
doc_id,
user_id: userId,
project_id: projectId,
doc_id: docId,
client: RealTimeClient.connect(),
})
}
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -36,9 +35,9 @@ describe('PubSubRace', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -66,8 +65,8 @@ describe('PubSubRace', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -112,9 +111,9 @@ describe('PubSubRace', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -142,8 +141,8 @@ describe('PubSubRace', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -195,9 +194,9 @@ describe('PubSubRace', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -225,8 +224,8 @@ describe('PubSubRace', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -277,9 +276,9 @@ describe('PubSubRace', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb()
}
)
@@ -307,8 +306,8 @@ describe('PubSubRace', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -36,10 +35,10 @@ describe('receiveUpdate', function () {
privilegeLevel: 'owner',
project: { name: 'Test Project' },
},
(error, { user_id, project_id }) => {
(error, { user_id: userId, project_id: projectId }) => {
if (error) return done(error)
this.user_id = user_id
this.project_id = project_id
this.user_id = userId
this.project_id = projectId
return cb()
}
)
@@ -49,8 +48,8 @@ describe('receiveUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id }) => {
this.doc_id = doc_id
(e, { doc_id: docId }) => {
this.doc_id = docId
return cb(e)
}
)
@@ -100,13 +99,10 @@ describe('receiveUpdate', function () {
privilegeLevel: 'owner',
project: { name: 'Test Project' },
},
(
error,
{ user_id: user_id_second, project_id: project_id_second }
) => {
(error, { user_id: userIdSecond, project_id: projectIdSecond }) => {
if (error) return done(error)
this.user_id_second = user_id_second
this.project_id_second = project_id_second
this.user_id_second = userIdSecond
this.project_id_second = projectIdSecond
return cb()
}
)
@@ -116,8 +112,8 @@ describe('receiveUpdate', function () {
return FixturesManager.setUpDoc(
this.project_id_second,
{ lines: this.lines, version: this.version, ops: this.ops },
(e, { doc_id: doc_id_second }) => {
this.doc_id_second = doc_id_second
(e, { doc_id: docIdSecond }) => {
this.doc_id_second = docIdSecond
return cb(e)
}
)
@@ -1,6 +1,3 @@
/* eslint-disable
camelcase,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
@@ -34,9 +31,9 @@ describe('Router', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -84,9 +81,9 @@ describe('Router', function () {
name: 'Test Project',
},
},
(e, { project_id, user_id }) => {
this.project_id = project_id
this.user_id = user_id
(e, { project_id: projectId, user_id: userId }) => {
this.project_id = projectId
this.user_id = userId
return cb(e)
}
)
@@ -1,6 +1,3 @@
/* eslint-disable
camelcase,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
@@ -31,16 +28,21 @@ module.exports = FixturesManager = {
if (!options.project) {
options.project = { name: 'Test Project' }
}
const { project_id, user_id, privilegeLevel, project, publicAccess } =
options
const {
project_id: projectId,
user_id: userId,
privilegeLevel,
project,
publicAccess,
} = options
const privileges = {}
privileges[user_id] = privilegeLevel
privileges[userId] = privilegeLevel
if (publicAccess) {
privileges['anonymous-user'] = publicAccess
}
MockWebServer.createMockProject(project_id, privileges, project)
MockWebServer.createMockProject(projectId, privileges, project)
return MockWebServer.run(error => {
if (error != null) {
throw error
@@ -48,7 +50,7 @@ module.exports = FixturesManager = {
return RealTimeClient.setSession(
{
user: {
_id: user_id,
_id: userId,
first_name: 'Joe',
last_name: 'Bloggs',
},
@@ -58,8 +60,8 @@ module.exports = FixturesManager = {
throw error
}
return callback(null, {
project_id,
user_id,
project_id: projectId,
user_id: userId,
privilegeLevel,
project,
})
@@ -68,7 +70,7 @@ module.exports = FixturesManager = {
})
},
setUpDoc(project_id, options, callback) {
setUpDoc(projectId, options, callback) {
if (options == null) {
options = {}
}
@@ -87,9 +89,9 @@ module.exports = FixturesManager = {
if (!options.ops) {
options.ops = ['mock', 'ops']
}
const { doc_id, lines, version, ops, ranges } = options
const { doc_id: docId, lines, version, ops, ranges } = options
MockDocUpdaterServer.createMockDoc(project_id, doc_id, {
MockDocUpdaterServer.createMockDoc(projectId, docId, {
lines,
version,
ops,
@@ -99,7 +101,13 @@ module.exports = FixturesManager = {
if (error != null) {
throw error
}
return callback(null, { project_id, doc_id, lines, version, ops })
return callback(null, {
project_id: projectId,
doc_id: docId,
lines,
version,
ops,
})
})
},
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -17,26 +16,26 @@ const express = require('express')
module.exports = MockDocUpdaterServer = {
docs: {},
createMockDoc(project_id, doc_id, data) {
return (MockDocUpdaterServer.docs[`${project_id}:${doc_id}`] = data)
createMockDoc(projectId, docId, data) {
return (MockDocUpdaterServer.docs[`${projectId}:${docId}`] = data)
},
getDocument(project_id, doc_id, fromVersion, callback) {
getDocument(projectId, docId, fromVersion, callback) {
if (callback == null) {
callback = function () {}
}
return callback(null, MockDocUpdaterServer.docs[`${project_id}:${doc_id}`])
return callback(null, MockDocUpdaterServer.docs[`${projectId}:${docId}`])
},
deleteProject: sinon.stub().callsArg(1),
getDocumentRequest(req, res, next) {
const { project_id, doc_id } = req.params
const { project_id: projectId, doc_id: docId } = req.params
let { fromVersion } = req.query
fromVersion = parseInt(fromVersion, 10)
return MockDocUpdaterServer.getDocument(
project_id,
doc_id,
projectId,
docId,
fromVersion,
(error, data) => {
if (error != null) {
@@ -51,8 +50,8 @@ module.exports = MockDocUpdaterServer = {
},
deleteProjectRequest(req, res, next) {
const { project_id } = req.params
return MockDocUpdaterServer.deleteProject(project_id, error => {
const { project_id: projectId } = req.params
return MockDocUpdaterServer.deleteProject(projectId, error => {
if (error != null) {
return next(error)
}
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -18,41 +17,41 @@ module.exports = MockWebServer = {
projects: {},
privileges: {},
createMockProject(project_id, privileges, project) {
MockWebServer.privileges[project_id] = privileges
return (MockWebServer.projects[project_id] = project)
createMockProject(projectId, privileges, project) {
MockWebServer.privileges[projectId] = privileges
return (MockWebServer.projects[projectId] = project)
},
joinProject(project_id, user_id, callback) {
joinProject(projectId, userId, callback) {
if (callback == null) {
callback = function () {}
}
return callback(
null,
MockWebServer.projects[project_id],
MockWebServer.privileges[project_id][user_id] ||
MockWebServer.privileges[project_id]['anonymous-user']
MockWebServer.projects[projectId],
MockWebServer.privileges[projectId][userId] ||
MockWebServer.privileges[projectId]['anonymous-user']
)
},
joinProjectRequest(req, res, next) {
const { project_id } = req.params
const { user_id } = req.query
if (project_id === '404404404404404404404404') {
const { project_id: projectId } = req.params
const { user_id: userId } = req.query
if (projectId === '404404404404404404404404') {
// not-found
return res.status(404).send()
}
if (project_id === '403403403403403403403403') {
if (projectId === '403403403403403403403403') {
// forbidden
return res.status(403).send()
}
if (project_id === '429429429429429429429429') {
if (projectId === '429429429429429429429429') {
// rate-limited
return res.status(429).send()
} else {
return MockWebServer.joinProject(
project_id,
user_id,
projectId,
userId,
(error, project, privilegeLevel) => {
if (error != null) {
return next(error)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -87,23 +86,23 @@ module.exports = Client = {
)
},
getConnectedClient(client_id, callback) {
getConnectedClient(clientId, callback) {
if (callback == null) {
callback = function () {}
}
return request.get(
{
url: `http://localhost:3026/clients/${client_id}`,
url: `http://localhost:3026/clients/${clientId}`,
json: true,
},
(error, response, data) => callback(error, data)
)
},
disconnectClient(client_id, callback) {
disconnectClient(clientId, callback) {
request.post(
{
url: `http://localhost:3026/client/${client_id}/disconnect`,
url: `http://localhost:3026/client/${clientId}/disconnect`,
},
(error, response, data) => callback(error, data)
)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
no-unused-vars,
*/
@@ -25,11 +24,11 @@ describe('ConnectedUsersManager', function () {
redis: {
realtime: {
key_schema: {
clientsInProject({ project_id }) {
return `clients_in_project:${project_id}`
clientsInProject({ project_id: projectId }) {
return `clients_in_project:${projectId}`
},
connectedUser({ project_id, client_id }) {
return `connected_user:${project_id}:${client_id}`
connectedUser({ project_id: projectId, client_id: clientId }) {
return `connected_user:${projectId}:${clientId}`
},
},
},
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -32,8 +31,8 @@ describe('DocumentUpdaterController', function () {
redis: {
documentupdater: {
key_schema: {
pendingUpdates({ doc_id }) {
return `PendingUpdates:${doc_id}`
pendingUpdates({ doc_id: docId }) {
return `PendingUpdates:${docId}`
},
},
},
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
no-unused-vars,
*/
@@ -28,8 +27,8 @@ describe('DocumentUpdaterManager', function () {
redis: {
documentupdater: {
key_schema: {
pendingUpdates({ doc_id }) {
return `PendingUpdates:${doc_id}`
pendingUpdates({ doc_id: docId }) {
return `PendingUpdates:${docId}`
},
},
},
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
no-useless-escape,
*/
@@ -43,8 +42,8 @@ describe('SafeJsonParse', function () {
return it('should return an error on oversized data', function (done) {
// we have a 2k overhead on top of max size
const big_blob = Array(16 * 1024).join('A')
const data = `{\"foo\": \"${big_blob}\"}`
const bigBlob = Array(16 * 1024).join('A')
const data = `{\"foo\": \"${bigBlob}\"}`
this.Settings.maxUpdateSize = 2 * 1024
return this.SafeJsonParse.parse(data, (error, parsed) => {
this.logger.error.called.should.equal(false)
@@ -1,5 +1,4 @@
/* eslint-disable
camelcase,
no-return-assign,
no-throw-literal,
no-unused-vars,
@@ -317,8 +316,8 @@ describe('WebsocketController', function () {
this.clientsInRoom = []
this.io = {
sockets: {
clients: room_id => {
if (room_id !== this.project_id) {
clients: roomId => {
if (roomId !== this.project_id) {
throw 'expected room_id to be project_id'
}
return this.clientsInRoom
@@ -396,8 +395,8 @@ describe('WebsocketController', function () {
this.clientsInRoom = ['mock-remaining-client']
this.io = {
sockets: {
clients: room_id => {
if (room_id !== this.project_id) {
clients: roomId => {
if (roomId !== this.project_id) {
throw 'expected room_id to be project_id'
}
return this.clientsInRoom
@@ -600,11 +599,11 @@ describe('WebsocketController', function () {
})
return it('should call the callback with the escaped lines', function () {
const escaped_lines = this.callback.args[0][1]
const escaped_word = escaped_lines.pop()
escaped_word.should.equal('räksmörgås')
const escapedLines = this.callback.args[0][1]
const escapedWord = escapedLines.pop()
escapedWord.should.equal('räksmörgås')
// Check that unescaping works
return decodeURIComponent(escape(escaped_word)).should.equal(
return decodeURIComponent(escape(escapedWord)).should.equal(
'räksmörgås'
)
})
@@ -623,10 +622,10 @@ describe('WebsocketController', function () {
})
return it('should call the callback with the encoded comment', function () {
const encoded_comments = this.callback.args[0][4]
const encoded_comment = encoded_comments.comments.pop()
const encoded_comment_text = encoded_comment.op.c
return encoded_comment_text.should.equal('räksmörgås')
const encodedComments = this.callback.args[0][4]
const encodedComment = encodedComments.comments.pop()
const encodedCommentText = encodedComment.op.c
return encodedCommentText.should.equal('räksmörgås')
})
})
@@ -641,10 +640,10 @@ describe('WebsocketController', function () {
this.callback
)
const encoded_changes = this.callback.args[0][4]
const encoded_change = encoded_changes.changes.pop()
const encoded_change_text = encoded_change.op.i
return encoded_change_text.should.equal('räksmörgås')
const encodedChanges = this.callback.args[0][4]
const encodedChange = encodedChanges.changes.pop()
const encodedChangeText = encodedChange.op.i
return encodedChangeText.should.equal('räksmörgås')
})
return it('should call the callback with the encoded delete change', function () {
@@ -657,10 +656,10 @@ describe('WebsocketController', function () {
this.callback
)
const encoded_changes = this.callback.args[0][4]
const encoded_change = encoded_changes.changes.pop()
const encoded_change_text = encoded_change.op.d
return encoded_change_text.should.equal('räksmörgås')
const encodedChanges = this.callback.args[0][4]
const encodedChange = encodedChanges.changes.pop()
const encodedChangeText = encodedChange.op.d
return encodedChangeText.should.equal('räksmörgås')
})
})
@@ -746,11 +745,7 @@ describe('WebsocketController', function () {
this.AuthorizationManager.assertClientCanViewProjectAndDoc.yields(
new Error()
)
this.DocumentUpdaterManager.checkDocument = (
project_id,
doc_id,
cb
) => {
this.DocumentUpdaterManager.checkDocument = (projectId, docId, cb) => {
this.client.disconnected = true
cb()
}
@@ -790,11 +785,7 @@ describe('WebsocketController', function () {
this.AuthorizationManager.assertClientCanViewProjectAndDoc.yields(
new Error()
)
this.DocumentUpdaterManager.checkDocument = (
project_id,
doc_id,
cb
) => {
this.DocumentUpdaterManager.checkDocument = (projectId, docId, cb) => {
this.DocumentUpdaterManager.checkDocument = sinon.stub().yields()
this.WebsocketController.joinDoc(
this.client,
@@ -838,11 +829,7 @@ describe('WebsocketController', function () {
this.AuthorizationManager.assertClientCanViewProjectAndDoc.yields(
new Error()
)
this.DocumentUpdaterManager.checkDocument = (
project_id,
doc_id,
cb
) => {
this.DocumentUpdaterManager.checkDocument = (projectId, docId, cb) => {
this.WebsocketController.leaveDoc(this.client, this.doc_id, () => {})
cb()
}
@@ -873,7 +860,7 @@ describe('WebsocketController', function () {
describe('when the client disconnects while RoomManager.joinDoc is running', function () {
beforeEach(function () {
this.RoomManager.joinDoc = (client, doc_id, cb) => {
this.RoomManager.joinDoc = (client, docId, cb) => {
this.client.disconnected = true
return cb()
}
@@ -909,8 +896,8 @@ describe('WebsocketController', function () {
return describe('when the client disconnects while DocumentUpdaterManager.getDocument is running', function () {
beforeEach(function () {
this.DocumentUpdaterManager.getDocument = (
project_id,
doc_id,
projectId,
docId,
fromVersion,
callback
) => {
@@ -1524,9 +1511,9 @@ describe('WebsocketController', function () {
this.logger.warn.called.should.equal(true)
return this.logger.warn.args[0].should.deep.equal([
{
user_id: this.user_id,
project_id: this.project_id,
doc_id: this.doc_id,
userId: this.user_id,
projectId: this.project_id,
docId: this.doc_id,
updateSize: 7372835,
},
'update is too large',