2022-03-29 21:53:07 +08:00
|
|
|
const { expect, default: test } = require('@playwright/test');
|
2022-01-20 03:50:59 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const { openChat } = require('./util');
|
|
|
|
const p = require('../core/parameters');
|
|
|
|
const e = require('../core/elements');
|
2022-03-21 23:04:43 +08:00
|
|
|
const { checkTextContent } = require('../core/util');
|
2022-03-29 21:53:07 +08:00
|
|
|
const { getSettings } = require('../core/settings');
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
class Chat extends Page {
|
|
|
|
constructor(browser, page) {
|
|
|
|
super(browser, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
async sendPublicMessage() {
|
2022-03-21 23:04:43 +08:00
|
|
|
await openChat(this);
|
2022-09-23 04:17:15 +08:00
|
|
|
await this.checkElementCount(e.chatUserMessageText, 0);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
await this.type(e.chatBox, e.message);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
2022-09-23 04:17:15 +08:00
|
|
|
await this.checkElementCount(e.chatUserMessageText, 1);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async clearChat() {
|
2022-03-21 23:04:43 +08:00
|
|
|
await openChat(this);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
await this.type(e.chatBox, e.message);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
2022-02-03 08:05:26 +08:00
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
// 1 message
|
2022-09-23 04:17:15 +08:00
|
|
|
await this.checkElementCount(e.chatUserMessageText, 1);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
// clear
|
|
|
|
await this.waitAndClick(e.chatOptions);
|
|
|
|
await this.waitAndClick(e.chatClear);
|
2022-02-03 08:05:26 +08:00
|
|
|
const clearMessage = this.getLocator(e.chatClearMessageText);
|
2022-01-20 03:50:59 +08:00
|
|
|
await expect(clearMessage).toBeVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
async copyChat(context) {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { publicChatOptionsEnabled } = getSettings();
|
|
|
|
test.fail(!publicChatOptionsEnabled, 'Public chat options (save and copy) are disabled');
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2022-03-29 21:53:07 +08:00
|
|
|
await openChat(this);
|
2022-01-20 03:50:59 +08:00
|
|
|
// sending a message
|
|
|
|
await this.type(e.chatBox, e.message);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
|
|
|
|
await this.waitAndClick(e.chatOptions);
|
|
|
|
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.waitAndClick(e.chatCopy);
|
|
|
|
// enable access to browser context clipboard
|
2022-09-16 22:22:05 +08:00
|
|
|
const copiedText = await this.getCopiedText(context);
|
2022-01-20 03:50:59 +08:00
|
|
|
const check = copiedText.includes(`${p.fullName}: ${e.message}`);
|
2022-09-17 05:02:32 +08:00
|
|
|
await expect(check).toBeTruthy();
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
2022-03-21 23:04:43 +08:00
|
|
|
async saveChat(testInfo) {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { publicChatOptionsEnabled } = getSettings();
|
|
|
|
test.fail(!publicChatOptionsEnabled, 'Public chat options (save and copy) are disabled');
|
|
|
|
|
2022-03-21 23:04:43 +08:00
|
|
|
await openChat(this);
|
|
|
|
await this.type(e.chatBox, e.message);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.waitAndClick(e.chatOptions);
|
2022-03-21 23:04:43 +08:00
|
|
|
const { content } = await this.handleDownload(e.chatSave, testInfo);
|
|
|
|
|
|
|
|
const dataToCheck = [
|
|
|
|
this.meetingId,
|
|
|
|
this.username,
|
|
|
|
e.message,
|
|
|
|
];
|
|
|
|
await checkTextContent(content, dataToCheck);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async characterLimit() {
|
2022-03-21 23:04:43 +08:00
|
|
|
await openChat(this);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2022-03-29 21:53:07 +08:00
|
|
|
const { maxMessageLength } = getSettings();
|
|
|
|
await this.page.fill(e.chatBox, e.uniqueCharacterMessage.repeat(maxMessageLength));
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
2022-09-23 04:17:15 +08:00
|
|
|
await this.checkElementCount(e.chatUserMessageText, 1);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2022-03-29 21:53:07 +08:00
|
|
|
await this.page.fill(e.chatBox, e.uniqueCharacterMessage.repeat(maxMessageLength + 1));
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.waitForSelector(e.typingIndicator);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
2022-09-23 04:17:15 +08:00
|
|
|
await this.checkElementCount(e.chatUserMessageText, 1);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async emptyMessage() {
|
2022-03-21 23:04:43 +08:00
|
|
|
await openChat(this);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
await this.waitAndClick(e.sendButton);
|
2022-09-23 04:17:15 +08:00
|
|
|
await this.checkElementCount(e.chatUserMessageText, 0);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
2022-08-30 20:28:34 +08:00
|
|
|
|
2022-09-17 04:26:47 +08:00
|
|
|
// Emojis
|
|
|
|
async sendEmoji() {
|
|
|
|
const { emojiPickerEnabled } = getSettings();
|
|
|
|
test.fail(!emojiPickerEnabled, 'Emoji Picker is disabled');
|
|
|
|
|
|
|
|
await openChat(this);
|
|
|
|
const message = this.getLocator(e.chatUserMessageText);
|
|
|
|
await expect(message).toHaveCount(0);
|
|
|
|
|
|
|
|
await this.waitAndClick(e.emojiPickerButton);
|
|
|
|
await this.waitAndClick(e.emojiSent);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await expect(message).toHaveCount(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
async emojiCopyChat(context) {
|
|
|
|
const { emojiPickerEnabled } = getSettings();
|
|
|
|
test.fail(!emojiPickerEnabled, 'Emoji Picker is disabled');
|
|
|
|
|
|
|
|
await openChat(this);
|
|
|
|
await this.waitAndClick(e.emojiPickerButton);
|
|
|
|
await this.waitAndClick(e.emojiSent);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
|
|
|
|
await this.waitAndClick(e.chatOptions);
|
|
|
|
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.waitAndClick(e.chatCopy);
|
|
|
|
|
|
|
|
const copiedText = await this.getCopiedText(context);
|
|
|
|
const check = copiedText.includes(`${p.fullName}: ${e.frequentlyUsedEmoji}`);
|
2022-09-17 05:02:32 +08:00
|
|
|
await expect(check).toBeTruthy();
|
2022-09-17 04:26:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async emojiSaveChat(testInfo) {
|
|
|
|
const { emojiPickerEnabled } = getSettings();
|
|
|
|
test.fail(!emojiPickerEnabled, 'Emoji Picker is disabled');
|
|
|
|
|
|
|
|
await openChat(this);
|
|
|
|
await this.waitAndClick(e.emojiPickerButton);
|
|
|
|
await this.waitAndClick(e.emojiSent);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.waitAndClick(e.chatOptions);
|
|
|
|
const { content } = await this.handleDownload(e.chatSave, testInfo);
|
|
|
|
|
|
|
|
const dataToCheck = [
|
|
|
|
this.meetingId,
|
|
|
|
this.username,
|
|
|
|
e.frequentlyUsedEmoji,
|
|
|
|
];
|
|
|
|
await checkTextContent(content, dataToCheck);
|
|
|
|
}
|
|
|
|
|
|
|
|
async autoConvertEmojiPublicChat() {
|
|
|
|
const { autoConvertEmojiEnabled } = getSettings();
|
|
|
|
test.fail(!autoConvertEmojiEnabled, 'Auto Convert Emoji is disabled');
|
|
|
|
|
|
|
|
await openChat(this);
|
|
|
|
const message = this.getLocator(e.chatUserMessageText);
|
|
|
|
await expect(message).toHaveCount(0);
|
|
|
|
|
|
|
|
await this.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await expect(message).toHaveCount(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
async autoConvertEmojiCopyChat(context) {
|
|
|
|
const { autoConvertEmojiEnabled } = getSettings();
|
|
|
|
test.fail(!autoConvertEmojiEnabled, 'Auto Convert Emoji is disabled');
|
|
|
|
|
|
|
|
await openChat(this);
|
|
|
|
await this.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
|
|
|
|
await this.waitAndClick(e.chatOptions);
|
|
|
|
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.waitAndClick(e.chatCopy);
|
|
|
|
|
|
|
|
const copiedText = await this.getCopiedText(context);
|
|
|
|
const check = copiedText.includes(`${p.fullName}: ${e.convertedEmojiMessage}`);
|
2022-09-17 05:02:32 +08:00
|
|
|
await expect(check).toBeTruthy();
|
2022-09-17 04:26:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async autoConvertEmojiSaveChat(testInfo) {
|
|
|
|
const { autoConvertEmojiEnabled } = getSettings();
|
|
|
|
test.fail(!autoConvertEmojiEnabled, 'Auto Convert Emoji is disabled');
|
|
|
|
|
|
|
|
await openChat(this);
|
|
|
|
await this.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
|
|
|
await this.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.waitAndClick(e.chatOptions);
|
|
|
|
const { content } = await this.handleDownload(e.chatSave, testInfo);
|
|
|
|
|
|
|
|
const dataToCheck = [
|
|
|
|
this.meetingId,
|
|
|
|
this.username,
|
|
|
|
e.convertedEmojiMessage,
|
|
|
|
];
|
|
|
|
await checkTextContent(content, dataToCheck);
|
|
|
|
}
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
2022-08-30 20:28:34 +08:00
|
|
|
exports.Chat = Chat;
|