Merge pull request #8094 from overleaf/jpa-handle-missing-output-files

[web] handle missing outputFiles array

GitOrigin-RevId: 9b1210ff620888f45ec1a3b38c9f91b5a3e22778
This commit is contained in:
Jakob Ackermann 2022-05-23 17:38:08 +01:00 committed by Copybot
parent 716aa174fb
commit 2c62ba29c7
2 changed files with 26 additions and 1 deletions

View file

@ -100,7 +100,7 @@ module.exports = CompileController = {
'zonal-clsi-lb-downloads',
{},
(_err, assignment) => {
if (assignment?.variant !== 'zonal') {
if (assignment?.variant !== 'zonal' && Array.isArray(outputFiles)) {
outputFiles.forEach(file => {
file.url = file.url.replace(/^\/zone\/\w/, '')
})

View file

@ -101,6 +101,31 @@ describe('CompileController', function () {
})
describe('zonal downloads', function () {
describe('when in the default split test variant and not output files were returned', function () {
beforeEach(function () {
this.getAssignment.yields(null, { variant: 'default' })
this.CompileManager.compile = sinon
.stub()
.callsArgWith(
3,
null,
(this.status = 'success'),
(this.outputFiles = null)
)
this.CompileController.compile(this.req, this.res, this.next)
})
it('should ignore the output files', function () {
this.res.statusCode.should.equal(200)
this.res.body.should.equal(
JSON.stringify({
status: this.status,
outputFiles: null,
})
)
})
})
describe('when in the default split test variant', function () {
beforeEach(function () {
this.getAssignment.yields(null, { variant: 'default' })