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

66 lines
2.1 KiB
JavaScript
Raw Normal View History

const { expect } = require('@playwright/test');
2021-12-01 13:36:20 +08:00
const e = require('../core/elements');
const { ELEMENT_WAIT_TIME } = require('../core/constants');
const { checkElementLengthEqualTo } = require('../core/util');
async function enableChatPopup(test) {
await test.waitAndClick(e.notificationsTab);
2022-01-20 21:03:18 +08:00
await test.waitAndClickElement(e.chatPopupAlertsBtn);
2021-12-01 13:36:20 +08:00
}
async function enableUserJoinPopup(test) {
await test.waitAndClick(e.notificationsTab);
await test.waitAndClickElement(e.userJoinPushAlerts);
}
async function saveSettings(page) {
await page.waitAndClick(e.modalConfirmButton);
}
async function checkNotificationText(test, text) {
await test.hasText(e.smallToastMsg, text);
}
async function checkNotificationIcon(test, icon) {
const check = await test.checkElement(`${e.toastContainer} ${icon}`);
expect(check).toBeTruthy();
}
2021-12-01 13:36:20 +08:00
async function publicChatMessageToast(page1, page2) {
// Open private Chat with the other User
await page1.waitAndClick(e.userListItem);
2022-01-20 21:03:18 +08:00
await page1.waitAndClick(e.startPrivateChat);
2021-12-01 13:36:20 +08:00
// send a public message
await page2.type(e.chatBox, e.publicMessage1);
await page2.waitAndClick(e.sendButton);
}
async function privateChatMessageToast(page2) {
// Open private Chat with the other User
await page2.waitAndClick(e.userListItem);
2022-01-20 21:03:18 +08:00
await page2.waitAndClick(e.startPrivateChat);
2021-12-01 13:36:20 +08:00
// wait for the private chat to be ready
await page2.page.waitForFunction(
checkElementLengthEqualTo,
[e.chatButton, 2],
{ timeout: ELEMENT_WAIT_TIME },
);
// send a private message
await page2.type(e.chatBox, e.message1);
await page2.waitAndClick(e.sendButton);
}
async function waitAndClearNotification(test) {
await test.waitAndClick(e.smallToastMsg);
await test.wasRemoved(e.smallToastMsg);
}
2021-12-01 13:36:20 +08:00
exports.privateChatMessageToast = privateChatMessageToast;
exports.publicChatMessageToast = publicChatMessageToast;
exports.enableUserJoinPopup = enableUserJoinPopup;
exports.checkNotificationText = checkNotificationText;
exports.checkNotificationIcon = checkNotificationIcon;
2021-12-01 13:36:20 +08:00
exports.enableChatPopup = enableChatPopup;
exports.saveSettings = saveSettings;
exports.waitAndClearNotification = waitAndClearNotification;