2022-01-29 03:52:22 +08:00
|
|
|
const { MultiUsers } = require("./multiusers");
|
|
|
|
const { openLockViewers } = require('./util');
|
|
|
|
const e = require('../core/elements');
|
|
|
|
const { expect } = require("@playwright/test");
|
|
|
|
const { ELEMENT_WAIT_LONGER_TIME, ELEMENT_WAIT_TIME } = require("../core/constants");
|
|
|
|
const { getNotesLocator } = require("../sharednotes/util");
|
2022-02-03 08:05:26 +08:00
|
|
|
const { waitAndClearNotification } = require("../notifications/util");
|
2022-02-04 22:13:42 +08:00
|
|
|
const { sleep } = require("../core/helpers");
|
2022-01-29 03:52:22 +08:00
|
|
|
|
|
|
|
class LockViewers extends MultiUsers {
|
|
|
|
constructor(browser, page) {
|
|
|
|
super(browser, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
async lockShareWebcam() {
|
|
|
|
await this.modPage.shareWebcam();
|
2022-02-03 08:05:26 +08:00
|
|
|
await this.userPage.hasElement(e.webcamVideoItem);
|
|
|
|
await this.userPage2.hasElement(e.webcamVideoItem);
|
2022-01-29 03:52:22 +08:00
|
|
|
await this.userPage.shareWebcam();
|
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockShareWebcam);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
2022-06-08 02:52:22 +08:00
|
|
|
await waitAndClearNotification(this.modPage);
|
2022-02-03 08:05:26 +08:00
|
|
|
const videoContainerLockedCount = await this.userPage2.getSelectorCount(e.webcamVideoItem);
|
2022-01-29 03:52:22 +08:00
|
|
|
expect(videoContainerLockedCount).toBe(1);
|
|
|
|
|
|
|
|
await this.userPage2.waitForSelector(e.dropdownWebcamButton);
|
|
|
|
await this.userPage2.hasText(e.dropdownWebcamButton, this.modPage.username);
|
|
|
|
await this.userPage.hasElementDisabled(e.joinVideo);
|
|
|
|
}
|
|
|
|
|
|
|
|
async lockSeeOtherViewersWebcams() {
|
|
|
|
await this.modPage.shareWebcam();
|
|
|
|
await this.userPage.shareWebcam();
|
|
|
|
await this.userPage2.shareWebcam();
|
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockSeeOtherViewersWebcam);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
2022-02-04 22:13:42 +08:00
|
|
|
await sleep(500);
|
2022-01-29 03:52:22 +08:00
|
|
|
const videoContainersCount = [
|
2022-02-03 08:05:26 +08:00
|
|
|
await this.modPage.getSelectorCount(e.webcamVideoItem),
|
|
|
|
await this.userPage.getSelectorCount(e.webcamVideoItem),
|
|
|
|
await this.userPage2.getSelectorCount(e.webcamVideoItem),
|
2022-01-29 03:52:22 +08:00
|
|
|
];
|
|
|
|
expect(videoContainersCount).toStrictEqual([3, 2, 2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
async lockShareMicrophone() {
|
|
|
|
await this.userPage.waitAndClick(e.joinAudio);
|
|
|
|
await this.userPage.joinMicrophone();
|
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockShareMicrophone);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
|
|
|
await this.userPage.wasRemoved(e.toggleMicrophoneButton);
|
|
|
|
await this.userPage2.waitAndClick(e.joinAudio);
|
|
|
|
await this.userPage2.waitForSelector(e.connecting);
|
|
|
|
await this.userPage2.hasElement(e.leaveAudio, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
async lockSendPublicChatMessages() {
|
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockPublicChat);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
|
|
|
await this.userPage.hasElementDisabled(e.chatBox);
|
|
|
|
await this.userPage.hasElementDisabled(e.sendButton);
|
|
|
|
await this.modPage.type(e.chatBox, e.message);
|
|
|
|
await this.modPage.waitAndClick(e.sendButton);
|
|
|
|
await this.userPage.waitForSelector(e.chatUserMessageText);
|
|
|
|
const messagesCount = this.userPage.getLocator(e.chatUserMessageText);
|
|
|
|
await expect(messagesCount).toHaveCount(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
async lockSendPrivateChatMessages() {
|
2022-02-05 03:26:35 +08:00
|
|
|
const lastUserItemLocator = this.userPage.getLocatorByIndex(e.userListItem, -1);
|
2022-02-03 08:45:23 +08:00
|
|
|
await this.userPage.clickOnLocator(lastUserItemLocator);
|
2022-02-05 03:26:35 +08:00
|
|
|
const startPrivateChatButton = this.userPage.getLocatorByIndex(e.startPrivateChat, -1);
|
2022-02-03 08:45:23 +08:00
|
|
|
await this.userPage.clickOnLocator(startPrivateChatButton);
|
2022-01-29 03:52:22 +08:00
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockPrivateChat);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
|
|
|
await this.userPage.hasElementDisabled(e.chatBox);
|
|
|
|
await this.userPage.hasElementDisabled(e.sendButton);
|
|
|
|
}
|
|
|
|
|
|
|
|
async lockEditSharedNotes() {
|
|
|
|
await this.userPage.waitAndClick(e.sharedNotes);
|
2022-03-01 03:46:13 +08:00
|
|
|
await this.userPage.waitForSelector(e.hideNotesLabel);
|
2022-01-29 03:52:22 +08:00
|
|
|
const sharedNotesLocator = getNotesLocator(this.userPage);
|
|
|
|
await sharedNotesLocator.type(e.message);
|
2022-03-02 04:11:45 +08:00
|
|
|
expect(sharedNotesLocator).toContainText(e.message, { timeout: ELEMENT_WAIT_TIME });
|
2022-01-29 03:52:22 +08:00
|
|
|
|
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockEditSharedNotes);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
|
|
|
await this.userPage.waitAndClick(e.sharedNotes);
|
|
|
|
await this.userPage.waitAndClick(e.sharedNotes);
|
|
|
|
// tries to type, but the element is not editable
|
2022-03-08 02:56:08 +08:00
|
|
|
await this.userPage.wasRemoved(e.etherpadFrame);
|
2022-01-29 03:52:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async lockSeeOtherViewersUserList() {
|
2022-04-27 20:46:15 +08:00
|
|
|
expect(await this.userPage.getLocator(e.userListItem).count()).toBe(2);
|
2022-01-29 03:52:22 +08:00
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockUserList);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
|
|
|
|
2022-04-27 20:46:15 +08:00
|
|
|
await sleep(1000);
|
|
|
|
expect(await this.userPage.getLocator(e.userListItem).count()).toBe(1);
|
2022-01-29 03:52:22 +08:00
|
|
|
await this.userPage2.hasText(e.userListItem, this.modPage.username);
|
|
|
|
}
|
2022-02-03 08:45:23 +08:00
|
|
|
|
|
|
|
async unlockUser() {
|
|
|
|
await openLockViewers(this.modPage);
|
|
|
|
await this.modPage.waitAndClickElement(e.lockShareWebcam);
|
|
|
|
await this.modPage.waitAndClick(e.applyLockSettings);
|
|
|
|
await this.userPage.hasElementDisabled(e.joinVideo);
|
|
|
|
await this.userPage2.hasElementDisabled(e.joinVideo);
|
|
|
|
|
2022-02-05 03:26:35 +08:00
|
|
|
const lastUserItemLocator = this.modPage.getLocatorByIndex(e.userListItem, -1);
|
2022-02-03 08:45:23 +08:00
|
|
|
await this.modPage.clickOnLocator(lastUserItemLocator);
|
2022-02-05 03:26:35 +08:00
|
|
|
const unlockUserButton = this.modPage.getLocatorByIndex(e.unlockUserButton, -1);
|
2022-02-03 08:45:23 +08:00
|
|
|
await this.modPage.clickOnLocator(unlockUserButton);
|
|
|
|
await this.userPage.hasElementDisabled(e.joinVideo);
|
|
|
|
await this.userPage2.hasElementEnabled(e.joinVideo);
|
|
|
|
}
|
2022-01-29 03:52:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.LockViewers = LockViewers;
|