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