mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
change_user_name test: refactor
This commit is contained in:
parent
38c9827161
commit
951c93fa6d
2 changed files with 62 additions and 57 deletions
|
@ -77,7 +77,49 @@ helper.settingsMenu = function () { return helper.padChrome$('#settings'); };
|
||||||
*
|
*
|
||||||
* @returns {HTMLElement} the settings button
|
* @returns {HTMLElement} the settings button
|
||||||
*/
|
*/
|
||||||
helper.settingsButton = function () { return helper.padChrome$("button[data-l10n-id='pad.toolbar.settings.title']"); };
|
helper.settingsButton = function () {
|
||||||
|
return helper.padChrome$("button[data-l10n-id='pad.toolbar.settings.title']");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles user list
|
||||||
|
*/
|
||||||
|
helper.toggleUserList = async function () {
|
||||||
|
const isVisible = helper.userListShown();
|
||||||
|
const button = helper.padChrome$("button[data-l10n-id='pad.toolbar.showusers.title']");
|
||||||
|
button.click();
|
||||||
|
await helper.waitForPromise(() => !isVisible);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the user name input field
|
||||||
|
*
|
||||||
|
* @returns {HTMLElement} user name input field
|
||||||
|
*/
|
||||||
|
helper.usernameField = function () {
|
||||||
|
return helper.padChrome$("input[data-l10n-id='pad.userlist.entername']");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the user list popup shown?
|
||||||
|
*
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
helper.userListShown = function () {
|
||||||
|
return helper.padChrome$('div#users').hasClass('popup-show');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the user name
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
helper.setUserName = async (name) => {
|
||||||
|
const userElement = helper.usernameField();
|
||||||
|
userElement.click();
|
||||||
|
userElement.val(name);
|
||||||
|
userElement.blur();
|
||||||
|
await helper.waitForPromise(() => !helper.usernameField().hasClass('editactive'));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the titlecross icon
|
* Gets the titlecross icon
|
||||||
|
|
|
@ -2,70 +2,33 @@ describe('change username value', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(function (cb) {
|
||||||
helper.newPad(cb);
|
helper.newPad(cb);
|
||||||
this.timeout(60000);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Remembers the user name after a refresh', function (done) {
|
it('Remembers the user name after a refresh', async function () {
|
||||||
this.timeout(60000);
|
helper.toggleUserList();
|
||||||
const chrome$ = helper.padChrome$;
|
helper.setUserName('😃');
|
||||||
|
|
||||||
// click on the settings button to make settings visible
|
|
||||||
const $userButton = chrome$('.buttonicon-showusers');
|
|
||||||
$userButton.click();
|
|
||||||
|
|
||||||
const $usernameInput = chrome$('#myusernameedit');
|
|
||||||
$usernameInput.click();
|
|
||||||
|
|
||||||
$usernameInput.val('John McLear');
|
|
||||||
$usernameInput.blur();
|
|
||||||
|
|
||||||
setTimeout(() => { // give it a second to save the username on the server side
|
|
||||||
helper.newPad({ // get a new pad, but don't clear the cookies
|
helper.newPad({ // get a new pad, but don't clear the cookies
|
||||||
clearCookies: false,
|
clearCookies: false,
|
||||||
cb() {
|
cb() {
|
||||||
const chrome$ = helper.padChrome$;
|
helper.toggleUserList();
|
||||||
|
|
||||||
// click on the settings button to make settings visible
|
expect(helper.usernameField().val()).to.be('😃');
|
||||||
const $userButton = chrome$('.buttonicon-showusers');
|
|
||||||
$userButton.click();
|
|
||||||
|
|
||||||
const $usernameInput = chrome$('#myusernameedit');
|
|
||||||
expect($usernameInput.val()).to.be('John McLear');
|
|
||||||
done();
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, 1000);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Own user name is shown when you enter a chat', async function () {
|
||||||
|
helper.toggleUserList();
|
||||||
|
helper.setUserName('😃');
|
||||||
|
|
||||||
it('Own user name is shown when you enter a chat', function (done) {
|
helper.showChat();
|
||||||
const inner$ = helper.padInner$;
|
helper.sendChatMessage('O hi{enter}');
|
||||||
const chrome$ = helper.padChrome$;
|
|
||||||
|
|
||||||
// click on the settings button to make settings visible
|
await helper.waitForPromise(() => {
|
||||||
const $userButton = chrome$('.buttonicon-showusers');
|
// username:hours:minutes text
|
||||||
$userButton.click();
|
const chatText = helper.chatTextParagraphs().text();
|
||||||
|
return chatText.indexOf('😃') === 0;
|
||||||
const $usernameInput = chrome$('#myusernameedit');
|
|
||||||
$usernameInput.click();
|
|
||||||
|
|
||||||
$usernameInput.val('John McLear');
|
|
||||||
$usernameInput.blur();
|
|
||||||
|
|
||||||
// click on the chat button to make chat visible
|
|
||||||
const $chatButton = chrome$('#chaticon');
|
|
||||||
$chatButton.click();
|
|
||||||
const $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(() => chrome$('#chattext').children('p').length !== 0 // wait until the chat message shows up
|
|
||||||
).done(() => {
|
|
||||||
const $firstChatMessage = chrome$('#chattext').children('p');
|
|
||||||
const containsJohnMcLear = $firstChatMessage.text().indexOf('John McLear') !== -1; // does the string contain John McLear
|
|
||||||
expect(containsJohnMcLear).to.be(true); // expect the first chat message to contain JohnMcLear
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue