Merge pull request #3653 from overleaf/jpa-merge-deleted-docs-sources

[EditorHttpController] fetch deletedDocs from docstore, merge w/ project

GitOrigin-RevId: 5cf46aa7ded034285051ddae21b5c80d8c806693
This commit is contained in:
Jakob Ackermann
2021-04-06 11:15:16 +02:00
committed by Copybot
parent 92194202d7
commit 3bdf7afbbf
7 changed files with 141 additions and 5 deletions

View File

@@ -106,6 +106,9 @@ describe('ProjectEditorHandler', function() {
token: 'my-secret-token2'
}
]
this.deletedDocsFromDocstore = [
{ _id: 'deleted-doc-id-from-docstore', name: 'docstore.tex' }
]
return (this.handler = SandboxedModule.require(modulePath))
})
@@ -115,7 +118,8 @@ describe('ProjectEditorHandler', function() {
return (this.result = this.handler.buildProjectModelView(
this.project,
this.members,
this.invites
this.invites,
this.deletedDocsFromDocstore
))
})
@@ -155,7 +159,8 @@ describe('ProjectEditorHandler', function() {
// omit deletedAt field
_id: this.project.deletedDocs[0]._id,
name: this.project.deletedDocs[0].name
}
},
this.deletedDocsFromDocstore[0]
])
})
@@ -235,6 +240,26 @@ describe('ProjectEditorHandler', function() {
})
})
describe('when docstore sends a deleted doc that is also present in the project', function() {
beforeEach(function() {
this.deletedDocsFromDocstore.push(this.project.deletedDocs[0])
this.result = this.handler.buildProjectModelView(
this.project,
this.members,
this.invites,
this.deletedDocsFromDocstore
)
})
it('should not send any duplicate', function() {
should.exist(this.result.deletedDocs)
this.result.deletedDocs.should.deep.equal([
this.project.deletedDocs[0],
this.deletedDocsFromDocstore[0]
])
})
})
describe('deletedByExternalDataSource', function() {
it('should set the deletedByExternalDataSource flag to false when it is not there', function() {
delete this.project.deletedByExternalDataSource