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