2012-10-09 17:04:11 +02:00
|
|
|
describe("change username value", function(){
|
|
|
|
//create a new pad before each test run
|
|
|
|
beforeEach(function(cb){
|
|
|
|
helper.newPad(cb);
|
2012-11-02 00:19:59 +01:00
|
|
|
this.timeout(60000);
|
2012-10-09 17:04:11 +02:00
|
|
|
});
|
|
|
|
|
2012-11-04 00:52:17 +01:00
|
|
|
it("Remembers the user name after a refresh", function(done) {
|
|
|
|
this.timeout(60000);
|
2012-10-30 18:45:37 +01:00
|
|
|
var chrome$ = helper.padChrome$;
|
2012-10-09 17:04:11 +02:00
|
|
|
|
|
|
|
//click on the settings button to make settings visible
|
|
|
|
var $userButton = chrome$(".buttonicon-showusers");
|
|
|
|
$userButton.click();
|
|
|
|
|
|
|
|
var $usernameInput = chrome$("#myusernameedit");
|
|
|
|
$usernameInput.click();
|
|
|
|
|
2012-11-04 00:52:17 +01:00
|
|
|
$usernameInput.val('John McLear');
|
|
|
|
$usernameInput.blur();
|
2012-10-28 18:52:40 +01:00
|
|
|
|
2012-11-04 00:52:17 +01:00
|
|
|
setTimeout(function(){ //give it a second to save the username on the server side
|
|
|
|
helper.newPad({ // get a new pad, but don't clear the cookies
|
|
|
|
clearCookies: false
|
|
|
|
, cb: function(){
|
|
|
|
var chrome$ = helper.padChrome$;
|
2012-10-09 17:04:11 +02:00
|
|
|
|
2012-11-04 00:52:17 +01:00
|
|
|
//click on the settings button to make settings visible
|
|
|
|
var $userButton = chrome$(".buttonicon-showusers");
|
|
|
|
$userButton.click();
|
2012-10-28 18:52:40 +01:00
|
|
|
|
2012-11-04 00:52:17 +01:00
|
|
|
var $usernameInput = chrome$("#myusernameedit");
|
|
|
|
expect($usernameInput.val()).to.be('John McLear')
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 0);
|
2012-10-30 18:45:37 +01:00
|
|
|
});
|
2012-10-09 17:04:11 +02:00
|
|
|
|
2012-10-28 18:47:17 +01:00
|
|
|
|
2012-11-04 00:52:17 +01:00
|
|
|
it("Own user name is shown when you enter a chat", function(done) {
|
2012-10-30 18:45:37 +01:00
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
2012-10-28 18:47:17 +01:00
|
|
|
|
2012-11-04 00:52:17 +01:00
|
|
|
//click on the settings button to make settings visible
|
|
|
|
var $userButton = chrome$(".buttonicon-showusers");
|
|
|
|
$userButton.click();
|
|
|
|
|
|
|
|
var $usernameInput = chrome$("#myusernameedit");
|
|
|
|
$usernameInput.click();
|
|
|
|
|
|
|
|
$usernameInput.val('John McLear');
|
|
|
|
$usernameInput.blur();
|
|
|
|
|
2012-10-28 18:47:17 +01:00
|
|
|
//click on the chat button to make chat visible
|
|
|
|
var $chatButton = chrome$("#chaticon");
|
|
|
|
$chatButton.click();
|
|
|
|
var $chatInput = chrome$("#chatinput");
|
|
|
|
$chatInput.sendkeys('O hi'); // 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");
|
2012-10-30 18:45:37 +01:00
|
|
|
var containsJohnMcLear = $firstChatMessage.text().indexOf("John McLear") !== -1; // does the string contain John McLear
|
2012-10-28 18:47:17 +01:00
|
|
|
expect(containsJohnMcLear).to.be(true); // expect the first chat message to contain JohnMcLear
|
2012-11-03 23:36:36 +01:00
|
|
|
done();
|
2012-10-30 18:45:37 +01:00
|
|
|
});
|
2012-10-09 17:04:11 +02:00
|
|
|
});
|
|
|
|
});
|