2018-11-23 20:55:16 +08:00
|
|
|
const Page = require('../core/page');
|
2021-09-22 11:51:29 +08:00
|
|
|
const e = require('../core/elements');
|
2021-10-01 02:36:31 +08:00
|
|
|
const p = require('../core/params');
|
2018-11-23 00:19:29 +08:00
|
|
|
const util = require('./util');
|
|
|
|
|
|
|
|
class Copy extends Page {
|
2018-11-23 03:15:52 +08:00
|
|
|
constructor() {
|
2021-09-23 03:22:47 +08:00
|
|
|
super();
|
2018-11-23 03:15:52 +08:00
|
|
|
}
|
|
|
|
|
2020-08-14 10:41:14 +08:00
|
|
|
async test(testName) {
|
2021-08-03 00:29:16 +08:00
|
|
|
try {
|
|
|
|
await util.openChat(this);
|
2021-08-14 04:33:27 +08:00
|
|
|
await this.screenshot(`${testName}`, `01-before-sending-chat-message-[${this.meetingId}]`);
|
|
|
|
|
2021-08-03 00:29:16 +08:00
|
|
|
// sending a message
|
|
|
|
await this.type(e.chatBox, e.message);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitAndClick(e.sendButton);
|
2021-08-14 04:33:27 +08:00
|
|
|
await this.screenshot(`${testName}`, `02-chat-message-sent-[${this.meetingId}]`);
|
|
|
|
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitAndClick(e.chatOptions);
|
2021-08-14 04:33:27 +08:00
|
|
|
await this.screenshot(`${testName}`, `03-chat-options-clicked-[${this.meetingId}]`);
|
|
|
|
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.waitAndClick(e.chatCopy);
|
2021-08-03 00:29:16 +08:00
|
|
|
// enable access to browser context clipboard
|
|
|
|
const context = await this.browser.defaultBrowserContext();
|
|
|
|
await context.overridePermissions(process.env.BBB_SERVER_URL, ['clipboard-read']);
|
2021-10-01 02:45:59 +08:00
|
|
|
const copiedText = await this.page.evaluate(async () => navigator.clipboard.readText());
|
2021-08-03 00:29:16 +08:00
|
|
|
return copiedText.includes(`${p.fullName}: ${e.message}`);
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-08-03 00:29:16 +08:00
|
|
|
return false;
|
2020-08-14 10:41:14 +08:00
|
|
|
}
|
2018-11-23 00:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = Copy;
|