2013-01-13 10:39:13 +01:00
|
|
|
describe("chat-load-messages", function(){
|
2013-01-13 11:03:52 +01:00
|
|
|
it("creates a pad", function(done) {
|
2013-01-13 10:39:13 +01:00
|
|
|
helper.newPad(done);
|
|
|
|
});
|
|
|
|
|
2013-01-13 11:03:52 +01:00
|
|
|
it("adds a lot of messages", function(done) {
|
2013-01-13 10:39:13 +01:00
|
|
|
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}');
|
|
|
|
}
|
2013-01-13 11:03:52 +01:00
|
|
|
helper.waitFor(function(){
|
|
|
|
return chatText.children("p").length == messages;
|
2013-01-13 11:29:28 +01:00
|
|
|
}).always(function(){
|
|
|
|
expect(chatText.children("p").length).to.be(messages);
|
2013-01-13 10:39:13 +01:00
|
|
|
$('#iframe-container iframe')[0].contentWindow.location.reload();
|
|
|
|
done();
|
2013-01-13 11:03:52 +01:00
|
|
|
});
|
2013-01-13 10:39:13 +01:00
|
|
|
});
|
|
|
|
|
2013-01-13 11:03:52 +01:00
|
|
|
it("checks initial message count", function(done) {
|
2013-01-13 11:29:28 +01:00
|
|
|
var chatText;
|
|
|
|
var expectedCount = 101;
|
2013-01-13 11:03:52 +01:00
|
|
|
helper.waitFor(function(){
|
2013-01-13 11:29:28 +01:00
|
|
|
// 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();
|
|
|
|
});
|
2013-01-13 10:39:13 +01:00
|
|
|
});
|
|
|
|
|
2013-01-13 11:03:52 +01:00
|
|
|
it("loads more messages", function(done) {
|
2013-01-13 11:29:28 +01:00
|
|
|
var expectedCount = 122;
|
2013-01-13 10:39:13 +01:00
|
|
|
var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
|
|
var chatButton = chrome$("#chaticon");
|
|
|
|
chatButton.click();
|
|
|
|
var chatText = chrome$("#chattext");
|
|
|
|
var loadMsgBtn = chrome$("#chatloadmessagesbutton");
|
|
|
|
|
|
|
|
loadMsgBtn.click();
|
2013-01-13 11:03:52 +01:00
|
|
|
helper.waitFor(function(){
|
2013-01-13 11:29:28 +01:00
|
|
|
return chatText.children("p").length == expectedCount;
|
|
|
|
}).always(function(){
|
|
|
|
expect(chatText.children("p").length).to.be(expectedCount);
|
|
|
|
done();
|
|
|
|
});
|
2013-01-13 10:39:13 +01:00
|
|
|
});
|
|
|
|
|
2013-01-13 11:03:52 +01:00
|
|
|
it("checks for button vanishing", function(done) {
|
2013-01-13 11:29:28 +01:00
|
|
|
var expectedDisplay = 'none';
|
2013-01-13 10:39:13 +01:00
|
|
|
var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
|
|
var chatButton = chrome$("#chaticon");
|
|
|
|
chatButton.click();
|
|
|
|
var chatText = chrome$("#chattext");
|
|
|
|
var loadMsgBtn = chrome$("#chatloadmessagesbutton");
|
|
|
|
|
|
|
|
loadMsgBtn.click();
|
2013-01-13 11:03:52 +01:00
|
|
|
helper.waitFor(function(){
|
2013-01-13 11:29:28 +01:00
|
|
|
return loadMsgBtn.css('display') == expectedDisplay;
|
|
|
|
}).always(function(){
|
|
|
|
expect(loadMsgBtn.css('display')).to.be(expectedDisplay);
|
|
|
|
done();
|
|
|
|
});
|
2013-01-13 10:39:13 +01:00
|
|
|
});
|
|
|
|
});
|