Refactored chat message test and included chat clear
This commit is contained in:
parent
11b46959e1
commit
345a7d343d
33
bigbluebutton-html5/tests/puppeteer/chat.test.js
Normal file
33
bigbluebutton-html5/tests/puppeteer/chat.test.js
Normal file
@ -0,0 +1,33 @@
|
||||
const Page = require('./page');
|
||||
const Send = require('./chat/send');
|
||||
const Clear = require('./chat/clear');
|
||||
|
||||
describe('Chat tests', () => {
|
||||
|
||||
test('Tests sending a message in chat', async () => {
|
||||
const test = new Send();
|
||||
try {
|
||||
await test.init(Page.getArgs());
|
||||
await test.test();
|
||||
await test.close();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
await test.close();
|
||||
throw new Error('Test failed');
|
||||
}
|
||||
});
|
||||
|
||||
test('Tests cleaning a message in chat', async () => {
|
||||
const test = new Clear();
|
||||
try {
|
||||
await test.init(Page.getArgs());
|
||||
await test.test();
|
||||
await test.close();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
await test.close();
|
||||
throw new Error('Test failed');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
28
bigbluebutton-html5/tests/puppeteer/chat/clear.js
Normal file
28
bigbluebutton-html5/tests/puppeteer/chat/clear.js
Normal file
@ -0,0 +1,28 @@
|
||||
// Test: Cleaning a chat message
|
||||
|
||||
const Page = require('../page');
|
||||
const helper = require('../helper');
|
||||
const e = require('./elements');
|
||||
const util = require('./util');
|
||||
|
||||
class Clear extends Page {
|
||||
async test() {
|
||||
await util.openChat(this);
|
||||
|
||||
const messages0 = await util.getTestElements(this);
|
||||
|
||||
await this.click(e.chatOptions);
|
||||
await this.click(e.chatClear, true);
|
||||
await this.screenshot('clear-chat.png', true);
|
||||
|
||||
// TODO: this must change
|
||||
const messages1 = await util.getTestElements(this);
|
||||
|
||||
console.log('\nChat messages before cleaning:');
|
||||
console.log(JSON.stringify(messages0, null, 2));
|
||||
console.log('\nChat messages after cleaning:');
|
||||
console.log(JSON.stringify(messages1, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Clear;
|
6
bigbluebutton-html5/tests/puppeteer/chat/elements.js
Normal file
6
bigbluebutton-html5/tests/puppeteer/chat/elements.js
Normal file
@ -0,0 +1,6 @@
|
||||
exports.chatButton = 'div._imports_ui_components_user_list_chat_list_item__styles__chatName';
|
||||
exports.chatBox = '#message-input';
|
||||
exports.sendButton = '[aria-label="Send Message"]';
|
||||
exports.chatMessages = '#chat-messages';
|
||||
exports.chatOptions = '[aria-label="Chat Options"]';
|
||||
exports.chatClear = 'i._imports_ui_components_dropdown_list__styles__itemIcon.icon-bbb-delete';
|
27
bigbluebutton-html5/tests/puppeteer/chat/send.js
Normal file
27
bigbluebutton-html5/tests/puppeteer/chat/send.js
Normal file
@ -0,0 +1,27 @@
|
||||
// Test: Sending a chat message
|
||||
|
||||
const Page = require('../page');
|
||||
const helper = require('../helper');
|
||||
const e = require('./elements');
|
||||
const util = require('./util');
|
||||
|
||||
class Send extends Page {
|
||||
async test() {
|
||||
await util.openChat(this);
|
||||
|
||||
const messages0 = await util.getTestElements(this);
|
||||
|
||||
await this.type(e.chatBox, 'Hello world!');
|
||||
await this.click(e.sendButton);
|
||||
await this.screenshot('test-chat.png', true);
|
||||
|
||||
const messages1 = await util.getTestElements(this);
|
||||
|
||||
console.log('\nChat messages before posting:');
|
||||
console.log(JSON.stringify(messages0, null, 2));
|
||||
console.log('\nChat messages after posting:');
|
||||
console.log(JSON.stringify(messages1, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Send;
|
30
bigbluebutton-html5/tests/puppeteer/chat/util.js
Normal file
30
bigbluebutton-html5/tests/puppeteer/chat/util.js
Normal file
@ -0,0 +1,30 @@
|
||||
const e = require('./elements');
|
||||
|
||||
async function openChat(test) {
|
||||
await test.createBBBMeeting();
|
||||
await test.joinWithoutAudio();
|
||||
await test.click(e.chatButton);
|
||||
await test.page.waitFor(e.chatBox);
|
||||
await test.page.waitFor(e.chatMessages);
|
||||
}
|
||||
|
||||
async function getTestElements(test) {
|
||||
const messages = await test.page.evaluate((chat) => {
|
||||
const messages = [];
|
||||
const children = document.querySelector(chat).childNodes;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let content = children[i].childNodes[0].childNodes[1];
|
||||
if (content) {
|
||||
content = content.childNodes;
|
||||
messages.push({ name: content[0].innerText, message: content[1].innerText });
|
||||
}
|
||||
}
|
||||
console.log(messages);
|
||||
return messages;
|
||||
}, e.chatMessages);
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
exports.openChat = openChat;
|
||||
exports.getTestElements = getTestElements;
|
@ -17,11 +17,6 @@ exports.leaveAudio = 'button[aria-label="Leave Audio"]';
|
||||
exports.videoMenu = 'button[aria-label="Open video menu dropdown"]';
|
||||
exports.screenShare = 'button[aria-label="Share your screen"]';
|
||||
|
||||
exports.chatButton = 'div._imports_ui_components_user_list_chat_list_item__styles__chatName';
|
||||
exports.chatBox = '#message-input';
|
||||
exports.sendButton = '[aria-label="Send Message"]';
|
||||
exports.chatMessages = '#chat-messages';
|
||||
|
||||
exports.whiteboard = 'svg._imports_ui_components_presentation__styles__svgStyles';
|
||||
exports.toolbox = '._imports_ui_components_whiteboard_whiteboard_toolbar__styles__toolbarContainer';
|
||||
exports.tools = 'button[aria-label="Tools"]';
|
||||
|
@ -1,49 +0,0 @@
|
||||
// Test: Sending a chat message
|
||||
|
||||
const Page = require('./page');
|
||||
const helper = require('./helper');
|
||||
const e = require('./elements');
|
||||
|
||||
class ChatTestPage extends Page {
|
||||
async test() {
|
||||
await this.createBBBMeeting();
|
||||
await this.joinWithoutAudio();
|
||||
|
||||
await this.click(e.chatButton);
|
||||
await this.page.waitFor(e.chatBox);
|
||||
await this.page.waitFor(e.chatMessages);
|
||||
|
||||
const messages0 = await this.getTestElements();
|
||||
|
||||
await this.type(e.chatBox, 'Hello world!');
|
||||
await this.click(e.sendButton);
|
||||
await this.screenshot('test-chat.png', true);
|
||||
|
||||
const messages1 = await this.getTestElements();
|
||||
|
||||
console.log('\nChat messages before posting:');
|
||||
console.log(JSON.stringify(messages0, null, 2));
|
||||
console.log('\nChat messages after posting:');
|
||||
console.log(JSON.stringify(messages1, null, 2));
|
||||
}
|
||||
|
||||
async getTestElements() {
|
||||
const messages = await this.page.evaluate((chat) => {
|
||||
const messages = [];
|
||||
const children = document.querySelector(chat).childNodes;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let content = children[i].childNodes[0].childNodes[1];
|
||||
if (content) {
|
||||
content = content.childNodes;
|
||||
messages.push({ name: content[0].innerText, message: content[1].innerText });
|
||||
}
|
||||
}
|
||||
console.log(messages);
|
||||
return messages;
|
||||
}, e.chatMessages);
|
||||
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = ChatTestPage;
|
@ -1,15 +0,0 @@
|
||||
const Page = require('./page');
|
||||
const ChatTestPage = require('./page-chat');
|
||||
|
||||
test('Tests sending a message in chat', async () => {
|
||||
const test = new ChatTestPage();
|
||||
try {
|
||||
await test.init(Page.getArgs());
|
||||
await test.test();
|
||||
await test.close();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
await test.close();
|
||||
throw new Error('Test failed');
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user