From 09fa1d49a1de70e07d9069e264e9e03211ea1672 Mon Sep 17 00:00:00 2001 From: mluto Date: Tue, 15 Jan 2013 22:17:40 +0100 Subject: [PATCH 1/2] Added ability to load the same pad twice with helper.newPad, use this in load-message-tests --- tests/frontend/helper.js | 11 ++++++----- tests/frontend/specs/chat_load_messages.js | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/frontend/helper.js b/tests/frontend/helper.js index ee57c869..bf5df508 100644 --- a/tests/frontend/helper.js +++ b/tests/frontend/helper.js @@ -56,13 +56,13 @@ var helper = {}; window.document.cookie = ""; } - helper.newPad = function(){ + helper.newPad = function(cb, padName){ //build opts object var opts = {clearCookies: true} - if(typeof arguments[0] === 'function'){ - opts.cb = arguments[0] + if(typeof cb === 'function'){ + opts.cb = cb } else { - opts = _.defaults(arguments[0], opts); + opts = _.defaults(cb, opts); } //clear cookies @@ -70,7 +70,8 @@ var helper = {}; helper.clearCookies(); } - var padName = "FRONTEND_TEST_" + helper.randomString(20); + if(!padName) + padName = "FRONTEND_TEST_" + helper.randomString(20); $iframe = $(""); //clean up inner iframe references diff --git a/tests/frontend/specs/chat_load_messages.js b/tests/frontend/specs/chat_load_messages.js index 8dc98691..cf625dc4 100644 --- a/tests/frontend/specs/chat_load_messages.js +++ b/tests/frontend/specs/chat_load_messages.js @@ -1,6 +1,9 @@ describe("chat-load-messages", function(){ + var padName; + it("creates a pad", function(done) { - helper.newPad(done); + padName = helper.newPad(done); + this.timeout(60000); }); it("adds a lot of messages", function(done) { @@ -11,6 +14,8 @@ describe("chat-load-messages", function(){ var chatInput = chrome$("#chatinput"); var chatText = chrome$("#chattext"); + this.timeout(10000); + var messages = 140; for(var i=1; i <= messages; i++) { var num = ''+i; @@ -25,20 +30,15 @@ describe("chat-load-messages", function(){ return chatText.children("p").length == messages; }).always(function(){ expect(chatText.children("p").length).to.be(messages); - $('#iframe-container iframe')[0].contentWindow.location.reload(); - done(); + helper.newPad(done, padName); }); }); it("checks initial message count", function(done) { var chatText; var expectedCount = 101; + var chrome$ = helper.padChrome$; helper.waitFor(function(){ - // wait for the frame to load - var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; - if(!chrome$) // page not fully loaded - return false; - var chatButton = chrome$("#chaticon"); chatButton.click(); chatText = chrome$("#chattext"); @@ -51,7 +51,7 @@ describe("chat-load-messages", function(){ it("loads more messages", function(done) { var expectedCount = 122; - var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; + var chrome$ = helper.padChrome$; var chatButton = chrome$("#chaticon"); chatButton.click(); var chatText = chrome$("#chattext"); @@ -68,7 +68,7 @@ describe("chat-load-messages", function(){ it("checks for button vanishing", function(done) { var expectedDisplay = 'none'; - var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; + var chrome$ = helper.padChrome$; var chatButton = chrome$("#chaticon"); chatButton.click(); var chatText = chrome$("#chattext"); From ae07b7384004ccffc97fb79ea394e93d6feea8e3 Mon Sep 17 00:00:00 2001 From: mluto Date: Tue, 15 Jan 2013 22:51:53 +0100 Subject: [PATCH 2/2] Increased timeouts to make IE9 happy, made button-test more strict --- tests/frontend/specs/chat_load_messages.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/frontend/specs/chat_load_messages.js b/tests/frontend/specs/chat_load_messages.js index cf625dc4..7b09b47e 100644 --- a/tests/frontend/specs/chat_load_messages.js +++ b/tests/frontend/specs/chat_load_messages.js @@ -14,7 +14,7 @@ describe("chat-load-messages", function(){ var chatInput = chrome$("#chatinput"); var chatText = chrome$("#chattext"); - this.timeout(10000); + this.timeout(60000); var messages = 140; for(var i=1; i <= messages; i++) { @@ -28,7 +28,7 @@ describe("chat-load-messages", function(){ } helper.waitFor(function(){ return chatText.children("p").length == messages; - }).always(function(){ + }, 60000).always(function(){ expect(chatText.children("p").length).to.be(messages); helper.newPad(done, padName); }); @@ -73,12 +73,15 @@ describe("chat-load-messages", function(){ chatButton.click(); var chatText = chrome$("#chattext"); var loadMsgBtn = chrome$("#chatloadmessagesbutton"); + var loadMsgBall = chrome$("#chatloadmessagesball"); loadMsgBtn.click(); helper.waitFor(function(){ - return loadMsgBtn.css('display') == expectedDisplay; + return loadMsgBtn.css('display') == expectedDisplay && + loadMsgBall.css('display') == expectedDisplay; }).always(function(){ expect(loadMsgBtn.css('display')).to.be(expectedDisplay); + expect(loadMsgBall.css('display')).to.be(expectedDisplay); done(); }); });