diff options
author | John McLear <john@mclear.co.uk> | 2013-01-13 10:31:45 -0800 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2013-01-13 10:31:45 -0800 |
commit | 33e0ec209779ed04960718782ac32f122ad42726 (patch) | |
tree | 90852901d26379fef7bf3d4a05160bfe47906cb6 /tests | |
parent | 6104987a4bae71f23fc237ac1651af195ce323b8 (diff) | |
parent | 21b99ccd53623439739929cc389e7330c66e7ede (diff) | |
download | etherpad-lite-33e0ec209779ed04960718782ac32f122ad42726.zip |
Merge pull request #1334 from mluto/load-more-chat-messages
Load more than 100 chat messages using a 'load more'-link
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/specs/chat_load_messages.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/frontend/specs/chat_load_messages.js b/tests/frontend/specs/chat_load_messages.js new file mode 100644 index 00000000..8dc98691 --- /dev/null +++ b/tests/frontend/specs/chat_load_messages.js @@ -0,0 +1,85 @@ +describe("chat-load-messages", function(){ + it("creates a pad", function(done) { + helper.newPad(done); + }); + + it("adds a lot of messages", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + var chatButton = chrome$("#chaticon"); + chatButton.click(); + var chatInput = chrome$("#chatinput"); + var chatText = chrome$("#chattext"); + + var messages = 140; + for(var i=1; i <= messages; i++) { + var num = ''+i; + if(num.length == 1) + num = '00'+num; + if(num.length == 2) + num = '0'+num; + chatInput.sendkeys('msg' + num); + chatInput.sendkeys('{enter}'); + } + helper.waitFor(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(); + }); + }); + + it("checks initial message count", function(done) { + var chatText; + var expectedCount = 101; + 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"); + return chatText.children("p").length == expectedCount; + }).always(function(){ + expect(chatText.children("p").length).to.be(expectedCount); + done(); + }); + }); + + it("loads more messages", function(done) { + var expectedCount = 122; + var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; + var chatButton = chrome$("#chaticon"); + chatButton.click(); + var chatText = chrome$("#chattext"); + var loadMsgBtn = chrome$("#chatloadmessagesbutton"); + + loadMsgBtn.click(); + helper.waitFor(function(){ + return chatText.children("p").length == expectedCount; + }).always(function(){ + expect(chatText.children("p").length).to.be(expectedCount); + done(); + }); + }); + + it("checks for button vanishing", function(done) { + var expectedDisplay = 'none'; + var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; + var chatButton = chrome$("#chaticon"); + chatButton.click(); + var chatText = chrome$("#chattext"); + var loadMsgBtn = chrome$("#chatloadmessagesbutton"); + + loadMsgBtn.click(); + helper.waitFor(function(){ + return loadMsgBtn.css('display') == expectedDisplay; + }).always(function(){ + expect(loadMsgBtn.css('display')).to.be(expectedDisplay); + done(); + }); + }); +}); |