Просмотр исходного кода

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

[web] handle missing outputFiles array

GitOrigin-RevId: 9b1210ff620888f45ec1a3b38c9f91b5a3e22778
Jakob Ackermann 4 лет назад
Родитель
Сommit
2c62ba29c7

+ 1 - 1
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/, '')
               })

+ 25 - 0
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' })