2020-06-17 23:29:43 +08:00
|
|
|
const path = require('path');
|
2020-03-14 04:08:30 +08:00
|
|
|
const MultiUsers = require('../user/multiusers');
|
2020-03-23 22:14:56 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const util = require('./util');
|
2021-10-20 04:12:00 +08:00
|
|
|
const utilPolling = require('../polling/util');
|
2021-10-23 03:22:34 +08:00
|
|
|
const utilScreenShare = require('../screenshare/util');
|
|
|
|
const utilPresentation = require('../presentation/util');
|
2021-08-15 03:43:44 +08:00
|
|
|
const e = require('../core/elements');
|
2021-09-30 20:36:08 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME, UPLOAD_PDF_WAIT_TIME, ELEMENT_WAIT_TIME } = require('../core/constants');
|
2021-09-03 04:25:51 +08:00
|
|
|
const { checkElementTextIncludes } = require('../core/util');
|
2020-03-14 04:08:30 +08:00
|
|
|
|
|
|
|
class Notifications extends MultiUsers {
|
|
|
|
constructor() {
|
2021-09-23 03:22:47 +08:00
|
|
|
super();
|
2020-03-14 04:08:30 +08:00
|
|
|
this.page1 = new Page();
|
|
|
|
this.page2 = new Page();
|
2020-03-18 01:13:30 +08:00
|
|
|
this.page3 = new Page();
|
|
|
|
this.page4 = new Page();
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
2021-02-26 23:52:17 +08:00
|
|
|
async init(meetingId, testName) {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.init(true, true, testName, 'User1', meetingId);
|
|
|
|
await this.page2.init(true, true, testName, 'User2', this.page1.meetingId);
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
2021-09-30 20:36:08 +08:00
|
|
|
async initUser3(shouldCloseAudioModal, testFolderName) {
|
|
|
|
await this.page3.init(true, shouldCloseAudioModal, testFolderName, 'User3');
|
2020-03-18 01:13:30 +08:00
|
|
|
}
|
|
|
|
|
2021-02-26 23:52:17 +08:00
|
|
|
async initUser4(testFolderName) {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page4.init(true, true, testFolderName, 'User', this.page3.meetingId);
|
2020-03-18 01:13:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Save Settings toast notification
|
2020-07-18 03:13:47 +08:00
|
|
|
async saveSettingsNotification(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await this.init(undefined, testName);
|
|
|
|
await this.page1.startRecording(testName);
|
|
|
|
await this.page1.screenshot(`${testName}`, `01-page01-initialized-${testName}`);
|
|
|
|
await util.popupMenu(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `02-page01-popupMenu-${testName}`);
|
|
|
|
await util.saveSettings(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `03-page01-save-settings-${testName}`);
|
2021-09-22 11:51:29 +08:00
|
|
|
const resp = await util.getLastToastValue(this.page1) === e.savedSettingsToast;
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `04-page01-saved-Settings-toast-${testName}`);
|
|
|
|
return resp === true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-18 01:13:30 +08:00
|
|
|
// Public chat toast notification
|
2020-07-18 03:13:47 +08:00
|
|
|
async publicChatNotification(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await this.init(undefined, testName);
|
|
|
|
await this.page1.startRecording(testName);
|
|
|
|
await this.page1.screenshot(`${testName}`, `01-page01-initialized-${testName}`);
|
|
|
|
await util.popupMenu(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `02-page01-popup-menu-${testName}`);
|
|
|
|
await util.enableChatPopup(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `03-page01-setting-popup-option-${testName}`);
|
|
|
|
await util.saveSettings(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `04-page01-applied-settings-${testName}`);
|
|
|
|
const expectedToastValue = await util.publicChatMessageToast(this.page1, this.page2);
|
|
|
|
await this.page1.screenshot(`${testName}`, `05-page01-public-chat-message-sent-${testName}`);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page1.waitAndClick(e.chatTitle);
|
|
|
|
await this.page1.waitForSelector(e.smallToastMsg);
|
|
|
|
await this.page1.waitForSelector(e.hasUnreadMessages);
|
2021-08-14 01:35:00 +08:00
|
|
|
const lastToast = await util.getLastToastValue(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `06-page01-public-chat-toast-${testName}`);
|
|
|
|
return expectedToastValue === lastToast;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-18 01:13:30 +08:00
|
|
|
// Private chat toast notification
|
2020-07-18 03:13:47 +08:00
|
|
|
async privateChatNotification(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await this.init(undefined, testName);
|
|
|
|
await this.page1.startRecording(testName);
|
|
|
|
await this.page1.screenshot(`${testName}`, `01-page01-initialized-${testName}`);
|
|
|
|
await util.popupMenu(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `02-page01-popup-menu-${testName}`);
|
|
|
|
await util.enableChatPopup(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `03-page01-setting-popup-option-${testName}`);
|
|
|
|
await util.saveSettings(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `04-page01-applied-settings-${testName}`);
|
|
|
|
const expectedToastValue = await util.privateChatMessageToast(this.page2);
|
|
|
|
await this.page1.screenshot(`${testName}`, `05-page01-private-chat-message-sent-${testName}`);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page1.waitForSelector(e.smallToastMsg);
|
|
|
|
await this.page1.waitForSelector(e.hasUnreadMessages);
|
2021-08-14 01:35:00 +08:00
|
|
|
const lastToast = await util.getLastToastValue(this.page1);
|
|
|
|
await this.page1.screenshot(`${testName}`, `06-page01-public-chat-toast-${testName}`);
|
|
|
|
return expectedToastValue === lastToast;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
2020-03-18 01:13:30 +08:00
|
|
|
|
|
|
|
// User join toast notification
|
2020-06-17 23:29:43 +08:00
|
|
|
async userJoinNotification(page) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await util.popupMenu(page);
|
|
|
|
await util.enableUserJoinPopup(page);
|
|
|
|
await util.saveSettings(page);
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-18 01:13:30 +08:00
|
|
|
}
|
|
|
|
|
2020-07-18 03:13:47 +08:00
|
|
|
async getUserJoinPopupResponse(testName) {
|
2020-08-14 10:41:14 +08:00
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.initUser3(true, testName);
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.page3.startRecording(testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`);
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.userJoinNotification(this.page3);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `02-page03-after-user-join-notification-activation-${testName}`);
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.initUser4(testName);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page3.waitForSelector(e.smallToastMsg, ELEMENT_WAIT_LONGER_TIME);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.page.waitForFunction(checkElementTextIncludes,
|
|
|
|
{ timeout: ELEMENT_WAIT_TIME },
|
2021-08-21 04:33:57 +08:00
|
|
|
'body', 'User joined the session'
|
2020-08-14 10:41:14 +08:00
|
|
|
);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `03-page03-user-join-toast-${testName}`);
|
2020-08-14 10:41:14 +08:00
|
|
|
return true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page3.logger(err);
|
2020-08-14 10:41:14 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-18 01:13:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-20 01:01:55 +08:00
|
|
|
// File upload notification
|
2020-07-18 03:13:47 +08:00
|
|
|
async fileUploaderNotification(testName) {
|
2020-08-14 10:41:14 +08:00
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.initUser3(true, testName);
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.page3.startRecording(testName);
|
2021-10-23 03:22:34 +08:00
|
|
|
await this.page3.screenshot(testName, '01-page03-audio-modal-closed');
|
|
|
|
await utilPresentation.uploadPresentation(this.page3, e.pdfFileName, UPLOAD_PDF_WAIT_TIME);
|
|
|
|
await this.page3.screenshot(testName, '02-page03-presentation-change-toast');
|
|
|
|
|
2020-08-14 10:41:14 +08:00
|
|
|
return true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page3.logger(err);
|
2020-08-14 10:41:14 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-20 01:01:55 +08:00
|
|
|
}
|
|
|
|
|
2020-06-17 23:29:43 +08:00
|
|
|
// Publish Poll Results notification
|
2020-07-18 03:13:47 +08:00
|
|
|
async publishPollResults(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page3.waitForSelector(e.whiteboard);
|
2021-10-20 04:12:00 +08:00
|
|
|
await utilPolling.startPoll(this.page3, true);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `02-page03-started-poll-${testName}`);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page3.waitForSelector(e.smallToastMsg);
|
2021-08-14 01:35:00 +08:00
|
|
|
const resp = await util.getLastToastValue(this.page3);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `03-page03-poll-toast-${testName}`);
|
2021-09-03 04:25:51 +08:00
|
|
|
return resp;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page3.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-20 22:42:04 +08:00
|
|
|
}
|
|
|
|
|
2020-07-18 03:13:47 +08:00
|
|
|
async audioNotification(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.initUser3(false, testName);
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.page3.startRecording(testName);
|
|
|
|
await this.page3.screenshot(`${testName}`, `01-page03-initialized-${testName}`);
|
|
|
|
await this.page3.joinMicrophone();
|
|
|
|
await this.page3.screenshot(`${testName}`, `02-page03-joined-microphone-${testName}`);
|
2021-09-22 11:51:29 +08:00
|
|
|
const resp = await util.getLastToastValue(this.page3) === e.joinAudioToast;
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `03-page03-audio-toast-${testName}`);
|
2021-09-03 04:25:51 +08:00
|
|
|
return resp;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page3.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-07-18 03:13:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async screenshareToast(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.initUser3(true, testName);
|
2021-08-14 01:35:00 +08:00
|
|
|
await this.page3.startRecording(testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`);
|
2021-08-14 01:35:00 +08:00
|
|
|
await utilScreenShare.startScreenshare(this.page3);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `02-page03-screenshare-started-${testName}`);
|
2021-08-14 01:35:00 +08:00
|
|
|
const response = await util.getLastToastValue(this.page3);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page3.screenshot(`${testName}`, `03-page03-screenshare-toast-${testName}`);
|
2021-09-03 04:25:51 +08:00
|
|
|
return response;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page3.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2020-07-18 03:13:47 +08:00
|
|
|
}
|
2020-03-14 04:08:30 +08:00
|
|
|
}
|
|
|
|
|
2023-04-04 04:23:26 +08:00
|
|
|
module.exports = exports = Notifications;
|