2022-03-29 21:53:07 +08:00
|
|
|
const { expect, default: test } = require('@playwright/test');
|
2022-11-22 21:44:28 +08:00
|
|
|
const playwright = require("playwright");
|
2021-11-18 04:07:14 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const e = require('../core/elements');
|
2022-06-08 02:52:22 +08:00
|
|
|
const { waitAndClearDefaultPresentationNotification } = require('../notifications/util');
|
2022-02-04 22:13:42 +08:00
|
|
|
const { sleep } = require('../core/helpers');
|
2022-12-08 02:53:56 +08:00
|
|
|
const { checkAvatarIcon, checkIsPresenter, checkMutedUsers } = require('./util');
|
2023-01-11 00:59:08 +08:00
|
|
|
const { getNotesLocator } = require('../sharednotes/util');
|
2022-03-21 23:04:43 +08:00
|
|
|
const { checkTextContent } = require('../core/util');
|
2022-03-29 21:53:07 +08:00
|
|
|
const { getSettings } = require('../core/settings');
|
2022-07-16 04:54:16 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
2021-11-16 00:42:29 +08:00
|
|
|
|
|
|
|
class MultiUsers {
|
2021-12-01 13:35:41 +08:00
|
|
|
constructor(browser, context) {
|
|
|
|
this.browser = browser;
|
|
|
|
this.context = context;
|
2021-11-16 00:42:29 +08:00
|
|
|
}
|
|
|
|
|
2022-06-24 09:38:49 +08:00
|
|
|
async initPages(page1, waitAndClearDefaultPresentationNotificationModPage = false) {
|
2021-12-01 13:35:41 +08:00
|
|
|
await this.initModPage(page1);
|
2022-06-24 09:38:49 +08:00
|
|
|
if (waitAndClearDefaultPresentationNotificationModPage) {
|
|
|
|
await waitAndClearDefaultPresentationNotification(this.modPage);
|
|
|
|
}
|
2021-12-01 13:35:41 +08:00
|
|
|
await this.initUserPage();
|
|
|
|
}
|
|
|
|
|
2021-12-15 01:10:44 +08:00
|
|
|
async initModPage(page, shouldCloseAudioModal = true, { fullName = 'Moderator', ...restOptions } = {}) {
|
|
|
|
const options = {
|
|
|
|
...restOptions,
|
2022-02-08 02:01:47 +08:00
|
|
|
fullName,
|
2021-12-15 01:10:44 +08:00
|
|
|
};
|
|
|
|
|
2021-12-01 13:35:41 +08:00
|
|
|
this.modPage = new Page(this.browser, page);
|
2021-12-15 01:10:44 +08:00
|
|
|
await this.modPage.init(true, shouldCloseAudioModal, options);
|
2021-12-01 13:35:41 +08:00
|
|
|
}
|
|
|
|
|
2022-02-08 02:01:47 +08:00
|
|
|
async initModPage2(shouldCloseAudioModal = true, context = this.context, { fullName = 'Moderator2', useModMeetingId = true, ...restOptions } = {}) {
|
|
|
|
const options = {
|
|
|
|
...restOptions,
|
|
|
|
fullName,
|
|
|
|
meetingId: (useModMeetingId) ? this.modPage.meetingId : undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
const page = await context.newPage();
|
|
|
|
this.modPage2 = new Page(this.browser, page);
|
|
|
|
await this.modPage2.init(true, shouldCloseAudioModal, options);
|
|
|
|
}
|
|
|
|
|
2021-12-15 01:10:44 +08:00
|
|
|
async initUserPage(shouldCloseAudioModal = true, context = this.context, { fullName = 'Attendee', useModMeetingId = true, ...restOptions } = {}) {
|
|
|
|
const options = {
|
|
|
|
...restOptions,
|
|
|
|
fullName,
|
|
|
|
meetingId: (useModMeetingId) ? this.modPage.meetingId : undefined,
|
|
|
|
};
|
|
|
|
|
2021-12-10 21:30:29 +08:00
|
|
|
const page = await context.newPage();
|
2021-12-01 13:35:41 +08:00
|
|
|
this.userPage = new Page(this.browser, page);
|
2021-12-15 01:10:44 +08:00
|
|
|
await this.userPage.init(false, shouldCloseAudioModal, options);
|
2021-11-16 00:42:29 +08:00
|
|
|
}
|
|
|
|
|
2022-11-22 21:44:28 +08:00
|
|
|
async initUserPage1(shouldCloseAudioModal = true, { fullName = 'Attendee', useModMeetingId = true, ...restOptions } = {}) {
|
|
|
|
const options = {
|
|
|
|
...restOptions,
|
|
|
|
fullName,
|
|
|
|
meetingId: (useModMeetingId) ? this.modPage.meetingId : undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
const page = await (await playwright.chromium.launch()).newPage();
|
|
|
|
this.userPage1 = new Page(this.browser, page);
|
|
|
|
await this.userPage1.init(false, shouldCloseAudioModal, options);
|
|
|
|
}
|
|
|
|
|
2022-01-29 03:52:22 +08:00
|
|
|
async initUserPage2(shouldCloseAudioModal = true, context = this.context, { fullName = 'Attendee2', useModMeetingId = true, ...restOptions } = {}) {
|
|
|
|
const options = {
|
|
|
|
...restOptions,
|
|
|
|
fullName,
|
|
|
|
meetingId: (useModMeetingId) ? this.modPage.meetingId : undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
const page = await context.newPage();
|
|
|
|
this.userPage2 = new Page(this.browser, page);
|
|
|
|
await this.userPage2.init(false, shouldCloseAudioModal, options);
|
|
|
|
}
|
|
|
|
|
2022-07-16 04:54:16 +08:00
|
|
|
async muteAnotherUser() {
|
|
|
|
await this.userPage.joinMicrophone();
|
|
|
|
await this.modPage.hasElement(e.joinAudio);
|
|
|
|
await this.modPage.waitAndClick(e.isTalking);
|
|
|
|
await this.userPage.hasElement(e.unmuteMicButton);
|
|
|
|
await this.modPage.hasElement(e.wasTalking);
|
|
|
|
await this.userPage.hasElement(e.wasTalking);
|
|
|
|
await this.userPage.wasRemoved(e.talkingIndicator, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.wasRemoved(e.talkingIndicator);
|
|
|
|
}
|
|
|
|
|
2021-11-23 05:51:16 +08:00
|
|
|
async userPresence() {
|
2022-09-23 04:17:15 +08:00
|
|
|
await this.modPage.checkElementCount(e.currentUser, 1);
|
|
|
|
await this.modPage.checkElementCount(e.userListItem, 1);
|
|
|
|
await this.userPage.checkElementCount(e.currentUser, 1);
|
|
|
|
await this.userPage.checkElementCount(e.userListItem, 1);
|
2021-12-10 21:30:29 +08:00
|
|
|
}
|
|
|
|
|
2022-02-08 02:45:42 +08:00
|
|
|
async makePresenter() {
|
|
|
|
await this.modPage.waitAndClick(e.userListItem);
|
|
|
|
await this.modPage.waitAndClick(e.makePresenter);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage.wasRemoved(e.wbToolbar);
|
2022-02-08 02:45:42 +08:00
|
|
|
|
|
|
|
await this.userPage.hasElement(e.startScreenSharing);
|
|
|
|
await this.userPage.hasElement(e.presentationToolbarWrapper);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.userPage.hasElement(e.wbToolbar);
|
2022-02-08 02:45:42 +08:00
|
|
|
await this.userPage.hasElement(e.actions);
|
2022-03-02 04:11:45 +08:00
|
|
|
const isPresenter = await checkIsPresenter(this.userPage);
|
|
|
|
expect(isPresenter).toBeTruthy();
|
2022-02-08 02:45:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async takePresenter() {
|
2022-03-02 04:11:45 +08:00
|
|
|
await this.modPage2.waitAndClick(e.currentUser);
|
2022-02-08 02:45:42 +08:00
|
|
|
await this.modPage2.waitAndClick(e.takePresenter);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage.wasRemoved(e.wbToolbar);
|
2022-02-08 02:45:42 +08:00
|
|
|
|
|
|
|
await this.modPage2.hasElement(e.startScreenSharing);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage2.hasElement(e.wbToolbar);
|
2022-02-08 02:45:42 +08:00
|
|
|
await this.modPage2.hasElement(e.presentationToolbarWrapper);
|
2022-03-02 04:11:45 +08:00
|
|
|
const isPresenter = await checkIsPresenter(this.modPage2);
|
|
|
|
expect(isPresenter).toBeTruthy();
|
2022-02-08 02:45:42 +08:00
|
|
|
await this.modPage2.waitAndClick(e.actions);
|
|
|
|
await this.modPage2.hasElement(e.managePresentations);
|
|
|
|
await this.modPage2.hasElement(e.polling);
|
|
|
|
await this.modPage2.hasElement(e.shareExternalVideoBtn);
|
|
|
|
}
|
|
|
|
|
2022-02-08 02:01:47 +08:00
|
|
|
async promoteToModerator() {
|
|
|
|
await checkAvatarIcon(this.userPage, false);
|
|
|
|
await this.userPage.wasRemoved(e.manageUsers);
|
|
|
|
await this.modPage.waitAndClick(e.userListItem);
|
|
|
|
await this.modPage.waitAndClick(e.promoteToModerator);
|
|
|
|
await checkAvatarIcon(this.userPage);
|
|
|
|
await this.userPage.hasElement(e.manageUsers);
|
|
|
|
}
|
|
|
|
|
|
|
|
async demoteToViewer() {
|
|
|
|
await checkAvatarIcon(this.modPage2);
|
|
|
|
await this.modPage2.hasElement(e.manageUsers);
|
|
|
|
await this.modPage.waitAndClick(e.userListItem);
|
|
|
|
await this.modPage.waitAndClick(e.demoteToViewer);
|
|
|
|
await checkAvatarIcon(this.modPage2, false);
|
|
|
|
await this.modPage2.wasRemoved(e.manageUsers);
|
|
|
|
}
|
|
|
|
|
2022-03-29 21:53:07 +08:00
|
|
|
async raiseAndLowerHand() {
|
|
|
|
const { raiseHandButton } = getSettings();
|
|
|
|
test.fail(!raiseHandButton, 'Raise/lower hand button is disabled');
|
|
|
|
|
2022-06-08 02:52:22 +08:00
|
|
|
await waitAndClearDefaultPresentationNotification(this.modPage);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.initUserPage();
|
2022-01-20 03:57:13 +08:00
|
|
|
await this.userPage.waitAndClick(e.raiseHandBtn);
|
2022-06-08 02:52:22 +08:00
|
|
|
await sleep(1000);
|
2022-01-20 03:57:13 +08:00
|
|
|
await this.userPage.hasElement(e.lowerHandBtn);
|
2021-12-10 21:30:29 +08:00
|
|
|
const getBackgroundColorComputed = (locator) => locator.evaluate((elem) => getComputedStyle(elem).backgroundColor);
|
2022-01-20 03:50:59 +08:00
|
|
|
const avatarInToastElementColor = this.modPage.getLocator(e.avatarsWrapperAvatar);
|
|
|
|
const avatarInUserListColor = this.modPage.getLocator(`${e.userListItem} > div ${e.userAvatar}`);
|
2021-12-10 21:30:29 +08:00
|
|
|
await expect(getBackgroundColorComputed(avatarInToastElementColor)).toStrictEqual(getBackgroundColorComputed(avatarInUserListColor));
|
2022-01-20 03:57:13 +08:00
|
|
|
await this.userPage.waitAndClick(e.lowerHandBtn);
|
|
|
|
await this.userPage.hasElement(e.raiseHandBtn);
|
2021-12-10 21:30:29 +08:00
|
|
|
}
|
2022-02-08 03:22:48 +08:00
|
|
|
|
|
|
|
async toggleUserList() {
|
|
|
|
await this.modPage.hasElement(e.chatWelcomeMessageText);
|
|
|
|
await this.modPage.hasElement(e.chatBox);
|
|
|
|
await this.modPage.hasElement(e.chatButton);
|
|
|
|
await this.modPage.waitAndClick(e.userListToggleBtn);
|
|
|
|
await this.modPage.wasRemoved(e.chatWelcomeMessageText);
|
|
|
|
await this.modPage.wasRemoved(e.chatBox);
|
|
|
|
await this.modPage.wasRemoved(e.chatButton);
|
|
|
|
await this.modPage.waitAndClick(e.userListToggleBtn);
|
|
|
|
await this.modPage.wasRemoved(e.chatWelcomeMessageText);
|
|
|
|
await this.modPage.wasRemoved(e.chatBox);
|
|
|
|
await this.modPage.hasElement(e.chatButton);
|
|
|
|
}
|
2022-03-21 23:04:43 +08:00
|
|
|
|
|
|
|
async saveUserNames(testInfo) {
|
|
|
|
await this.modPage.waitAndClick(e.manageUsers);
|
|
|
|
const { content } = await this.modPage.handleDownload(e.downloadUserNamesList, testInfo);
|
|
|
|
|
|
|
|
const dataToCheck = [
|
|
|
|
this.modPage.username,
|
|
|
|
this.userPage.username,
|
|
|
|
this.modPage.meetingId,
|
|
|
|
];
|
|
|
|
await checkTextContent(content, dataToCheck);
|
|
|
|
}
|
2021-12-10 21:30:29 +08:00
|
|
|
|
2022-02-04 22:13:42 +08:00
|
|
|
async selectRandomUser() {
|
|
|
|
// check with no viewer joined
|
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.selectRandomUser);
|
|
|
|
await this.modPage.hasElement(e.noViewersSelectedMessage);
|
|
|
|
// check with only one viewer
|
|
|
|
await this.modPage.waitAndClick(e.closeModal);
|
|
|
|
await this.initUserPage();
|
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.selectRandomUser);
|
|
|
|
await this.modPage.hasText(e.selectedUserName, this.userPage.username);
|
|
|
|
// check with more users
|
|
|
|
await this.modPage.waitAndClick(e.closeModal);
|
|
|
|
await this.initUserPage2();
|
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.selectRandomUser);
|
|
|
|
const nameSelected = await this.modPage.getLocator(e.selectedUserName).textContent();
|
|
|
|
await this.userPage.hasText(e.selectedUserName, nameSelected);
|
|
|
|
await this.userPage2.hasText(e.selectedUserName, nameSelected);
|
|
|
|
// user close modal just for you
|
|
|
|
await this.userPage.waitAndClick(e.closeModal);
|
|
|
|
await this.userPage.wasRemoved(e.selectedUserName);
|
|
|
|
await this.userPage2.hasElement(e.selectedUserName);
|
|
|
|
await this.modPage.hasElement(e.selectedUserName);
|
|
|
|
// moderator close modal
|
|
|
|
await this.modPage.waitAndClick(e.selectAgainRadomUser);
|
|
|
|
await sleep(500);
|
|
|
|
await this.modPage.waitAndClick(e.closeModal);
|
|
|
|
await this.userPage.wasRemoved(e.selectedUserName);
|
|
|
|
await this.userPage2.wasRemoved(e.selectedUserName);
|
|
|
|
}
|
|
|
|
|
2021-11-23 05:51:16 +08:00
|
|
|
async whiteboardAccess() {
|
2021-12-02 12:12:14 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
await this.modPage.waitAndClick(e.userListItem);
|
|
|
|
await this.modPage.waitAndClick(e.changeWhiteboardAccess);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage.waitForSelector(e.multiUsersWhiteboardOff);
|
|
|
|
const resp = await this.modPage.page.evaluate((multiUsersWbBtn) => {
|
|
|
|
return document.querySelector(multiUsersWbBtn).parentElement.children[1].innerText;
|
|
|
|
}, e.multiUsersWhiteboardOff);
|
2021-11-23 05:51:16 +08:00
|
|
|
await expect(resp).toBeTruthy();
|
|
|
|
}
|
2022-12-08 02:53:56 +08:00
|
|
|
|
|
|
|
async muteAllUsers() {
|
|
|
|
await this.modPage.joinMicrophone();
|
|
|
|
await this.modPage2.joinMicrophone();
|
|
|
|
await this.userPage.joinMicrophone();
|
|
|
|
await this.modPage.waitAndClick(e.manageUsers);
|
|
|
|
await this.modPage.waitAndClick(e.muteAll);
|
|
|
|
|
|
|
|
await checkMutedUsers(this.modPage);
|
|
|
|
await checkMutedUsers(this.modPage2);
|
|
|
|
await checkMutedUsers(this.userPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
async muteAllUsersExceptPresenter(){
|
|
|
|
await this.modPage.joinMicrophone();
|
|
|
|
await this.modPage2.joinMicrophone();
|
|
|
|
await this.userPage.joinMicrophone();
|
|
|
|
await this.modPage.waitAndClick(e.manageUsers);
|
|
|
|
await this.modPage.waitAndClick(e.muteAllExceptPresenter);
|
|
|
|
|
|
|
|
await this.modPage.hasElement(e.isTalking);
|
|
|
|
await checkMutedUsers(this.modPage2);
|
|
|
|
await checkMutedUsers(this.userPage);
|
|
|
|
}
|
2022-12-22 02:30:08 +08:00
|
|
|
|
2022-12-09 02:32:31 +08:00
|
|
|
async giveAndRemoveWhiteboardAccess() {
|
|
|
|
await this.whiteboardAccess();
|
|
|
|
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
await this.modPage.waitAndClick(e.userListItem);
|
|
|
|
await this.modPage.waitAndClick(e.changeWhiteboardAccess);
|
|
|
|
|
|
|
|
await this.modPage.hasElement(e.multiUsersWhiteboardOn);
|
|
|
|
}
|
2023-01-10 21:39:18 +08:00
|
|
|
|
|
|
|
async writeClosedCaptions() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
await this.modPage2.waitForSelector(e.whiteboard);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.manageUsers);
|
|
|
|
await this.modPage.waitAndClick(e.writeClosedCaptions);
|
|
|
|
await this.modPage.waitAndClick(e.startWritingClosedCaptions);
|
|
|
|
|
2023-01-11 00:59:08 +08:00
|
|
|
await this.modPage.waitAndClick(e.startViewingClosedCaptionsBtn);
|
|
|
|
await this.modPage2.waitAndClick(e.startViewingClosedCaptionsBtn);
|
|
|
|
|
2023-01-10 21:39:18 +08:00
|
|
|
await this.modPage.waitAndClick(e.startViewingClosedCaptions);
|
|
|
|
await this.modPage2.waitAndClick(e.startViewingClosedCaptions);
|
2023-01-11 00:59:08 +08:00
|
|
|
|
|
|
|
const notesLocator = getNotesLocator(this.modPage);
|
|
|
|
await notesLocator.type(e.message);
|
|
|
|
|
2023-01-13 19:53:27 +08:00
|
|
|
await this.modPage.hasText(e.liveCaptions, "Hello World!");
|
|
|
|
await this.modPage2.hasText(e.liveCaptions, "Hello World!");
|
2023-01-10 21:39:18 +08:00
|
|
|
}
|
2021-11-16 00:42:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.MultiUsers = MultiUsers;
|