pad.pub0.org/tests/frontend/specs/chat_load_messages.js

89 lines
2.6 KiB
JavaScript
Raw Normal View History

2013-01-13 09:39:13 +00:00
describe("chat-load-messages", function(){
var padName;
it("creates a pad", function(done) {
padName = helper.newPad(done);
this.timeout(60000);
2013-01-13 09:39:13 +00:00
});
it("adds a lot of messages", function(done) {
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;
2013-01-13 09:39:13 +00:00
var chatButton = chrome$("#chaticon");
chatButton.click();
var chatInput = chrome$("#chatinput");
var chatText = chrome$("#chattext");
this.timeout(60000);
2013-01-13 09:39:13 +00:00
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;
}, 60000).always(function(){
expect(chatText.children("p").length).to.be(messages);
helper.newPad(done, padName);
});
2013-01-13 09:39:13 +00:00
});
it("checks initial message count", function(done) {
var chatText;
var expectedCount = 101;
var chrome$ = helper.padChrome$;
helper.waitFor(function(){
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 09:39:13 +00:00
});
it("loads more messages", function(done) {
var expectedCount = 122;
var chrome$ = helper.padChrome$;
2013-01-13 09:39:13 +00:00
var chatButton = chrome$("#chaticon");
chatButton.click();
var chatText = chrome$("#chattext");
var loadMsgBtn = chrome$("#chatloadmessagesbutton");
2013-01-13 09:39:13 +00:00
loadMsgBtn.click();
helper.waitFor(function(){
return chatText.children("p").length == expectedCount;
}).always(function(){
expect(chatText.children("p").length).to.be(expectedCount);
done();
});
2013-01-13 09:39:13 +00:00
});
it("checks for button vanishing", function(done) {
var expectedDisplay = 'none';
var chrome$ = helper.padChrome$;
2013-01-13 09:39:13 +00:00
var chatButton = chrome$("#chaticon");
chatButton.click();
var chatText = chrome$("#chattext");
var loadMsgBtn = chrome$("#chatloadmessagesbutton");
var loadMsgBall = chrome$("#chatloadmessagesball");
2013-01-13 09:39:13 +00:00
loadMsgBtn.click();
helper.waitFor(function(){
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();
});
2013-01-13 09:39:13 +00:00
});
});