Acceptance tests for project-output-file

This commit is contained in:
Shane Kilkelly 2018-06-14 10:03:29 +01:00
parent 48a4f6c4c4
commit 28257462ae
3 changed files with 78 additions and 1 deletions

View file

@ -17,7 +17,7 @@ services:
PROJECT_HISTORY_ENABLED: 'true'
ENABLED_LINKED_FILE_TYPES: 'url'
LINKED_URL_PROXY: 'http://localhost:6543'
ENABLED_LINKED_FILE_TYPES: 'url,project_file'
ENABLED_LINKED_FILE_TYPES: 'url,project_file,project_output_file'
SHARELATEX_CONFIG: /app/test/acceptance/config/settings.test.coffee
depends_on:
- redis

View file

@ -8,6 +8,8 @@ MockFileStoreApi = require './helpers/MockFileStoreApi'
request = require "./helpers/request"
User = require "./helpers/User"
MockClsiApi = require "./helpers/MockClsiApi"
express = require("express")
LinkedUrlProxy = express()
@ -344,3 +346,69 @@ describe "LinkedFiles", ->
# TODO: Add test for asking for host that return ENOTFOUND
# (This will probably end up handled by the proxy)
describe "creating a linked output file", ->
before (done) ->
async.series [
(cb) =>
@owner.createProject 'output-test-one', {template: 'blank'}, (error, project_id) =>
@project_one_id = project_id
cb(error)
(cb) =>
@owner.getProject @project_one_id, (error, project) =>
@project_one = project
@project_one_root_folder_id = project.rootFolder[0]._id.toString()
cb(error)
(cb) =>
@owner.createProject 'output-test-two', {template: 'blank'}, (error, project_id) =>
@project_two_id = project_id
cb(error)
(cb) =>
@owner.getProject @project_two_id, (error, project) =>
@project_two = project
@project_two_root_folder_id = project.rootFolder[0]._id.toString()
cb(error)
], done
it 'should import the output.pdf file from the source project', (done) ->
@owner.request.post {
url: "/project/#{@project_one_id}/linked_file",
json:
name: 'test.pdf',
parent_folder_id: @project_one_root_folder_id,
provider: 'project_output_file',
data:
source_project_id: @project_two_id,
source_output_file_path: "output.pdf",
}, (error, response, body) =>
new_file_id = body.new_file_id
@existing_file_id = new_file_id
expect(new_file_id).to.exist
@owner.getProject @project_one_id, (error, project) =>
return done(error) if error?
firstFile = project.rootFolder[0].fileRefs[0]
expect(firstFile._id.toString()).to.equal(new_file_id.toString())
expect(firstFile.linkedFileData).to.deep.equal {
provider: 'project_output_file',
source_project_id: @project_two_id,
source_output_file_path: "output.pdf",
source_project_display_name: "output-test-two"
}
expect(firstFile.name).to.equal('test.pdf')
done()
it 'should refresh the file', (done) ->
@owner.request.post {
url: "/project/#{@project_one_id}/linked_file/#{@existing_file_id}/refresh",
json: true
}, (error, response, body) =>
new_file_id = body.new_file_id
expect(new_file_id).to.exist
expect(new_file_id).to.not.equal @existing_file_id
@refreshed_file_id = new_file_id
@owner.getProject @project_one_id, (error, project) =>
return done(error) if error?
firstFile = project.rootFolder[0].fileRefs[0]
expect(firstFile._id.toString()).to.equal(new_file_id.toString())
expect(firstFile.name).to.equal('test.pdf')
done()

View file

@ -1,4 +1,5 @@
express = require("express")
bodyParser = require "body-parser"
app = express()
module.exports = MockClsiApi =
@ -30,6 +31,14 @@ module.exports = MockClsiApi =
else
res.sendStatus(404)
app.post "/project/:project_id/compile", (req, res, next) =>
res.json {
outputFiles: [{path: 'output.pdf'}]
}
app.get "/project/:project_id/output/:output_path", (req, res, next) =>
res.status(200).send("hello")
app.listen 3013, (error) ->
throw error if error?
.on "error", (error) ->