bigbluebutton-Github/bigbluebutton-html5/tests/puppeteer/page-chat.js
browniecab b5bd5754a1 Use Jest for running tests
(cherry picked from commit d82cef50e99e9da6f0d6b94f2bd950bf063d6400)
2018-10-03 13:45:28 -04:00

58 lines
1.5 KiB
JavaScript

// 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.page.waitFor(e.chatButton);
await this.page.click(e.chatButton);
await this.page.waitFor(e.chatBox);
await this.page.waitFor(e.chatMessages);
var messages0 = await this.getTestElements();
await this.page.type(e.chatBox, "Hello world!");
await this.page.click(e.sendButton);
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-chat.png"});
var 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()
{
var messages = await this.page.evaluate((chat) =>
{
var messages = [];
var children = document.querySelector(chat).childNodes;
for(var i = 0; i < children.length; i++)
{
var 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;