Merge pull request #9563 from overleaf/em-tpds-merge-metadata

Return metadata from TPDS update endpoint in web

GitOrigin-RevId: 9154be67f7f975807c6e986a5d6fb66013c9a384
This commit is contained in:
Eric Mc Sween
2022-09-12 15:59:16 +01:00
committed by Copybot
parent ceb000eb2b
commit 19c73cbd73
13 changed files with 236 additions and 200 deletions

View File

@@ -34,7 +34,7 @@ describe('ProjectEntityUpdateHandler', function () {
this.name = options.name
this.lines = options.lines
this._id = docId
this.rev = 0
this.rev = options.rev ?? 0
}
}
this.FileModel = class File {
@@ -516,14 +516,15 @@ describe('ProjectEntityUpdateHandler', function () {
describe('adding a doc', function () {
beforeEach(function () {
this.path = '/path/to/doc'
this.rev = 5
this.newDoc = new this.DocModel({
name: this.docName,
lines: undefined,
_id: docId,
rev: 0,
rev: this.rev,
})
this.DocstoreManager.updateDoc.yields(null, false, (this.rev = 5))
this.DocstoreManager.updateDoc.yields(null, false, this.rev)
this.TpdsUpdateSender.addDoc.yields()
this.ProjectEntityMongoUpdateHandler.addDoc.yields(
null,
@@ -555,18 +556,16 @@ describe('ProjectEntityUpdateHandler', function () {
docLines: this.docLines.join('\n'),
},
]
this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(
projectId,
projectHistoryId,
userId,
{
newDocs,
newProject: this.project,
},
this.source
)
.should.equal(true)
this.DocumentUpdaterHandler.updateProjectStructure.should.have.been.calledWith(
projectId,
projectHistoryId,
userId,
{
newDocs,
newProject: this.project,
},
this.source
)
})
})
@@ -1020,6 +1019,7 @@ describe('ProjectEntityUpdateHandler', function () {
describe('updating an existing file', function () {
beforeEach(function () {
this.existingFile = { _id: fileId, name: this.fileName, rev: 1 }
this.newFile = { _id: ObjectId(), name: this.fileName, rev: 3 }
this.folder = { _id: folderId, fileRefs: [this.existingFile], docs: [] }
this.ProjectLocator.findElement.yields(null, this.folder)
this.newProject = 'new-project-stub'
@@ -1028,7 +1028,8 @@ describe('ProjectEntityUpdateHandler', function () {
this.existingFile,
this.project,
{ fileSystem: this.fileSystemPath },
this.newProject
this.newProject,
this.newFile
)
this.ProjectEntityUpdateHandler.upsertFile(
projectId,
@@ -1065,8 +1066,8 @@ describe('ProjectEntityUpdateHandler', function () {
this.TpdsUpdateSender.addFile.should.have.been.calledWith({
projectId,
projectName: this.project.name,
fileId: this.file._id,
rev: this.existingFile.rev + 1,
fileId: this.newFile._id,
rev: this.newFile.rev,
path: this.fileSystemPath,
folderId,
})
@@ -1088,7 +1089,7 @@ describe('ProjectEntityUpdateHandler', function () {
]
const newFiles = [
{
file: this.file,
file: this.newFile,
path: this.fileSystemPath,
url: this.fileUrl,
},