bigbluebutton-Github/bigbluebutton-html5/tests/puppeteer/notifications/util.js
Mohamed Amine Ben Salah d8c5aa46d9
multiple automated tests suites updates + add missing polling specs and move them with old ones to a polling test suite (#10766)
* updating old tests + collecting more snapshots [WIP]

* updates old test suites and collects more visual regressions screenshots

* remove snapshots and their collection temporary

* run tests from packages.json

* update test execution command/export constants from .env to core/constants.js

* update tests/puppeteer/README.md file

* update LOOP_INTERVAL variable call and assign timeouts to the webcam share spec

* redefine waitForSelector func in page.js, update chat test suite specs and add poll chat message test spec

* Merge remote-tracking branch 'upstream/develop' into updating-old-tests-visual-with-visual-regressions

* update webcam test specs collecting videoPreviewTimeout and use it to wait for videoPreview selector

* update custom parameters test suite

* update breakout test suite

* update webcam layout test suite

* update multiusers test suite

* update notifications test suite

* update presentation test suite

* whiteboard test suite

* screenshare test suite

* update sharednotes test suite

* user ELEMENT_WAIT_TIME variable from timeouts constants.js

* list TEST CONSTANTS by category

* add poll test suite and assigns the right unassigned timeouts

* set test pages to headless
2021-02-16 15:57:10 -05:00

126 lines
4.5 KiB
JavaScript

const ne = require('../notifications/elements');
const ule = require('../user/elements');
const ce = require('../chat/elements');
const e = require('../core/elements');
const { ELEMENT_WAIT_TIME } = require('../core/constants');
async function clickTestElement(element) {
await document.querySelectorAll(element)[0].click();
}
async function popupMenu(test) {
await test.page.evaluate(clickTestElement, e.options);
await test.page.evaluate(clickTestElement, ne.settings);
}
async function enableChatPopup(test) {
await test.waitForSelector(ne.notificationsTab, ELEMENT_WAIT_TIME);
await test.page.evaluate(clickTestElement, ne.notificationsTab);
await test.waitForSelector(ne.chatPushAlerts, ELEMENT_WAIT_TIME);
await test.page.evaluate(clickTestElement, ne.chatPushAlerts);
}
async function enableUserJoinPopup(test) {
await test.waitForSelector(ne.notificationsTab, ELEMENT_WAIT_TIME);
await test.page.evaluate(clickTestElement, ne.notificationsTab);
await test.waitForSelector(ne.userJoinPushAlerts, ELEMENT_WAIT_TIME);
await test.page.evaluate(clickTestElement, ne.userJoinPushAlerts);
}
async function saveSettings(page) {
await page.waitForSelector(ne.saveSettings, ELEMENT_WAIT_TIME);
await page.click(ne.saveSettings, true);
}
async function waitForToast(test) {
await test.waitForSelector(ne.smallToastMsg, ELEMENT_WAIT_TIME);
const resp = await test.page.evaluate(getTestElement, ne.smallToastMsg) !== null;
return resp;
}
async function getLastToastValue(test) {
await test.waitForSelector(ne.smallToastMsg, ELEMENT_WAIT_TIME);
const toast = test.page.evaluate(async () => {
const lastToast = await document.querySelectorAll('div[data-test="toastSmallMsg"]')[0].innerText;
return lastToast;
});
return toast;
}
async function getOtherToastValue(test) {
await test.waitForSelector(ne.smallToastMsg, ELEMENT_WAIT_TIME);
const toast = test.page.evaluate(async () => {
const lastToast = await document.querySelectorAll('div[data-test="toastSmallMsg"]')[1].innerText;
return lastToast;
});
return toast;
}
async function getTestElement(element) {
await document.querySelectorAll(element)[1];
}
async function clickOnElement(element) {
await document.querySelectorAll(element)[0].click();
}
async function clickThePrivateChatButton(element) {
await document.querySelectorAll(element)[0].click();
}
async function publicChatMessageToast(page1, page2) {
// Open private Chat with the other User
await page1.page.evaluate(clickOnElement, ule.userListItem);
await page1.page.evaluate(clickThePrivateChatButton, ce.activeChat);
// send a public message
await page2.page.type(ce.publicChat, ce.publicMessage1);
await page2.click(ce.sendButton, true);
return ne.publicChatToast;
}
async function privateChatMessageToast(page2) {
// Open private Chat with the other User
await page2.page.evaluate(clickOnElement, ule.userListItem);
await page2.page.evaluate(clickThePrivateChatButton, ce.activeChat);
// send a private message
await page2.page.type(ce.privateChat, ce.message1);
await page2.click(ce.sendButton, true);
return ne.privateChatToast;
}
// File upload notification
async function uploadFileMenu(test) {
await test.page.evaluate(clickOnElement, ne.dropdownContent);
await test.page.evaluate(clickOnElement, ne.uploadPresentation);
}
async function getFileItemStatus(element, value) {
document.querySelectorAll(element)[1].innerText.includes(value);
}
async function startPoll(test) {
await test.page.evaluate(clickOnElement, ne.dropdownContent);
await test.page.evaluate(clickOnElement, ne.polling);
await test.waitForSelector(ne.hidePollDesc, ELEMENT_WAIT_TIME);
await test.waitForSelector(ne.pollBtn, ELEMENT_WAIT_TIME);
await test.page.evaluate(clickOnElement, ne.pollBtn);
await test.waitForSelector(ne.publishLabel, ELEMENT_WAIT_TIME);
await test.page.evaluate(clickOnElement, ne.publishLabel);
}
exports.getFileItemStatus = getFileItemStatus;
exports.privateChatMessageToast = privateChatMessageToast;
exports.publicChatMessageToast = publicChatMessageToast;
exports.enableUserJoinPopup = enableUserJoinPopup;
exports.getOtherToastValue = getOtherToastValue;
exports.getLastToastValue = getLastToastValue;
exports.enableChatPopup = enableChatPopup;
exports.uploadFileMenu = uploadFileMenu;
exports.getTestElement = getTestElement;
exports.saveSettings = saveSettings;
exports.waitForToast = waitForToast;
exports.popupMenu = popupMenu;
exports.clickTestElement = clickTestElement;
exports.startPoll = startPoll;
exports.clickOnElement = clickOnElement;