diff --git a/.travis.yml b/.travis.yml index 751954129..8e003fc45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,10 @@ services: cache: false before_install: + - sudo add-apt-repository -y ppa:libreoffice/ppa + - sudo apt-get update - sudo apt-get -y install libreoffice + - sudo apt-get -y install libreoffice-pdfimport install: - "bin/installDeps.sh" @@ -38,20 +41,17 @@ jobs: - name: "Run the Backend tests" install: - "bin/installDeps.sh" - # Set soffice to /usr/bin/soffice - - "sed 's/\"soffice\": null,/\"soffice\": \"/usr/bin/soffice\",/g' settings.json.template > settings.json" - # Set allowAnyoneToImport to true - - "sed 's/\"allowAnyoneToImport\": false,/\"allowAnyoneToInput\": true,/g' settings.json > settings.json" - "cd src && npm install && cd -" script: - "tests/frontend/travis/runnerBackend.sh" - - name: "Test the Dockerfile" - install: - - "cd src && npm install && cd -" - script: - - "docker build -t etherpad:test ." - - "docker run -d -p 9001:9001 etherpad:test && sleep 3" - - "cd src && npm run test-container" +## Temporarily commented out the Dockerfile tests +# - name: "Test the Dockerfile" +# install: +# - "cd src && npm install && cd -" +# script: +# - "docker build -t etherpad:test ." +# - "docker run -d -p 9001:9001 etherpad:test && sleep 3" +# - "cd src && npm run test-container" - name: "Load test Etherpad" install: - "bin/installDeps.sh" diff --git a/tests/backend/specs/api/importexportGetPost.js b/tests/backend/specs/api/importexportGetPost.js index aad5fd3ce..405d54a4c 100644 --- a/tests/backend/specs/api/importexportGetPost.js +++ b/tests/backend/specs/api/importexportGetPost.js @@ -1,12 +1,7 @@ /* * Import and Export tests for the /p/whateverPadId/import and /p/whateverPadId/export endpoints. - * Executed using request. Designed to find flaws and bugs */ -// import wont work due to sessions missing -// Waiting on https://github.com/ether/etherpad-lite/pull/4012/files to be merged to be fully functional -// Logic for creating sessions is the sessionandGroups.js test spec - const assert = require('assert'); const supertest = require(__dirname+'/../../../../src/node_modules/supertest'); const fs = require('fs'); @@ -77,10 +72,9 @@ Example Curl command for testing import URI: */ describe('Imports and Exports', function(){ - it('creates a new Pad, imports content to it, checks that content', function(done) { if(!settings.allowAnyoneToImport){ - console.log("not anyone can import so not testing -- to include this test set allowAnyoneToImport to true in settings.json"); + console.warn("not anyone can import so not testing -- to include this test set allowAnyoneToImport to true in settings.json"); done(); }else{ api.get(endPoint('createPad')+"&padID="+testPadId) @@ -138,18 +132,21 @@ describe('Imports and Exports', function(){ }); }); - xit('exports DOC', function(done) { + it('exports DOC', function(done) { if(!settings.allowAnyoneToImport) return done(); if((settings.abiword && settings.abiword.indexOf("/" === -1)) && (settings.office && settings.soffice.indexOf("/" === -1))) return done(); - request(host + '/p/'+testPadId+'/export/doc', function (err, res, body) { - // expect length to be > 9000 - // TODO: At some point checking that the contents is correct would be suitable - if(body.length >= 9000){ - done(); - }else{ - throw new Error("Word Document export length is not right"); - } - }) + try{ + request(host + '/p/'+testPadId+'/export/doc', function (err, res, body) { + // TODO: At some point checking that the contents is correct would be suitable + if(body.length >= 9000){ + done(); + }else{ + throw new Error("Word Document export length is not right"); + } + }) + }catch(e){ + throw new Error(e); + } }) it('Tries to import .docx that uses soffice or abiword', function(done) { @@ -161,7 +158,7 @@ describe('Imports and Exports', function(){ throw new Error("Failed to import", err); } else { if(res.body.indexOf("FrameCall('undefined', 'ok');") === -1){ - throw new Error("Failed DOCX import", testPadId); + throw new Error("Failed DOCX import"); }else{ done(); }; @@ -197,7 +194,7 @@ describe('Imports and Exports', function(){ throw new Error("Failed to import", err); } else { if(res.body.indexOf("FrameCall('undefined', 'ok');") === -1){ - throw new Error("Failed PDF import", testPadId); + throw new Error("Failed PDF import"); }else{ done(); }; diff --git a/tests/backend/specs/api/test.pdf b/tests/backend/specs/api/test.pdf index 79c9c2832..774c2ea70 100644 Binary files a/tests/backend/specs/api/test.pdf and b/tests/backend/specs/api/test.pdf differ diff --git a/tests/frontend/travis/runnerBackend.sh b/tests/frontend/travis/runnerBackend.sh index 404e2d806..5f02ebd2e 100755 --- a/tests/frontend/travis/runnerBackend.sh +++ b/tests/frontend/travis/runnerBackend.sh @@ -9,6 +9,15 @@ MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" # reliably move to the etherpad base folder before running it cd "${MY_DIR}/../../../" +# Set soffice to /usr/bin/soffice +sed 's#\"soffice\": null,#\"soffice\":\"/usr/bin/soffice\",#g' settings.json.template > settings.json.soffice + +# Set allowAnyoneToImport to true +sed 's/\"allowAnyoneToImport\": false,/\"allowAnyoneToImport\": true,/g' settings.json.soffice > settings.json.allowImport + +# Set "max": 10 to 100 to not agressively rate limit +sed 's/\"max\": 10/\"max\": 10/g' settings.json.allowImport > settings.json + # start Etherpad, assuming all dependencies are already installed. # # This is possible because the "install" section of .travis.yml already contains @@ -28,9 +37,6 @@ echo "Now I will try for 15 seconds to connect to Etherpad on http://localhost:9 echo "Successfully connected to Etherpad on http://localhost:9001" -# a copy of settings.json is necessary for the backend tests to work -cp settings.json.template settings.json - # run the backend tests echo "Now run the backend tests" cd src