diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 8f256cb5c..d0ebf20de 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -381,7 +381,7 @@ function getHTMLFromAtext(pad, atext, authorColors) // TODO Check against Uls // don't do anything because the next item is a nested ol openener so we need to keep the li open }else{ - pieces.push(""); + pieces.push("
  • "); } diff --git a/tests/backend/specs/api/importexportGetPost.js b/tests/backend/specs/api/importexportGetPost.js index 405d54a4c..e4e07639a 100644 --- a/tests/backend/specs/api/importexportGetPost.js +++ b/tests/backend/specs/api/importexportGetPost.js @@ -12,6 +12,7 @@ const path = require('path'); const async = require(__dirname+'/../../../../src/node_modules/async'); const request = require(__dirname+'/../../../../src/node_modules/request'); const padText = fs.readFileSync("../tests/backend/specs/api/test.txt"); +const etherpadDoc = fs.readFileSync("../tests/backend/specs/api/test.etherpad"); const wordDoc = fs.readFileSync("../tests/backend/specs/api/test.doc"); const wordXDoc = fs.readFileSync("../tests/backend/specs/api/test.docx"); const odtDoc = fs.readFileSync("../tests/backend/specs/api/test.odt"); @@ -121,7 +122,7 @@ describe('Imports and Exports', function(){ throw new Error("Failed DOC import", testPadId); }else{ done(); - }; + } } }); @@ -161,7 +162,7 @@ describe('Imports and Exports', function(){ throw new Error("Failed DOCX import"); }else{ done(); - }; + } } }); @@ -197,7 +198,7 @@ describe('Imports and Exports', function(){ throw new Error("Failed PDF import"); }else{ done(); - }; + } } }); @@ -233,7 +234,7 @@ describe('Imports and Exports', function(){ throw new Error("Failed ODT import", testPadId); }else{ done(); - }; + } } }); @@ -257,6 +258,55 @@ describe('Imports and Exports', function(){ }) }) + it('Tries to import .etherpad', function(done) { + if(!settings.allowAnyoneToImport) return done(); + + var req = request.post(host + '/p/'+testPadId+'/import', function (err, res, body) { + if (err) { + throw new Error("Failed to import", err); + } else { + if(res.body.indexOf("FrameCall(\'true\', \'ok\');") === -1){ + throw new Error("Failed Etherpad import", err, testPadId); + }else{ + done(); + } + } + }); + + let form = req.form(); + form.append('file', etherpadDoc, { + filename: '/test.etherpad', + contentType: 'application/etherpad' + }); + }); + + it('exports Etherpad', function(done) { + request(host + '/p/'+testPadId+'/export/etherpad', function (err, res, body) { + // TODO: At some point checking that the contents is correct would be suitable + if(body.indexOf("hello") !== -1){ + done(); + }else{ + console.error("body"); + throw new Error("Etherpad Document does not include hello"); + } + }) + }) + + it('exports HTML for this Etherpad file', function(done) { + request(host + '/p/'+testPadId+'/export/html', function (err, res, body) { + + // broken pre fix export -- + var expectedHTML = ''; + // expect body to include + if(body.indexOf(expectedHTML) !== -1){ + done(); + }else{ + console.error(body); + throw new Error("Exported HTML nested list items is not right", body); + } + }) + }) + it('tries to import Plain Text to a pad that does not exist', function(done) { var req = request.post(host + '/p/'+testPadId+testPadId+testPadId+'/import', function (err, res, body) { if (res.statusCode === 200) { diff --git a/tests/backend/specs/api/test.etherpad b/tests/backend/specs/api/test.etherpad new file mode 100644 index 000000000..1c3121949 --- /dev/null +++ b/tests/backend/specs/api/test.etherpad @@ -0,0 +1 @@ +{"pad:Pd4b1Kgvv9qHZZtj8yzl":{"atext":{"text":"*hello\n","attribs":"*0*1*5*3*4+1*0+5|1+1"},"pool":{"numToAttrib":{"0":["author","a.ElbBWNTxmtRrfFqn"],"1":["insertorder","first"],"2":["list","bullet1"],"3":["lmkr","1"],"4":["start","1"],"5":["list","bullet2"]},"nextNum":6},"head":5,"chatHead":-1,"publicStatus":false,"passwordHash":null,"savedRevisions":[]},"globalAuthor:a.ElbBWNTxmtRrfFqn":{"colorId":50,"name":null,"timestamp":1595111151414,"padIDs":"Pd4b1Kgvv9qHZZtj8yzl"},"pad:Pd4b1Kgvv9qHZZtj8yzl:revs:0":{"changeset":"Z:1>bj|7+bj$Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at https://etherpad.org\n\nWarning: DirtyDB is used. This is fine for testing but not recommended for production. -- To suppress these warning messages change suppressErrorsInPadText to true in your settings.json\n","meta":{"author":"","timestamp":1595111092400,"pool":{"numToAttrib":{},"attribToNum":{},"nextNum":0},"atext":{"text":"Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at https://etherpad.org\n\nWarning: DirtyDB is used. This is fine for testing but not recommended for production. -- To suppress these warning messages change suppressErrorsInPadText to true in your settings.json\n\n","attribs":"|8+bk"}}},"pad:Pd4b1Kgvv9qHZZtj8yzl:revs:1":{"changeset":"Z:bk1*0*1*2*3*4+1$*","meta":{"author":"a.ElbBWNTxmtRrfFqn","timestamp":1595111119434}},"pad:Pd4b1Kgvv9qHZZtj8yzl:revs:3":{"changeset":"Z:2>0*5*4=1$","meta":{"author":"a.ElbBWNTxmtRrfFqn","timestamp":1595111127471}},"pad:Pd4b1Kgvv9qHZZtj8yzl:revs:4":{"changeset":"Z:2>2=1*0+2$he","meta":{"author":"a.ElbBWNTxmtRrfFqn","timestamp":1595111128230}},"pad:Pd4b1Kgvv9qHZZtj8yzl:revs:5":{"changeset":"Z:4>3=3*0+3$llo","meta":{"author":"a.ElbBWNTxmtRrfFqn","timestamp":1595111128727}}} \ No newline at end of file diff --git a/tests/frontend/travis/runnerBackend.sh b/tests/frontend/travis/runnerBackend.sh index 5f02ebd2e..2bbe17cb3 100755 --- a/tests/frontend/travis/runnerBackend.sh +++ b/tests/frontend/travis/runnerBackend.sh @@ -16,7 +16,7 @@ sed 's#\"soffice\": null,#\"soffice\":\"/usr/bin/soffice\",#g' settings.json.tem 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 +sed 's/\"max\": 10/\"max\": 100/g' settings.json.allowImport > settings.json # start Etherpad, assuming all dependencies are already installed. #