pad.libre-service.eu-etherpad/tests/frontend/specs/chat.js
John McLear 915849b319
Low hanging lint frontend tests (#4695)
* lint: low hanging specs/alphabet.js

* lint: low hanging specs/authorship_of_editions.js

* lint: low hanging specs/bold.js

* lint: low hanging specs/caret.js

* lint: low hanging specs/change_user_color.js

* lint: low hanging specs/change_user_name.js

* lint: low hanging specs/chat.js

* lint: low hanging specs/chat_load_messages.js

* lint: low hanging specs/clear_authorship_colors.js

* lint: low hanging specs/delete.js

* lint: low hanging specs/drag_and_drop.js

* lint: low hanging specs/embed_value.js

* lint: low hanging specs/enter.js

* lint: low hanging specs/font_type.js

* lint: low hanging specs/helper.js

* lint: low hanging specs/importexport.js

* lint: low hanging specs/importindents.js

* lint: low hanging specs/indentation.js

* lint: low hanging specs/italic.js

* lint: low hanging specs/language.js

* lint: low hanging specs/multiple_authors_clear_authorship_colors.js

* lint: low hanging specs/ordered_list.js

* lint: low hanging specs/pad_modal.js

* lint: low hanging specs/redo.js

* lint: low hanging specs/responsiveness.js

* lint: low hanging specs/select_formatting_buttons.js

* lint: low hanging specs/strikethrough.js

* lint: low hanging specs/timeslider.js

* lint: low hanging specs/timeslider_labels.js

* lint: low hanging specs/timeslider_numeric_padID.js

* lint: low hanging specs/timeslider_revisions.js

* lint: low hanging specs/undo.js

* lint: low hanging specs/unordered_list.js

* lint: low hanging specs/xxauto_reconnect.js

* lint: attempt to do remote_runner.js

* lint: helper linting

* lint: rate limit linting

* use constructor for Event to make eslint happier

* for squash: lint fix refinements

* for squash: lint fix refinements

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-02-01 20:23:14 +00:00

116 lines
3.8 KiB
JavaScript

'use strict';
describe('Chat messages and UI', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
});
it('opens chat, sends a message, makes sure it exists ' +
'on the page and hides chat', async function () {
const chatValue = 'JohnMcLear';
await helper.showChat();
await helper.sendChatMessage(`${chatValue}{enter}`);
expect(helper.chatTextParagraphs().length).to.be(1);
// <p data-authorid="a.qjkwNs4z0pPROphS"
// class="author-a-qjkwz78zs4z122z0pz80zz82zz79zphz83z">
// <b>unnamed:</b>
// <span class="time author-a-qjkwz78zs4z122z0pz80zz82zz79zphz83z">12:38
// </span> JohnMcLear
// </p>
const username = helper.chatTextParagraphs().children('b').text();
const time = helper.chatTextParagraphs().children('.time').text();
expect(helper.chatTextParagraphs().text()).to.be(`${username}${time} ${chatValue}`);
await helper.hideChat();
});
it("makes sure that an empty message can't be sent", async function () {
const chatValue = 'mluto';
await helper.showChat();
// simulate a keypress of typing enter, mluto and enter (to send 'mluto')
await helper.sendChatMessage(`{enter}${chatValue}{enter}`);
const chat = helper.chatTextParagraphs();
expect(chat.length).to.be(1);
// check that the received message is not the empty one
const username = chat.children('b').text();
const time = chat.children('.time').text();
expect(chat.text()).to.be(`${username}${time} ${chatValue}`);
});
it('makes chat stick to right side of the screen via settings, ' +
'remove sticky via settings, close it', async function () {
await helper.showSettings();
await helper.enableStickyChatviaSettings();
expect(helper.isChatboxShown()).to.be(true);
expect(helper.isChatboxSticky()).to.be(true);
await helper.disableStickyChatviaSettings();
expect(helper.isChatboxSticky()).to.be(false);
expect(helper.isChatboxShown()).to.be(true);
await helper.hideChat();
expect(helper.isChatboxSticky()).to.be(false);
expect(helper.isChatboxShown()).to.be(false);
});
it('makes chat stick to right side of the screen via icon on the top' +
' right, remove sticky via icon, close it', async function () {
await helper.showChat();
await helper.enableStickyChatviaIcon();
expect(helper.isChatboxShown()).to.be(true);
expect(helper.isChatboxSticky()).to.be(true);
await helper.disableStickyChatviaIcon();
expect(helper.isChatboxShown()).to.be(true);
expect(helper.isChatboxSticky()).to.be(false);
await helper.hideChat();
expect(helper.isChatboxSticky()).to.be(false);
expect(helper.isChatboxShown()).to.be(false);
});
xit('Checks showChat=false URL Parameter hides chat then' +
' when removed it shows chat', function (done) {
this.timeout(60000);
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
clearCookies: false,
params: {
showChat: 'false',
}, cb() {
const chrome$ = helper.padChrome$;
const chaticon = chrome$('#chaticon');
// chat should be hidden.
expect(chaticon.is(':visible')).to.be(false);
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
clearCookies: false,
cb() {
const chrome$ = helper.padChrome$;
const chaticon = chrome$('#chaticon');
// chat should be visible.
expect(chaticon.is(':visible')).to.be(true);
done();
},
});
}, 1000);
},
});
}, 1000);
});
});