Merge pull request #9696 from overleaf/em-fix-dropbox-top-level

Fix Dropbox metadata collection for top level folders

GitOrigin-RevId: a6262968f206cfd3459f2bae628f156d22bccd91
This commit is contained in:
Eric Mc Sween 2022-09-21 09:02:15 -04:00 committed by Copybot
parent a6307d8497
commit 33d9f08599
2 changed files with 21 additions and 1 deletions

View file

@ -103,7 +103,7 @@ async function updateFolder(req, res) {
entityId: metadata.folderId.toString(),
projectId: metadata.projectId.toString(),
path: metadata.path,
folderId: metadata.parentFolderId.toString(),
folderId: metadata.parentFolderId?.toString() || null,
})
}

View file

@ -201,6 +201,26 @@ describe('TpdsController', function () {
this.TpdsController.updateFolder(this.req, this.res)
})
it('supports top level folders', function (done) {
const metadata = {
folderId: ObjectId(),
projectId: ObjectId(),
path: '/',
parentFolderId: null,
}
this.TpdsUpdateHandler.promises.createFolder.resolves(metadata)
this.res.json.callsFake(body => {
expect(body).to.deep.equal({
entityId: metadata.folderId.toString(),
projectId: metadata.projectId.toString(),
path: metadata.path,
folderId: null,
})
done()
})
this.TpdsController.updateFolder(this.req, this.res)
})
it("returns a 409 if the folder couldn't be created", function (done) {
this.TpdsUpdateHandler.promises.createFolder.resolves(null)
this.HttpErrorHandler.conflict.callsFake((req, res) => {