From b4ec07312b8926f29623f23548dfc0b2b6554902 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 13 Mar 2013 15:00:04 -0300 Subject: [PATCH 1/3] add keystroke tests for relevant buttonpresses and change naming schema to something more sane --- .../{keystroke_alphabet.js => alphabet.js} | 0 .../specs/{button_bold.js => bold.js} | 37 +++++++++- tests/frontend/specs/button_italic.js | 36 ---------- .../specs/{keystroke_chat.js => chat.js} | 35 +++++++++- tests/frontend/specs/chat_always_on_screen.js | 40 ----------- ...p_colors.js => clear_authorship_colors.js} | 0 .../specs/{keystroke_delete.js => delete.js} | 0 .../specs/{keystroke_enter.js => enter.js} | 0 .../{button_indentation.js => indentation.js} | 22 +++++- tests/frontend/specs/italic.js | 67 +++++++++++++++++++ tests/frontend/specs/language.js | 3 +- ...button_ordered_list.js => ordered_list.js} | 0 .../specs/{button_redo.js => redo.js} | 35 +++++++++- ...tton_strikethrough.js => strikethrough.js} | 0 .../{button_timeslider.js => timeslider.js} | 0 .../specs/{button_undo.js => undo.js} | 32 ++++++++- ..._clickable.js => urls_become_clickable.js} | 0 17 files changed, 222 insertions(+), 85 deletions(-) rename tests/frontend/specs/{keystroke_alphabet.js => alphabet.js} (100%) rename tests/frontend/specs/{button_bold.js => bold.js} (51%) delete mode 100644 tests/frontend/specs/button_italic.js rename tests/frontend/specs/{keystroke_chat.js => chat.js} (69%) delete mode 100644 tests/frontend/specs/chat_always_on_screen.js rename tests/frontend/specs/{button_clear_authorship_colors.js => clear_authorship_colors.js} (100%) rename tests/frontend/specs/{keystroke_delete.js => delete.js} (100%) rename tests/frontend/specs/{keystroke_enter.js => enter.js} (100%) rename tests/frontend/specs/{button_indentation.js => indentation.js} (90%) create mode 100644 tests/frontend/specs/italic.js rename tests/frontend/specs/{button_ordered_list.js => ordered_list.js} (100%) rename tests/frontend/specs/{button_redo.js => redo.js} (50%) rename tests/frontend/specs/{button_strikethrough.js => strikethrough.js} (100%) rename tests/frontend/specs/{button_timeslider.js => timeslider.js} (100%) rename tests/frontend/specs/{button_undo.js => undo.js} (50%) rename tests/frontend/specs/{keystroke_urls_become_clickable.js => urls_become_clickable.js} (100%) diff --git a/tests/frontend/specs/keystroke_alphabet.js b/tests/frontend/specs/alphabet.js similarity index 100% rename from tests/frontend/specs/keystroke_alphabet.js rename to tests/frontend/specs/alphabet.js diff --git a/tests/frontend/specs/button_bold.js b/tests/frontend/specs/bold.js similarity index 51% rename from tests/frontend/specs/button_bold.js rename to tests/frontend/specs/bold.js index 1feafe614..b5d2a212b 100644 --- a/tests/frontend/specs/button_bold.js +++ b/tests/frontend/specs/bold.js @@ -5,7 +5,7 @@ describe("bold button", function(){ this.timeout(60000); }); - it("makes text bold", function(done) { + it("makes text bold on click", function(done) { var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; @@ -33,4 +33,37 @@ describe("bold button", function(){ done(); }); -}); \ No newline at end of file + + it("makes text bold on keypress", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + //get the first text element out of the inner iframe + var $firstTextElement = inner$("div").first(); + + //select this text element + $firstTextElement.sendkeys('{selectall}'); + + var e = inner$.Event("keydown"); + e.ctrlKey = true; // Control key + e.which = 66; // z + inner$("#innerdocbody").trigger(e); + + //ace creates a new dom element when you press a button, so just get the first text element again + var $newFirstTextElement = inner$("div").first(); + + // is there a element now? + var isBold = $newFirstTextElement.find("b").length === 1; + + //expect it to be bold + expect(isBold).to.be(true); + + //make sure the text hasn't changed + expect($newFirstTextElement.text()).to.eql($firstTextElement.text()); + + done(); + }); + + + +}); diff --git a/tests/frontend/specs/button_italic.js b/tests/frontend/specs/button_italic.js deleted file mode 100644 index fc2e15a79..000000000 --- a/tests/frontend/specs/button_italic.js +++ /dev/null @@ -1,36 +0,0 @@ -describe("italic button", function(){ - //create a new pad before each test run - beforeEach(function(cb){ - helper.newPad(cb); - this.timeout(60000); - }); - - it("makes text italic", function(done) { - var inner$ = helper.padInner$; - var chrome$ = helper.padChrome$; - - //get the first text element out of the inner iframe - var $firstTextElement = inner$("div").first(); - - //select this text element - $firstTextElement.sendkeys('{selectall}'); - - //get the bold button and click it - var $boldButton = chrome$(".buttonicon-italic"); - $boldButton.click(); - - //ace creates a new dom element when you press a button, so just get the first text element again - var $newFirstTextElement = inner$("div").first(); - - // is there a element now? - var isItalic = $newFirstTextElement.find("i").length === 1; - - //expect it to be bold - expect(isItalic).to.be(true); - - //make sure the text hasn't changed - expect($newFirstTextElement.text()).to.eql($firstTextElement.text()); - - done(); - }); -}); diff --git a/tests/frontend/specs/keystroke_chat.js b/tests/frontend/specs/chat.js similarity index 69% rename from tests/frontend/specs/keystroke_chat.js rename to tests/frontend/specs/chat.js index e49087286..a488193f7 100644 --- a/tests/frontend/specs/keystroke_chat.js +++ b/tests/frontend/specs/chat.js @@ -1,4 +1,4 @@ -describe("send chat message", function(){ +describe("Chat messages and UI", function(){ //create a new pad before each test run beforeEach(function(cb){ helper.newPad(cb); @@ -64,5 +64,36 @@ describe("send chat message", function(){ }); }); -}); + it("makes chat stick to right side of the screen", 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 + $stickychatCheckbox.attr('selected','selected'); + $stickychatCheckbox.change(); + $stickychatCheckbox.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/chat_always_on_screen.js b/tests/frontend/specs/chat_always_on_screen.js deleted file mode 100644 index 4873763fe..000000000 --- a/tests/frontend/specs/chat_always_on_screen.js +++ /dev/null @@ -1,40 +0,0 @@ -describe("chat always ons creen select", function(){ - //create a new pad before each test run - beforeEach(function(cb){ - helper.newPad(cb); - this.timeout(60000); - }); - - it("makes chat stick to right side of the screen", 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 - $stickychatCheckbox.attr('selected','selected'); - $stickychatCheckbox.change(); - $stickychatCheckbox.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/button_clear_authorship_colors.js b/tests/frontend/specs/clear_authorship_colors.js similarity index 100% rename from tests/frontend/specs/button_clear_authorship_colors.js rename to tests/frontend/specs/clear_authorship_colors.js diff --git a/tests/frontend/specs/keystroke_delete.js b/tests/frontend/specs/delete.js similarity index 100% rename from tests/frontend/specs/keystroke_delete.js rename to tests/frontend/specs/delete.js diff --git a/tests/frontend/specs/keystroke_enter.js b/tests/frontend/specs/enter.js similarity index 100% rename from tests/frontend/specs/keystroke_enter.js rename to tests/frontend/specs/enter.js diff --git a/tests/frontend/specs/button_indentation.js b/tests/frontend/specs/indentation.js similarity index 90% rename from tests/frontend/specs/button_indentation.js rename to tests/frontend/specs/indentation.js index 9c8e317e6..06d90aa86 100644 --- a/tests/frontend/specs/button_indentation.js +++ b/tests/frontend/specs/indentation.js @@ -5,7 +5,26 @@ describe("indentation button", function(){ this.timeout(60000); }); - it("indent text", function(done){ + it("indent text with keypress", function(done){ + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + //get the first text element out of the inner iframe + var $firstTextElement = inner$("div").first(); + + //select this text element + $firstTextElement.sendkeys('{selectall}'); + + var e = inner$.Event("keydown"); + e.keyCode = 9; // tab :| + inner$("#innerdocbody").trigger(e); + + helper.waitFor(function(){ + return inner$("div").first().find("ul li").length === 1; + }).done(done); + }); + + it("indent text with button", function(done){ var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; @@ -176,4 +195,5 @@ describe("indentation button", function(){ expect(isLI).to.be(true); },1000); });*/ + }); diff --git a/tests/frontend/specs/italic.js b/tests/frontend/specs/italic.js new file mode 100644 index 000000000..052d2df4f --- /dev/null +++ b/tests/frontend/specs/italic.js @@ -0,0 +1,67 @@ +describe("italic some text", function(){ + //create a new pad before each test run + beforeEach(function(cb){ + helper.newPad(cb); + this.timeout(60000); + }); + + it("makes text italic using button", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + //get the first text element out of the inner iframe + var $firstTextElement = inner$("div").first(); + + //select this text element + $firstTextElement.sendkeys('{selectall}'); + + //get the bold button and click it + var $boldButton = chrome$(".buttonicon-italic"); + $boldButton.click(); + + //ace creates a new dom element when you press a button, so just get the first text element again + var $newFirstTextElement = inner$("div").first(); + + // is there a element now? + var isItalic = $newFirstTextElement.find("i").length === 1; + + //expect it to be bold + expect(isItalic).to.be(true); + + //make sure the text hasn't changed + expect($newFirstTextElement.text()).to.eql($firstTextElement.text()); + + done(); + }); + + it("makes text italic using keypress", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + //get the first text element out of the inner iframe + var $firstTextElement = inner$("div").first(); + + //select this text element + $firstTextElement.sendkeys('{selectall}'); + + var e = inner$.Event("keydown"); + e.ctrlKey = true; // Control key + e.which = 105; // i + inner$("#innerdocbody").trigger(e); + + //ace creates a new dom element when you press a button, so just get the first text element again + var $newFirstTextElement = inner$("div").first(); + + // is there a element now? + var isItalic = $newFirstTextElement.find("i").length === 1; + + //expect it to be bold + expect(isItalic).to.be(true); + + //make sure the text hasn't changed + expect($newFirstTextElement.text()).to.eql($firstTextElement.text()); + + done(); + }); + +}); diff --git a/tests/frontend/specs/language.js b/tests/frontend/specs/language.js index ab7f2b3d7..d607ff982 100644 --- a/tests/frontend/specs/language.js +++ b/tests/frontend/specs/language.js @@ -13,7 +13,6 @@ describe("Language select and change", function(){ }); // Destroy language cookies - it("makes text german", function(done) { var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; @@ -92,7 +91,7 @@ describe("Language select and change", function(){ var $languageoption = $language.find("[value=ar]"); //select arabic - $languageoption.attr('selected','selected'); + // $languageoption.attr('selected','selected'); // Breaks the test.. $language.val("ar"); $languageoption.change(); diff --git a/tests/frontend/specs/button_ordered_list.js b/tests/frontend/specs/ordered_list.js similarity index 100% rename from tests/frontend/specs/button_ordered_list.js rename to tests/frontend/specs/ordered_list.js diff --git a/tests/frontend/specs/button_redo.js b/tests/frontend/specs/redo.js similarity index 50% rename from tests/frontend/specs/button_redo.js rename to tests/frontend/specs/redo.js index 3ce69142f..c14972219 100644 --- a/tests/frontend/specs/button_redo.js +++ b/tests/frontend/specs/redo.js @@ -4,7 +4,7 @@ describe("undo button then redo button", function(){ this.timeout(60000); }); - it("undo some typing", function(done){ + it("redo some typing with button", function(done){ var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; @@ -33,5 +33,38 @@ describe("undo button then redo button", function(){ done(); }); }); + + it("redo some typing with keypress", function(done){ + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + // get the first text element inside the editable space + var $firstTextElement = inner$("div span").first(); + var originalValue = $firstTextElement.text(); // get the original value + var newString = "Foo"; + + $firstTextElement.sendkeys(newString); // send line 1 to the pad + var modifiedValue = $firstTextElement.text(); // get the modified value + expect(modifiedValue).not.to.be(originalValue); // expect the value to change + + var e = inner$.Event("keydown"); + e.ctrlKey = true; // Control key + e.which = 90; // z + inner$("#innerdocbody").trigger(e); + + var e = inner$.Event("keydown"); + e.ctrlKey = true; // Control key + e.which = 121; // y + inner$("#innerdocbody").trigger(e); + + helper.waitFor(function(){ + console.log(inner$("div span").first().text()); + return inner$("div span").first().text() === newString; + }).done(function(){ + var finalValue = inner$("div").first().text(); + expect(finalValue).to.be(modifiedValue); // expect the value to change + done(); + }); + }); }); diff --git a/tests/frontend/specs/button_strikethrough.js b/tests/frontend/specs/strikethrough.js similarity index 100% rename from tests/frontend/specs/button_strikethrough.js rename to tests/frontend/specs/strikethrough.js diff --git a/tests/frontend/specs/button_timeslider.js b/tests/frontend/specs/timeslider.js similarity index 100% rename from tests/frontend/specs/button_timeslider.js rename to tests/frontend/specs/timeslider.js diff --git a/tests/frontend/specs/button_undo.js b/tests/frontend/specs/undo.js similarity index 50% rename from tests/frontend/specs/button_undo.js rename to tests/frontend/specs/undo.js index 412b786be..8ba752ac5 100644 --- a/tests/frontend/specs/button_undo.js +++ b/tests/frontend/specs/undo.js @@ -4,7 +4,8 @@ describe("undo button", function(){ this.timeout(60000); }); - it("undo some typing", function(done){ +/* + it("undo some typing by clicking undo button", function(done){ var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; @@ -29,5 +30,34 @@ describe("undo button", function(){ done(); }); }); +*/ + + it("undo some typing using a keypress", function(done){ + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + // get the first text element inside the editable space + var $firstTextElement = inner$("div span").first(); + var originalValue = $firstTextElement.text(); // get the original value + + $firstTextElement.sendkeys("foo"); // send line 1 to the pad + var modifiedValue = $firstTextElement.text(); // get the modified value + expect(modifiedValue).not.to.be(originalValue); // expect the value to change + + var e = inner$.Event("keydown"); + e.ctrlKey = true; // Control key + e.which = 90; // z + inner$("#innerdocbody").trigger(e); + + helper.waitFor(function(){ + return inner$("div span").first().text() === originalValue; + }).done(function(){ + var finalValue = inner$("div span").first().text(); + expect(finalValue).to.be(originalValue); // expect the value to change + done(); + }); + }); + + }); diff --git a/tests/frontend/specs/keystroke_urls_become_clickable.js b/tests/frontend/specs/urls_become_clickable.js similarity index 100% rename from tests/frontend/specs/keystroke_urls_become_clickable.js rename to tests/frontend/specs/urls_become_clickable.js From 5690f2d01ea04806ffada6eb395750a8f2007de3 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 13 Mar 2013 15:06:08 -0300 Subject: [PATCH 2/3] not z, is b! --- tests/frontend/specs/bold.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/frontend/specs/bold.js b/tests/frontend/specs/bold.js index b5d2a212b..2fb6bbfeb 100644 --- a/tests/frontend/specs/bold.js +++ b/tests/frontend/specs/bold.js @@ -46,7 +46,7 @@ describe("bold button", function(){ var e = inner$.Event("keydown"); e.ctrlKey = true; // Control key - e.which = 66; // z + e.which = 66; // b inner$("#innerdocbody").trigger(e); //ace creates a new dom element when you press a button, so just get the first text element again @@ -63,7 +63,4 @@ describe("bold button", function(){ done(); }); - - - }); From b81be97f94f1b973a60021e9db7116f8d2b8b039 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 13 Mar 2013 15:08:19 -0300 Subject: [PATCH 3/3] typo --- tests/frontend/specs/enter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/frontend/specs/enter.js b/tests/frontend/specs/enter.js index e46b1d2fe..baafeded2 100644 --- a/tests/frontend/specs/enter.js +++ b/tests/frontend/specs/enter.js @@ -5,7 +5,7 @@ describe("enter keystroke", function(){ this.timeout(60000); }); - it("creates a enw line & puts cursor onto a new line", function(done) { + it("creates a new line & puts cursor onto a new line", function(done) { var inner$ = helper.padInner$; var chrome$ = helper.padChrome$;