2021-09-22 11:51:29 +08:00
|
|
|
const e = require('../core/elements');
|
2018-11-22 04:58:45 +08:00
|
|
|
|
|
|
|
async function openChat(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitForSelector(e.chatBox);
|
|
|
|
await test.waitForSelector(e.chatMessages);
|
2018-11-22 04:58:45 +08:00
|
|
|
}
|
|
|
|
|
2020-02-20 01:28:27 +08:00
|
|
|
async function sendPublicChatMessage(page1, page2) {
|
|
|
|
// send a public message
|
2021-09-22 22:05:03 +08:00
|
|
|
await page1.type(e.chatBox, e.publicMessage1);
|
2021-09-22 21:11:56 +08:00
|
|
|
await page1.waitAndClick(e.sendButton);
|
2020-02-20 01:28:27 +08:00
|
|
|
await page1.page.screenshot(true);
|
2021-09-22 22:05:03 +08:00
|
|
|
await page2.type(e.chatBox, e.publicMessage2);
|
2021-09-22 21:11:56 +08:00
|
|
|
await page2.waitAndClick(e.sendButton);
|
2020-02-20 01:28:27 +08:00
|
|
|
await page2.page.screenshot(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function openPrivateChatMessage(page1, page2) {
|
|
|
|
// Open private Chat with the other User
|
2021-09-22 21:11:56 +08:00
|
|
|
await page1.waitAndClick(e.userListItem);
|
|
|
|
await page2.waitAndClick(e.userListItem);
|
|
|
|
await page1.waitAndClick(e.activeChat);
|
|
|
|
await page2.waitAndClick(e.activeChat);
|
2020-02-20 01:28:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function sendPrivateChatMessage(page1, page2) {
|
|
|
|
// send a private message
|
2021-09-22 11:51:29 +08:00
|
|
|
await page1.waitForSelector(e.hidePrivateChat);
|
|
|
|
await page2.waitForSelector(e.hidePrivateChat);
|
2020-02-20 01:28:27 +08:00
|
|
|
|
2021-09-22 22:05:03 +08:00
|
|
|
await page1.type(e.chatBox, e.message1);
|
2021-09-22 21:11:56 +08:00
|
|
|
await page1.waitAndClick(e.sendButton);
|
2020-02-20 01:28:27 +08:00
|
|
|
await page1.page.screenshot(true);
|
2021-09-22 22:05:03 +08:00
|
|
|
await page2.type(e.chatBox, e.message2);
|
2021-09-22 21:11:56 +08:00
|
|
|
await page2.waitAndClick(e.sendButton);
|
2020-02-20 01:28:27 +08:00
|
|
|
await page2.page.screenshot(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function checkForPublicMessageReception(page1, page2) {
|
|
|
|
const publicChat1 = await page1.page.$$(`${e.chatUserMessage} ${e.chatMessageText}`);
|
|
|
|
const publicChat2 = await page2.page.$$(`${e.chatUserMessage} ${e.chatMessageText}`);
|
|
|
|
|
|
|
|
const checkPublicMessage1 = await publicChat1[0].evaluate(n => n.innerText);
|
|
|
|
const checkPublicMessage2 = await publicChat2[1].evaluate(n => n.innerText);
|
|
|
|
|
|
|
|
const response = checkPublicMessage1 == e.publicMessage1 && checkPublicMessage2 == e.publicMessage2;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2020-10-09 03:25:35 +08:00
|
|
|
async function checkForPrivateMessageReception(page1, page2) {
|
|
|
|
const privateChat1 = await page1.page.$$(`${e.chatUserMessage} ${e.chatMessageText}`);
|
|
|
|
const privateChat2 = await page2.page.$$(`${e.chatUserMessage} ${e.chatMessageText}`);
|
|
|
|
|
|
|
|
const checkPrivateMessage1 = await privateChat1[0].evaluate(n => n.innerText);
|
|
|
|
const checkPrivateMessage2 = await privateChat2[1].evaluate(n => n.innerText);
|
|
|
|
|
|
|
|
const response = checkPrivateMessage1 == e.message1 && checkPrivateMessage2 == e.message2;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2018-11-22 04:58:45 +08:00
|
|
|
async function getTestElements(test) {
|
2020-01-29 03:25:27 +08:00
|
|
|
const messages = await test.page.$$(`${e.chatUserMessage} ${e.chatMessageText}`);
|
2018-11-22 04:58:45 +08:00
|
|
|
return messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.openChat = openChat;
|
|
|
|
exports.getTestElements = getTestElements;
|
2020-02-20 01:28:27 +08:00
|
|
|
exports.openPrivateChatMessage = openPrivateChatMessage;
|
|
|
|
exports.sendPrivateChatMessage = sendPrivateChatMessage;
|
|
|
|
exports.checkForPublicMessageReception = checkForPublicMessageReception;
|
|
|
|
exports.checkForPrivateMessageReception = checkForPrivateMessageReception;
|
|
|
|
exports.sendPublicChatMessage = sendPublicChatMessage;
|