mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-05 23:29:00 +02:00
Merge pull request #7251 from overleaf/jpa-convert-doc-to-file-script
[web] convert convert-to-file endpoint into a script GitOrigin-RevId: 5babebae5df8510b83f09ec4a2bb4064cca5ec75
This commit is contained in:
@@ -510,66 +510,4 @@ describe('EditorHttpController', function () {
|
||||
expect(this.res.sendStatus).to.have.been.calledWith(204)
|
||||
})
|
||||
})
|
||||
|
||||
describe('convertDocToFile', function () {
|
||||
beforeEach(function (done) {
|
||||
this.req.params = {
|
||||
Project_id: this.project._id.toString(),
|
||||
entity_id: this.doc._id.toString(),
|
||||
}
|
||||
this.req.body = { userId: this.user._id.toString() }
|
||||
this.res.json.callsFake(() => done())
|
||||
this.EditorHttpController.convertDocToFile(this.req, this.res)
|
||||
})
|
||||
|
||||
describe('when successful', function () {
|
||||
it('should convert the doc to a file', function () {
|
||||
expect(
|
||||
this.ProjectEntityUpdateHandler.promises.convertDocToFile
|
||||
).to.have.been.calledWith(
|
||||
this.project._id.toString(),
|
||||
this.doc._id.toString(),
|
||||
this.user._id.toString()
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the file id in the response', function () {
|
||||
expect(this.res.json).to.have.been.calledWith({
|
||||
fileId: this.file._id.toString(),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the doc has ranges', function () {
|
||||
it('should return a 422 - Unprocessable Entity', function (done) {
|
||||
this.ProjectEntityUpdateHandler.promises.convertDocToFile.rejects(
|
||||
new Errors.DocHasRangesError({})
|
||||
)
|
||||
this.HttpErrorHandler.unprocessableEntity = sinon.spy(
|
||||
(req, res, message) => {
|
||||
expect(req).to.exist
|
||||
expect(res).to.exist
|
||||
expect(message).to.equal('Document has comments or tracked changes')
|
||||
done()
|
||||
}
|
||||
)
|
||||
this.EditorHttpController.convertDocToFile(this.req, this.res)
|
||||
})
|
||||
})
|
||||
|
||||
describe("when the doc does't exist", function () {
|
||||
it('should return a 404 - not found', function (done) {
|
||||
this.ProjectEntityUpdateHandler.promises.convertDocToFile.rejects(
|
||||
new Errors.NotFoundError({})
|
||||
)
|
||||
this.HttpErrorHandler.notFound = sinon.spy((req, res, message) => {
|
||||
expect(req).to.exist
|
||||
expect(res).to.exist
|
||||
expect(message).to.equal('Document not found')
|
||||
done()
|
||||
})
|
||||
this.EditorHttpController.convertDocToFile(this.req, this.res)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user