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 } ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . waitingUsersBtn , 'should display the waiting users button' ) ;
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 ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasText ( e . lobbyMessage , /test/ , 'should the lobby message contain the text "test"' ) ;
2022-10-11 01:47:44 +08:00
}
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 } ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasText ( e . guestMessage , /wait/ , 'should the guest message contain the text "wait" for the attendee' ) ;
await this . userPage . hasText ( e . positionInWaitingQueue , /first/ , 'should the position in waiting queue contain the text "first" for the attendee' ) ;
2022-10-11 01:47:44 +08:00
await this . modPage . waitAndClick ( e . waitingUsersBtn ) ;
await this . modPage . waitAndClick ( e . allowEveryone ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasText ( e . guestMessage , /approved/ , 'should the guest message contain the text "approved" for the attendee' , ELEMENT _WAIT _LONGER _TIME ) ;
await this . modPage . hasElement ( e . viewerAvatar , 'should display the viewer avatar for the moderator' , ELEMENT _WAIT _LONGER _TIME ) ;
await this . userPage . hasElement ( e . audioModal , 'should display the audio modal for the attendee' ) ;
2022-10-11 01:47:44 +08:00
}
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 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasText ( e . guestMessage , /denied/ , 'should the guest message contain the text "denied" for the attendee' , ELEMENT _WAIT _LONGER _TIME ) ;
2022-10-11 01:47:44 +08:00
}
async rememberChoice ( ) {
await setGuestPolicyOption ( this . modPage , e . askModerator ) ;
await sleep ( 500 ) ;
await this . modPage . waitAndClick ( e . waitingUsersBtn ) ;
await this . modPage . waitAndClick ( e . rememberCheckboxId ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElementEnabled ( e . rememberCheckboxId , 'should display the remember checkbox id as enabled' ) ;
2022-10-11 01:47:44 +08:00
await this . modPage . waitAndClick ( e . denyEveryone ) ;
2024-03-07 01:28:18 +08:00
await this . initUserPage ( false , this . context , { shouldCheckAllInitialSteps : false } ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . deniedMessageElement , 'should display the denied message for the attendee' ) ;
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 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasText ( e . guestMessage , /test/ , 'should the guest message contain the text "test" for the attendee' , ELEMENT _WAIT _LONGER _TIME ) ;
2022-10-11 01:47:44 +08:00
}
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 } ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasText ( e . guestMessage , /wait/ , 'should the guest message contain the text "wait" for the attendee' ) ;
await this . userPage . hasText ( e . positionInWaitingQueue , /first/ , 'should the position in waiting queue contain the text "first"' ) ;
2022-10-11 01:47:44 +08:00
await this . modPage . waitAndClick ( e . waitingUsersBtn ) ;
await this . modPage . waitAndClick ( e . acceptGuest ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasText ( e . guestMessage , /approved/ , 'should the guest message contain the text "approved" for the attendee' , ELEMENT _WAIT _LONGER _TIME ) ;
2022-10-11 01:47:44 +08:00
await this . modPage . waitForSelector ( e . viewerAvatar , ELEMENT _WAIT _LONGER _TIME ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . audioModal , 'should display the audio modal for the attendee' ) ;
2022-10-11 01:47:44 +08:00
}
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 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasText ( e . guestMessage , /denied/ , 'should the guest message contain the text "denied" for the attendee' , 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 } ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . audioModal , 'should display the audio modal for the attendee' ) ;
2022-01-20 03:50:59 +08:00
}
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 } ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . deniedMessageElement , 'should display the denied message for the attendee' ) ;
2022-01-20 03:50:59 +08:00
}
}
exports . GuestPolicy = GuestPolicy ;