2018-11-22 04:58:45 +08:00
|
|
|
// Test: Sending a chat message
|
|
|
|
|
2018-11-23 20:55:16 +08:00
|
|
|
const Page = require('../core/page');
|
2018-11-22 04:58:45 +08:00
|
|
|
const e = require('./elements');
|
|
|
|
const util = require('./util');
|
|
|
|
|
|
|
|
class Send extends Page {
|
2018-11-23 03:15:52 +08:00
|
|
|
constructor() {
|
|
|
|
super('chat-send');
|
|
|
|
}
|
|
|
|
|
2020-08-14 10:41:14 +08:00
|
|
|
async test(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await util.openChat(this);
|
2018-11-22 04:58:45 +08:00
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
// 0 messages
|
|
|
|
const chat0 = await this.page.evaluate((chatSelector) => document.querySelectorAll(chatSelector).length === 0, e.chatUserMessageText);
|
2021-08-14 04:33:27 +08:00
|
|
|
await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`);
|
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
// send a message
|
|
|
|
await this.type(e.chatBox, e.message);
|
2021-08-14 04:33:27 +08:00
|
|
|
await this.screenshot(`${testName}`, `02-typing-chat-message-[${this.meetingId}]`);
|
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.click(e.sendButton, true);
|
2021-08-14 04:33:27 +08:00
|
|
|
await this.screenshot(`${testName}`, `03-after-chat-message-send-[${this.meetingId}]`);
|
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
2020-01-29 03:25:27 +08:00
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
// 1 message
|
|
|
|
const chat1 = await this.page.evaluate((chatSelector) => document.querySelectorAll(chatSelector).length === 1, e.chatUserMessageText);
|
|
|
|
return chat0 === chat1;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2018-11-22 04:58:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = Send;
|