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

222 lines
9.2 KiB
JavaScript
Raw Normal View History

2020-06-17 23:29:43 +08:00
const path = require('path');
const MultiUsers = require('../user/multiusers');
const Page = require('../core/page');
const util = require('./util');
const utilPolling = require('../polling/util');
2020-07-18 03:13:47 +08:00
const utilScreenShare = require('../screenshare/util'); // utils imported from screenshare folder
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');
class Notifications extends MultiUsers {
constructor() {
2021-09-23 03:22:47 +08:00
super();
this.page1 = new Page();
this.page2 = new Page();
this.page3 = new Page();
this.page4 = new Page();
}
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);
}
2021-09-30 20:36:08 +08:00
async initUser3(shouldCloseAudioModal, testFolderName) {
await this.page3.init(true, shouldCloseAudioModal, testFolderName, 'User3');
}
async initUser4(testFolderName) {
2021-09-30 20:36:08 +08:00
await this.page4.init(true, true, testFolderName, 'User', this.page3.meetingId);
}
// Save Settings toast notification
2020-07-18 03:13:47 +08:00
async saveSettingsNotification(testName) {
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}`);
const resp = await util.getLastToastValue(this.page1) === e.savedSettingsToast;
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);
return false;
}
}
// Public chat toast notification
2020-07-18 03:13:47 +08:00
async publicChatNotification(testName) {
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}`);
await this.page1.waitAndClick(e.chatTitle);
await this.page1.waitForSelector(e.smallToastMsg);
await this.page1.waitForSelector(e.hasUnreadMessages);
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);
return false;
}
}
// Private chat toast notification
2020-07-18 03:13:47 +08:00
async privateChatNotification(testName) {
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}`);
await this.page1.waitForSelector(e.smallToastMsg);
await this.page1.waitForSelector(e.hasUnreadMessages);
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);
return false;
}
}
// User join toast notification
2020-06-17 23:29:43 +08:00
async userJoinNotification(page) {
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);
return false;
}
}
2020-07-18 03:13:47 +08:00
async getUserJoinPopupResponse(testName) {
try {
2021-09-30 20:36:08 +08:00
await this.initUser3(true, testName);
await this.page3.startRecording(testName);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`);
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}`);
await this.initUser4(testName);
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'
);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `03-page03-user-join-toast-${testName}`);
return true;
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.page3.logger(err);
return false;
}
}
2020-03-20 01:01:55 +08:00
// File upload notification
2020-07-18 03:13:47 +08:00
async fileUploaderNotification(testName) {
try {
2021-09-30 20:36:08 +08:00
await this.initUser3(true, testName);
await this.page3.startRecording(testName);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`);
await util.uploadFileMenu(this.page3);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `02-page03-upload-file-menu-${testName}`);
await this.page3.waitForSelector(e.fileUpload);
const fileUpload = await this.page3.page.$(e.fileUpload);
await fileUpload.uploadFile(path.join(__dirname, `../media/${e.pdfFileName}.pdf`));
2021-10-01 02:38:18 +08:00
await this.page3.page.waitForFunction(checkElementTextIncludes,
{ timeout: ELEMENT_WAIT_TIME },
'body', 'To be uploaded ...'
);
await this.page3.waitAndClick(e.upload);
2021-10-01 02:38:18 +08:00
await this.page3.page.waitForFunction(checkElementTextIncludes,
{ timeout: ELEMENT_WAIT_TIME },
'body', 'Converting file'
);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `03-page03-file-uploaded-and-ready-${testName}`);
await this.page3.waitForSelector(e.smallToastMsg, UPLOAD_PDF_WAIT_TIME);
await this.page3.waitForSelector(e.whiteboard);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `04-page03-presentation-changed-${testName}`);
2021-10-01 02:38:18 +08:00
await this.page3.page.waitForFunction(checkElementTextIncludes,
{ timeout: ELEMENT_WAIT_TIME },
2021-08-21 04:33:57 +08:00
'body', 'Current presentation'
);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `05-page03-presentation-change-toast-${testName}`);
return true;
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.page3.logger(err);
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) {
try {
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`);
await this.page3.waitForSelector(e.whiteboard);
await utilPolling.startPoll(this.page3, true);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `02-page03-started-poll-${testName}`);
await this.page3.waitForSelector(e.smallToastMsg);
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);
return false;
}
2020-03-20 22:42:04 +08:00
}
2020-07-18 03:13:47 +08:00
async audioNotification(testName) {
try {
2021-09-30 20:36:08 +08:00
await this.initUser3(false, testName);
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}`);
const resp = await util.getLastToastValue(this.page3) === e.joinAudioToast;
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);
return false;
}
2020-07-18 03:13:47 +08:00
}
async screenshareToast(testName) {
try {
2021-09-30 20:36:08 +08:00
await this.initUser3(true, testName);
await this.page3.startRecording(testName);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`);
await utilScreenShare.startScreenshare(this.page3);
2021-09-30 20:36:08 +08:00
await this.page3.screenshot(`${testName}`, `02-page03-screenshare-started-${testName}`);
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);
return false;
}
2020-07-18 03:13:47 +08:00
}
}
2021-09-30 20:36:08 +08:00
module.exports = exports = Notifications;