Merge test fixes for import/export. Fixes #3425.

Now we have a working test for #3268 (fe08d2a1db).
pull/3437/head
muxator 2018-08-09 18:54:55 +02:00
commit b466acd881
1 changed files with 29 additions and 7 deletions

View File

@ -14,7 +14,19 @@ var apiVersion = 1;
var testPadId = makeid();
var lastEdited = "";
var text = generateLongText();
var ULhtml = '<!DOCTYPE html><html><body><ul class="bullet"><li>one</li><li>2</li></ul><br><ul><ul class="bullet"><li>UL2</li></ul></ul></body></html>';
/*
* Html document with nested lists of different types, to test its import and
* verify it is exported back correctly
*/
var ulHtml = '<!doctype html><html><body><ul class="bullet"><li>one</li><li>two</li><li>0</li><li>1</li><li>2<ul class="bullet"><li>3</li><li>4</li></ul></li></ul><ol class="number"><li>item<ol class="number"><li>item1</li><li>item2</li></ol></li></ol></body></html>';
/*
* When exported back, Etherpad produces an html which is not exactly the same
* textually, but at least it remains standard compliant and has an equal DOM
* structure.
*/
var expectedHtml = '<!doctype html><html><body><ul class="bullet"><li>one</li><li>two</li><li>0</li><li>1</li><li>2<ul class="bullet"><li>3</li><li>4</ul></li></ul><ol class="number"><li>item<ol class="number"><li>item1</li><li>item2</ol></li></ol></body></html>';
describe('Connectivity', function(){
it('errors if can not connect', function(done) {
@ -522,8 +534,8 @@ describe('setHTML', function(){
})
describe('setHTML', function(){
it('Sets the HTML of a Pad with a bunch of weird unordered lists inserted', function(done) {
api.get(endPoint('setHTML')+"&padID="+testPadId+"&html="+ULhtml)
it('Sets the HTML of a Pad with complex nested lists of different types', function(done) {
api.get(endPoint('setHTML')+"&padID="+testPadId+"&html="+ulHtml)
.expect(function(res){
if(res.body.code !== 0) throw new Error("List HTML cant be imported")
})
@ -533,12 +545,22 @@ describe('setHTML', function(){
})
describe('getHTML', function(){
it('Gets the HTML of a Pad with a bunch of weird unordered lists inserted', function(done) {
it('Gets back the HTML of a Pad with complex nested lists of different types', function(done) {
api.get(endPoint('getHTML')+"&padID="+testPadId)
.expect(function(res){
var ehtml = res.body.data.html.replace("<br></body>", "</body>").toLowerCase();
var uhtml = ULhtml.toLowerCase();
if(ehtml !== uhtml) throw new Error("Imported HTML does not match served HTML.\nExpected:\n" + uhtml + "\n\nReceived:\n" + ehtml)
var receivedHtml = res.body.data.html.replace("<br></body>", "</body>").toLowerCase();
if (receivedHtml !== expectedHtml) {
throw new Error(`HTML received from export is not the one we were expecting.
Received:
${receivedHtml}
Expected:
${expectedHtml}
Which is a slightly modified version of the originally imported one:
${ulHtml}`);
}
})
.expect('Content-Type', /json/)
.expect(200, done)