summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2013-03-13 15:00:04 -0300
committerJohn McLear <john@mclear.co.uk>2013-03-13 15:00:04 -0300
commitb4ec07312b8926f29623f23548dfc0b2b6554902 (patch)
tree16357d96a4918cc0222502d5b08dbd96acf0b693
parentacb4b4ebafd366c85662cf5de2a9b15df7eb170b (diff)
downloadetherpad-lite-b4ec07312b8926f29623f23548dfc0b2b6554902.zip
add keystroke tests for relevant buttonpresses and change naming schema to something more sane
-rw-r--r--tests/frontend/specs/alphabet.js (renamed from tests/frontend/specs/keystroke_alphabet.js)0
-rw-r--r--tests/frontend/specs/bold.js (renamed from tests/frontend/specs/button_bold.js)37
-rw-r--r--tests/frontend/specs/button_italic.js36
-rw-r--r--tests/frontend/specs/chat.js (renamed from tests/frontend/specs/keystroke_chat.js)35
-rw-r--r--tests/frontend/specs/chat_always_on_screen.js40
-rw-r--r--tests/frontend/specs/clear_authorship_colors.js (renamed from tests/frontend/specs/button_clear_authorship_colors.js)0
-rw-r--r--tests/frontend/specs/delete.js (renamed from tests/frontend/specs/keystroke_delete.js)0
-rw-r--r--tests/frontend/specs/enter.js (renamed from tests/frontend/specs/keystroke_enter.js)0
-rw-r--r--tests/frontend/specs/indentation.js (renamed from tests/frontend/specs/button_indentation.js)22
-rw-r--r--tests/frontend/specs/italic.js67
-rw-r--r--tests/frontend/specs/language.js3
-rw-r--r--tests/frontend/specs/ordered_list.js (renamed from tests/frontend/specs/button_ordered_list.js)0
-rw-r--r--tests/frontend/specs/redo.js (renamed from tests/frontend/specs/button_redo.js)35
-rw-r--r--tests/frontend/specs/strikethrough.js (renamed from tests/frontend/specs/button_strikethrough.js)0
-rw-r--r--tests/frontend/specs/timeslider.js (renamed from tests/frontend/specs/button_timeslider.js)0
-rw-r--r--tests/frontend/specs/undo.js (renamed from tests/frontend/specs/button_undo.js)32
-rw-r--r--tests/frontend/specs/urls_become_clickable.js (renamed from tests/frontend/specs/keystroke_urls_become_clickable.js)0
17 files changed, 222 insertions, 85 deletions
diff --git a/tests/frontend/specs/keystroke_alphabet.js b/tests/frontend/specs/alphabet.js
index 131a81c0..131a81c0 100644
--- a/tests/frontend/specs/keystroke_alphabet.js
+++ b/tests/frontend/specs/alphabet.js
diff --git a/tests/frontend/specs/button_bold.js b/tests/frontend/specs/bold.js
index 1feafe61..b5d2a212 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 <b> 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 fc2e15a7..00000000
--- 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 <i> 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
index e4908728..a488193f 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 4873763f..00000000
--- 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
index 5db35612..5db35612 100644
--- a/tests/frontend/specs/button_clear_authorship_colors.js
+++ b/tests/frontend/specs/clear_authorship_colors.js
diff --git a/tests/frontend/specs/keystroke_delete.js b/tests/frontend/specs/delete.js
index 86e76f56..86e76f56 100644
--- a/tests/frontend/specs/keystroke_delete.js
+++ b/tests/frontend/specs/delete.js
diff --git a/tests/frontend/specs/keystroke_enter.js b/tests/frontend/specs/enter.js
index e46b1d2f..e46b1d2f 100644
--- a/tests/frontend/specs/keystroke_enter.js
+++ b/tests/frontend/specs/enter.js
diff --git a/tests/frontend/specs/button_indentation.js b/tests/frontend/specs/indentation.js
index 9c8e317e..06d90aa8 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 00000000..052d2df4
--- /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 <i> 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 <i> 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 ab7f2b3d..d607ff98 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
index ca7d755e..ca7d755e 100644
--- a/tests/frontend/specs/button_ordered_list.js
+++ b/tests/frontend/specs/ordered_list.js
diff --git a/tests/frontend/specs/button_redo.js b/tests/frontend/specs/redo.js
index 3ce69142..c1497221 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
index 9afcea0f..9afcea0f 100644
--- a/tests/frontend/specs/button_strikethrough.js
+++ b/tests/frontend/specs/strikethrough.js
diff --git a/tests/frontend/specs/button_timeslider.js b/tests/frontend/specs/timeslider.js
index cb37bacb..cb37bacb 100644
--- a/tests/frontend/specs/button_timeslider.js
+++ b/tests/frontend/specs/timeslider.js
diff --git a/tests/frontend/specs/button_undo.js b/tests/frontend/specs/undo.js
index 412b786b..8ba752ac 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
index 8c72d748..8c72d748 100644
--- a/tests/frontend/specs/keystroke_urls_become_clickable.js
+++ b/tests/frontend/specs/urls_become_clickable.js