2022-03-29 21:53:07 +08:00
|
|
|
const { expect, default: test } = require('@playwright/test');
|
2023-06-08 10:16:50 +08:00
|
|
|
const { openPublicChat, openPrivateChat, checkLastMessageSent } = require('./util');
|
2022-01-20 03:50:59 +08:00
|
|
|
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');
|
2023-04-27 20:36:19 +08:00
|
|
|
const { MultiUsers } = require('../user/multiusers');
|
|
|
|
const { sleep } = require('../core/helpers');
|
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
class Chat extends MultiUsers {
|
|
|
|
constructor(browser, context) {
|
|
|
|
super(browser, context);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async sendPublicMessage() {
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, 0);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.type(e.chatBox, e.message);
|
2023-10-06 20:09:20 +08:00
|
|
|
await this.userPage.hasElement(e.typingIndicator);
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
async sendPrivateMessage() {
|
|
|
|
await openPrivateChat(this.modPage);
|
|
|
|
await this.modPage.waitForSelector(e.hidePrivateChat);
|
|
|
|
await sleep(500); // prevent a race condition when running on a deployed server
|
|
|
|
// modPage send message
|
|
|
|
await this.modPage.type(e.chatBox, e.message1);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.userPage.waitUntilHaveCountSelector(e.chatButton, 2);
|
|
|
|
await this.userPage.waitAndClickElement(e.chatButton, 1);
|
|
|
|
await this.userPage.waitForSelector(e.hidePrivateChat);
|
|
|
|
// check sent messages
|
|
|
|
await this.modPage.hasText(e.chatUserMessageText, e.message1);
|
|
|
|
await this.userPage.hasText(e.chatUserMessageText, e.message1);
|
|
|
|
// userPage send message
|
|
|
|
await this.userPage.type(e.chatBox, e.message2);
|
2023-10-06 20:09:20 +08:00
|
|
|
await this.modPage.hasElement(e.typingIndicator);
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.userPage.waitAndClick(e.sendButton);
|
|
|
|
// check sent messages
|
2023-09-07 02:18:13 +08:00
|
|
|
await this.modPage.hasText(`${e.chatUserMessageText}>>nth=1`, e.message2);
|
|
|
|
await this.userPage.hasText(`${e.chatUserMessageText}>>nth=1`, e.message2);
|
2023-04-27 20:36:19 +08:00
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.chatButton);
|
|
|
|
await this.userPage.waitAndClick(e.chatButton);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async clearChat() {
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
const userMessageTextCount = await this.modPage.getSelectorCount(e.chatUserMessageText);
|
|
|
|
|
|
|
|
await this.modPage.type(e.chatBox, e.message);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
// 1 message
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, userMessageTextCount + 1);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
// clear
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
|
|
|
await this.modPage.waitAndClick(e.chatClear);
|
2023-09-07 02:18:13 +08:00
|
|
|
await this.modPage.hasText(e.chatUserMessageText, 'The public chat history was cleared by a moderator');
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async copyChat(context) {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { publicChatOptionsEnabled } = getSettings();
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2023-10-31 20:31:01 +08:00
|
|
|
|
|
|
|
if(!publicChatOptionsEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
|
|
|
await this.modPage.hasElement(e.chatClear);
|
2023-11-15 00:30:35 +08:00
|
|
|
return this.modPage.wasRemoved(e.chatCopy);
|
2023-10-31 20:31:01 +08:00
|
|
|
}
|
2022-01-20 03:50:59 +08:00
|
|
|
// sending a message
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.type(e.chatBox, e.message);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.modPage.waitAndClick(e.chatCopy);
|
2022-01-20 03:50:59 +08:00
|
|
|
// enable access to browser context clipboard
|
2023-04-27 20:36:19 +08:00
|
|
|
const copiedText = await this.modPage.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();
|
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2023-10-31 20:31:01 +08:00
|
|
|
if(!publicChatOptionsEnabled) {
|
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
2023-11-16 20:00:22 +08:00
|
|
|
return this.modPage.wasRemoved(e.chatSave);
|
2023-10-31 20:31:01 +08:00
|
|
|
}
|
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.type(e.chatBox, e.message);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
|
|
|
const chatSaveLocator = this.modPage.getLocator(e.chatSave);
|
|
|
|
const { content } = await this.modPage.handleDownload(chatSaveLocator, testInfo);
|
2022-03-21 23:04:43 +08:00
|
|
|
|
|
|
|
const dataToCheck = [
|
2023-04-27 20:36:19 +08:00
|
|
|
this.modPage.meetingId,
|
|
|
|
this.modPage.username,
|
2022-03-21 23:04:43 +08:00
|
|
|
e.message,
|
|
|
|
];
|
|
|
|
await checkTextContent(content, dataToCheck);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async characterLimit() {
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2022-03-29 21:53:07 +08:00
|
|
|
const { maxMessageLength } = getSettings();
|
2023-06-08 10:16:50 +08:00
|
|
|
const initialMessagesCount = await this.modPage.getSelectorCount(e.chatUserMessageText);
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.page.fill(e.chatBox, e.uniqueCharacterMessage.repeat(maxMessageLength));
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
2023-06-08 10:16:50 +08:00
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, initialMessagesCount + 1);
|
2023-04-27 20:36:19 +08:00
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await this.modPage.page.fill(e.chatBox, e.uniqueCharacterMessage.repeat(maxMessageLength));
|
|
|
|
await this.modPage.type(e.chatBox, '123'); // it should has no effect
|
2023-09-07 02:18:13 +08:00
|
|
|
await this.modPage.waitForSelector(e.errorTypingIndicator); // warning below input message saying it has exceeded the maximum of characters
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
2023-06-08 10:16:50 +08:00
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, initialMessagesCount + 2);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async emptyMessage() {
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2022-01-20 03:50:59 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
const userMessageTextCount = await this.modPage.getSelectorCount(e.chatUserMessageText);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, userMessageTextCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
async copyPastePublicMessage() {
|
|
|
|
await this.modPage.type(e.chatBox, 'test');
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await checkLastMessageSent(this.modPage, /test/);
|
|
|
|
|
|
|
|
const text = await this.modPage.getLocator(e.chatUserMessageText).last().boundingBox();
|
|
|
|
|
|
|
|
await this.modPage.mouseDoubleClick(text.x, text.y);
|
|
|
|
await this.modPage.press('Control+KeyC');
|
|
|
|
await this.modPage.getLocator(e.chatBox).focus();
|
|
|
|
await this.modPage.press('Control+KeyV');
|
2023-06-08 10:16:50 +08:00
|
|
|
await this.modPage.type(e.chatBox, '2');
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await checkLastMessageSent(this.modPage, /test2/);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
2022-08-30 20:28:34 +08:00
|
|
|
|
2022-09-17 04:26:47 +08:00
|
|
|
async sendEmoji() {
|
|
|
|
const { emojiPickerEnabled } = getSettings();
|
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2023-11-01 20:26:35 +08:00
|
|
|
if(!emojiPickerEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 00:30:35 +08:00
|
|
|
return this.modPage.wasRemoved(e.emojiPickerButton);
|
2023-11-01 20:26:35 +08:00
|
|
|
}
|
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
const message = this.modPage.getLocator(e.chatUserMessageText);
|
2022-09-17 04:26:47 +08:00
|
|
|
await expect(message).toHaveCount(0);
|
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitAndClick(e.emojiPickerButton);
|
|
|
|
await this.modPage.waitAndClick(e.emojiSent);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
2022-09-17 04:26:47 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
2022-09-17 04:26:47 +08:00
|
|
|
await expect(message).toHaveCount(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
async emojiCopyChat(context) {
|
|
|
|
const { emojiPickerEnabled } = getSettings();
|
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this);
|
2023-11-01 20:26:35 +08:00
|
|
|
if(!emojiPickerEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.wasRemoved(e.emojiPickerButton);
|
2023-11-01 20:26:35 +08:00
|
|
|
}
|
2022-09-17 04:26:47 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
async closePrivateChat() {
|
|
|
|
await openPrivateChat(this.modPage);
|
|
|
|
await this.modPage.waitUntilHaveCountSelector(e.chatButton, 2);
|
|
|
|
const privateChatLocator = this.modPage.getLocatorByIndex(e.chatButton, -1);
|
|
|
|
expect(privateChatLocator).toContainText(this.userPage.username);
|
|
|
|
|
|
|
|
const chatMessageCount = await this.modPage.getSelectorCount(e.chatUserMessageText);
|
|
|
|
|
|
|
|
await this.modPage.hasElement(e.hidePrivateChat);
|
|
|
|
await this.modPage.hasElement(e.closePrivateChat);
|
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, chatMessageCount);
|
|
|
|
await this.modPage.type(e.chatBox, e.message1);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.userPage.waitUntilHaveCountSelector(e.chatButton, 2);
|
|
|
|
await this.modPage.waitAndClick(e.closePrivateChat);
|
|
|
|
await this.modPage.wasRemoved(e.hidePrivateChat);
|
|
|
|
await this.modPage.waitUntilHaveCountSelector(e.chatButton, 1, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
const userChatCount = await this.userPage.getSelectorCount(e.chatButton);
|
|
|
|
await this.modPage.waitAndClick(e.chatButton);
|
|
|
|
expect(userChatCount).toBe(2);
|
|
|
|
}
|
|
|
|
|
2022-09-17 04:26:47 +08:00
|
|
|
async emojiSaveChat(testInfo) {
|
|
|
|
const { emojiPickerEnabled } = getSettings();
|
|
|
|
|
2023-11-01 20:26:35 +08:00
|
|
|
await openPublicChat(this.modPage);
|
|
|
|
if(!emojiPickerEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.wasRemoved(e.emojiPickerButton);
|
2023-11-01 20:26:35 +08:00
|
|
|
}
|
|
|
|
await this.modPage.waitAndClick(e.emojiPickerButton);
|
|
|
|
await this.modPage.waitAndClick(e.emojiSent);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
|
|
|
const chatSaveLocator = this.modPage.getLocator(e.chatSave);
|
|
|
|
const { content } = await this.modPage.handleDownload(chatSaveLocator, testInfo);
|
2022-09-17 04:26:47 +08:00
|
|
|
|
|
|
|
const dataToCheck = [
|
2023-11-01 20:26:35 +08:00
|
|
|
this.modPage.meetingId,
|
|
|
|
this.modPage.username,
|
2022-09-17 04:26:47 +08:00
|
|
|
e.frequentlyUsedEmoji,
|
|
|
|
];
|
|
|
|
await checkTextContent(content, dataToCheck);
|
|
|
|
}
|
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
async emojiSendPrivateChat() {
|
|
|
|
const { emojiPickerEnabled } = getSettings();
|
|
|
|
|
|
|
|
await openPrivateChat(this.modPage);
|
|
|
|
await this.modPage.waitForSelector(e.hidePrivateChat);
|
|
|
|
await sleep(500); // prevent a race condition when running on a deployed server
|
|
|
|
// modPage send message
|
2023-11-01 20:26:35 +08:00
|
|
|
if(!emojiPickerEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.wasRemoved(e.emojiPickerButton);
|
2023-11-01 20:26:35 +08:00
|
|
|
}
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitAndClick(e.emojiPickerButton);
|
|
|
|
await this.modPage.waitAndClick(e.emojiSent);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.userPage.waitUntilHaveCountSelector(e.chatButton, 2);
|
|
|
|
await this.userPage.waitAndClickElement(e.chatButton, 1);
|
|
|
|
await this.userPage.waitForSelector(e.hidePrivateChat);
|
|
|
|
// check sent messages
|
|
|
|
await this.modPage.hasText(e.chatUserMessageText, e.frequentlyUsedEmoji);
|
|
|
|
await this.userPage.hasText(e.chatUserMessageText, e.frequentlyUsedEmoji);
|
|
|
|
// userPage send message
|
|
|
|
await this.userPage.waitAndClick(e.emojiPickerButton);
|
|
|
|
await this.userPage.waitAndClick(e.emojiSent);
|
|
|
|
await this.userPage.waitAndClick(e.sendButton);
|
|
|
|
// check sent messages
|
|
|
|
await this.modPage.hasText(e.privateChat, e.frequentlyUsedEmoji);
|
|
|
|
await this.userPage.hasText(e.privateChat, e.frequentlyUsedEmoji);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.chatButton);
|
|
|
|
}
|
|
|
|
|
2022-09-17 04:26:47 +08:00
|
|
|
async autoConvertEmojiPublicChat() {
|
|
|
|
const { autoConvertEmojiEnabled } = getSettings();
|
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
try {
|
|
|
|
await this.modPage.hasElement(e.hidePrivateChat);
|
|
|
|
await this.modPage.waitAndClick(e.chatButton);
|
|
|
|
} catch {
|
2023-09-27 03:41:58 +08:00
|
|
|
await this.modPage.hasElement(e.hidePublicChat);
|
2023-04-27 20:36:19 +08:00
|
|
|
}
|
2022-09-17 04:26:47 +08:00
|
|
|
|
2023-09-07 02:18:13 +08:00
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
|
|
|
await this.modPage.waitAndClick(e.chatClear);
|
|
|
|
|
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, 1);
|
2023-04-27 20:36:19 +08:00
|
|
|
|
|
|
|
await this.modPage.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
2023-11-01 20:26:35 +08:00
|
|
|
|
|
|
|
if(!autoConvertEmojiEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.hasText(`${e.chatUserMessageText}>>nth=1`, ":)");
|
2023-11-01 20:26:35 +08:00
|
|
|
}
|
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
2023-09-07 02:18:13 +08:00
|
|
|
await this.modPage.checkElementCount(e.chatUserMessageText, 2);
|
2022-09-17 04:26:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async autoConvertEmojiCopyChat(context) {
|
|
|
|
const { autoConvertEmojiEnabled } = getSettings();
|
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this);
|
2022-09-17 04:26:47 +08:00
|
|
|
await this.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.waitAndClick(e.sendButton);
|
2023-11-08 19:50:16 +08:00
|
|
|
if(!autoConvertEmojiEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.hasText(`${e.chatUserMessageText}>>nth=1`, ":)");
|
2023-11-08 19:50:16 +08:00
|
|
|
}
|
2022-09-17 04:26:47 +08:00
|
|
|
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();
|
|
|
|
|
2023-06-08 10:16:50 +08:00
|
|
|
await openPublicChat(this.modPage);
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
2023-11-01 20:26:35 +08:00
|
|
|
if(!autoConvertEmojiEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.hasText(`${e.chatUserMessageText}>>nth=1`, ':)');
|
2023-11-01 20:26:35 +08:00
|
|
|
}
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.modPage.waitForSelector(e.chatUserMessageText);
|
|
|
|
await this.modPage.waitAndClick(e.chatOptions);
|
|
|
|
const chatSaveLocator = this.modPage.getLocator(e.chatSave);
|
|
|
|
const { content } = await this.modPage.handleDownload(chatSaveLocator, testInfo);
|
2022-09-17 04:26:47 +08:00
|
|
|
|
|
|
|
const dataToCheck = [
|
2023-04-27 20:36:19 +08:00
|
|
|
this.modPage.meetingId,
|
|
|
|
this.modPage.username,
|
2022-09-17 04:26:47 +08:00
|
|
|
e.convertedEmojiMessage,
|
|
|
|
];
|
|
|
|
await checkTextContent(content, dataToCheck);
|
|
|
|
}
|
2022-12-01 19:19:03 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
async autoConvertEmojiSendPrivateChat() {
|
2023-11-01 22:28:38 +08:00
|
|
|
const { autoConvertEmojiEnabled, emojiPickerEnabled } = getSettings();
|
2022-12-01 19:19:03 +08:00
|
|
|
|
2023-04-27 20:36:19 +08:00
|
|
|
await openPrivateChat(this.modPage);
|
|
|
|
await this.modPage.waitForSelector(e.hidePrivateChat);
|
|
|
|
await sleep(500); // prevent a race condition when running on a deployed server
|
|
|
|
// modPage send message
|
|
|
|
await this.modPage.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
2023-11-01 22:28:38 +08:00
|
|
|
if(!autoConvertEmojiEnabled && !emojiPickerEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.hasText(`${e.chatUserMessageText}>>nth=0`, ":)");
|
2023-11-01 22:28:38 +08:00
|
|
|
} else if (!autoConvertEmojiEnabled) {
|
2023-11-16 20:00:22 +08:00
|
|
|
await this.modPage.hasElement(e.chatBox);
|
2023-11-15 04:15:26 +08:00
|
|
|
return this.modPage.hasText(`${e.chatUserMessageText}>>nth=2`, ":)");
|
2023-11-01 20:26:35 +08:00
|
|
|
}
|
2023-04-27 20:36:19 +08:00
|
|
|
await this.userPage.waitUntilHaveCountSelector(e.chatButton, 2);
|
|
|
|
await this.userPage.waitForSelector(e.hidePrivateChat);
|
|
|
|
// check sent messages
|
|
|
|
await checkLastMessageSent(this.modPage, e.convertedEmojiMessage)
|
|
|
|
await checkLastMessageSent(this.userPage, e.convertedEmojiMessage);
|
|
|
|
// userPage send message
|
|
|
|
await this.userPage.type(e.chatBox, e.autoConvertEmojiMessage);
|
|
|
|
await this.userPage.waitAndClick(e.sendButton);
|
|
|
|
// check sent messages
|
2023-09-07 02:18:13 +08:00
|
|
|
const lastMessageLocator = await this.modPage.getLocator(e.chatUserMessageText).last();
|
|
|
|
await expect(lastMessageLocator).toHaveText(e.convertedEmojiMessage);
|
|
|
|
const lastMessageLocatorUser = await this.userPage.getLocator(e.chatUserMessageText).last()
|
|
|
|
await expect(lastMessageLocatorUser).toHaveText(e.convertedEmojiMessage);
|
2022-12-01 19:19:03 +08:00
|
|
|
}
|
2023-04-27 20:36:19 +08:00
|
|
|
|
|
|
|
async chatDisabledUserLeaves() {
|
|
|
|
await openPrivateChat(this.modPage);
|
|
|
|
await this.modPage.waitForSelector(e.sendButton);
|
|
|
|
await this.userPage.waitAndClick(e.optionsButton);
|
|
|
|
await this.userPage.waitAndClick(e.logout);
|
2023-09-07 02:18:13 +08:00
|
|
|
await this.modPage.hasElement(e.partnerDisconnectedMessage, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.wasRemoved(e.sendButton);
|
2023-04-27 20:36:19 +08:00
|
|
|
}
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
2023-04-04 04:21:24 +08:00
|
|
|
exports.Chat = Chat;
|