diff options
Diffstat (limited to 'tests/frontend/specs')
-rw-r--r-- | tests/frontend/specs/bold.js | 3 | ||||
-rw-r--r-- | tests/frontend/specs/caret.js | 22 | ||||
-rw-r--r-- | tests/frontend/specs/chat.js | 31 | ||||
-rw-r--r-- | tests/frontend/specs/clear_authorship_colors.js | 5 | ||||
-rw-r--r-- | tests/frontend/specs/font_type.js | 2 | ||||
-rw-r--r-- | tests/frontend/specs/importexport.js | 237 | ||||
-rw-r--r-- | tests/frontend/specs/importindents.js | 111 | ||||
-rw-r--r-- | tests/frontend/specs/indentation.js | 2 | ||||
-rw-r--r-- | tests/frontend/specs/italic.js | 2 | ||||
-rw-r--r-- | tests/frontend/specs/redo.js | 2 | ||||
-rw-r--r-- | tests/frontend/specs/responsiveness.js | 2 | ||||
-rw-r--r-- | tests/frontend/specs/timeslider_revisions.js | 14 | ||||
-rw-r--r-- | tests/frontend/specs/undo.js | 2 | ||||
-rw-r--r-- | tests/frontend/specs/unordered_list.js | 35 |
14 files changed, 454 insertions, 16 deletions
diff --git a/tests/frontend/specs/bold.js b/tests/frontend/specs/bold.js index 95da7331..b54466e4 100644 --- a/tests/frontend/specs/bold.js +++ b/tests/frontend/specs/bold.js @@ -43,7 +43,8 @@ describe("bold button", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$.browser.mozilla){ // if it's a mozilla browser + + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/caret.js b/tests/frontend/specs/caret.js index b33f5168..14ff8d6a 100644 --- a/tests/frontend/specs/caret.js +++ b/tests/frontend/specs/caret.js @@ -1,11 +1,19 @@ describe("As the caret is moved is the UI properly updated?", function(){ var padName; var numberOfRows = 50; +/* + + //create a new pad before each test run + beforeEach(function(cb){ + helper.newPad(cb); + this.timeout(60000); + }); - it("creates a pad", function(done) { + xit("creates a pad", function(done) { padName = helper.newPad(done); this.timeout(60000); }); +*/ /* Tests to do * Keystroke up (38), down (40), left (37), right (39) with and without special keys IE control / shift @@ -20,10 +28,12 @@ describe("As the caret is moved is the UI properly updated?", function(){ * How do we keep the authors focus on a line if the lines above the author are modified? We should only redraw the user to a location if they are typing and make sure shift and arrow keys aren't redrawing the UI else highlight - copy/paste would get broken * How can we simulate an edit event in the test framework? */ - - // THIS DOESNT WORK AS IT DOESNT MOVE THE CURSOR! +/* + // THIS DOESNT WORK IN CHROME AS IT DOESNT MOVE THE CURSOR! it("down arrow", function(done){ var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + var $newFirstTextElement = inner$("div").first(); $newFirstTextElement.focus(); keyEvent(inner$, 37, false, false); // arrow down @@ -31,9 +41,10 @@ describe("As the caret is moved is the UI properly updated?", function(){ done(); }); -/* + it("Creates N lines", function(done){ var inner$ = helper.padInner$; +console.log(inner$); var chrome$ = helper.padChrome$; var $newFirstTextElement = inner$("div").first(); @@ -224,7 +235,6 @@ describe("As the caret is moved is the UI properly updated?", function(){ }); var i = 0; while(i < numberOfRows){ // press down arrow -console.log("dwn"); keyEvent(inner$, 40, false, false); i++; } @@ -287,7 +297,7 @@ function prepareDocument(n, target){ // generates a random document with random } function keyEvent(target, charCode, ctrl, shift){ // sends a charCode to the window - if(target.browser.mozilla){ // if it's a mozilla browser + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/chat.js b/tests/frontend/specs/chat.js index ccb8b569..7ebb76fb 100644 --- a/tests/frontend/specs/chat.js +++ b/tests/frontend/specs/chat.js @@ -96,4 +96,35 @@ describe("Chat messages and UI", function(){ done(); }); + + it("makes chat stick to right side of the screen then makes it one step smaller", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + //click on the settings button to make settings visible + var $settingsButton = chrome$(".buttonicon-settings"); + $settingsButton.click(); + + //get the chat selector + var $stickychatCheckbox = chrome$("#options-stickychat"); + + //select chat always on screen and fire change event + $stickychatCheckbox.attr('selected','selected'); + $stickychatCheckbox.change(); + $stickychatCheckbox.click(); + + //check if chat changed to get the stickychat Class + var $chatbox = chrome$("#chatbox"); + var hasStickyChatClass = $chatbox.hasClass("stickyChat"); + expect(hasStickyChatClass).to.be(true); + + //select chat always on screen and fire change event + chrome$('#titlecross').click(); + + //check if chat changed to remove the stickychat Class + var hasStickyChatClass = $chatbox.hasClass("stickyChat"); + expect(hasStickyChatClass).to.be(false); + + done(); + }); }); diff --git a/tests/frontend/specs/clear_authorship_colors.js b/tests/frontend/specs/clear_authorship_colors.js index 5db35612..1417f63c 100644 --- a/tests/frontend/specs/clear_authorship_colors.js +++ b/tests/frontend/specs/clear_authorship_colors.js @@ -47,6 +47,11 @@ describe("clear authorship colors button", function(){ var hasAuthorClass = inner$("div").first().attr("class").indexOf("author") !== -1; expect(hasAuthorClass).to.be(false); + setTimeout(function(){ + var disconnectVisible = chrome$("div.disconnected").attr("class").indexOf("visible") === -1 + expect(disconnectVisible).to.be(true); + },1000); + done(); }); diff --git a/tests/frontend/specs/font_type.js b/tests/frontend/specs/font_type.js index 25d9df05..41b1de34 100644 --- a/tests/frontend/specs/font_type.js +++ b/tests/frontend/specs/font_type.js @@ -24,7 +24,7 @@ describe("font select", function(){ //check if font changed to monospace var fontFamily = inner$("body").css("font-family").toLowerCase(); - expect(fontFamily).to.be("monospace"); + expect(fontFamily).to.be("courier new"); done(); }); diff --git a/tests/frontend/specs/importexport.js b/tests/frontend/specs/importexport.js new file mode 100644 index 00000000..59607dba --- /dev/null +++ b/tests/frontend/specs/importexport.js @@ -0,0 +1,237 @@ +describe("import functionality", function(){ + beforeEach(function(cb){ + helper.newPad(cb); // creates a new pad + this.timeout(60000); + }); + + function getinnertext(){ + var inner = helper.padInner$ + if(!inner){ + return "" + } + var newtext = "" + inner("div").each(function(line,el){ + newtext += el.innerHTML+"\n" + }) + return newtext + } + function importrequest(data,importurl,type){ + var success; + var error; + var result = $.ajax({ + url: importurl, + type: "post", + processData: false, + async: false, + contentType: 'multipart/form-data; boundary=boundary', + accepts: { + text: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" + }, + data: 'Content-Type: multipart/form-data; boundary=--boundary\r\n\r\n--boundary\r\nContent-Disposition: form-data; name="file"; filename="import.'+type+'"\r\nContent-Type: text/plain\r\n\r\n' + data + '\r\n\r\n--boundary', + error: function(res){ + error = res + } + }) + expect(error).to.be(undefined) + return result + } + function exportfunc(link){ + var exportresults = [] + $.ajaxSetup({ + async:false + }) + $.get(link+"/export/html",function(data){ + var start = data.indexOf("<body>") + var end = data.indexOf("</body>") + var html = data.substr(start+6,end-start-6) + exportresults.push(["html",html]) + }) + $.get(link+"/export/txt",function(data){ + exportresults.push(["txt",data]) + }) + return exportresults + } + + it("import a pad with newlines from txt", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var textWithNewLines = 'imported text\nnewline' + importrequest(textWithNewLines,importurl,"txt") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('<span class="">imported text</span>\n<span class="">newline</span>\n<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be("imported text<br>newline<br><br>") + expect(results[1][1]).to.be("imported text\nnewline\n\n") + done() + }) + it("import a pad with newlines from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithNewLines = '<html><body>htmltext<br/>newline</body></html>' + importrequest(htmlWithNewLines,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('<span class="">htmltext</span>\n<span class="">newline</span>\n<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be("htmltext<br>newline<br><br>") + expect(results[1][1]).to.be("htmltext\nnewline\n\n") + done() + }) + it("import a pad with attributes from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithNewLines = '<html><body>htmltext<br/><span class="b s i u"><b><i><s><u>newline</u></s></i></b></body></html>' + importrequest(htmlWithNewLines,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('<span class="">htmltext</span>\n<span class="b i s u"><b><i><s><u>newline</u></s></i></b></span>\n<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('htmltext<br><strong><em><s><u>newline</u></s></em></strong><br><br>') + expect(results[1][1]).to.be('htmltext\nnewline\n\n') + done() + }) + it("import a pad with bullets from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li><li>bullet2 line 2</li></ul></ul></body></html>' + importrequest(htmlWithBullets,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('\ +<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\ +<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\ +<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n\ +<ul class="list-bullet2"><li><span class="">bullet2 line 2</span></li></ul>\n\ +<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li><li>bullet2 line 2</li></ul></ul><br>') + expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t* bullet2 line 2\n\n') + done() + }) + it("import a pad with bullets and newlines from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1"><ul class="list-bullet2"><li>bullet2 line 2</li></ul></ul></body></html>' + importrequest(htmlWithBullets,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('\ +<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\ +<br>\n\ +<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\ +<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n\ +<br>\n\ +<ul class="list-bullet2"><li><span class="">bullet2 line 2</span></li></ul>\n\ +<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet"><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul></ul><br><ul><ul class="bullet"><li>bullet2 line 2</li></ul></ul><br>') + expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t* bullet2 line 2\n\n') + done() + }) + it("import a pad with bullets and newlines and attributes from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1"><ul class="list-bullet2"><ul class="list-bullet3"><ul class="list-bullet4"><li><span class="b s i u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>bullet4 line 2 bs</s></b></span></li><li><span class="u"><u>bullet4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li></ul></ul></ul></ul></body></html>' + importrequest(htmlWithBullets,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('\ +<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\<br>\n\ +<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\ +<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n<br>\n\ +<ul class="list-bullet4"><li><span class="b i s u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li></ul>\n\ +<ul class="list-bullet4"><li><span class="b s"><b><s>bullet4 line 2 bs</s></b></span></li></ul>\n\ +<ul class="list-bullet4"><li><span class="u"><u>bullet4 line 2 u</u></span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n\ +<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet"><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul></ul><br><ul><ul><ul><ul class="bullet"><li><strong><em><s><u>bullet4 line 2 bisu</u></s></em></strong></li><li><strong><s>bullet4 line 2 bs</s></strong></li><li><u>bullet4 line 2 u<em><s>uis</s></em></u></li></ul></ul></ul></ul><br>') + expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\n') + done() + }) + it("import a pad with nested bullets from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><ul class="list-bullet1"><ul class="list-bullet2"><ul class="list-bullet3"><ul class="list-bullet4"><li>bullet4 line 2</li><li>bullet4 line 2</li><li>bullet4 line 2</li></ul><li>bullet3 line 1</li></ul></ul><li>bullet2 line 1</li></ul></body></html>' + importrequest(htmlWithBullets,importurl,"html") + var oldtext=getinnertext() + helper.waitFor(function(){ + return oldtext != getinnertext() +// return expect(getinnertext()).to.be('\ +//<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\ +//<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\ +//<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n\ +//<ul class="list-bullet4"><li><span class="">bullet4 line 2</span></li></ul>\n\ +//<ul class="list-bullet4"><li><span class="">bullet4 line 2</span></li></ul>\n\ +//<ul class="list-bullet4"><li><span class="">bullet4 line 2</span></li></ul>\n\ +//<br>\n') + }) + + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li><ul><ul class="bullet"><li>bullet4 line 2</li><li>bullet4 line 2</li><li>bullet4 line 2</li></ul><li>bullet3 line 1</li></ul></ul><li>bullet2 line 1</li></ul><br>') + expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t* bullet3 line 1\n\t* bullet2 line 1\n\n') + done() + }) + it("import a pad with 8 levels of bullets and newlines and attributes from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1"><ul class="list-bullet2"><ul class="list-bullet3"><ul class="list-bullet4"><li><span class="b s i u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>bullet4 line 2 bs</s></b></span></li><li><span class="u"><u>bullet4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li><ul class="list-bullet5"><ul class="list-bullet6"><ul class="list-bullet7"><ul class="list-bullet8"><li><span class="">foo</span></li><li><span class="b s"><b><s>foobar bs</b></s></span></li></ul></ul></ul></ul><ul class="list-bullet5"><li>foobar</li></ul></ul></ul></ul></body></html>' + importrequest(htmlWithBullets,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('\ +<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\<br>\n\ +<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\ +<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n<br>\n\ +<ul class="list-bullet4"><li><span class="b i s u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li></ul>\n\ +<ul class="list-bullet4"><li><span class="b s"><b><s>bullet4 line 2 bs</s></b></span></li></ul>\n\ +<ul class="list-bullet4"><li><span class="u"><u>bullet4 line 2 u</u></span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n\ +<ul class="list-bullet8"><li><span class="">foo</span></li></ul>\n\ +<ul class="list-bullet8"><li><span class="b s"><b><s>foobar bs</s></b></span></li></ul>\n\ +<ul class="list-bullet5"><li><span class="">foobar</span></li></ul>\n\ +<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet"><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul></ul><br><ul><ul><ul><ul class="bullet"><li><strong><em><s><u>bullet4 line 2 bisu</u></s></em></strong></li><li><strong><s>bullet4 line 2 bs</s></strong></li><li><u>bullet4 line 2 u<em><s>uis</s></em></u></li><ul><ul><ul><ul class="bullet"><li>foo</li><li><strong><s>foobar bs</s></strong></li></ul></ul></ul><li>foobar</li></ul></ul></ul></ul></ul><br>') + expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\t\t\t\t\t\t\t\t* foo\n\t\t\t\t\t\t\t\t* foobar bs\n\t\t\t\t\t* foobar\n\n') + done() + }) + + xit("import a pad with ordered lists from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ol class="list-number1" start="1"><li>number 1 line 1</li></ol><ol class="list-number1" start="2"><li>number 2 line 2</li></ol></body></html>' + importrequest(htmlWithBullets,importurl,"html") + -console.error(getinnertext()) + expect(getinnertext()).to.be('\ +<ol class="list-number1" start="1"><li><span class="">number 1 line 1</span></li></ol>\n\ +<ol class="list-number1" start="2"><li><span class="">number 2 line 2</span></li></ol>\n\ +<br>\n') + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ol class="list-number1" start="1"><li>number 1 line 1</li></ol><ol class="list-number1" start="2"><li>number 2 line 2</li></ol>') + expect(results[1][1]).to.be('') + done() + }) + xit("import a pad with ordered lists and newlines from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ol class="list-number1" start="1"><li>number 9 line 1</li></ol><br/><ol class="list-number1" start="2"><li>number 10 line 2</li><ol class="list-number2"><li>number 2 times line 1</li></ol></ol><br/><ol class="list-bullet1"><ol class="list-number2"><li>number 2 times line 2</li></ol></ol></body></html>' + importrequest(htmlWithBullets,importurl,"html") + expect(getinnertext()).to.be('\ +<ol class="list-number1" start="1"><li><span class="">number 9 line 1</span></li></ol>\n\ +<br>\n\ +<ol class="list-number1" start="2"><li><span class="">number 10 line 2</span></li></ol>\n\ +<ol class="list-number2"><li><span class="">number 2 times line 1</span></li></ol>\n\ +<br>\n\ +<ol class="list-number2"><li><span class="">number 2 times line 2</span></li></ol>\n\ +<br>\n') + var results = exportfunc(helper.padChrome$.window.location.href) + console.error(results) + done() + }) + xit("import a pad with nested ordered lists and attributes and newlines from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithBullets = '<html><body><ol class="list-number1" start="1"><li><span class="b s i u"><b><i><s><u>bold strikethrough italics underline</u></s><i/></b></span> line <span class="b"><b>1bold</b></span></li></ol><br/><span class="i"><i><ol class="list-number1" start="2"><li>number 10 line 2</li><ol class="list-number2"><li>number 2 times line 1</li></ol></ol></i></span><br/><ol class="list-bullet1"><ol class="list-number2"><li>number 2 times line 2</li></ol></ol></body></html>' + importrequest(htmlWithBullets,importurl,"html") + expect(getinnertext()).to.be('\ +<ol class="list-number1"><li><span class="b i s u"><b><i><s><u>bold strikethrough italics underline</u></s></i></b></span><span class=""> line </span><span class="b"><b>1bold</b></span></li></ol>\n\ +<br>\n\ +<ol class="list-number1"><li><span class="i"><i>number 10 line 2</i></span></li></ol>\n\ +<ol class="list-number2"><li><span class="i"><i>number 2 times line 1</i></span></li></ol>\n\ +<br>\n\ +<ol class="list-number2"><li><span class="">number 2 times line 2</span></li></ol>\n\ +<br>\n') + var results = exportfunc(helper.padChrome$.window.location.href) + console.error(results) + done() + }) +}) diff --git a/tests/frontend/specs/importindents.js b/tests/frontend/specs/importindents.js new file mode 100644 index 00000000..db2b33b0 --- /dev/null +++ b/tests/frontend/specs/importindents.js @@ -0,0 +1,111 @@ +describe("import indents functionality", function(){ + beforeEach(function(cb){ + helper.newPad(cb); // creates a new pad + this.timeout(60000); + }); + + function getinnertext(){ + var inner = helper.padInner$ + var newtext = "" + inner("div").each(function(line,el){ + newtext += el.innerHTML+"\n" + }) + return newtext + } + function importrequest(data,importurl,type){ + var success; + var error; + var result = $.ajax({ + url: importurl, + type: "post", + processData: false, + async: false, + contentType: 'multipart/form-data; boundary=boundary', + accepts: { + text: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" + }, + data: 'Content-Type: multipart/form-data; boundary=--boundary\r\n\r\n--boundary\r\nContent-Disposition: form-data; name="file"; filename="import.'+type+'"\r\nContent-Type: text/plain\r\n\r\n' + data + '\r\n\r\n--boundary', + error: function(res){ + error = res + } + }) + expect(error).to.be(undefined) + return result + } + function exportfunc(link){ + var exportresults = [] + $.ajaxSetup({ + async:false + }) + $.get(link+"/export/html",function(data){ + var start = data.indexOf("<body>") + var end = data.indexOf("</body>") + var html = data.substr(start+6,end-start-6) + exportresults.push(["html",html]) + }) + $.get(link+"/export/txt",function(data){ + exportresults.push(["txt",data]) + }) + return exportresults + } + + it("import a pad with indents from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li><li>indent line 2</li><ul class="list-indent2"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul></body></html>' + importrequest(htmlWithIndents,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('\ +<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n\ +<ul class="list-indent1"><li><span class="">indent line 2</span></li></ul>\n\ +<ul class="list-indent2"><li><span class="">indent2 line 1</span></li></ul>\n\ +<ul class="list-indent2"><li><span class="">indent2 line 2</span></li></ul>\n\ +<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li><li>indent line 2</li><ul class="indent"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul><br>') + expect(results[1][1]).to.be('\tindent line 1\n\tindent line 2\n\t\tindent2 line 1\n\t\tindent2 line 2\n\n') + done() + }) + + it("import a pad with indented lists and newlines from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/><ul class="list-indent1"><li>indent 1 line 2</li><ul class="list-indent2"><li>indent 2 times line 1</li></ul></ul><br/><ul class="list-indent1"><ul class="list-indent2"><li>indent 2 times line 2</li></ul></ul></body></html>' + importrequest(htmlWithIndents,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('\ +<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n\ +<br>\n\ +<ul class="list-indent1"><li><span class="">indent 1 line 2</span></li></ul>\n\ +<ul class="list-indent2"><li><span class="">indent 2 times line 1</span></li></ul>\n\ +<br>\n\ +<ul class="list-indent2"><li><span class="">indent 2 times line 2</span></li></ul>\n\ +<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li></ul><br><ul class="indent"><li>indent 1 line 2</li><ul class="indent"><li>indent 2 times line 1</li></ul></ul><br><ul><ul class="indent"><li>indent 2 times line 2</li></ul></ul><br>') + expect(results[1][1]).to.be('\tindent line 1\n\n\tindent 1 line 2\n\t\tindent 2 times line 1\n\n\t\tindent 2 times line 2\n\n') + done() + }) + it("import a pad with 8 levels of indents and newlines and attributes from html", function(done){ + var importurl = helper.padChrome$.window.location.href+'/import' + var htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/><ul class="list-indent1"><li>indent line 2</li><ul class="list-indent2"><li>indent2 line 1</li></ul></ul><br/><ul class="list-indent1"><ul class="list-indent2"><ul class="list-indent3"><ul class="list-indent4"><li><span class="b s i u"><b><i><s><u>indent4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>indent4 line 2 bs</s></b></span></li><li><span class="u"><u>indent4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li><ul class="list-indent5"><ul class="list-indent6"><ul class="list-indent7"><ul class="list-indent8"><li><span class="">foo</span></li><li><span class="b s"><b><s>foobar bs</b></s></span></li></ul></ul></ul></ul><ul class="list-indent5"><li>foobar</li></ul></ul></ul></ul></body></html>' + importrequest(htmlWithIndents,importurl,"html") + helper.waitFor(function(){ + return expect(getinnertext()).to.be('\ +<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n\<br>\n\ +<ul class="list-indent1"><li><span class="">indent line 2</span></li></ul>\n\ +<ul class="list-indent2"><li><span class="">indent2 line 1</span></li></ul>\n<br>\n\ +<ul class="list-indent4"><li><span class="b i s u"><b><i><s><u>indent4 line 2 bisu</u></s></i></b></span></li></ul>\n\ +<ul class="list-indent4"><li><span class="b s"><b><s>indent4 line 2 bs</s></b></span></li></ul>\n\ +<ul class="list-indent4"><li><span class="u"><u>indent4 line 2 u</u></span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n\ +<ul class="list-indent8"><li><span class="">foo</span></li></ul>\n\ +<ul class="list-indent8"><li><span class="b s"><b><s>foobar bs</s></b></span></li></ul>\n\ +<ul class="list-indent5"><li><span class="">foobar</span></li></ul>\n\ +<br>\n') + }) + var results = exportfunc(helper.padChrome$.window.location.href) + expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li></ul><br><ul class="indent"><li>indent line 2</li><ul class="indent"><li>indent2 line 1</li></ul></ul><br><ul><ul><ul><ul class="indent"><li><strong><em><s><u>indent4 line 2 bisu</u></s></em></strong></li><li><strong><s>indent4 line 2 bs</s></strong></li><li><u>indent4 line 2 u<em><s>uis</s></em></u></li><ul><ul><ul><ul class="indent"><li>foo</li><li><strong><s>foobar bs</s></strong></li></ul></ul></ul><li>foobar</li></ul></ul></ul></ul></ul><br>') + expect(results[1][1]).to.be('\tindent line 1\n\n\tindent line 2\n\t\tindent2 line 1\n\n\t\t\t\tindent4 line 2 bisu\n\t\t\t\tindent4 line 2 bs\n\t\t\t\tindent4 line 2 uuis\n\t\t\t\t\t\t\t\tfoo\n\t\t\t\t\t\t\t\tfoobar bs\n\t\t\t\t\tfoobar\n\n') + done() + }) +}) diff --git a/tests/frontend/specs/indentation.js b/tests/frontend/specs/indentation.js index 3d14a7a8..8e851d87 100644 --- a/tests/frontend/specs/indentation.js +++ b/tests/frontend/specs/indentation.js @@ -15,7 +15,7 @@ describe("indentation button", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$.browser.mozilla){ // if it's a mozilla browser + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/italic.js b/tests/frontend/specs/italic.js index 29dbae59..bf7f2bc6 100644 --- a/tests/frontend/specs/italic.js +++ b/tests/frontend/specs/italic.js @@ -44,7 +44,7 @@ describe("italic some text", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$.browser.mozilla){ // if it's a mozilla browser + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/redo.js b/tests/frontend/specs/redo.js index c2f8a95a..caa32fee 100644 --- a/tests/frontend/specs/redo.js +++ b/tests/frontend/specs/redo.js @@ -47,7 +47,7 @@ describe("undo button then redo button", function(){ var modifiedValue = $firstTextElement.text(); // get the modified value expect(modifiedValue).not.to.be(originalValue); // expect the value to change - if(inner$.browser.mozilla){ // if it's a mozilla browser + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/responsiveness.js b/tests/frontend/specs/responsiveness.js index 44bdd611..ff7dace1 100644 --- a/tests/frontend/specs/responsiveness.js +++ b/tests/frontend/specs/responsiveness.js @@ -19,7 +19,7 @@ describe('Responsiveness of Editor', function() { helper.newPad(cb); this.timeout(6000); }); - it('Fast response to keypress in pad with large amount of contents', function(done) { + xit('Fast response to keypress in pad with large amount of contents', function(done) { var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; var chars = '0000000000'; // row of placeholder chars diff --git a/tests/frontend/specs/timeslider_revisions.js b/tests/frontend/specs/timeslider_revisions.js index 67938134..2afd2e9d 100644 --- a/tests/frontend/specs/timeslider_revisions.js +++ b/tests/frontend/specs/timeslider_revisions.js @@ -4,7 +4,8 @@ describe("timeslider", function(){ helper.newPad(cb); this.timeout(6000); }); - it("loads adds a hundred revisions", function(done) { + + it("loads adds a hundred revisions", function(done) { // passes var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; @@ -18,6 +19,7 @@ describe("timeslider", function(){ inner$("div").first().sendkeys('a'); }, timePerRev*i); } + chrome$('.buttonicon-savedRevision').click(); setTimeout(function() { // go to timeslider @@ -50,13 +52,18 @@ describe("timeslider", function(){ setTimeout(function() { //make sure the text has changed expect( timeslider$('#padcontent').text() ).not.to.eql( latestContents ); + var starIsVisible = timeslider$('.star').is(":visible"); + expect( starIsVisible ).to.eql( true ); done(); }, 1000); }, 6000); }, revs*timePerRev); }); - it("changes the url when clicking on the timeslider", function(done) { + + + // Disabled as jquery trigger no longer works properly + xit("changes the url when clicking on the timeslider", function(done) { var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; @@ -80,7 +87,6 @@ describe("timeslider", function(){ var $sliderBar = timeslider$('#ui-slider-bar'); var latestContents = timeslider$('#padcontent').text(); - var oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash; // Click somewhere on the timeslider @@ -111,6 +117,7 @@ describe("timeslider", function(){ var oldLength = inner$('body').text().length + newLines / 2; expect( oldLength ).to.not.eql( 0 ); inner$("div").first().sendkeys('a'); + var timeslider$; // wait for our additional revision to be added helper.waitFor(function(){ @@ -140,6 +147,7 @@ describe("timeslider", function(){ }); }); }); + it("checks the export url", function(done) { var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; diff --git a/tests/frontend/specs/undo.js b/tests/frontend/specs/undo.js index 0c58c9b8..b8b7c785 100644 --- a/tests/frontend/specs/undo.js +++ b/tests/frontend/specs/undo.js @@ -44,7 +44,7 @@ describe("undo button", function(){ var modifiedValue = $firstTextElement.text(); // get the modified value expect(modifiedValue).not.to.be(originalValue); // expect the value to change - if(inner$.browser.mozilla){ // if it's a mozilla browser + if(inner$(window)[0].bowser.firefox){ // if it's a mozilla browser var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/unordered_list.js b/tests/frontend/specs/unordered_list.js new file mode 100644 index 00000000..4ea77b8a --- /dev/null +++ b/tests/frontend/specs/unordered_list.js @@ -0,0 +1,35 @@ +describe("assign unordered list", function(){ + //create a new pad before each test run + beforeEach(function(cb){ + helper.newPad(cb); + this.timeout(60000); + }); + + it("insert unordered list text then removes by outdent", function(done){ + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + var originalText = inner$("div").first().text(); + + var $insertunorderedlistButton = chrome$(".buttonicon-insertunorderedlist"); + $insertunorderedlistButton.click(); + + helper.waitFor(function(){ + var newText = inner$("div").first().text(); + if(newText === originalText){ + return inner$("div").first().find("ul li").length === 1; + } + }).done(function(){ + + // remove indentation by bullet and ensure text string remains the same + chrome$(".buttonicon-outdent").click(); + helper.waitFor(function(){ + var newText = inner$("div").first().text(); + return (newText === originalText); + }).done(function(){ + done(); + }); + + }); + }); + +}); |