2022-01-20 04:00:40 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
2022-06-08 02:52:22 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
2021-12-01 13:36:20 +08:00
|
|
|
const e = require('../core/elements');
|
2022-03-01 03:46:13 +08:00
|
|
|
const { sleep } = require('../core/helpers');
|
2021-12-01 13:36:20 +08:00
|
|
|
|
|
|
|
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) {
|
2024-07-31 06:49:02 +08:00
|
|
|
await test.hasText(e.smallToastMsg, text, 'should appear the text on the toast message notification');
|
2021-12-01 13:36:20 +08:00
|
|
|
}
|
|
|
|
|
2022-01-20 04:00:40 +08:00
|
|
|
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);
|
2022-06-08 02:52:22 +08:00
|
|
|
await page1.waitForSelector(e.hidePrivateChat);
|
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
|
2022-02-05 03:26:35 +08:00
|
|
|
await page2.waitUntilHaveCountSelector(e.chatButton, 2);
|
2021-12-01 13:36:20 +08:00
|
|
|
// send a private message
|
|
|
|
await page2.type(e.chatBox, e.message1);
|
2022-03-01 03:46:13 +08:00
|
|
|
await sleep(1000);
|
2021-12-01 13:36:20 +08:00
|
|
|
await page2.waitAndClick(e.sendButton);
|
|
|
|
}
|
|
|
|
|
2022-06-08 02:52:22 +08:00
|
|
|
async function waitAndClearNotification(testPage) {
|
|
|
|
await testPage.waitAndClick(e.smallToastMsg, ELEMENT_WAIT_LONGER_TIME);
|
2024-07-31 06:49:02 +08:00
|
|
|
await testPage.wasRemoved(e.smallToastMsg, 'should the new small toast message disappear');
|
2022-06-08 02:52:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function waitAndClearDefaultPresentationNotification(testPage) {
|
2024-07-31 06:49:02 +08:00
|
|
|
await testPage.hasElement(e.whiteboard, 'should the whiteboard appear on the meeting', ELEMENT_WAIT_LONGER_TIME);
|
2022-08-20 07:57:17 +08:00
|
|
|
const hasCurrentPresentationToast = await testPage.checkElement(e.currentPresentationToast);
|
|
|
|
if (hasCurrentPresentationToast) {
|
2023-02-14 21:59:46 +08:00
|
|
|
await testPage.waitAndClick(e.currentPresentationToast, ELEMENT_WAIT_LONGER_TIME);
|
2024-07-31 06:49:02 +08:00
|
|
|
await testPage.wasRemoved(e.currentPresentationToast, 'should disappear the current presentation toast');
|
2022-06-08 02:52:22 +08:00
|
|
|
}
|
2021-12-04 05:44:55 +08:00
|
|
|
}
|
|
|
|
|
2021-12-01 13:36:20 +08:00
|
|
|
exports.privateChatMessageToast = privateChatMessageToast;
|
|
|
|
exports.publicChatMessageToast = publicChatMessageToast;
|
|
|
|
exports.enableUserJoinPopup = enableUserJoinPopup;
|
|
|
|
exports.checkNotificationText = checkNotificationText;
|
2022-01-20 04:00:40 +08:00
|
|
|
exports.checkNotificationIcon = checkNotificationIcon;
|
2021-12-01 13:36:20 +08:00
|
|
|
exports.enableChatPopup = enableChatPopup;
|
|
|
|
exports.saveSettings = saveSettings;
|
2021-12-10 21:22:41 +08:00
|
|
|
exports.waitAndClearNotification = waitAndClearNotification;
|
2022-06-08 02:52:22 +08:00
|
|
|
exports.waitAndClearDefaultPresentationNotification = waitAndClearDefaultPresentationNotification;
|