2020-02-08 02:03:06 +08:00
|
|
|
const Page = require('../core/page');
|
2021-09-22 11:51:29 +08:00
|
|
|
const e = require('../core/elements');
|
2021-10-20 04:12:00 +08:00
|
|
|
const util = require('./util');
|
|
|
|
const utilChat = require('../chat/util');
|
2021-10-12 02:18:34 +08:00
|
|
|
const { ELEMENT_WAIT_TIME, ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
2021-10-07 22:29:18 +08:00
|
|
|
const { getElementLength, checkElementLengthEqualTo } = require('../core/util');
|
2020-02-08 02:03:06 +08:00
|
|
|
|
2020-02-13 04:18:41 +08:00
|
|
|
class MultiUsers {
|
2020-02-08 02:03:06 +08:00
|
|
|
constructor() {
|
2020-02-13 04:18:41 +08:00
|
|
|
this.page1 = new Page();
|
|
|
|
this.page2 = new Page();
|
2021-09-23 05:03:12 +08:00
|
|
|
this.userPage = new Page();
|
2020-02-08 02:03:06 +08:00
|
|
|
}
|
|
|
|
|
2020-02-13 04:18:41 +08:00
|
|
|
// Join BigBlueButton meeting
|
2021-09-30 20:36:08 +08:00
|
|
|
async init(testFolderName) {
|
|
|
|
await this.initMod1(testFolderName);
|
|
|
|
await this.page2.init(true, true, testFolderName, 'Mod2', this.page1.meetingId);
|
2021-09-23 05:03:12 +08:00
|
|
|
}
|
|
|
|
|
2021-09-30 20:36:08 +08:00
|
|
|
async initMod1(testFolderName) {
|
|
|
|
await this.page1.init(true, true, testFolderName, 'Mod1')
|
2020-02-08 02:03:06 +08:00
|
|
|
}
|
|
|
|
|
2021-03-30 18:49:07 +08:00
|
|
|
// Join BigBlueButton meeting
|
2021-09-30 20:36:08 +08:00
|
|
|
async initUserPage(shouldCloseAudioModal, testFolderName) {
|
|
|
|
await this.userPage.init(false, shouldCloseAudioModal, testFolderName, 'Attendee', this.page1.meetingId);
|
2021-03-30 18:49:07 +08:00
|
|
|
}
|
|
|
|
|
2020-02-11 06:09:17 +08:00
|
|
|
// Run the test for the page
|
|
|
|
async checkForOtherUser() {
|
2021-09-22 11:51:29 +08:00
|
|
|
const firstCheck = await this.page1.page.evaluate(getElementLength, e.userListItem) > 0;
|
|
|
|
const secondCheck = await this.page1.page.evaluate(getElementLength, e.userListItem) > 0;
|
2020-02-13 04:18:41 +08:00
|
|
|
return {
|
|
|
|
firstCheck,
|
|
|
|
secondCheck,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-23 01:05:34 +08:00
|
|
|
async multiUsersPublicChat(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 11:51:29 +08:00
|
|
|
const chat0 = await this.page1.page.evaluate(getElementLength, e.chatUserMessageText);
|
2021-10-20 04:12:00 +08:00
|
|
|
await utilChat.sendPublicChatMessage(this.page1, this.page2, testName);
|
2021-09-22 11:51:29 +08:00
|
|
|
const chat1 = await this.page1.page.evaluate(getElementLength, e.chatUserMessageText);
|
2021-09-23 01:05:34 +08:00
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
return chat0 !== chat1;
|
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-02-20 01:28:27 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 01:05:34 +08:00
|
|
|
async multiUsersPrivateChat(testName) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-10-20 04:12:00 +08:00
|
|
|
await utilChat.openPrivateChatMessage(this.page1, this.page2);
|
2021-09-23 00:51:35 +08:00
|
|
|
const chat0 = await this.page1.page.evaluate(checkElementLengthEqualTo, e.chatUserMessageText, 0);
|
|
|
|
|
2021-10-20 04:12:00 +08:00
|
|
|
await utilChat.sendPrivateChatMessage(this.page1, this.page2, testName);
|
2021-09-23 00:51:35 +08:00
|
|
|
const receivedMessages = await this.page1.hasElement(e.chatUserMessageText, true) && await this.page2.hasElement(e.chatUserMessageText, true);
|
|
|
|
|
|
|
|
return chat0 && receivedMessages;
|
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-02-20 01:28:27 +08:00
|
|
|
}
|
|
|
|
|
2020-02-13 04:18:41 +08:00
|
|
|
async test() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
const checks = await this.checkForOtherUser();
|
|
|
|
return checks.firstCheck !== false && checks.secondCheck !== false;
|
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-02-08 02:03:06 +08:00
|
|
|
}
|
2020-02-11 06:09:17 +08:00
|
|
|
|
2021-09-23 05:03:12 +08:00
|
|
|
async askModeratorGuestPolicy(testName) {
|
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.initMod1(testName);
|
|
|
|
await this.page1.screenshot(`${testName}`, `01-after-closing-audio-modal-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.manageUsers);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `02-opened-users-managing-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.guestPolicyLabel);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `03-opened-guest-policy-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.askModerator);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `04-clicked-askModerator-[${this.page1.meetingId}]`);
|
|
|
|
await this.initUserPage(false, testName);
|
2021-09-23 05:03:12 +08:00
|
|
|
await this.page1.bringToFront();
|
|
|
|
|
|
|
|
const responseLoggedIn = await this.page1.hasElement(e.waitingUsersBtn);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `05-after-viewer-acceptance-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
return responseLoggedIn;
|
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async alwaysAcceptGuestPolicy(testName) {
|
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.initMod1(testName);
|
|
|
|
await this.page1.screenshot(`${testName}`, `01-after-closing-audio-modal-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.manageUsers);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `02-opened-users-managing-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.guestPolicyLabel);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `03-opened-guest-policy-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.alwaysAccept);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `04-clicked-alwaysAccept-[${this.page1.meetingId}]`);
|
|
|
|
await this.initUserPage(false, testName);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
const responseLoggedIn = await this.userPage.hasElement(e.whiteboard);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.userPage.screenshot(`${testName}`, `05-after-viewer-connection-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
return responseLoggedIn;
|
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async alwaysDenyGuestPolicy(testName) {
|
|
|
|
try {
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.initMod1(testName);
|
|
|
|
await this.page1.screenshot(`${testName}`, `01-after-closing-audio-modal-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.manageUsers);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `02-opened-users-managing-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.guestPolicyLabel);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `03-opened-guest-policy-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
await this.page1.waitAndClick(e.alwaysDeny);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.page1.screenshot(`${testName}`, `04-clicked-alwaysAccept-[${this.page1.meetingId}]`);
|
|
|
|
await this.initUserPage(false, testName);
|
2021-09-23 05:03:12 +08:00
|
|
|
|
|
|
|
const responseLoggedIn = await this.userPage.hasElement(e.joinMeetingDemoPage);
|
2021-09-30 20:36:08 +08:00
|
|
|
await this.userPage.screenshot(`${testName}`, `05-after-viewer-gets-denied-[${this.page1.meetingId}]`);
|
2021-09-23 05:03:12 +08:00
|
|
|
return responseLoggedIn;
|
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 18:49:07 +08:00
|
|
|
async testWhiteboardAccess() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page1.waitForSelector(e.whiteboard);
|
2021-09-23 05:03:12 +08:00
|
|
|
await this.page1.waitAndClick(e.userListItem);
|
|
|
|
await this.page1.waitAndClick(e.changeWhiteboardAccess);
|
2021-09-23 00:51:35 +08:00
|
|
|
await this.page1.waitForSelector(e.multiWhiteboardTool);
|
2021-09-03 02:31:24 +08:00
|
|
|
const resp = await this.page1.page.evaluate((multiWhiteboardTool) => {
|
|
|
|
return document.querySelector(multiWhiteboardTool).children[0].innerText === '1';
|
2021-09-22 11:51:29 +08:00
|
|
|
}, e.multiWhiteboardTool);
|
2021-08-14 01:35:00 +08:00
|
|
|
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;
|
|
|
|
}
|
2021-03-30 18:49:07 +08:00
|
|
|
}
|
|
|
|
|
2021-04-07 08:09:43 +08:00
|
|
|
// Raise Hand
|
|
|
|
async raiseHandTest() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page2.waitAndClick(e.raiseHandLabel);
|
2021-09-23 00:51:35 +08:00
|
|
|
const resp = await this.page2.hasElement(e.lowerHandLabel, true);
|
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
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;
|
|
|
|
}
|
2021-04-07 08:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lower Hand
|
|
|
|
async lowerHandTest() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page2.waitAndClick(e.lowerHandLabel);
|
2021-09-23 00:51:35 +08:00
|
|
|
await this.page2.waitAndClick(e.lowerHandLabel, ELEMENT_WAIT_TIME, true);
|
|
|
|
const resp = await this.page2.hasElement(e.raiseHandLabel, true);
|
|
|
|
|
2021-08-14 01:35:00 +08:00
|
|
|
return resp === true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page2.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2021-04-07 08:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get Avatars Colors from Userlist and Notification toast
|
|
|
|
async getAvatarColorAndCompareWithUserListItem() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 11:51:29 +08:00
|
|
|
const avatarInToastElementColor = await this.page1.page.$eval(e.avatarsWrapperAvatar, (elem) => getComputedStyle(elem).backgroundColor);
|
|
|
|
const avatarInUserListColor = await this.page1.page.$eval(`${e.userListItem} > div ${e.userAvatar}`, (elem) => getComputedStyle(elem).backgroundColor);
|
2021-08-14 01:35:00 +08:00
|
|
|
return avatarInToastElementColor === avatarInUserListColor;
|
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;
|
|
|
|
}
|
2021-04-07 08:09:43 +08:00
|
|
|
}
|
|
|
|
|
2021-04-07 08:39:18 +08:00
|
|
|
async userOfflineWithInternetProblem() {
|
|
|
|
try {
|
|
|
|
await this.page2.page.evaluate(() => window.dispatchEvent(new CustomEvent('socketstats', { detail: { rtt: 2000 } })));
|
2021-05-26 00:05:11 +08:00
|
|
|
await this.page2.page.setOfflineMode(true);
|
2021-04-07 08:39:18 +08:00
|
|
|
await this.page2.close();
|
2021-10-20 04:12:00 +08:00
|
|
|
await util.connectionStatus(this.page1);
|
2021-09-23 00:51:35 +08:00
|
|
|
const connectionStatusItemEmpty = await this.page1.wasRemoved(e.connectionStatusItemEmpty);
|
2021-10-12 02:18:34 +08:00
|
|
|
const connectionStatusOfflineUser = await this.page1.hasElement(e.connectionStatusOfflineUser, true, ELEMENT_WAIT_LONGER_TIME);
|
2021-09-23 00:51:35 +08:00
|
|
|
|
|
|
|
return connectionStatusItemEmpty && connectionStatusOfflineUser;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-04-07 08:39:18 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-26 00:05:11 +08:00
|
|
|
async userlistNotAppearOnMobile() {
|
|
|
|
try {
|
2021-09-22 11:51:29 +08:00
|
|
|
const userlistPanel = await this.page1.page.evaluate(checkElementLengthEqualTo, e.chatButtonKey, 0);
|
|
|
|
const chatPanel = await this.page2.page.evaluate(checkElementLengthEqualTo, e.chatButtonKey, 0);
|
2021-05-26 00:05:11 +08:00
|
|
|
return userlistPanel && chatPanel;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-05-26 00:05:11 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-05 01:57:12 +08:00
|
|
|
async usersConnectionStatus(testName) {
|
|
|
|
try {
|
2021-10-07 22:29:18 +08:00
|
|
|
await this.page1.shareWebcam(true);
|
2021-10-05 01:57:12 +08:00
|
|
|
await this.page1.screenshot(testName, '01-page1-after-share-webcam');
|
|
|
|
await this.initUserPage(false, testName);
|
|
|
|
await this.userPage.joinMicrophone();
|
|
|
|
await this.userPage.screenshot(testName, '02-userPage-after-join-microhpone');
|
2021-10-07 22:29:18 +08:00
|
|
|
await this.userPage.shareWebcam(true);
|
2021-10-05 01:57:12 +08:00
|
|
|
await this.userPage.screenshot(testName, '03-userPage-after-share-webcam');
|
|
|
|
await this.userPage.waitAndClick(e.connectionStatusBtn);
|
|
|
|
try {
|
2021-10-20 04:12:00 +08:00
|
|
|
await this.userPage.page.waitForFunction(util.checkNetworkStatus, { timeout: ELEMENT_WAIT_TIME },
|
2021-10-05 01:57:12 +08:00
|
|
|
e.connectionDataContainer, e.connectionNetwordData
|
|
|
|
);
|
|
|
|
await this.userPage.screenshot(testName, '04-connection-network-success');
|
|
|
|
return true;
|
|
|
|
} catch (err) {
|
|
|
|
await this.userPage.screenshot(testName, '04-connection-network-failed');
|
|
|
|
this.userPage.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
this.page1.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-15 22:18:02 +08:00
|
|
|
async disableWebcamsFromConnectionStatus() {
|
|
|
|
try {
|
|
|
|
await this.page1.shareWebcam(true, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.page2.shareWebcam(true, ELEMENT_WAIT_LONGER_TIME);
|
2021-10-20 04:12:00 +08:00
|
|
|
await util.connectionStatus(this.page1);
|
2021-10-15 22:18:02 +08:00
|
|
|
await this.page1.waitAndClickElement(e.dataSavingWebcams);
|
|
|
|
await this.page1.waitAndClickElement(e.closeConnectionStatusModal);
|
|
|
|
await this.page1.waitForSelector(e.smallToastMsg);
|
|
|
|
const checkUserWhoHasDisabled = await this.page1.page.evaluate(checkElementLengthEqualTo, e.videoContainer, 1);
|
|
|
|
const checkSecondUser = await this.page2.page.evaluate(checkElementLengthEqualTo, e.videoContainer, 2);
|
|
|
|
|
|
|
|
return checkUserWhoHasDisabled && checkSecondUser;
|
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-26 00:05:11 +08:00
|
|
|
async whiteboardNotAppearOnMobile() {
|
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page1.waitAndClick(e.userListButton);
|
|
|
|
await this.page2.waitAndClick(e.userListButton);
|
|
|
|
await this.page2.waitAndClick(e.chatButtonKey);
|
2021-10-12 04:30:01 +08:00
|
|
|
const onUserListPanel = await this.page1.wasRemoved(e.hidePresentation);
|
|
|
|
const onChatPanel = await this.page2.wasRemoved(e.hidePresentation);
|
2021-09-23 00:51:35 +08:00
|
|
|
|
2021-05-26 00:05:11 +08:00
|
|
|
return onUserListPanel && onChatPanel;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-05-26 00:05:11 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async chatPanelNotAppearOnMobile() {
|
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.page2.waitAndClick(e.userListButton);
|
|
|
|
await this.page2.waitAndClick(e.chatButtonKey);
|
2021-09-22 11:51:29 +08:00
|
|
|
const whiteboard = await this.page1.page.evaluate(checkElementLengthEqualTo, e.chatButtonKey, 0);
|
2021-10-12 04:30:01 +08:00
|
|
|
const onChatPanel = await this.page2.hasElement(e.chatButtonKey, false);
|
2021-09-23 00:51:35 +08:00
|
|
|
|
2021-05-26 00:05:11 +08:00
|
|
|
return whiteboard && onChatPanel;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-05-26 00:05:11 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-11 06:09:17 +08:00
|
|
|
// Close all Pages
|
2020-06-17 23:29:43 +08:00
|
|
|
async close(page1, page2) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await page1.close();
|
|
|
|
await page2.close();
|
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-02-11 06:09:17 +08:00
|
|
|
}
|
2020-03-21 04:31:58 +08:00
|
|
|
|
2020-03-23 20:15:10 +08:00
|
|
|
async closePage(page) {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await page.close();
|
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-21 04:31:58 +08:00
|
|
|
}
|
2020-02-08 02:03:06 +08:00
|
|
|
}
|
|
|
|
|
2021-09-30 20:36:08 +08:00
|
|
|
module.exports = exports = MultiUsers;
|