mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-30 12:24:25 +02:00
Merge pull request #3942 from overleaf/prettier-trailing-comma
Set Prettier's "trailingComma" setting to "es5" GitOrigin-RevId: 9f14150511929a855b27467ad17be6ab262fe5d5
This commit is contained in:
@@ -22,9 +22,9 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
name: 'project name',
|
||||
overleaf: {
|
||||
history: {
|
||||
id: projectHistoryId
|
||||
}
|
||||
}
|
||||
id: projectHistoryId,
|
||||
},
|
||||
},
|
||||
}
|
||||
this.fileUrl = 'filestore.example.com/file'
|
||||
this.user = { _id: new ObjectId() }
|
||||
@@ -72,40 +72,40 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
getDoc: sinon.stub(),
|
||||
isDocDeleted: sinon.stub(),
|
||||
updateDoc: sinon.stub(),
|
||||
deleteDoc: sinon.stub()
|
||||
deleteDoc: sinon.stub(),
|
||||
}
|
||||
this.DocumentUpdaterHandler = {
|
||||
flushDocToMongo: sinon.stub().yields(),
|
||||
updateProjectStructure: sinon.stub().yields(),
|
||||
setDocument: sinon.stub(),
|
||||
resyncProjectHistory: sinon.stub(),
|
||||
deleteDoc: sinon.stub().yields()
|
||||
deleteDoc: sinon.stub().yields(),
|
||||
}
|
||||
this.fs = {
|
||||
unlink: sinon.stub().yields()
|
||||
unlink: sinon.stub().yields(),
|
||||
}
|
||||
this.LockManager = {
|
||||
runWithLock: sinon.spy((namespace, id, runner, callback) =>
|
||||
runner(callback)
|
||||
)
|
||||
),
|
||||
}
|
||||
this.ProjectModel = {
|
||||
updateOne: sinon.stub()
|
||||
updateOne: sinon.stub(),
|
||||
}
|
||||
this.ProjectGetter = {
|
||||
getProject: sinon.stub(),
|
||||
getProjectWithoutDocLines: sinon.stub()
|
||||
getProjectWithoutDocLines: sinon.stub(),
|
||||
}
|
||||
this.ProjectLocator = {
|
||||
findElement: sinon.stub(),
|
||||
findElementByPath: sinon.stub()
|
||||
findElementByPath: sinon.stub(),
|
||||
}
|
||||
this.ProjectUpdater = {
|
||||
markAsUpdated: sinon.stub()
|
||||
markAsUpdated: sinon.stub(),
|
||||
}
|
||||
this.ProjectEntityHandler = {
|
||||
getDocPathByProjectIdAndDocId: sinon.stub(),
|
||||
getAllEntitiesFromProject: sinon.stub()
|
||||
getAllEntitiesFromProject: sinon.stub(),
|
||||
}
|
||||
this.ProjectEntityMongoUpdateHandler = {
|
||||
addDoc: sinon.stub(),
|
||||
@@ -120,7 +120,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
renameEntity: sinon.stub(),
|
||||
deleteEntity: sinon.stub(),
|
||||
replaceDocWithFile: sinon.stub(),
|
||||
replaceFileWithDoc: sinon.stub()
|
||||
replaceFileWithDoc: sinon.stub(),
|
||||
}
|
||||
this.TpdsUpdateSender = {
|
||||
addFile: sinon.stub().yields(),
|
||||
@@ -128,19 +128,19 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
deleteEntity: sinon.stub().yields(),
|
||||
moveEntity: sinon.stub(),
|
||||
promises: {
|
||||
moveEntity: sinon.stub().resolves()
|
||||
}
|
||||
moveEntity: sinon.stub().resolves(),
|
||||
},
|
||||
}
|
||||
this.FileStoreHandler = {
|
||||
copyFile: sinon.stub(),
|
||||
uploadFileFromDisk: sinon.stub(),
|
||||
deleteFile: sinon.stub()
|
||||
deleteFile: sinon.stub(),
|
||||
}
|
||||
this.FileWriter = {
|
||||
writeLinesToDisk: sinon.stub()
|
||||
writeLinesToDisk: sinon.stub(),
|
||||
}
|
||||
this.EditorRealTimeController = {
|
||||
emitToRoom: sinon.stub()
|
||||
emitToRoom: sinon.stub(),
|
||||
}
|
||||
this.ProjectEntityUpdateHandler = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
@@ -162,8 +162,8 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.ProjectEntityMongoUpdateHandler,
|
||||
'../ThirdPartyDataStore/TpdsUpdateSender': this.TpdsUpdateSender,
|
||||
'../Editor/EditorRealTimeController': this.EditorRealTimeController,
|
||||
'../../infrastructure/FileWriter': this.FileWriter
|
||||
}
|
||||
'../../infrastructure/FileWriter': this.FileWriter,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -171,7 +171,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.path = '/somewhere/something.tex'
|
||||
this.doc = {
|
||||
_id: docId
|
||||
_id: docId,
|
||||
}
|
||||
this.version = 42
|
||||
this.ranges = { mock: 'ranges' }
|
||||
@@ -180,7 +180,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.DocstoreManager.isDocDeleted.yields(null, false)
|
||||
this.ProjectGetter.getProject.yields(null, this.project)
|
||||
this.ProjectLocator.findElement.yields(null, this.doc, {
|
||||
fileSystem: this.path
|
||||
fileSystem: this.path,
|
||||
})
|
||||
this.TpdsUpdateSender.addDoc.yields()
|
||||
})
|
||||
@@ -204,7 +204,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.ProjectGetter.getProject
|
||||
.calledWith(projectId, {
|
||||
name: true,
|
||||
rootFolder: true
|
||||
rootFolder: true,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -214,7 +214,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.calledWith({
|
||||
project: this.project,
|
||||
type: 'docs',
|
||||
element_id: docId
|
||||
element_id: docId,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -247,7 +247,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
project_name: this.project.name,
|
||||
doc_id: docId,
|
||||
rev: this.rev,
|
||||
path: this.path
|
||||
path: this.path,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -509,7 +509,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
name: this.docName,
|
||||
lines: undefined,
|
||||
_id: docId,
|
||||
rev: 0
|
||||
rev: 0,
|
||||
})
|
||||
this.DocstoreManager.updateDoc.yields(null, false, (this.rev = 5))
|
||||
this.TpdsUpdateSender.addDoc.yields()
|
||||
@@ -539,13 +539,13 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
doc: this.newDoc,
|
||||
path: this.path,
|
||||
docLines: this.docLines.join('\n')
|
||||
}
|
||||
docLines: this.docLines.join('\n'),
|
||||
},
|
||||
]
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
.calledWith(projectId, projectHistoryId, userId, {
|
||||
newDocs,
|
||||
newProject: this.project
|
||||
newProject: this.project,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -582,7 +582,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
_id: fileId,
|
||||
rev: 0,
|
||||
name: this.fileName,
|
||||
linkedFileData: this.linkedFileData
|
||||
linkedFileData: this.linkedFileData,
|
||||
}
|
||||
this.FileStoreHandler.uploadFileFromDisk.yields(
|
||||
null,
|
||||
@@ -633,7 +633,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
project_name: this.project.name,
|
||||
file_id: fileId,
|
||||
rev: 0,
|
||||
path: this.path
|
||||
path: this.path,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -650,13 +650,13 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
file: this.newFile,
|
||||
path: this.path,
|
||||
url: this.fileUrl
|
||||
}
|
||||
url: this.fileUrl,
|
||||
},
|
||||
]
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
.calledWith(projectId, projectHistoryId, userId, {
|
||||
newFiles,
|
||||
newProject: this.project
|
||||
newProject: this.project,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -670,7 +670,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
_id: fileId,
|
||||
rev: 0,
|
||||
name: this.fileName,
|
||||
linkedFileData: this.linkedFileData
|
||||
linkedFileData: this.linkedFileData,
|
||||
}
|
||||
this.TpdsUpdateSender.addFile.yields()
|
||||
this.ProjectEntityMongoUpdateHandler.addFile.yields(
|
||||
@@ -704,7 +704,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
_id: newFileId,
|
||||
name: 'dummy-upload-filename',
|
||||
rev: 0,
|
||||
linkedFileData: this.linkedFileData
|
||||
linkedFileData: this.linkedFileData,
|
||||
}
|
||||
this.oldFile = { _id: fileId, rev: 3 }
|
||||
this.path = '/path/to/file'
|
||||
@@ -738,7 +738,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
projectId,
|
||||
{
|
||||
name: 'dummy-upload-filename',
|
||||
linkedFileData: this.linkedFileData
|
||||
linkedFileData: this.linkedFileData,
|
||||
},
|
||||
this.fileSystemPath
|
||||
)
|
||||
@@ -758,7 +758,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
project_name: this.project.name,
|
||||
file_id: newFileId,
|
||||
rev: this.oldFile.rev + 1,
|
||||
path: this.path
|
||||
path: this.path,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -774,21 +774,21 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
const oldFiles = [
|
||||
{
|
||||
file: this.oldFile,
|
||||
path: this.path
|
||||
}
|
||||
path: this.path,
|
||||
},
|
||||
]
|
||||
const newFiles = [
|
||||
{
|
||||
file: this.newFile,
|
||||
path: this.path,
|
||||
url: this.newFileUrl
|
||||
}
|
||||
url: this.newFileUrl,
|
||||
},
|
||||
]
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
.calledWith(projectId, projectHistoryId, userId, {
|
||||
oldFiles,
|
||||
newFiles,
|
||||
newProject: this.newProject
|
||||
newProject: this.newProject,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -822,7 +822,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.folder = {
|
||||
_id: folderId,
|
||||
docs: [this.existingDoc],
|
||||
fileRefs: [this.existingFile]
|
||||
fileRefs: [this.existingFile],
|
||||
}
|
||||
this.ProjectLocator.findElement.yields(null, this.folder)
|
||||
this.DocumentUpdaterHandler.setDocument.yields()
|
||||
@@ -843,7 +843,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.calledWith({
|
||||
project_id: projectId,
|
||||
element_id: folderId,
|
||||
type: 'folder'
|
||||
type: 'folder',
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -877,7 +877,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.newDoc = { _id: docId }
|
||||
this.ProjectLocator.findElement.yields(null, this.folder)
|
||||
this.ProjectEntityUpdateHandler.addDocWithRanges = {
|
||||
withoutLock: sinon.stub().yields(null, this.newDoc)
|
||||
withoutLock: sinon.stub().yields(null, this.newDoc),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertDoc(
|
||||
@@ -896,7 +896,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.calledWith({
|
||||
project_id: projectId,
|
||||
element_id: folderId,
|
||||
type: 'folder'
|
||||
type: 'folder',
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -925,7 +925,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.newDoc = { _id: docId }
|
||||
this.ProjectLocator.findElement.yields(null, this.folder)
|
||||
this.ProjectEntityUpdateHandler.addDocWithRanges = {
|
||||
withoutLock: sinon.stub().yields(null, this.newDoc)
|
||||
withoutLock: sinon.stub().yields(null, this.newDoc),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertDoc(
|
||||
@@ -949,7 +949,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.newProject = {
|
||||
name: 'new project',
|
||||
overleaf: { history: { id: projectHistoryId } }
|
||||
overleaf: { history: { id: projectHistoryId } },
|
||||
}
|
||||
this.existingFile = { _id: fileId, name: 'foo.tex', rev: 12 }
|
||||
this.folder = { _id: folderId, docs: [], fileRefs: [this.existingFile] }
|
||||
@@ -961,10 +961,10 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.withArgs({
|
||||
project_id: projectId,
|
||||
element_id: this.folder._id,
|
||||
type: 'folder'
|
||||
type: 'folder',
|
||||
})
|
||||
.yields(null, this.folder, {
|
||||
fileSystem: this.folderPath
|
||||
fileSystem: this.folderPath,
|
||||
})
|
||||
this.DocstoreManager.updateDoc.yields()
|
||||
this.ProjectEntityMongoUpdateHandler.replaceFileWithDoc.yields(
|
||||
@@ -1008,7 +1008,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
doc_id: this.newDoc._id,
|
||||
path: this.filePath,
|
||||
project_name: this.newProject.name,
|
||||
rev: this.existingFile.rev + 1
|
||||
rev: this.existingFile.rev + 1,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1016,22 +1016,22 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
const oldFiles = [
|
||||
{
|
||||
file: this.existingFile,
|
||||
path: this.filePath
|
||||
}
|
||||
path: this.filePath,
|
||||
},
|
||||
]
|
||||
const newDocs = [
|
||||
{
|
||||
doc: sinon.match(this.newDoc),
|
||||
path: this.filePath,
|
||||
docLines: this.docLines.join('\n')
|
||||
}
|
||||
docLines: this.docLines.join('\n'),
|
||||
},
|
||||
]
|
||||
expect(
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
).to.have.been.calledWith(projectId, projectHistoryId, userId, {
|
||||
oldFiles,
|
||||
newDocs,
|
||||
newProject: this.newProject
|
||||
newProject: this.newProject,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1083,7 +1083,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.folder = { _id: folderId, fileRefs: [this.existingFile], docs: [] }
|
||||
this.ProjectLocator.findElement.yields(null, this.folder)
|
||||
this.ProjectEntityUpdateHandler.replaceFile = {
|
||||
mainTask: sinon.stub().yields(null, this.newFile)
|
||||
mainTask: sinon.stub().yields(null, this.newFile),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertFile(
|
||||
@@ -1120,7 +1120,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.newFile = { _id: fileId }
|
||||
this.ProjectLocator.findElement.yields(null, this.folder)
|
||||
this.ProjectEntityUpdateHandler.addFile = {
|
||||
mainTask: sinon.stub().yields(null, this.newFile)
|
||||
mainTask: sinon.stub().yields(null, this.newFile),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertFile(
|
||||
@@ -1139,7 +1139,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.calledWith({
|
||||
project_id: projectId,
|
||||
element_id: folderId,
|
||||
type: 'folder'
|
||||
type: 'folder',
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -1168,7 +1168,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.newFile = { _id: fileId }
|
||||
this.ProjectLocator.findElement.yields(null, this.folder)
|
||||
this.ProjectEntityUpdateHandler.addFile = {
|
||||
mainTask: sinon.stub().yields(null, this.newFile)
|
||||
mainTask: sinon.stub().yields(null, this.newFile),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertFile(
|
||||
@@ -1195,20 +1195,20 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.folder = {
|
||||
_id: folderId,
|
||||
fileRefs: [],
|
||||
docs: [this.existingDoc]
|
||||
docs: [this.existingDoc],
|
||||
}
|
||||
this.ProjectLocator.findElement
|
||||
.withArgs({
|
||||
project_id: this.project._id.toString(),
|
||||
element_id: folderId,
|
||||
type: 'folder'
|
||||
type: 'folder',
|
||||
})
|
||||
.yields(null, this.folder)
|
||||
this.ProjectLocator.findElement
|
||||
.withArgs({
|
||||
project_id: this.project._id.toString(),
|
||||
element_id: this.existingDoc._id,
|
||||
type: 'doc'
|
||||
type: 'doc',
|
||||
})
|
||||
.yields(null, this.existingDoc, { fileSystem: this.path })
|
||||
|
||||
@@ -1217,11 +1217,11 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
_id: newFileId,
|
||||
name: 'dummy-upload-filename',
|
||||
rev: 0,
|
||||
linkedFileData: this.linkedFileData
|
||||
linkedFileData: this.linkedFileData,
|
||||
}
|
||||
this.newProject = {
|
||||
name: 'new project',
|
||||
overleaf: { history: { id: projectHistoryId } }
|
||||
overleaf: { history: { id: projectHistoryId } },
|
||||
}
|
||||
this.FileStoreHandler.uploadFileFromDisk.yields(
|
||||
null,
|
||||
@@ -1254,20 +1254,20 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
const oldDocs = [
|
||||
{
|
||||
doc: this.existingDoc,
|
||||
path: this.path
|
||||
}
|
||||
path: this.path,
|
||||
},
|
||||
]
|
||||
const newFiles = [
|
||||
{
|
||||
file: this.newFile,
|
||||
path: this.path,
|
||||
url: this.newFileUrl
|
||||
}
|
||||
url: this.newFileUrl,
|
||||
},
|
||||
]
|
||||
const updates = {
|
||||
oldDocs,
|
||||
newFiles,
|
||||
newProject: this.newProject
|
||||
newProject: this.newProject,
|
||||
}
|
||||
expect(
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
@@ -1296,10 +1296,10 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.doc = { _id: docId }
|
||||
this.isNewDoc = true
|
||||
this.ProjectEntityUpdateHandler.mkdirp = {
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
|
||||
}
|
||||
this.ProjectEntityUpdateHandler.upsertDoc = {
|
||||
withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc)
|
||||
withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertDocWithPath(
|
||||
@@ -1352,10 +1352,10 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.doc = { _id: docId }
|
||||
this.isNewDoc = true
|
||||
this.ProjectEntityUpdateHandler.mkdirp = {
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
|
||||
}
|
||||
this.ProjectEntityUpdateHandler.upsertDoc = {
|
||||
withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc)
|
||||
withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertDocWithPath(
|
||||
@@ -1382,10 +1382,10 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.doc = { _id: docId }
|
||||
this.isNewDoc = true
|
||||
this.ProjectEntityUpdateHandler.mkdirp = {
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
|
||||
}
|
||||
this.ProjectEntityUpdateHandler.upsertDoc = {
|
||||
withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc)
|
||||
withoutLock: sinon.stub().yields(null, this.doc, this.isNewDoc),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertDocWithPath(
|
||||
@@ -1419,10 +1419,10 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.newFile
|
||||
)
|
||||
this.ProjectEntityUpdateHandler.mkdirp = {
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
|
||||
}
|
||||
this.ProjectEntityUpdateHandler.upsertFile = {
|
||||
mainTask: sinon.stub().yields(null, this.file, this.isNewFile)
|
||||
mainTask: sinon.stub().yields(null, this.file, this.isNewFile),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertFileWithPath(
|
||||
@@ -1476,10 +1476,10 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.file = { _id: fileId }
|
||||
this.isNewFile = true
|
||||
this.ProjectEntityUpdateHandler.mkdirp = {
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
|
||||
}
|
||||
this.ProjectEntityUpdateHandler.upsertFile = {
|
||||
mainTask: sinon.stub().yields(null, this.file, this.isNewFile)
|
||||
mainTask: sinon.stub().yields(null, this.file, this.isNewFile),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertFileWithPath(
|
||||
@@ -1506,10 +1506,10 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.file = { _id: fileId }
|
||||
this.isNewFile = true
|
||||
this.ProjectEntityUpdateHandler.mkdirp = {
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder)
|
||||
withoutLock: sinon.stub().yields(null, this.newFolders, this.folder),
|
||||
}
|
||||
this.ProjectEntityUpdateHandler.upsertFile = {
|
||||
mainTask: sinon.stub().yields(null, this.file, this.isNewFile)
|
||||
mainTask: sinon.stub().yields(null, this.file, this.isNewFile),
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler.upsertFileWithPath(
|
||||
@@ -1577,7 +1577,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.calledWith({
|
||||
project_id: projectId,
|
||||
path: this.path,
|
||||
project_name: this.projectBeforeDeletion.name
|
||||
project_name: this.projectBeforeDeletion.name,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -1593,7 +1593,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.doc = { _id: docId }
|
||||
this.ProjectLocator.findElementByPath.yields(null, this.doc, 'doc')
|
||||
this.ProjectEntityUpdateHandler.deleteEntity = {
|
||||
withoutLock: sinon.stub().yields()
|
||||
withoutLock: sinon.stub().yields(),
|
||||
}
|
||||
this.path = '/path/to/doc.tex'
|
||||
this.ProjectEntityUpdateHandler.deleteEntityWithPath(
|
||||
@@ -1753,7 +1753,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
project_name: this.project_name,
|
||||
startPath: this.startPath,
|
||||
endPath: this.endPath,
|
||||
rev: this.rev
|
||||
rev: this.rev,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -1812,7 +1812,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
project_name: this.project_name,
|
||||
startPath: this.startPath,
|
||||
endPath: this.endPath,
|
||||
rev: this.rev
|
||||
rev: this.rev,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -1920,18 +1920,18 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
const docs = [
|
||||
{
|
||||
doc: {
|
||||
_id: docId
|
||||
_id: docId,
|
||||
},
|
||||
path: 'main.tex'
|
||||
}
|
||||
path: 'main.tex',
|
||||
},
|
||||
]
|
||||
const files = [
|
||||
{
|
||||
file: {
|
||||
_id: fileId
|
||||
_id: fileId,
|
||||
},
|
||||
path: 'universe.png'
|
||||
}
|
||||
path: 'universe.png',
|
||||
},
|
||||
]
|
||||
this.ProjectEntityHandler.getAllEntitiesFromProject.yields(
|
||||
null,
|
||||
@@ -1962,15 +1962,15 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
const docs = [
|
||||
{
|
||||
doc: docId,
|
||||
path: 'main.tex'
|
||||
}
|
||||
path: 'main.tex',
|
||||
},
|
||||
]
|
||||
const files = [
|
||||
{
|
||||
file: fileId,
|
||||
path: 'universe.png',
|
||||
url: `www.filestore.test/${projectId}/${fileId}`
|
||||
}
|
||||
url: `www.filestore.test/${projectId}/${fileId}`,
|
||||
},
|
||||
]
|
||||
this.DocumentUpdaterHandler.resyncProjectHistory
|
||||
.calledWith(projectId, projectHistoryId, docs, files)
|
||||
@@ -2028,7 +2028,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
.calledWith(projectId, projectHistoryId, userId, {
|
||||
oldFiles,
|
||||
newProject: this.newProject
|
||||
newProject: this.newProject,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -2062,7 +2062,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
.calledWith(projectId, projectHistoryId, userId, {
|
||||
oldDocs,
|
||||
newProject: this.newProject
|
||||
newProject: this.newProject,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -2075,14 +2075,14 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
name: 'subfolder',
|
||||
fileRefs: [
|
||||
(this.file1 = { _id: 'file-id-1', name: 'file-name-1' })
|
||||
(this.file1 = { _id: 'file-id-1', name: 'file-name-1' }),
|
||||
],
|
||||
docs: [(this.doc1 = { _id: 'doc-id-1', name: 'doc-name-1' })],
|
||||
folders: []
|
||||
}
|
||||
folders: [],
|
||||
},
|
||||
],
|
||||
fileRefs: [(this.file2 = { _id: 'file-id-2', name: 'file-name-2' })],
|
||||
docs: [(this.doc2 = { _id: 'doc-id-2', name: 'doc-name-2' })]
|
||||
docs: [(this.doc2 = { _id: 'doc-id-2', name: 'doc-name-2' })],
|
||||
}
|
||||
|
||||
this.ProjectEntityUpdateHandler._cleanUpDoc = sinon.stub().yields()
|
||||
@@ -2131,17 +2131,17 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
it('should should send one update to the doc updater for all docs and files', function () {
|
||||
const oldFiles = [
|
||||
{ file: this.file2, path: '/folder/file-name-2' },
|
||||
{ file: this.file1, path: '/folder/subfolder/file-name-1' }
|
||||
{ file: this.file1, path: '/folder/subfolder/file-name-1' },
|
||||
]
|
||||
const oldDocs = [
|
||||
{ doc: this.doc2, path: '/folder/doc-name-2' },
|
||||
{ doc: this.doc1, path: '/folder/subfolder/doc-name-1' }
|
||||
{ doc: this.doc1, path: '/folder/subfolder/doc-name-1' },
|
||||
]
|
||||
this.DocumentUpdaterHandler.updateProjectStructure
|
||||
.calledWith(projectId, projectHistoryId, userId, {
|
||||
oldFiles,
|
||||
oldDocs,
|
||||
newProject: this.newProject
|
||||
newProject: this.newProject,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
@@ -2152,7 +2152,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.doc = {
|
||||
_id: ObjectId(),
|
||||
name: 'test.tex'
|
||||
name: 'test.tex',
|
||||
}
|
||||
this.path = '/path/to/doc'
|
||||
this.ProjectEntityUpdateHandler.unsetRootDoc = sinon.stub().yields()
|
||||
@@ -2228,14 +2228,14 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.withArgs({
|
||||
project_id: this.project._id,
|
||||
element_id: this.doc._id,
|
||||
type: 'doc'
|
||||
type: 'doc',
|
||||
})
|
||||
.yields(null, this.doc, { fileSystem: this.path })
|
||||
this.ProjectLocator.findElement
|
||||
.withArgs({
|
||||
project_id: this.project._id.toString(),
|
||||
element_id: this.file._id,
|
||||
type: 'file'
|
||||
type: 'file',
|
||||
})
|
||||
.yields(null, this.file, this.docPath, this.folder)
|
||||
this.DocstoreManager.getDoc
|
||||
@@ -2300,9 +2300,9 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
oldDocs: [{ doc: this.doc, path: this.path }],
|
||||
newFiles: [
|
||||
{ file: this.file, path: this.path, url: this.fileStoreUrl }
|
||||
{ file: this.file, path: this.path, url: this.fileStoreUrl },
|
||||
],
|
||||
newProject: this.project
|
||||
newProject: this.project,
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user