diff --git a/tests/backend/specs/api/pad.js b/tests/backend/specs/api/pad.js index 2a613ebf0..26abfd2c8 100644 --- a/tests/backend/specs/api/pad.js +++ b/tests/backend/specs/api/pad.js @@ -14,7 +14,19 @@ var apiVersion = 1; var testPadId = makeid(); var lastEdited = ""; var text = generateLongText(); -var ULhtml = '
'; + +/* + * Html document with nested lists of different types, to test its import and + * verify it is exported back correctly + */ +var ulHtml = '
  1. item
    1. item1
    2. item2
'; + +/* + * 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 = '
  1. item
    1. item1
    2. item2
'; 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("
", "").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("
", "").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)