mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #33972 from overleaf/mj-web-show-pandoc-error
[web] Expose conversion errors during project exports GitOrigin-RevId: 2e808bd65f03e81405db4727f2f5773d3b14cbe7
This commit is contained in:
committed by
Copybot
parent
e7a202a0bf
commit
51ca5c0156
@@ -10,7 +10,14 @@ import sinon from 'sinon'
|
||||
import MockRequest from '../helpers/MockRequest.mjs'
|
||||
import MockResponse from '../helpers/MockResponse.mjs'
|
||||
import ArchiveErrors from '../../../../app/src/Features/Uploads/ArchiveErrors.mjs'
|
||||
import { FileTooLargeError } from '../../../../app/src/Features/Errors/Errors.js'
|
||||
import {
|
||||
FileTooLargeError,
|
||||
DocumentConversionError,
|
||||
} from '../../../../app/src/Features/Errors/Errors.js'
|
||||
|
||||
vi.mock('../../../../app/src/Features/Errors/Errors.js', () =>
|
||||
vi.importActual('../../../../app/src/Features/Errors/Errors.js')
|
||||
)
|
||||
|
||||
const modulePath =
|
||||
'../../../../app/src/Features/Uploads/ProjectUploadController.mjs'
|
||||
@@ -693,6 +700,54 @@ describe('ProjectUploadController', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the conversion fails with a user-facing error', async function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.DocumentConversionManager.promises.convertDocumentToLaTeXZipArchive =
|
||||
sinon
|
||||
.stub()
|
||||
.rejects(new DocumentConversionError('parse error at line 5'))
|
||||
|
||||
await new Promise(resolve => {
|
||||
ctx.res.json = data => {
|
||||
expect(data).to.deep.equal({
|
||||
success: false,
|
||||
error: 'parse error at line 5',
|
||||
})
|
||||
resolve()
|
||||
}
|
||||
ctx.ProjectUploadController.importDocument(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
|
||||
it('should return http 422', function (ctx) {
|
||||
expect(ctx.res.statusCode).to.equal(422)
|
||||
})
|
||||
|
||||
it('should unlink the uploaded file', function (ctx) {
|
||||
expect(ctx.fsPromises.unlink).to.have.been.calledWith(ctx.req.file.path)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the conversion fails without a specific message', async function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.DocumentConversionManager.promises.convertDocumentToLaTeXZipArchive =
|
||||
sinon.stub().rejects(new DocumentConversionError())
|
||||
|
||||
await new Promise(resolve => {
|
||||
ctx.res.json = data => {
|
||||
expect(data.success).to.equal(false)
|
||||
expect(data.error).to.equal('upload_failed')
|
||||
resolve()
|
||||
}
|
||||
ctx.ProjectUploadController.importDocument(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
|
||||
it('should return http 422', function (ctx) {
|
||||
expect(ctx.res.statusCode).to.equal(422)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the converted archive is too large', async function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.DocumentConversionManager.promises.convertDocumentToLaTeXZipArchive =
|
||||
|
||||
Reference in New Issue
Block a user