2022-01-20 03:50:59 +08:00
|
|
|
const { MultiUsers } = require("./multiusers");
|
|
|
|
const e = require('../core/elements');
|
|
|
|
const { sleep } = require('../core/helpers');
|
2022-02-04 04:10:26 +08:00
|
|
|
const { setGuestPolicyOption } = require("./util");
|
2022-10-11 01:47:44 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require("../core/constants");
|
2022-01-20 03:50:59 +08:00
|
|
|
|
|
|
|
class GuestPolicy extends MultiUsers {
|
|
|
|
constructor(browser, context) {
|
|
|
|
super(browser, context);
|
|
|
|
}
|
|
|
|
|
2022-10-11 01:47:44 +08:00
|
|
|
async messageToGuestLobby() {
|
2022-02-04 04:10:26 +08:00
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await sleep(500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.modPage.hasElement(e.waitingUsersBtn);
|
2022-10-11 01:47:44 +08:00
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.waitingUsersBtn);
|
|
|
|
await this.modPage.type(e.waitingUsersLobbyMessage, 'test');
|
|
|
|
await this.modPage.waitAndClick(e.sendLobbyMessage);
|
|
|
|
await this.modPage.hasText(e.lobbyMessage, /test/);
|
|
|
|
}
|
|
|
|
|
|
|
|
async allowEveryone() {
|
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await sleep(500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2022-10-11 01:47:44 +08:00
|
|
|
await this.userPage.hasText(e.guestMessage, /wait/);
|
|
|
|
await this.userPage.hasText(e.positionInWaitingQueue, /first/);
|
|
|
|
await this.modPage.waitAndClick(e.waitingUsersBtn);
|
|
|
|
await this.modPage.waitAndClick(e.allowEveryone);
|
|
|
|
|
|
|
|
await this.userPage.hasText(e.guestMessage, /approved/, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.hasElement(e.viewerAvatar, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.userPage.hasElement(e.audioModal);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
async denyEveryone() {
|
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await sleep(500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2022-10-11 01:47:44 +08:00
|
|
|
await this.modPage.waitAndClick(e.waitingUsersBtn);
|
|
|
|
await this.modPage.waitAndClick(e.denyEveryone);
|
|
|
|
|
|
|
|
await this.userPage.hasText(e.guestMessage, /denied/, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
async rememberChoice() {
|
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await sleep(500);
|
|
|
|
await this.modPage.waitAndClick(e.waitingUsersBtn);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.rememberCheckboxId);
|
|
|
|
await this.modPage.hasElementEnabled(e.rememberCheckboxId);
|
|
|
|
await this.modPage.waitAndClick(e.denyEveryone);
|
|
|
|
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2023-05-19 21:11:24 +08:00
|
|
|
await this.userPage.hasElement(e.deniedMessageElement);
|
2022-10-11 01:47:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async messageToSpecificUser() {
|
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await sleep(500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2022-10-11 01:47:44 +08:00
|
|
|
await this.modPage.waitAndClick(e.waitingUsersBtn);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.privateMessageGuest);
|
|
|
|
await this.modPage.type(e.inputPrivateLobbyMesssage, 'test');
|
|
|
|
await this.modPage.waitAndClick(e.sendPrivateLobbyMessage);
|
|
|
|
await this.userPage.hasText(e.guestMessage, /test/, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
async acceptSpecificUser() {
|
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await sleep(500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2022-10-11 01:47:44 +08:00
|
|
|
await this.userPage.hasText(e.guestMessage, /wait/);
|
|
|
|
await this.userPage.hasText(e.positionInWaitingQueue, /first/);
|
|
|
|
await this.modPage.waitAndClick(e.waitingUsersBtn);
|
|
|
|
await this.modPage.waitAndClick(e.acceptGuest);
|
|
|
|
await this.userPage.hasText(e.guestMessage, /approved/, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
|
|
|
|
await this.modPage.waitForSelector(e.viewerAvatar, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.userPage.hasElement(e.audioModal);
|
|
|
|
}
|
|
|
|
|
|
|
|
async denySpecificUser() {
|
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await sleep(500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2022-10-11 01:47:44 +08:00
|
|
|
await this.modPage.waitAndClick(e.waitingUsersBtn);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.denyGuest);
|
|
|
|
await this.userPage.hasText(e.guestMessage, /denied/, ELEMENT_WAIT_LONGER_TIME);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async alwaysAccept() {
|
2022-02-04 04:10:26 +08:00
|
|
|
await setGuestPolicyOption(this.modPage, e.askModerator);
|
|
|
|
await setGuestPolicyOption(this.modPage, e.alwaysAccept);
|
|
|
|
await sleep(500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.userPage.hasElement(e.audioModal);
|
|
|
|
}
|
|
|
|
|
|
|
|
async alwaysDeny() {
|
2022-02-04 04:10:26 +08:00
|
|
|
await setGuestPolicyOption(this.modPage, e.alwaysDeny);
|
2022-01-20 03:50:59 +08:00
|
|
|
await sleep(1500);
|
2024-03-07 01:28:18 +08:00
|
|
|
await this.initUserPage(false, this.context, { shouldCheckAllInitialSteps: false });
|
2023-05-19 21:11:24 +08:00
|
|
|
await this.userPage.hasElement(e.deniedMessageElement);
|
2022-01-20 03:50:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.GuestPolicy = GuestPolicy;
|