Skip to content

Commit b466acd

Browse files
committed
Merge test fixes for import/export. Fixes #3425.
Now we have a working test for #3268 (fe08d2a).
2 parents 10f0cb3 + 718b175 commit b466acd

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

tests/backend/specs/api/pad.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@ var apiVersion = 1;
1414
var testPadId = makeid();
1515
var lastEdited = "";
1616
var text = generateLongText();
17-
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>';
17+
18+
/*
19+
* Html document with nested lists of different types, to test its import and
20+
* verify it is exported back correctly
21+
*/
22+
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>';
23+
24+
/*
25+
* When exported back, Etherpad produces an html which is not exactly the same
26+
* textually, but at least it remains standard compliant and has an equal DOM
27+
* structure.
28+
*/
29+
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>';
1830

1931
describe('Connectivity', function(){
2032
it('errors if can not connect', function(done) {
@@ -522,8 +534,8 @@ describe('setHTML', function(){
522534
})
523535

524536
describe('setHTML', function(){
525-
it('Sets the HTML of a Pad with a bunch of weird unordered lists inserted', function(done) {
526-
api.get(endPoint('setHTML')+"&padID="+testPadId+"&html="+ULhtml)
537+
it('Sets the HTML of a Pad with complex nested lists of different types', function(done) {
538+
api.get(endPoint('setHTML')+"&padID="+testPadId+"&html="+ulHtml)
527539
.expect(function(res){
528540
if(res.body.code !== 0) throw new Error("List HTML cant be imported")
529541
})
@@ -533,12 +545,22 @@ describe('setHTML', function(){
533545
})
534546

535547
describe('getHTML', function(){
536-
it('Gets the HTML of a Pad with a bunch of weird unordered lists inserted', function(done) {
548+
it('Gets back the HTML of a Pad with complex nested lists of different types', function(done) {
537549
api.get(endPoint('getHTML')+"&padID="+testPadId)
538550
.expect(function(res){
539-
var ehtml = res.body.data.html.replace("<br></body>", "</body>").toLowerCase();
540-
var uhtml = ULhtml.toLowerCase();
541-
if(ehtml !== uhtml) throw new Error("Imported HTML does not match served HTML.\nExpected:\n" + uhtml + "\n\nReceived:\n" + ehtml)
551+
var receivedHtml = res.body.data.html.replace("<br></body>", "</body>").toLowerCase();
552+
553+
if (receivedHtml !== expectedHtml) {
554+
throw new Error(`HTML received from export is not the one we were expecting.
555+
Received:
556+
${receivedHtml}
557+
558+
Expected:
559+
${expectedHtml}
560+
561+
Which is a slightly modified version of the originally imported one:
562+
${ulHtml}`);
563+
}
542564
})
543565
.expect('Content-Type', /json/)
544566
.expect(200, done)

0 commit comments

Comments
 (0)