From 2c62ba29c792ea28de514e5d6541a581700dc175 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 23 May 2022 17:38:08 +0100 Subject: [PATCH] Merge pull request #8094 from overleaf/jpa-handle-missing-output-files [web] handle missing outputFiles array GitOrigin-RevId: 9b1210ff620888f45ec1a3b38c9f91b5a3e22778 --- .../src/Features/Compile/CompileController.js | 2 +- .../src/Compile/CompileControllerTests.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/services/web/app/src/Features/Compile/CompileController.js b/services/web/app/src/Features/Compile/CompileController.js index 7d3916a7a5..1f4b512598 100644 --- a/services/web/app/src/Features/Compile/CompileController.js +++ b/services/web/app/src/Features/Compile/CompileController.js @@ -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/, '') }) diff --git a/services/web/test/unit/src/Compile/CompileControllerTests.js b/services/web/test/unit/src/Compile/CompileControllerTests.js index f69aead526..9c8ad93d0e 100644 --- a/services/web/test/unit/src/Compile/CompileControllerTests.js +++ b/services/web/test/unit/src/Compile/CompileControllerTests.js @@ -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' })