[misc] run format_fix and lint:fix
This commit is contained in:
@@ -24,7 +24,7 @@ describe('DiffGenerator', function () {
|
||||
return (this.meta = {
|
||||
start_ts: this.ts,
|
||||
end_ts: this.ts,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('DiffGenerator', function () {
|
||||
const content = 'hello world'
|
||||
const rewoundContent = this.DiffGenerator.rewindOp(content, {
|
||||
p: 6,
|
||||
i: 'wo'
|
||||
i: 'wo',
|
||||
})
|
||||
return rewoundContent.should.equal('hello rld')
|
||||
})
|
||||
@@ -45,7 +45,7 @@ describe('DiffGenerator', function () {
|
||||
const content = 'hello rld'
|
||||
const rewoundContent = this.DiffGenerator.rewindOp(content, {
|
||||
p: 6,
|
||||
d: 'wo'
|
||||
d: 'wo',
|
||||
})
|
||||
return rewoundContent.should.equal('hello world')
|
||||
})
|
||||
@@ -65,7 +65,7 @@ describe('DiffGenerator', function () {
|
||||
const content = 'foobar'
|
||||
const rewoundContent = this.DiffGenerator.rewindOp(content, {
|
||||
p: 4,
|
||||
i: 'bar'
|
||||
i: 'bar',
|
||||
})
|
||||
return rewoundContent.should.equal('foo')
|
||||
})
|
||||
@@ -78,8 +78,8 @@ describe('DiffGenerator', function () {
|
||||
const update = {
|
||||
op: [
|
||||
{ p: 3, i: 'bbb' },
|
||||
{ p: 6, i: 'ccc' }
|
||||
]
|
||||
{ p: 6, i: 'ccc' },
|
||||
],
|
||||
}
|
||||
const rewoundContent = this.DiffGenerator.rewindUpdate(content, update)
|
||||
return rewoundContent.should.equal('aaa')
|
||||
@@ -91,7 +91,7 @@ describe('DiffGenerator', function () {
|
||||
const content = 'aaabbbccc'
|
||||
const updates = [
|
||||
{ op: [{ p: 3, i: 'bbb' }] },
|
||||
{ op: [{ p: 6, i: 'ccc' }] }
|
||||
{ op: [{ p: 6, i: 'ccc' }] },
|
||||
]
|
||||
const rewoundContent = this.DiffGenerator.rewindUpdates(content, updates)
|
||||
return rewoundContent.should.equal('aaa')
|
||||
@@ -105,7 +105,7 @@ describe('DiffGenerator', function () {
|
||||
this.updates = [
|
||||
{ i: 'mock-update-1' },
|
||||
{ i: 'mock-update-2' },
|
||||
{ i: 'mock-update-3' }
|
||||
{ i: 'mock-update-3' },
|
||||
]
|
||||
this.DiffGenerator.applyUpdateToDiff = sinon.stub().returns(this.diff)
|
||||
this.DiffGenerator.compressDiff = sinon.stub().returns(this.diff)
|
||||
@@ -124,8 +124,8 @@ describe('DiffGenerator', function () {
|
||||
.calledWith(
|
||||
[
|
||||
{
|
||||
u: this.content
|
||||
}
|
||||
u: this.content,
|
||||
},
|
||||
],
|
||||
this.updates[0]
|
||||
)
|
||||
@@ -133,7 +133,7 @@ describe('DiffGenerator', function () {
|
||||
})
|
||||
|
||||
it('should apply each update', function () {
|
||||
return Array.from(this.updates).map((update) =>
|
||||
return Array.from(this.updates).map(update =>
|
||||
this.DiffGenerator.applyUpdateToDiff
|
||||
.calledWith(sinon.match.any, update)
|
||||
.should.equal(true)
|
||||
@@ -153,18 +153,18 @@ describe('DiffGenerator', function () {
|
||||
const diff = this.DiffGenerator.compressDiff([
|
||||
{
|
||||
i: 'foo',
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } },
|
||||
},
|
||||
{
|
||||
i: 'bar',
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id } }
|
||||
}
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id } },
|
||||
},
|
||||
])
|
||||
return expect(diff).to.deep.equal([
|
||||
{
|
||||
i: 'foobar',
|
||||
meta: { start_ts: 5, end_ts: 20, user: { id: this.user_id } }
|
||||
}
|
||||
meta: { start_ts: 5, end_ts: 20, user: { id: this.user_id } },
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -174,12 +174,12 @@ describe('DiffGenerator', function () {
|
||||
const input = [
|
||||
{
|
||||
i: 'foo',
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } },
|
||||
},
|
||||
{
|
||||
i: 'bar',
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id_2 } }
|
||||
}
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id_2 } },
|
||||
},
|
||||
]
|
||||
const output = this.DiffGenerator.compressDiff(input)
|
||||
return expect(output).to.deep.equal(input)
|
||||
@@ -191,18 +191,18 @@ describe('DiffGenerator', function () {
|
||||
const diff = this.DiffGenerator.compressDiff([
|
||||
{
|
||||
d: 'foo',
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } },
|
||||
},
|
||||
{
|
||||
d: 'bar',
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id } }
|
||||
}
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id } },
|
||||
},
|
||||
])
|
||||
return expect(diff).to.deep.equal([
|
||||
{
|
||||
d: 'foobar',
|
||||
meta: { start_ts: 5, end_ts: 20, user: { id: this.user_id } }
|
||||
}
|
||||
meta: { start_ts: 5, end_ts: 20, user: { id: this.user_id } },
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -212,12 +212,12 @@ describe('DiffGenerator', function () {
|
||||
const input = [
|
||||
{
|
||||
d: 'foo',
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }
|
||||
meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } },
|
||||
},
|
||||
{
|
||||
d: 'bar',
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id_2 } }
|
||||
}
|
||||
meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id_2 } },
|
||||
},
|
||||
]
|
||||
const output = this.DiffGenerator.compressDiff(input)
|
||||
return expect(output).to.deep.equal(input)
|
||||
@@ -230,34 +230,34 @@ describe('DiffGenerator', function () {
|
||||
it('should insert into the middle of (u)nchanged text', function () {
|
||||
const diff = this.DiffGenerator.applyUpdateToDiff([{ u: 'foobar' }], {
|
||||
op: [{ p: 3, i: 'baz' }],
|
||||
meta: this.meta
|
||||
meta: this.meta,
|
||||
})
|
||||
return expect(diff).to.deep.equal([
|
||||
{ u: 'foo' },
|
||||
{ i: 'baz', meta: this.meta },
|
||||
{ u: 'bar' }
|
||||
{ u: 'bar' },
|
||||
])
|
||||
})
|
||||
|
||||
it('should insert into the start of (u)changed text', function () {
|
||||
const diff = this.DiffGenerator.applyUpdateToDiff([{ u: 'foobar' }], {
|
||||
op: [{ p: 0, i: 'baz' }],
|
||||
meta: this.meta
|
||||
meta: this.meta,
|
||||
})
|
||||
return expect(diff).to.deep.equal([
|
||||
{ i: 'baz', meta: this.meta },
|
||||
{ u: 'foobar' }
|
||||
{ u: 'foobar' },
|
||||
])
|
||||
})
|
||||
|
||||
it('should insert into the end of (u)changed text', function () {
|
||||
const diff = this.DiffGenerator.applyUpdateToDiff([{ u: 'foobar' }], {
|
||||
op: [{ p: 6, i: 'baz' }],
|
||||
meta: this.meta
|
||||
meta: this.meta,
|
||||
})
|
||||
return expect(diff).to.deep.equal([
|
||||
{ u: 'foobar' },
|
||||
{ i: 'baz', meta: this.meta }
|
||||
{ i: 'baz', meta: this.meta },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -269,7 +269,7 @@ describe('DiffGenerator', function () {
|
||||
return expect(diff).to.deep.equal([
|
||||
{ i: 'foo', meta: this.meta },
|
||||
{ i: 'baz', meta: this.meta },
|
||||
{ i: 'bar', meta: this.meta }
|
||||
{ i: 'bar', meta: this.meta },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -282,7 +282,7 @@ describe('DiffGenerator', function () {
|
||||
{ d: 'deleted', meta: this.meta },
|
||||
{ u: 'foo' },
|
||||
{ i: 'baz', meta: this.meta },
|
||||
{ u: 'bar' }
|
||||
{ u: 'bar' },
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -297,7 +297,7 @@ describe('DiffGenerator', function () {
|
||||
return expect(diff).to.deep.equal([
|
||||
{ u: 'foo' },
|
||||
{ d: 'baz', meta: this.meta },
|
||||
{ u: 'bar' }
|
||||
{ u: 'bar' },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -308,7 +308,7 @@ describe('DiffGenerator', function () {
|
||||
)
|
||||
return expect(diff).to.deep.equal([
|
||||
{ d: 'foo', meta: this.meta },
|
||||
{ u: 'bazbar' }
|
||||
{ u: 'bazbar' },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -319,7 +319,7 @@ describe('DiffGenerator', function () {
|
||||
)
|
||||
return expect(diff).to.deep.equal([
|
||||
{ u: 'foobaz' },
|
||||
{ d: 'bar', meta: this.meta }
|
||||
{ d: 'bar', meta: this.meta },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -333,7 +333,7 @@ describe('DiffGenerator', function () {
|
||||
{ d: 'o', meta: this.meta },
|
||||
{ d: 'baz', meta: this.meta },
|
||||
{ d: 'b', meta: this.meta },
|
||||
{ u: 'ar' }
|
||||
{ u: 'ar' },
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -346,7 +346,7 @@ describe('DiffGenerator', function () {
|
||||
)
|
||||
return expect(diff).to.deep.equal([
|
||||
{ i: 'foo', meta: this.meta },
|
||||
{ i: 'bar', meta: this.meta }
|
||||
{ i: 'bar', meta: this.meta },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -375,7 +375,7 @@ describe('DiffGenerator', function () {
|
||||
{ u: 'fo' },
|
||||
{ d: 'o', meta: this.meta },
|
||||
{ d: 'b', meta: this.meta },
|
||||
{ u: 'ar' }
|
||||
{ u: 'ar' },
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -391,7 +391,7 @@ describe('DiffGenerator', function () {
|
||||
{ d: 'o', meta: this.meta },
|
||||
{ d: 'baz', meta: this.meta },
|
||||
{ d: 'b', meta: this.meta },
|
||||
{ u: 'ar' }
|
||||
{ u: 'ar' },
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -401,7 +401,7 @@ describe('DiffGenerator', function () {
|
||||
return expect(() =>
|
||||
this.DiffGenerator.applyUpdateToDiff([{ u: 'foobazbar' }], {
|
||||
op: [{ p: 3, d: 'xxx' }],
|
||||
meta: this.meta
|
||||
meta: this.meta,
|
||||
})
|
||||
).to.throw(this.DiffGenerator.ConsistencyError)
|
||||
})
|
||||
@@ -410,7 +410,7 @@ describe('DiffGenerator', function () {
|
||||
return expect(() =>
|
||||
this.DiffGenerator.applyUpdateToDiff([{ u: 'foobazbar' }], {
|
||||
op: [{ p: 0, d: 'xxx' }],
|
||||
meta: this.meta
|
||||
meta: this.meta,
|
||||
})
|
||||
).to.throw(this.DiffGenerator.ConsistencyError)
|
||||
})
|
||||
@@ -419,7 +419,7 @@ describe('DiffGenerator', function () {
|
||||
return expect(() =>
|
||||
this.DiffGenerator.applyUpdateToDiff([{ u: 'foobazbar' }], {
|
||||
op: [{ p: 6, d: 'xxx' }],
|
||||
meta: this.meta
|
||||
meta: this.meta,
|
||||
})
|
||||
).to.throw(this.DiffGenerator.ConsistencyError)
|
||||
})
|
||||
@@ -434,7 +434,7 @@ describe('DiffGenerator', function () {
|
||||
return expect(diff).to.deep.equal([
|
||||
{ u: 'foo' },
|
||||
{ i: 'baz', meta: this.meta },
|
||||
{ d: 'bar', meta: this.meta }
|
||||
{ d: 'bar', meta: this.meta },
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -447,7 +447,7 @@ describe('DiffGenerator', function () {
|
||||
)
|
||||
return expect(diff).to.deep.equal([
|
||||
{ d: 'bar', meta: this.meta },
|
||||
{ i: 'baz', meta: this.meta }
|
||||
{ i: 'baz', meta: this.meta },
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -21,8 +21,8 @@ describe('DiffManager', function () {
|
||||
requires: {
|
||||
'./UpdatesManager': (this.UpdatesManager = {}),
|
||||
'./DocumentUpdaterManager': (this.DocumentUpdaterManager = {}),
|
||||
'./DiffGenerator': (this.DiffGenerator = {})
|
||||
}
|
||||
'./DiffGenerator': (this.DiffGenerator = {}),
|
||||
},
|
||||
})
|
||||
this.callback = sinon.stub()
|
||||
this.from = new Date()
|
||||
@@ -114,23 +114,23 @@ describe('DiffManager', function () {
|
||||
{
|
||||
op: 'mock-4',
|
||||
v: 42,
|
||||
meta: { start_ts: new Date(this.to.getTime() + 20) }
|
||||
meta: { start_ts: new Date(this.to.getTime() + 20) },
|
||||
},
|
||||
{
|
||||
op: 'mock-3',
|
||||
v: 41,
|
||||
meta: { start_ts: new Date(this.to.getTime() + 10) }
|
||||
meta: { start_ts: new Date(this.to.getTime() + 10) },
|
||||
},
|
||||
{
|
||||
op: 'mock-2',
|
||||
v: 40,
|
||||
meta: { start_ts: new Date(this.to.getTime() - 10) }
|
||||
meta: { start_ts: new Date(this.to.getTime() - 10) },
|
||||
},
|
||||
{
|
||||
op: 'mock-1',
|
||||
v: 39,
|
||||
meta: { start_ts: new Date(this.to.getTime() - 20) }
|
||||
}
|
||||
meta: { start_ts: new Date(this.to.getTime() - 20) },
|
||||
},
|
||||
]
|
||||
this.fromVersion = 39
|
||||
this.toVersion = 40
|
||||
@@ -333,23 +333,23 @@ describe('DiffManager', function () {
|
||||
{
|
||||
op: 'mock-4',
|
||||
v: 42,
|
||||
meta: { start_ts: new Date(this.to.getTime() + 20) }
|
||||
meta: { start_ts: new Date(this.to.getTime() + 20) },
|
||||
},
|
||||
{
|
||||
op: 'mock-3',
|
||||
v: 41,
|
||||
meta: { start_ts: new Date(this.to.getTime() + 10) }
|
||||
meta: { start_ts: new Date(this.to.getTime() + 10) },
|
||||
},
|
||||
{
|
||||
op: 'mock-2',
|
||||
v: 40,
|
||||
meta: { start_ts: new Date(this.to.getTime() - 10) }
|
||||
meta: { start_ts: new Date(this.to.getTime() - 10) },
|
||||
},
|
||||
{
|
||||
op: 'mock-1',
|
||||
v: 39,
|
||||
meta: { start_ts: new Date(this.to.getTime() - 20) }
|
||||
}
|
||||
meta: { start_ts: new Date(this.to.getTime() - 20) },
|
||||
},
|
||||
]
|
||||
this.fromVersion = 39
|
||||
this.rewound_content = 'rewound-content'
|
||||
@@ -400,7 +400,7 @@ describe('DiffManager', function () {
|
||||
this.version = 50
|
||||
this.updates = [
|
||||
{ op: 'mock-1', v: 40 },
|
||||
{ op: 'mock-1', v: 39 }
|
||||
{ op: 'mock-1', v: 39 },
|
||||
]
|
||||
this.DiffManager.getLatestDocAndUpdates = sinon
|
||||
.stub()
|
||||
|
||||
@@ -25,12 +25,12 @@ describe('MongoAWS', function () {
|
||||
trackchanges: {
|
||||
s3: {
|
||||
secret: 's3-secret',
|
||||
key: 's3-key'
|
||||
key: 's3-key',
|
||||
},
|
||||
stores: {
|
||||
doc_history: 's3-bucket'
|
||||
}
|
||||
}
|
||||
doc_history: 's3-bucket',
|
||||
},
|
||||
},
|
||||
}),
|
||||
child_process: (this.child_process = {}),
|
||||
'mongo-uri': (this.mongouri = {}),
|
||||
@@ -40,8 +40,8 @@ describe('MongoAWS', function () {
|
||||
'./mongodb': { db: (this.db = {}), ObjectId },
|
||||
JSONStream: (this.JSONStream = {}),
|
||||
'readline-stream': (this.readline = sinon.stub()),
|
||||
'@overleaf/metrics': { inc() {} }
|
||||
}
|
||||
'@overleaf/metrics': { inc() {} },
|
||||
},
|
||||
})
|
||||
|
||||
this.project_id = ObjectId().toString()
|
||||
|
||||
+6
-6
@@ -20,9 +20,9 @@ describe('DocumentUpdaterManager', function () {
|
||||
requires: {
|
||||
request: (this.request = {}),
|
||||
'@overleaf/settings': (this.settings = {
|
||||
apis: { documentupdater: { url: 'http://example.com' } }
|
||||
})
|
||||
}
|
||||
apis: { documentupdater: { url: 'http://example.com' } },
|
||||
}),
|
||||
},
|
||||
})
|
||||
this.callback = sinon.stub()
|
||||
this.lines = ['one', 'two', 'three']
|
||||
@@ -35,7 +35,7 @@ describe('DocumentUpdaterManager', function () {
|
||||
this.body = JSON.stringify({
|
||||
lines: this.lines,
|
||||
version: this.version,
|
||||
ops: []
|
||||
ops: [],
|
||||
})
|
||||
this.request.get = sinon
|
||||
.stub()
|
||||
@@ -135,8 +135,8 @@ describe('DocumentUpdaterManager', function () {
|
||||
lines: this.content.split('\n'),
|
||||
source: 'restore',
|
||||
user_id: this.user_id,
|
||||
undoing: true
|
||||
}
|
||||
undoing: true,
|
||||
},
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
@@ -24,8 +24,8 @@ describe('HttpController', function () {
|
||||
'./RestoreManager': (this.RestoreManager = {}),
|
||||
'./PackManager': (this.PackManager = {}),
|
||||
'./DocArchiveManager': (this.DocArchiveManager = {}),
|
||||
'./HealthChecker': (this.HealthChecker = {})
|
||||
}
|
||||
'./HealthChecker': (this.HealthChecker = {}),
|
||||
},
|
||||
})
|
||||
this.doc_id = 'doc-id-123'
|
||||
this.project_id = 'project-id-123'
|
||||
@@ -39,8 +39,8 @@ describe('HttpController', function () {
|
||||
this.req = {
|
||||
params: {
|
||||
doc_id: this.doc_id,
|
||||
project_id: this.project_id
|
||||
}
|
||||
project_id: this.project_id,
|
||||
},
|
||||
}
|
||||
this.res = { sendStatus: sinon.stub() }
|
||||
this.UpdatesManager.processUncompressedUpdatesWithLock = sinon
|
||||
@@ -64,8 +64,8 @@ describe('HttpController', function () {
|
||||
beforeEach(function () {
|
||||
this.req = {
|
||||
params: {
|
||||
project_id: this.project_id
|
||||
}
|
||||
project_id: this.project_id,
|
||||
},
|
||||
}
|
||||
this.res = { sendStatus: sinon.stub() }
|
||||
this.UpdatesManager.processUncompressedUpdatesForProject = sinon
|
||||
@@ -92,12 +92,12 @@ describe('HttpController', function () {
|
||||
this.req = {
|
||||
params: {
|
||||
doc_id: this.doc_id,
|
||||
project_id: this.project_id
|
||||
project_id: this.project_id,
|
||||
},
|
||||
query: {
|
||||
from: this.from.toString(),
|
||||
to: this.to.toString()
|
||||
}
|
||||
to: this.to.toString(),
|
||||
},
|
||||
}
|
||||
this.res = { json: sinon.stub() }
|
||||
this.diff = [{ u: 'mock-diff' }]
|
||||
@@ -128,12 +128,12 @@ describe('HttpController', function () {
|
||||
this.min_count = 10
|
||||
this.req = {
|
||||
params: {
|
||||
project_id: this.project_id
|
||||
project_id: this.project_id,
|
||||
},
|
||||
query: {
|
||||
before: this.before.toString(),
|
||||
min_count: this.min_count.toString()
|
||||
}
|
||||
min_count: this.min_count.toString(),
|
||||
},
|
||||
}
|
||||
this.res = { json: sinon.stub() }
|
||||
this.updates = ['mock-summarized-updates']
|
||||
@@ -147,7 +147,7 @@ describe('HttpController', function () {
|
||||
return this.UpdatesManager.getSummarizedProjectUpdates
|
||||
.calledWith(this.project_id, {
|
||||
before: this.before,
|
||||
min_count: this.min_count
|
||||
min_count: this.min_count,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -156,7 +156,7 @@ describe('HttpController', function () {
|
||||
return this.res.json
|
||||
.calledWith({
|
||||
updates: this.updates,
|
||||
nextBeforeTimestamp: this.nextBeforeTimestamp
|
||||
nextBeforeTimestamp: this.nextBeforeTimestamp,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -169,11 +169,11 @@ describe('HttpController', function () {
|
||||
params: {
|
||||
doc_id: this.doc_id,
|
||||
project_id: this.project_id,
|
||||
version: this.version
|
||||
version: this.version,
|
||||
},
|
||||
headers: {
|
||||
'x-user-id': this.user_id
|
||||
}
|
||||
'x-user-id': this.user_id,
|
||||
},
|
||||
}
|
||||
this.res = { sendStatus: sinon.stub() }
|
||||
|
||||
|
||||
@@ -24,18 +24,18 @@ describe('LockManager', function () {
|
||||
beforeEach(function () {
|
||||
this.Settings = {
|
||||
redis: {
|
||||
lock: {}
|
||||
}
|
||||
lock: {},
|
||||
},
|
||||
}
|
||||
this.LockManager = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'@overleaf/redis-wrapper': {
|
||||
createClient: () => {
|
||||
return (this.rclient = { auth: sinon.stub() })
|
||||
}
|
||||
},
|
||||
},
|
||||
'@overleaf/settings': this.Settings
|
||||
}
|
||||
'@overleaf/settings': this.Settings,
|
||||
},
|
||||
})
|
||||
|
||||
this.key = 'lock-key'
|
||||
@@ -240,7 +240,7 @@ describe('LockManager', function () {
|
||||
describe('when the runner function returns an error', function () {
|
||||
beforeEach(function () {
|
||||
this.error = new Error('oops')
|
||||
this.runner = (releaseLock) => {
|
||||
this.runner = releaseLock => {
|
||||
if (releaseLock == null) {
|
||||
releaseLock = function (error) {}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ describe('MongoManager', function () {
|
||||
requires: {
|
||||
'./mongodb': { db: (this.db = {}), ObjectId },
|
||||
'./PackManager': (this.PackManager = {}),
|
||||
'@overleaf/metrics': { timeAsyncMethod() {} }
|
||||
}
|
||||
'@overleaf/metrics': { timeAsyncMethod() {} },
|
||||
},
|
||||
})
|
||||
this.callback = sinon.stub()
|
||||
this.doc_id = ObjectId().toString()
|
||||
@@ -166,10 +166,10 @@ describe('MongoManager', function () {
|
||||
.calledWith(
|
||||
{
|
||||
doc_id: ObjectId(this.doc_id),
|
||||
project_id: { $exists: false }
|
||||
project_id: { $exists: false },
|
||||
},
|
||||
{
|
||||
$set: { project_id: ObjectId(this.project_id) }
|
||||
$set: { project_id: ObjectId(this.project_id) },
|
||||
}
|
||||
)
|
||||
.should.equal(true)
|
||||
@@ -184,7 +184,7 @@ describe('MongoManager', function () {
|
||||
beforeEach(function () {
|
||||
this.metadata = { mock: 'metadata' }
|
||||
this.db.projectHistoryMetaData = {
|
||||
findOne: sinon.stub().callsArgWith(1, null, this.metadata)
|
||||
findOne: sinon.stub().callsArgWith(1, null, this.metadata),
|
||||
}
|
||||
return this.MongoManager.getProjectMetaData(
|
||||
this.project_id,
|
||||
@@ -207,7 +207,7 @@ describe('MongoManager', function () {
|
||||
beforeEach(function () {
|
||||
this.metadata = { mock: 'metadata' }
|
||||
this.db.projectHistoryMetaData = {
|
||||
updateOne: sinon.stub().yields()
|
||||
updateOne: sinon.stub().yields(),
|
||||
}
|
||||
return this.MongoManager.setProjectMetaData(
|
||||
this.project_id,
|
||||
@@ -220,13 +220,13 @@ describe('MongoManager', function () {
|
||||
return this.db.projectHistoryMetaData.updateOne
|
||||
.calledWith(
|
||||
{
|
||||
project_id: ObjectId(this.project_id)
|
||||
project_id: ObjectId(this.project_id),
|
||||
},
|
||||
{
|
||||
$set: this.metadata
|
||||
$set: this.metadata,
|
||||
},
|
||||
{
|
||||
upsert: true
|
||||
upsert: true,
|
||||
}
|
||||
)
|
||||
.should.equal(true)
|
||||
|
||||
@@ -31,9 +31,9 @@ describe('PackManager', function () {
|
||||
'@overleaf/metrics': { inc() {} },
|
||||
'./ProjectIterator': require('../../../../app/js/ProjectIterator.js'), // Cache for speed
|
||||
'@overleaf/settings': {
|
||||
redis: { lock: { key_schema: {} } }
|
||||
}
|
||||
}
|
||||
redis: { lock: { key_schema: {} } },
|
||||
},
|
||||
},
|
||||
})
|
||||
this.callback = sinon.stub()
|
||||
this.doc_id = ObjectId().toString()
|
||||
@@ -51,20 +51,20 @@ describe('PackManager', function () {
|
||||
_id: '12345',
|
||||
pack: [
|
||||
{ op: 'op-1', meta: 'meta-1', v: 1 },
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 }
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 },
|
||||
],
|
||||
n: 2,
|
||||
sz: 100
|
||||
sz: 100,
|
||||
}
|
||||
this.newUpdates = [
|
||||
{ op: 'op-3', meta: 'meta-3', v: 3 },
|
||||
{ op: 'op-4', meta: 'meta-4', v: 4 }
|
||||
{ op: 'op-4', meta: 'meta-4', v: 4 },
|
||||
]
|
||||
return (this.db.docHistory = {
|
||||
insertOne: sinon.stub().yields(),
|
||||
insert: sinon.stub().callsArg(1),
|
||||
updateOne: sinon.stub().yields(),
|
||||
findAndModify: sinon.stub().callsArg(1)
|
||||
findAndModify: sinon.stub().callsArg(1),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -95,10 +95,10 @@ describe('PackManager', function () {
|
||||
|
||||
return describe('for many small updates', function () {
|
||||
beforeEach(function () {
|
||||
this.newUpdates = __range__(0, 2048, true).map((i) => ({
|
||||
this.newUpdates = __range__(0, 2048, true).map(i => ({
|
||||
op: `op-${i}`,
|
||||
meta: `meta-${i}`,
|
||||
v: i
|
||||
v: i,
|
||||
}))
|
||||
return this.PackManager.insertCompressedUpdates(
|
||||
this.project_id,
|
||||
@@ -209,10 +209,10 @@ describe('PackManager', function () {
|
||||
|
||||
describe('for many small updates', function () {
|
||||
beforeEach(function () {
|
||||
this.newUpdates = __range__(0, 2048, true).map((i) => ({
|
||||
this.newUpdates = __range__(0, 2048, true).map(i => ({
|
||||
op: `op-${i}`,
|
||||
meta: `meta-${i}`,
|
||||
v: i
|
||||
v: i,
|
||||
}))
|
||||
return this.PackManager.insertCompressedUpdates(
|
||||
this.project_id,
|
||||
@@ -292,12 +292,12 @@ describe('PackManager', function () {
|
||||
0.75 * this.PackManager.MAX_SIZE,
|
||||
true
|
||||
)
|
||||
.map((j) => 'a')
|
||||
.map(j => 'a')
|
||||
.join('')
|
||||
this.newUpdates = [0, 1, 2, 3, 4].map((i) => ({
|
||||
this.newUpdates = [0, 1, 2, 3, 4].map(i => ({
|
||||
op: `op-${i}-${longString}`,
|
||||
meta: `meta-${i}`,
|
||||
v: i
|
||||
v: i,
|
||||
}))
|
||||
return this.PackManager.insertCompressedUpdates(
|
||||
this.project_id,
|
||||
@@ -393,7 +393,7 @@ describe('PackManager', function () {
|
||||
doc_id: ObjectId(this.doc_id),
|
||||
n: this.newUpdates.length,
|
||||
v: this.newUpdates[0].v,
|
||||
v_end: this.newUpdates[this.newUpdates.length - 1].v
|
||||
v_end: this.newUpdates[this.newUpdates.length - 1].v,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -401,7 +401,7 @@ describe('PackManager', function () {
|
||||
it('should set an expiry time in the future', function () {
|
||||
return this.db.docHistory.insertOne
|
||||
.calledWithMatch({
|
||||
expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000)
|
||||
expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000),
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -419,12 +419,12 @@ describe('PackManager', function () {
|
||||
_id: '12345',
|
||||
pack: [
|
||||
{ op: 'op-1', meta: 'meta-1', v: 1 },
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 }
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 },
|
||||
],
|
||||
n: 2,
|
||||
sz: 100,
|
||||
meta: { start_ts: Date.now() - 6 * 3600 * 1000 },
|
||||
expiresAt: new Date(Date.now())
|
||||
expiresAt: new Date(Date.now()),
|
||||
}
|
||||
|
||||
return this.PackManager.flushCompressedUpdates(
|
||||
@@ -444,7 +444,7 @@ describe('PackManager', function () {
|
||||
{ _id: this.lastUpdate._id },
|
||||
{
|
||||
$push: { pack: { $each: this.newUpdates } },
|
||||
$set: { v_end: this.newUpdates[this.newUpdates.length - 1].v }
|
||||
$set: { v_end: this.newUpdates[this.newUpdates.length - 1].v },
|
||||
}
|
||||
)
|
||||
.should.equal(true)
|
||||
@@ -453,7 +453,7 @@ describe('PackManager', function () {
|
||||
it('should set an expiry time in the future', function () {
|
||||
return this.db.docHistory.updateOne
|
||||
.calledWithMatch(sinon.match.any, {
|
||||
$set: { expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000) }
|
||||
$set: { expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000) },
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -472,12 +472,12 @@ describe('PackManager', function () {
|
||||
_id: '12345',
|
||||
pack: [
|
||||
{ op: 'op-1', meta: 'meta-1', v: 1 },
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 }
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 },
|
||||
],
|
||||
n: 2,
|
||||
sz: 100,
|
||||
meta: { start_ts: Date.now() - 6 * 3600 * 1000 },
|
||||
expiresAt: new Date(Date.now())
|
||||
expiresAt: new Date(Date.now()),
|
||||
}
|
||||
|
||||
return this.PackManager.flushCompressedUpdates(
|
||||
@@ -499,7 +499,7 @@ describe('PackManager', function () {
|
||||
doc_id: ObjectId(this.doc_id),
|
||||
n: this.newUpdates.length,
|
||||
v: this.newUpdates[0].v,
|
||||
v_end: this.newUpdates[this.newUpdates.length - 1].v
|
||||
v_end: this.newUpdates[this.newUpdates.length - 1].v,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -522,12 +522,12 @@ describe('PackManager', function () {
|
||||
_id: '12345',
|
||||
pack: [
|
||||
{ op: 'op-1', meta: 'meta-1', v: 1 },
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 }
|
||||
{ op: 'op-2', meta: 'meta-2', v: 2 },
|
||||
],
|
||||
n: 2,
|
||||
sz: 100,
|
||||
meta: { start_ts: Date.now() - 30 * 24 * 3600 * 1000 },
|
||||
expiresAt: new Date(Date.now() - 30 * 24 * 3600 * 1000)
|
||||
expiresAt: new Date(Date.now() - 30 * 24 * 3600 * 1000),
|
||||
}
|
||||
|
||||
return this.PackManager.flushCompressedUpdates(
|
||||
@@ -549,7 +549,7 @@ describe('PackManager', function () {
|
||||
doc_id: ObjectId(this.doc_id),
|
||||
n: this.newUpdates.length,
|
||||
v: this.newUpdates[0].v,
|
||||
v_end: this.newUpdates[this.newUpdates.length - 1].v
|
||||
v_end: this.newUpdates[this.newUpdates.length - 1].v,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -557,7 +557,7 @@ describe('PackManager', function () {
|
||||
it('should set an expiry time in the future', function () {
|
||||
return this.db.docHistory.insertOne
|
||||
.calledWithMatch({
|
||||
expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000)
|
||||
expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000),
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -602,7 +602,7 @@ describe('PackManager', function () {
|
||||
describe('when an archive is in progress', function () {
|
||||
beforeEach(function () {
|
||||
this.db.docHistoryIndex = {
|
||||
findOne: sinon.stub().callsArgWith(2, null, { inS3: false })
|
||||
findOne: sinon.stub().callsArgWith(2, null, { inS3: false }),
|
||||
}
|
||||
return this.PackManager.checkArchiveNotInProgress(
|
||||
this.project_id,
|
||||
@@ -624,7 +624,7 @@ describe('PackManager', function () {
|
||||
describe('when an archive is completed', function () {
|
||||
beforeEach(function () {
|
||||
this.db.docHistoryIndex = {
|
||||
findOne: sinon.stub().callsArgWith(2, null, { inS3: true })
|
||||
findOne: sinon.stub().callsArgWith(2, null, { inS3: true }),
|
||||
}
|
||||
return this.PackManager.checkArchiveNotInProgress(
|
||||
this.project_id,
|
||||
@@ -646,7 +646,7 @@ describe('PackManager', function () {
|
||||
return describe('when the archive has not started or completed', function () {
|
||||
beforeEach(function () {
|
||||
this.db.docHistoryIndex = {
|
||||
findOne: sinon.stub().callsArgWith(2, null, {})
|
||||
findOne: sinon.stub().callsArgWith(2, null, {}),
|
||||
}
|
||||
return this.PackManager.checkArchiveNotInProgress(
|
||||
this.project_id,
|
||||
|
||||
@@ -24,9 +24,9 @@ describe('RedisManager', function () {
|
||||
createClient: () => {
|
||||
return (this.rclient = {
|
||||
auth: sinon.stub(),
|
||||
multi: () => this.rclient
|
||||
multi: () => this.rclient,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
'@overleaf/settings': {
|
||||
redis: {
|
||||
@@ -37,12 +37,12 @@ describe('RedisManager', function () {
|
||||
},
|
||||
docsWithHistoryOps({ project_id }) {
|
||||
return `DocsWithHistoryOps:${project_id}`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
this.doc_id = 'doc-id-123'
|
||||
this.project_id = 'project-id-123'
|
||||
@@ -54,9 +54,9 @@ describe('RedisManager', function () {
|
||||
beforeEach(function () {
|
||||
this.rawUpdates = [
|
||||
{ v: 42, op: 'mock-op-42' },
|
||||
{ v: 45, op: 'mock-op-45' }
|
||||
{ v: 45, op: 'mock-op-45' },
|
||||
]
|
||||
this.jsonUpdates = Array.from(this.rawUpdates).map((update) =>
|
||||
this.jsonUpdates = Array.from(this.rawUpdates).map(update =>
|
||||
JSON.stringify(update)
|
||||
)
|
||||
this.rclient.lrange = sinon.stub().callsArgWith(3, null, this.jsonUpdates)
|
||||
|
||||
@@ -19,8 +19,8 @@ describe('RestoreManager', function () {
|
||||
this.RestoreManager = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'./DocumentUpdaterManager': (this.DocumentUpdaterManager = {}),
|
||||
'./DiffManager': (this.DiffManager = {})
|
||||
}
|
||||
'./DiffManager': (this.DiffManager = {}),
|
||||
},
|
||||
})
|
||||
this.callback = sinon.stub()
|
||||
this.project_id = 'mock-project-id'
|
||||
|
||||
@@ -15,18 +15,18 @@ const modulePath = '../../../../app/js/UpdateCompressor.js'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
const bigstring = __range__(0, 2 * 1024 * 1024, true)
|
||||
.map((i) => 'a')
|
||||
.map(i => 'a')
|
||||
.join('')
|
||||
const mediumstring = __range__(0, 1024 * 1024, true)
|
||||
.map((j) => 'a')
|
||||
.map(j => 'a')
|
||||
.join('')
|
||||
|
||||
describe('UpdateCompressor', function () {
|
||||
beforeEach(function () {
|
||||
this.UpdateCompressor = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'../lib/diff_match_patch': require('../../../../app/lib/diff_match_patch')
|
||||
}
|
||||
'../lib/diff_match_patch': require('../../../../app/lib/diff_match_patch'),
|
||||
},
|
||||
})
|
||||
this.user_id = 'user-id-1'
|
||||
this.other_user_id = 'user-id-2'
|
||||
@@ -41,37 +41,37 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: [
|
||||
(this.op1 = { p: 0, i: 'Foo' }),
|
||||
(this.op2 = { p: 6, i: 'bar' })
|
||||
(this.op2 = { p: 6, i: 'bar' }),
|
||||
],
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: [(this.op3 = { p: 10, i: 'baz' })],
|
||||
meta: { ts: this.ts2, user_id: this.other_user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
op: this.op1,
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: this.op2,
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: this.op3,
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.other_user_id
|
||||
user_id: this.other_user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -81,15 +81,15 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: [],
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
}
|
||||
v: 42,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
op: this.UpdateCompressor.NOOP,
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
}
|
||||
v: 42,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -100,23 +100,23 @@ describe('UpdateCompressor', function () {
|
||||
op: [
|
||||
(this.op1 = { p: 0, i: 'Foo' }),
|
||||
(this.op2 = { p: 9, c: 'baz' }),
|
||||
(this.op3 = { p: 6, i: 'bar' })
|
||||
(this.op3 = { p: 6, i: 'bar' }),
|
||||
],
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
}
|
||||
v: 42,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
op: this.op1,
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: this.op3,
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
}
|
||||
v: 42,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -130,44 +130,44 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: (this.op2 = { p: 6, i: 'bar' }),
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: (this.op3 = { p: 10, i: 'baz' }),
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.other_user_id
|
||||
user_id: this.other_user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
op: [this.op1, this.op2],
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: [this.op3],
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.other_user_id
|
||||
user_id: this.other_user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -179,17 +179,17 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
}
|
||||
v: 42,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
op: [],
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
}
|
||||
v: 42,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -202,13 +202,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, i: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -216,10 +216,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -229,13 +229,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 5, i: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -243,10 +243,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -256,13 +256,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 9, i: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -270,19 +270,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 9, i: 'bar' },
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -292,13 +292,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, i: bigstring },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -306,19 +306,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, i: bigstring },
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -328,13 +328,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: bigstring },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3 + bigstring.length, i: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -342,19 +342,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3 + bigstring.length, i: 'bar' },
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -364,13 +364,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: mediumstring },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3 + mediumstring.length, i: mediumstring },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -378,19 +378,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3 + mediumstring.length, i: mediumstring },
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -402,13 +402,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, d: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3, d: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -416,10 +416,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -429,13 +429,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, d: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 1, d: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -443,10 +443,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -456,13 +456,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, d: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 9, d: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -470,19 +470,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 9, d: 'bar' },
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -494,13 +494,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 5, d: 'o' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -508,10 +508,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -521,13 +521,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'fobaro' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 5, d: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -535,10 +535,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -548,13 +548,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3, d: 'foo' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -562,10 +562,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -575,13 +575,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foo' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 9, d: 'bar' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -589,19 +589,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 9, d: 'bar' },
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -611,13 +611,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, i: 'foobar' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, d: 'bardle' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -625,19 +625,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, d: 'bardle' },
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -649,13 +649,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, d: 'one two three four five six seven eight' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3, i: 'one 2 three four five six seven eight' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -663,19 +663,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
v: 43,
|
||||
},
|
||||
{
|
||||
op: { p: 7, i: '2' },
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -685,13 +685,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: { p: 3, d: 'one two three four five six seven eight' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 3, i: 'one two three four five six seven eight' },
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -699,10 +699,10 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -714,13 +714,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: this.UpdateCompressor.NOOP,
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, i: 'bar' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -728,19 +728,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, i: 'bar' },
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -752,13 +752,13 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: this.UpdateCompressor.NOOP,
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, d: 'bar' },
|
||||
meta: { ts: this.ts1, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
).to.deep.equal([
|
||||
{
|
||||
@@ -766,19 +766,19 @@ describe('UpdateCompressor', function () {
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: { p: 6, d: 'bar' },
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -792,45 +792,45 @@ describe('UpdateCompressor', function () {
|
||||
{
|
||||
op: [
|
||||
{ p: 1000, d: 'hello' },
|
||||
{ p: 1000, i: 'HELLO()' }
|
||||
{ p: 1000, i: 'HELLO()' },
|
||||
],
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
[
|
||||
{
|
||||
op: [{ p: 1006, i: 'WORLD' }],
|
||||
meta: { ts: this.ts2, user_id: this.user_id },
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
]
|
||||
)
|
||||
).to.deep.equal([
|
||||
{
|
||||
op: [
|
||||
{ p: 1000, d: 'hello' },
|
||||
{ p: 1000, i: 'HELLO()' }
|
||||
{ p: 1000, i: 'HELLO()' },
|
||||
],
|
||||
meta: {
|
||||
start_ts: this.ts1,
|
||||
end_ts: this.ts1,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 42
|
||||
v: 42,
|
||||
},
|
||||
{
|
||||
op: [{ p: 1006, i: 'WORLD' }],
|
||||
meta: {
|
||||
start_ts: this.ts2,
|
||||
end_ts: this.ts2,
|
||||
user_id: this.user_id
|
||||
user_id: this.user_id,
|
||||
},
|
||||
v: 43
|
||||
}
|
||||
v: 43,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -23,8 +23,8 @@ describe('UpdateTrimmer', function () {
|
||||
this.UpdateTrimmer = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'./WebApiManager': (this.WebApiManager = {}),
|
||||
'./MongoManager': (this.MongoManager = {})
|
||||
}
|
||||
'./MongoManager': (this.MongoManager = {}),
|
||||
},
|
||||
})
|
||||
|
||||
this.callback = sinon.stub()
|
||||
|
||||
@@ -38,12 +38,12 @@ describe('UpdatesManager', function () {
|
||||
key_schema: {
|
||||
historyLock({ doc_id }) {
|
||||
return `HistoryLock:${doc_id}`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
this.doc_id = 'doc-id-123'
|
||||
this.project_id = 'project-id-123'
|
||||
@@ -79,7 +79,7 @@ describe('UpdatesManager', function () {
|
||||
beforeEach(function () {
|
||||
this.rawUpdates = [
|
||||
{ v: 12, op: 'mock-op-12' },
|
||||
{ v: 13, op: 'mock-op-13' }
|
||||
{ v: 13, op: 'mock-op-13' },
|
||||
]
|
||||
this.compressedUpdates = [{ v: 13, op: 'compressed-op-12' }]
|
||||
|
||||
@@ -127,7 +127,7 @@ describe('UpdatesManager', function () {
|
||||
this.lastCompressedUpdate = { v: 11, op: 'compressed-op-11' }
|
||||
this.compressedUpdates = [
|
||||
{ v: 12, op: 'compressed-op-11+12' },
|
||||
{ v: 13, op: 'compressed-op-12' }
|
||||
{ v: 13, op: 'compressed-op-12' },
|
||||
]
|
||||
|
||||
this.MongoManager.peekLastCompressedUpdate = sinon
|
||||
@@ -148,7 +148,7 @@ describe('UpdatesManager', function () {
|
||||
beforeEach(function () {
|
||||
this.rawUpdates = [
|
||||
{ v: 12, op: 'mock-op-12' },
|
||||
{ v: 13, op: 'mock-op-13' }
|
||||
{ v: 13, op: 'mock-op-13' },
|
||||
]
|
||||
return this.UpdatesManager.compressAndSaveRawUpdates(
|
||||
this.project_id,
|
||||
@@ -192,11 +192,11 @@ describe('UpdatesManager', function () {
|
||||
beforeEach(function () {
|
||||
this.lastCompressedUpdate = {
|
||||
pack: [{ v: 11, op: 'compressed-op-11' }],
|
||||
v: 11
|
||||
v: 11,
|
||||
}
|
||||
this.rawUpdates = [
|
||||
{ v: 12, op: 'mock-op-12' },
|
||||
{ v: 13, op: 'mock-op-13' }
|
||||
{ v: 13, op: 'mock-op-13' },
|
||||
]
|
||||
this.MongoManager.peekLastCompressedUpdate = sinon
|
||||
.stub()
|
||||
@@ -250,7 +250,7 @@ describe('UpdatesManager', function () {
|
||||
{ v: 10, op: 'mock-op-10' },
|
||||
{ v: 11, op: 'mock-op-11' },
|
||||
{ v: 12, op: 'mock-op-12' },
|
||||
{ v: 13, op: 'mock-op-13' }
|
||||
{ v: 13, op: 'mock-op-13' },
|
||||
]
|
||||
|
||||
return this.UpdatesManager.compressAndSaveRawUpdates(
|
||||
@@ -303,7 +303,7 @@ describe('UpdatesManager', function () {
|
||||
beforeEach(function () {
|
||||
this.rawUpdates = [
|
||||
{ v: 13, op: 'mock-op-13' },
|
||||
{ v: 12, op: 'mock-op-12' }
|
||||
{ v: 12, op: 'mock-op-12' },
|
||||
]
|
||||
return this.UpdatesManager.compressAndSaveRawUpdates(
|
||||
this.project_id,
|
||||
@@ -347,7 +347,7 @@ describe('UpdatesManager', function () {
|
||||
beforeEach(function () {
|
||||
this.rawUpdates = [
|
||||
{ v: 12, op: 'mock-op-12' },
|
||||
{ v: 13, op: 'mock-op-13' }
|
||||
{ v: 13, op: 'mock-op-13' },
|
||||
]
|
||||
return this.UpdatesManager.compressAndSaveRawUpdates(
|
||||
this.project_id,
|
||||
@@ -454,7 +454,7 @@ describe('UpdatesManager', function () {
|
||||
'mock-update-1',
|
||||
'mock-update-2',
|
||||
'mock-update-3',
|
||||
'mock-update-4'
|
||||
'mock-update-4',
|
||||
]
|
||||
this.redisArray = this.updates.slice()
|
||||
this.RedisManager.getOldestDocUpdates = (
|
||||
@@ -673,7 +673,7 @@ describe('UpdatesManager', function () {
|
||||
})
|
||||
|
||||
it('should process the doc ops for the each doc_id', function () {
|
||||
return Array.from(this.doc_ids).map((doc_id) =>
|
||||
return Array.from(this.doc_ids).map(doc_id =>
|
||||
this.UpdatesManager._processUncompressedUpdatesForDocWithLock
|
||||
.calledWith(this.project_id, doc_id, this.temporary)
|
||||
.should.equal(true)
|
||||
@@ -692,26 +692,26 @@ describe('UpdatesManager', function () {
|
||||
doc_id: 123,
|
||||
v: 456,
|
||||
op: 'mock-updates',
|
||||
meta: { user_id: 123, start_ts: 1233, end_ts: 1234 }
|
||||
}
|
||||
meta: { user_id: 123, start_ts: 1233, end_ts: 1234 },
|
||||
},
|
||||
]
|
||||
this.options = { before: 'mock-before', limit: 'mock-limit' }
|
||||
this.summarizedUpdates = [
|
||||
{
|
||||
meta: { user_ids: [123], start_ts: 1233, end_ts: 1234 },
|
||||
docs: { '123': { fromV: 456, toV: 456 } }
|
||||
}
|
||||
docs: { 123: { fromV: 456, toV: 456 } },
|
||||
},
|
||||
]
|
||||
this.updatesWithUserInfo = ['updates-with-user-info']
|
||||
this.done_state = false
|
||||
this.iterator = {
|
||||
next: (cb) => {
|
||||
next: cb => {
|
||||
this.done_state = true
|
||||
return cb(null, this.updates)
|
||||
},
|
||||
done: () => {
|
||||
return this.done_state
|
||||
}
|
||||
},
|
||||
}
|
||||
this.PackManager.makeProjectIterator = sinon
|
||||
.stub()
|
||||
@@ -867,22 +867,22 @@ describe('UpdatesManager', function () {
|
||||
this.updates = [
|
||||
{
|
||||
meta: {
|
||||
user_id: this.user_id_1
|
||||
user_id: this.user_id_1,
|
||||
},
|
||||
op: 'mock-op-1'
|
||||
op: 'mock-op-1',
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
user_id: this.user_id_1
|
||||
user_id: this.user_id_1,
|
||||
},
|
||||
op: 'mock-op-2'
|
||||
op: 'mock-op-2',
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
user_id: this.user_id_2
|
||||
user_id: this.user_id_2,
|
||||
},
|
||||
op: 'mock-op-3'
|
||||
}
|
||||
op: 'mock-op-3',
|
||||
},
|
||||
]
|
||||
this.user_info = {}
|
||||
this.user_info[this.user_id_1] = { email: 'user1@sharelatex.com' }
|
||||
@@ -920,27 +920,27 @@ describe('UpdatesManager', function () {
|
||||
{
|
||||
meta: {
|
||||
user: {
|
||||
email: 'user1@sharelatex.com'
|
||||
}
|
||||
email: 'user1@sharelatex.com',
|
||||
},
|
||||
},
|
||||
op: 'mock-op-1'
|
||||
op: 'mock-op-1',
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
user: {
|
||||
email: 'user1@sharelatex.com'
|
||||
}
|
||||
email: 'user1@sharelatex.com',
|
||||
},
|
||||
},
|
||||
op: 'mock-op-2'
|
||||
op: 'mock-op-2',
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
user: {
|
||||
email: 'user2@sharelatex.com'
|
||||
}
|
||||
email: 'user2@sharelatex.com',
|
||||
},
|
||||
},
|
||||
op: 'mock-op-3'
|
||||
}
|
||||
op: 'mock-op-3',
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -950,16 +950,16 @@ describe('UpdatesManager', function () {
|
||||
this.updates = [
|
||||
{
|
||||
meta: {
|
||||
user_id: null
|
||||
user_id: null,
|
||||
},
|
||||
op: 'mock-op-1'
|
||||
op: 'mock-op-1',
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
user_id: 'anonymous-user'
|
||||
user_id: 'anonymous-user',
|
||||
},
|
||||
op: 'mock-op-2'
|
||||
}
|
||||
op: 'mock-op-2',
|
||||
},
|
||||
]
|
||||
this.WebApiManager.getUserInfo = (user_id, callback) => {
|
||||
if (callback == null) {
|
||||
@@ -986,12 +986,12 @@ describe('UpdatesManager', function () {
|
||||
return expect(this.results).to.deep.equal([
|
||||
{
|
||||
meta: {},
|
||||
op: 'mock-op-1'
|
||||
op: 'mock-op-1',
|
||||
},
|
||||
{
|
||||
meta: {},
|
||||
op: 'mock-op-2'
|
||||
}
|
||||
op: 'mock-op-2',
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -1011,19 +1011,19 @@ describe('UpdatesManager', function () {
|
||||
meta: {
|
||||
user_id: this.user_1.id,
|
||||
start_ts: this.now + 20,
|
||||
end_ts: this.now + 30
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
v: 5
|
||||
v: 5,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-1',
|
||||
meta: {
|
||||
user_id: this.user_2.id,
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
v: 4
|
||||
}
|
||||
v: 4,
|
||||
},
|
||||
])
|
||||
|
||||
return expect(result).to.deep.equal([
|
||||
@@ -1031,15 +1031,15 @@ describe('UpdatesManager', function () {
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 4,
|
||||
toV: 5
|
||||
}
|
||||
toV: 5,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_1.id, this.user_2.id],
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 30
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1051,47 +1051,47 @@ describe('UpdatesManager', function () {
|
||||
meta: {
|
||||
user_id: this.user_2.id,
|
||||
start_ts: this.now + oneDay,
|
||||
end_ts: this.now + oneDay + 10
|
||||
end_ts: this.now + oneDay + 10,
|
||||
},
|
||||
v: 5
|
||||
v: 5,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-1',
|
||||
meta: {
|
||||
user_id: this.user_1.id,
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
v: 4
|
||||
}
|
||||
v: 4,
|
||||
},
|
||||
])
|
||||
return expect(result).to.deep.equal([
|
||||
{
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 5,
|
||||
toV: 5
|
||||
}
|
||||
toV: 5,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_2.id],
|
||||
start_ts: this.now + oneDay,
|
||||
end_ts: this.now + oneDay + 10
|
||||
}
|
||||
end_ts: this.now + oneDay + 10,
|
||||
},
|
||||
},
|
||||
{
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 4,
|
||||
toV: 4
|
||||
}
|
||||
toV: 4,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_1.id],
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1103,34 +1103,34 @@ describe('UpdatesManager', function () {
|
||||
meta: {
|
||||
user_id: this.user_1.id,
|
||||
start_ts: this.now + 20,
|
||||
end_ts: this.now + 30
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
v: 5
|
||||
v: 5,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-2',
|
||||
meta: {
|
||||
user_id: this.user_2.id,
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
v: 4
|
||||
}
|
||||
v: 4,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 6,
|
||||
toV: 8
|
||||
}
|
||||
toV: 8,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_1.id],
|
||||
start_ts: this.now + 40,
|
||||
end_ts: this.now + 50
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 50,
|
||||
},
|
||||
},
|
||||
]
|
||||
)
|
||||
return expect(result).to.deep.equal([
|
||||
@@ -1138,19 +1138,19 @@ describe('UpdatesManager', function () {
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
toV: 8,
|
||||
fromV: 6
|
||||
fromV: 6,
|
||||
},
|
||||
'doc-id-2': {
|
||||
toV: 5,
|
||||
fromV: 4
|
||||
}
|
||||
fromV: 4,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_1.id, this.user_2.id],
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 50
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 50,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1161,34 +1161,34 @@ describe('UpdatesManager', function () {
|
||||
meta: {
|
||||
user_id: this.user_1.id,
|
||||
start_ts: this.now + 20,
|
||||
end_ts: this.now + 30
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
v: 5
|
||||
v: 5,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-1',
|
||||
meta: {
|
||||
user_id: null,
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
v: 4
|
||||
}
|
||||
v: 4,
|
||||
},
|
||||
])
|
||||
return expect(result).to.deep.equal([
|
||||
{
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 4,
|
||||
toV: 5
|
||||
}
|
||||
toV: 5,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_1.id, null],
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 30
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1199,34 +1199,34 @@ describe('UpdatesManager', function () {
|
||||
meta: {
|
||||
user_id: null,
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
v: 4
|
||||
v: 4,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-1',
|
||||
meta: {
|
||||
user_id: this.user_1.id,
|
||||
start_ts: this.now + 20,
|
||||
end_ts: this.now + 30
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
v: 5
|
||||
}
|
||||
v: 5,
|
||||
},
|
||||
])
|
||||
return expect(result).to.deep.equal([
|
||||
{
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 4,
|
||||
toV: 5
|
||||
}
|
||||
toV: 5,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [null, this.user_1.id],
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 30
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1237,43 +1237,43 @@ describe('UpdatesManager', function () {
|
||||
meta: {
|
||||
user_id: this.user_1.id,
|
||||
start_ts: this.now + 20,
|
||||
end_ts: this.now + 30
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
v: 5
|
||||
v: 5,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-1',
|
||||
meta: {
|
||||
user_id: null,
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
v: 4
|
||||
v: 4,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-1',
|
||||
meta: {
|
||||
user_id: null,
|
||||
start_ts: this.now + 2,
|
||||
end_ts: this.now + 4
|
||||
end_ts: this.now + 4,
|
||||
},
|
||||
v: 4
|
||||
}
|
||||
v: 4,
|
||||
},
|
||||
])
|
||||
return expect(result).to.deep.equal([
|
||||
{
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 4,
|
||||
toV: 5
|
||||
}
|
||||
toV: 5,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_1.id, null],
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 30
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1285,19 +1285,19 @@ describe('UpdatesManager', function () {
|
||||
meta: {
|
||||
user_id: this.user_1.id,
|
||||
start_ts: this.now + 20,
|
||||
end_ts: this.now + 30
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
v: 5
|
||||
v: 5,
|
||||
},
|
||||
{
|
||||
doc_id: 'doc-id-1',
|
||||
meta: {
|
||||
user_id: this.user_2.id,
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
v: 4
|
||||
}
|
||||
v: 4,
|
||||
},
|
||||
])
|
||||
|
||||
return expect(result).to.deep.equal([
|
||||
@@ -1305,28 +1305,28 @@ describe('UpdatesManager', function () {
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 5,
|
||||
toV: 5
|
||||
}
|
||||
toV: 5,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_1.id],
|
||||
start_ts: this.now + 20,
|
||||
end_ts: this.now + 30
|
||||
}
|
||||
end_ts: this.now + 30,
|
||||
},
|
||||
},
|
||||
{
|
||||
docs: {
|
||||
'doc-id-1': {
|
||||
fromV: 4,
|
||||
toV: 4
|
||||
}
|
||||
toV: 4,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
user_ids: [this.user_2.id],
|
||||
start_ts: this.now,
|
||||
end_ts: this.now + 10
|
||||
}
|
||||
}
|
||||
end_ts: this.now + 10,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -24,11 +24,11 @@ describe('WebApiManager', function () {
|
||||
web: {
|
||||
url: 'http://example.com',
|
||||
user: 'sharelatex',
|
||||
pass: 'password'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
pass: 'password',
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
})
|
||||
this.callback = sinon.stub()
|
||||
this.user_id = 'mock-user-id'
|
||||
@@ -38,7 +38,7 @@ describe('WebApiManager', function () {
|
||||
id: this.user_id,
|
||||
first_name: 'Leo',
|
||||
last_nane: 'Lion',
|
||||
extra_param: 'blah'
|
||||
extra_param: 'blah',
|
||||
}
|
||||
return (this.project = { features: 'mock-features' })
|
||||
})
|
||||
@@ -60,8 +60,8 @@ describe('WebApiManager', function () {
|
||||
auth: {
|
||||
user: this.settings.apis.web.user,
|
||||
pass: this.settings.apis.web.pass,
|
||||
sendImmediately: true
|
||||
}
|
||||
sendImmediately: true,
|
||||
},
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -72,7 +72,7 @@ describe('WebApiManager', function () {
|
||||
id: this.user_id,
|
||||
email: this.user_info.email,
|
||||
first_name: this.user_info.first_name,
|
||||
last_name: this.user_info.last_name
|
||||
last_name: this.user_info.last_name,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -150,8 +150,8 @@ describe('WebApiManager', function () {
|
||||
auth: {
|
||||
user: this.settings.apis.web.user,
|
||||
pass: this.settings.apis.web.pass,
|
||||
sendImmediately: true
|
||||
}
|
||||
sendImmediately: true,
|
||||
},
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user