mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 05:12:25 +00:00
Merge pull request #202 from overleaf/jpa-fix-output-pdf-check
[misc] CompileController: exact match for output.pdf
This commit is contained in:
commit
96b8d001f7
2 changed files with 42 additions and 5 deletions
|
@ -80,11 +80,7 @@ module.exports = CompileController = {
|
||||||
let file
|
let file
|
||||||
status = 'failure'
|
status = 'failure'
|
||||||
for (file of Array.from(outputFiles)) {
|
for (file of Array.from(outputFiles)) {
|
||||||
if (
|
if (file.path === 'output.pdf') {
|
||||||
file.path != null
|
|
||||||
? file.path.match(/output\.pdf$/)
|
|
||||||
: undefined
|
|
||||||
) {
|
|
||||||
status = 'success'
|
status = 'success'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,47 @@ describe('CompileController', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('with user provided fake_output.pdf', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
this.output_files = [
|
||||||
|
{
|
||||||
|
path: 'fake_output.pdf',
|
||||||
|
type: 'pdf',
|
||||||
|
build: 1234
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'output.log',
|
||||||
|
type: 'log',
|
||||||
|
build: 1234
|
||||||
|
}
|
||||||
|
]
|
||||||
|
this.CompileManager.doCompileWithLock = sinon
|
||||||
|
.stub()
|
||||||
|
.callsArgWith(1, null, this.output_files)
|
||||||
|
this.CompileController.compile(this.req, this.res)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return the JSON response with status failure', function () {
|
||||||
|
this.res.status.calledWith(200).should.equal(true)
|
||||||
|
this.res.send
|
||||||
|
.calledWith({
|
||||||
|
compile: {
|
||||||
|
status: 'failure',
|
||||||
|
error: null,
|
||||||
|
outputFiles: this.output_files.map((file) => {
|
||||||
|
return {
|
||||||
|
url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
|
||||||
|
path: file.path,
|
||||||
|
type: file.type,
|
||||||
|
build: file.build
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.should.equal(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('with an error', function () {
|
describe('with an error', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.CompileManager.doCompileWithLock = sinon
|
this.CompileManager.doCompileWithLock = sinon
|
||||||
|
|
Loading…
Reference in a new issue