2020-03-20 01:01:55 +08:00
|
|
|
const e = require('../core/elements');
|
2021-02-17 04:57:10 +08:00
|
|
|
const { ELEMENT_WAIT_TIME } = require('../core/constants');
|
2021-09-22 21:11:56 +08:00
|
|
|
const { getElementText, checkElement, checkElementLengthEqualTo } = require('../core/util');
|
2020-03-18 01:13:30 +08:00
|
|
|
|
2020-06-17 23:29:43 +08:00
|
|
|
async function popupMenu(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitAndClick(e.options);
|
|
|
|
await test.waitAndClick(e.settings);
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function enableChatPopup(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitAndClick(e.notificationsTab);
|
|
|
|
await test.waitAndClickElement(e.chatPushAlerts);
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-18 01:13:30 +08:00
|
|
|
async function enableUserJoinPopup(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitAndClick(e.notificationsTab);
|
|
|
|
await test.waitAndClickElement(e.userJoinPushAlerts);
|
2020-03-18 01:13:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-23 20:15:10 +08:00
|
|
|
async function saveSettings(page) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await page.waitAndClick(e.modalConfirmButton);
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function waitForToast(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitForSelector(e.smallToastMsg);
|
2021-09-22 11:51:29 +08:00
|
|
|
const resp = await test.page.evaluate(checkElement, e.smallToastMsg, 1);
|
2020-03-14 04:08:30 +08:00
|
|
|
return resp;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getLastToastValue(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitForSelector(e.smallToastMsg);
|
2021-09-22 11:51:29 +08:00
|
|
|
const toast = test.page.evaluate(getElementText, e.smallToastMsg);
|
2020-03-14 04:08:30 +08:00
|
|
|
return toast;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getOtherToastValue(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitForSelector(e.smallToastMsg);
|
2021-09-22 11:51:29 +08:00
|
|
|
const toast = test.page.evaluate(getElementText, e.smallToastMsg, 1);
|
2020-03-14 04:08:30 +08:00
|
|
|
return toast;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function publicChatMessageToast(page1, page2) {
|
|
|
|
// Open private Chat with the other User
|
2021-09-22 21:11:56 +08:00
|
|
|
await page1.waitAndClick(e.userListItem);
|
|
|
|
await page1.waitAndClick(e.activeChat);
|
2020-03-14 04:08:30 +08:00
|
|
|
// send a public message
|
2021-09-22 22:05:03 +08:00
|
|
|
await page2.type(e.chatBox, e.publicMessage1);
|
2021-09-22 21:11:56 +08:00
|
|
|
await page2.waitAndClick(e.sendButton);
|
2021-09-22 11:51:29 +08:00
|
|
|
return e.publicChatToast;
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function privateChatMessageToast(page2) {
|
|
|
|
// Open private Chat with the other User
|
2021-09-22 21:11:56 +08:00
|
|
|
await page2.waitAndClick(e.userListItem);
|
|
|
|
await page2.waitAndClick(e.activeChat);
|
2021-08-03 02:31:44 +08:00
|
|
|
// wait for the private chat to be ready
|
|
|
|
await page2.page.waitForFunction(
|
2021-08-21 04:33:57 +08:00
|
|
|
checkElementLengthEqualTo,
|
2021-08-03 02:31:44 +08:00
|
|
|
{ timeout: ELEMENT_WAIT_TIME },
|
2021-09-22 11:51:29 +08:00
|
|
|
e.chatButton, 2
|
2021-08-03 02:31:44 +08:00
|
|
|
);
|
2020-03-14 04:08:30 +08:00
|
|
|
// send a private message
|
2021-09-22 22:05:03 +08:00
|
|
|
await page2.type(e.chatBox, e.message1);
|
2021-09-22 21:11:56 +08:00
|
|
|
await page2.waitAndClick(e.sendButton);
|
2021-09-22 11:51:29 +08:00
|
|
|
return e.privateChatToast;
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-20 01:01:55 +08:00
|
|
|
// File upload notification
|
|
|
|
async function uploadFileMenu(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitAndClick(e.actions);
|
|
|
|
await test.waitAndClick(e.uploadPresentation);
|
2020-03-20 01:01:55 +08:00
|
|
|
}
|
|
|
|
|
2020-03-20 22:42:04 +08:00
|
|
|
async function startPoll(test) {
|
2021-09-22 21:11:56 +08:00
|
|
|
await test.waitAndClick(e.actions);
|
|
|
|
await test.waitAndClick(e.polling);
|
|
|
|
await test.waitForSelector(e.hidePollDesc);
|
|
|
|
await test.waitAndClick(e.pollYesNoAbstentionBtn);
|
|
|
|
await test.waitAndClick(e.startPoll);
|
|
|
|
await test.waitAndClick(e.publishLabel);
|
2020-03-20 22:42:04 +08:00
|
|
|
}
|
|
|
|
|
2020-03-14 04:08:30 +08:00
|
|
|
exports.privateChatMessageToast = privateChatMessageToast;
|
|
|
|
exports.publicChatMessageToast = publicChatMessageToast;
|
2020-03-18 01:13:30 +08:00
|
|
|
exports.enableUserJoinPopup = enableUserJoinPopup;
|
2020-03-14 04:08:30 +08:00
|
|
|
exports.getOtherToastValue = getOtherToastValue;
|
|
|
|
exports.getLastToastValue = getLastToastValue;
|
|
|
|
exports.enableChatPopup = enableChatPopup;
|
2020-03-20 01:01:55 +08:00
|
|
|
exports.uploadFileMenu = uploadFileMenu;
|
2020-03-14 04:08:30 +08:00
|
|
|
exports.saveSettings = saveSettings;
|
|
|
|
exports.waitForToast = waitForToast;
|
|
|
|
exports.popupMenu = popupMenu;
|
2020-03-20 22:42:04 +08:00
|
|
|
exports.startPoll = startPoll;
|