bigbluebutton-Github/bigbluebutton-tests/puppeteer/notifications/util.js

94 lines
2.9 KiB
JavaScript
Raw Normal View History

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