diff --git a/helpers/publishHelpers.js b/helpers/publishHelpers.js index 65370250..233410db 100644 --- a/helpers/publishHelpers.js +++ b/helpers/publishHelpers.js @@ -29,6 +29,7 @@ module.exports = { }; }, parsePublishApiRequestFiles ({file}) { + logger.debug('file', file); // make sure a file was provided if (!file) { throw new Error('no file with key of [file] found in request'); diff --git a/routes/api-routes.js b/routes/api-routes.js index b6472216..bd9ac3e1 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -126,6 +126,7 @@ module.exports = (app) => { // route to run a publish request on the daemon app.post('/api/claim-publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => { logger.debug('api/claim-publish body:', body); + logger.debug('api/claim-publish files:', files); let name, fileName, filePath, fileType, nsfw, license, title, description, thumbnail, channelName, channelPassword; // validate the body and files of the request try { @@ -134,7 +135,7 @@ module.exports = (app) => { ({fileName, filePath, fileType} = parsePublishApiRequestFiles(files)); ({channelName, channelPassword} = parsePublishApiChannel(body, user)); } catch (error) { - logger.debug('publish request rejected, insufficient request parameters'); + logger.debug('publish request rejected, insufficient request parameters', error); return res.status(400).json({success: false, message: error.message}); } // check channel authorization diff --git a/test/end-to-end/end-to-end.tests.js b/test/end-to-end/end-to-end.tests.js index 142b39fd..40dd4e66 100644 --- a/test/end-to-end/end-to-end.tests.js +++ b/test/end-to-end/end-to-end.tests.js @@ -2,12 +2,14 @@ const chai = require('chai'); const expect = chai.expect; const chaiHttp = require('chai-http'); const { host } = require('../../config/speechConfig.js').site; -const timeout = 600000; +const requestTimeout = 20000; +const publishTimeout = 120000; +const fs = require('fs'); chai.use(chaiHttp); function testFor200StatusResponse (host, url) { - return it(`should receive a status code 200 within ${timeout}ms`, function (done) { + return it(`should receive a status code 200 within ${requestTimeout}ms`, function (done) { chai.request(host) .get(url) .end(function (err, res) { @@ -15,11 +17,11 @@ function testFor200StatusResponse (host, url) { expect(res).to.have.status(200); done(); }); - }).timeout(timeout); + }).timeout(requestTimeout); } function testShowRequestFor200StatusResponse (host, url) { - return it(`should receive a status code 200 within ${timeout}ms`, function (done) { + return it(`should receive a status code 200 within ${requestTimeout}ms`, function (done) { chai.request(host) .get(url) .set('accept', 'text/html') @@ -28,7 +30,7 @@ function testShowRequestFor200StatusResponse (host, url) { expect(res).to.have.status(200); done(); }); - }).timeout(timeout); + }).timeout(requestTimeout); } describe('end-to-end', function () { @@ -79,4 +81,29 @@ describe('end-to-end', function () { testShowRequestFor200StatusResponse(host, claimUrlWithShortClaimId); }); }); + + describe('publish', function () { + const publishUrl = '/api/claim-publish'; + const name = 'test-name2'; + const filePath = './test/mock-files/bird.jpeg'; + const fileName = 'byrd.jpeg'; + + describe(publishUrl, function () { + it(`should receive a status code 200 within ${publishTimeout}ms`, function (done) { + chai.request(host) + .post(publishUrl) + .type('form') + .attach('file', fs.readFileSync(filePath), fileName) + .field('name', name) + .end(function (err, res) { + // expect(err).to.be.null; + expect(res).to.have.status(200); + done(); + }); + }).timeout(publishTimeout); + }); + + }); + + }); diff --git a/test/mock-files/bird.jpeg b/test/mock-files/bird.jpeg new file mode 100644 index 00000000..cd1b140c Binary files /dev/null and b/test/mock-files/bird.jpeg differ diff --git a/testpage.html b/testpage.html deleted file mode 100644 index 2d29d095..00000000 --- a/testpage.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Test Page - - - - - - - - - - - -