2013-03-13 18:00:04 +00:00
|
|
|
describe("Chat messages and UI", function(){
|
2012-10-28 17:38:56 +00:00
|
|
|
//create a new pad before each test run
|
|
|
|
beforeEach(function(cb){
|
|
|
|
helper.newPad(cb);
|
2012-11-01 23:19:59 +00:00
|
|
|
this.timeout(60000);
|
2012-10-28 17:38:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("opens chat, sends a message and makes sure it exists on the page", function(done) {
|
2020-03-24 00:04:24 +00:00
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
2012-10-28 17:38:56 +00:00
|
|
|
var chatValue = "JohnMcLear";
|
|
|
|
|
|
|
|
//click on the chat button to make chat visible
|
|
|
|
var $chatButton = chrome$("#chaticon");
|
|
|
|
$chatButton.click();
|
|
|
|
var $chatInput = chrome$("#chatinput");
|
|
|
|
$chatInput.sendkeys('JohnMcLear'); // simulate a keypress of typing JohnMcLear
|
|
|
|
$chatInput.sendkeys('{enter}'); // simulate a keypress of enter actually does evt.which = 10 not 13
|
|
|
|
|
|
|
|
//check if chat shows up
|
|
|
|
helper.waitFor(function(){
|
|
|
|
return chrome$("#chattext").children("p").length !== 0; // wait until the chat message shows up
|
|
|
|
}).done(function(){
|
|
|
|
var $firstChatMessage = chrome$("#chattext").children("p");
|
|
|
|
var containsMessage = $firstChatMessage.text().indexOf("JohnMcLear") !== -1; // does the string contain JohnMcLear?
|
|
|
|
expect(containsMessage).to.be(true); // expect the first chat message to contain JohnMcLear
|
|
|
|
|
|
|
|
// do a slightly more thorough check
|
|
|
|
var username = $firstChatMessage.children("b");
|
|
|
|
var usernameValue = username.text();
|
|
|
|
var time = $firstChatMessage.children(".time");
|
|
|
|
var timeValue = time.text();
|
2013-03-05 19:01:22 +00:00
|
|
|
var discoveredValue = $firstChatMessage.text();
|
|
|
|
var chatMsgExists = (discoveredValue.indexOf("JohnMcLear") !== -1);
|
|
|
|
expect(chatMsgExists).to.be(true);
|
2012-10-28 17:38:56 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2013-01-14 16:45:11 +00:00
|
|
|
|
|
|
|
it("makes sure that an empty message can't be sent", function(done) {
|
2020-03-24 00:04:24 +00:00
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
2013-12-05 07:41:29 +00:00
|
|
|
|
2013-01-14 16:45:11 +00:00
|
|
|
//click on the chat button to make chat visible
|
|
|
|
var $chatButton = chrome$("#chaticon");
|
|
|
|
$chatButton.click();
|
|
|
|
var $chatInput = chrome$("#chatinput");
|
|
|
|
$chatInput.sendkeys('{enter}'); // simulate a keypress of enter (to send an empty message)
|
|
|
|
$chatInput.sendkeys('mluto'); // simulate a keypress of typing mluto
|
|
|
|
$chatInput.sendkeys('{enter}'); // simulate a keypress of enter (to send 'mluto')
|
|
|
|
|
|
|
|
//check if chat shows up
|
|
|
|
helper.waitFor(function(){
|
|
|
|
return chrome$("#chattext").children("p").length !== 0; // wait until the chat message shows up
|
|
|
|
}).done(function(){
|
|
|
|
// check that the empty message is not there
|
|
|
|
expect(chrome$("#chattext").children("p").length).to.be(1);
|
|
|
|
// check that the received message is not the empty one
|
|
|
|
var $firstChatMessage = chrome$("#chattext").children("p");
|
|
|
|
var containsMessage = $firstChatMessage.text().indexOf("mluto") !== -1;
|
|
|
|
expect(containsMessage).to.be(true);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2013-03-05 19:01:22 +00:00
|
|
|
|
2013-03-13 18:00:04 +00:00
|
|
|
it("makes chat stick to right side of the screen", function(done) {
|
2020-03-24 00:04:24 +00:00
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
2013-03-13 18:00:04 +00:00
|
|
|
|
|
|
|
//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");
|
|
|
|
|
2020-04-18 10:17:14 +00:00
|
|
|
//select chat always on screen
|
|
|
|
if (!$stickychatCheckbox.is(':checked')) {
|
|
|
|
$stickychatCheckbox.click();
|
|
|
|
}
|
|
|
|
|
|
|
|
// due to animation, we need to make some timeout...
|
|
|
|
setTimeout(function() {
|
|
|
|
//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.click();
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
//check if chat changed to remove the stickychat Class
|
|
|
|
var hasStickyChatClass = $chatbox.hasClass("stickyChat");
|
|
|
|
expect(hasStickyChatClass).to.be(false);
|
|
|
|
|
|
|
|
done();
|
|
|
|
}, 10)
|
|
|
|
}, 10)
|
|
|
|
|
|
|
|
|
2013-03-13 18:00:04 +00:00
|
|
|
});
|
2014-12-28 19:25:46 +00:00
|
|
|
|
|
|
|
it("makes chat stick to right side of the screen then makes it one step smaller", function(done) {
|
2020-03-24 00:04:24 +00:00
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
2014-12-28 19:25:46 +00:00
|
|
|
|
2020-04-18 10:17:14 +00:00
|
|
|
// open chat
|
|
|
|
chrome$('#chaticon').click();
|
2014-12-28 19:25:46 +00:00
|
|
|
|
2020-04-18 10:17:14 +00:00
|
|
|
// select chat always on screen from chatbox
|
|
|
|
chrome$('.stick-to-screen-btn').click();
|
2014-12-28 19:25:46 +00:00
|
|
|
|
2020-04-18 10:17:14 +00:00
|
|
|
// due to animation, we need to make some timeout...
|
|
|
|
setTimeout(function() {
|
|
|
|
//check if chat changed to get the stickychat Class
|
|
|
|
var $chatbox = chrome$("#chatbox");
|
|
|
|
var hasStickyChatClass = $chatbox.hasClass("stickyChat");
|
|
|
|
expect(hasStickyChatClass).to.be(true);
|
2014-12-28 19:25:46 +00:00
|
|
|
|
2020-04-18 10:17:14 +00:00
|
|
|
// select chat always on screen and fire change event
|
|
|
|
chrome$('#titlecross').click();
|
2014-12-28 19:25:46 +00:00
|
|
|
|
2020-04-18 10:17:14 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
//check if chat changed to remove the stickychat Class
|
|
|
|
var hasStickyChatClass = $chatbox.hasClass("stickyChat");
|
|
|
|
expect(hasStickyChatClass).to.be(false);
|
2014-12-28 19:25:46 +00:00
|
|
|
|
2020-04-18 10:17:14 +00:00
|
|
|
done();
|
|
|
|
}, 10)
|
|
|
|
}, 10)
|
2014-12-28 19:25:46 +00:00
|
|
|
});
|
2013-03-13 18:00:04 +00:00
|
|
|
});
|