bigbluebutton-Github/bigbluebutton-tests/puppeteer/chat/copy.js

42 lines
1.4 KiB
JavaScript
Raw Normal View History

// Test: Cleaning a chat message
2018-11-23 20:55:16 +08:00
const Page = require('../core/page');
const e = require('./elements');
const p = require('../params');
const util = require('./util');
const { ELEMENT_WAIT_TIME } = require('../core/constants');
class Copy extends Page {
constructor() {
super('chat-copy');
}
async test(testName) {
try {
await util.openChat(this);
await this.screenshot(`${testName}`, `01-before-sending-chat-message-[${this.meetingId}]`);
// sending a message
await this.type(e.chatBox, e.message);
await this.click(e.sendButton);
await this.screenshot(`${testName}`, `02-chat-message-sent-[${this.meetingId}]`);
await this.click(e.chatOptions);
await this.screenshot(`${testName}`, `03-chat-options-clicked-[${this.meetingId}]`);
await this.waitForSelector(e.chatUserMessageText, ELEMENT_WAIT_TIME);
await this.click(e.chatCopy);
// enable access to browser context clipboard
const context = await this.browser.defaultBrowserContext();
await context.overridePermissions(process.env.BBB_SERVER_URL, ['clipboard-read']);
const copiedText = await this.page.evaluate(async () => await navigator.clipboard.readText());
return copiedText.includes(`${p.fullName}: ${e.message}`);
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.logger(err);
return false;
}
}
}
module.exports = exports = Copy;