2022-01-29 03:52:22 +08:00
const { MultiUsers } = require ( "./multiusers" ) ;
2023-07-03 21:01:05 +08:00
const { openLockViewers , drawArrow } = require ( './util' ) ;
2022-01-29 03:52:22 +08:00
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 ) ;
}
2023-07-05 21:05:57 +08:00
async lockShareWebcam ( ) {
2022-01-29 03:52:22 +08:00
await this . modPage . shareWebcam ( ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . webcamVideoItem , 'should display the webcam video item for the moderator' ) ;
await this . userPage . hasElement ( e . webcamVideoItem , 'should display the webcam video item for the attendee' ) ;
2022-01-29 03:52:22 +08:00
await this . userPage . shareWebcam ( ) ;
2023-07-05 02:01:19 +08:00
2024-07-31 06:49:02 +08:00
await this . modPage . hasNElements ( e . webcamVideoItem , 2 , 'should display two webcam video item for the moderator' ) ;
await this . userPage . hasNElements ( e . webcamVideoItem , 2 , 'should display two webcam video item for the attendee' ) ;
2022-01-29 03:52:22 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . checkElementCount ( e . webcamContainer , 1 , 'should display one webcam container for the attendee' ) ;
2023-07-05 02:01:19 +08:00
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( true ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . hasElementDisabled ( e . joinVideo , 'should the join video button to be disabled for the second attendee' ) ;
2023-07-03 21:01:05 +08:00
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
await this . userPage2 . waitAndClick ( e . joinVideo ) ;
await this . userPage2 . waitAndClick ( e . startSharingWebcam ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . checkElementCount ( e . webcamContainer , 2 , 'should display two webcams container for the moderator' ) ;
await this . userPage . hasElementDisabled ( e . joinVideo , 'should the join video button to be disabled' ) ;
2022-01-29 03:52:22 +08:00
}
2023-07-05 21:05:57 +08:00
async lockSeeOtherViewersWebcams ( ) {
2022-01-29 03:52:22 +08:00
await this . modPage . shareWebcam ( ) ;
await this . userPage . shareWebcam ( ) ;
2023-07-05 21:05:57 +08:00
2022-01-29 03:52:22 +08:00
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 ) ,
2022-01-29 03:52:22 +08:00
] ;
2024-07-31 06:49:02 +08:00
await expect ( videoContainersCount , 'should the videos containter count to be stricted equal to 2 for the moderator and the attendee' ) . toStrictEqual ( [ 2 , 2 ] ) ;
2023-07-03 21:01:05 +08:00
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( true ) ;
2023-07-03 21:01:05 +08:00
await this . userPage2 . shareWebcam ( ) ;
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . checkElementCount ( e . webcamContainer , 3 , 'should display three webcams container for the moderator' ) ;
await this . userPage . checkElementCount ( e . webcamContainer , 2 , 'should display two webcams container for the first attendee' ) ;
await this . userPage2 . checkElementCount ( e . webcamContainer , 3 , 'should display three webcam container for the second attendee' ) ;
2022-01-29 03:52:22 +08:00
}
2023-07-05 21:05:57 +08:00
async lockShareMicrophone ( ) {
2022-01-29 03:52:22 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . wasRemoved ( e . isTalking , 'should not display the is talking element for the first attendee' ) ;
2022-07-02 04:55:32 +08:00
await this . userPage . waitForSelector ( e . unmuteMicButton ) ;
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( false ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . hasElement ( e . leaveListenOnly , 'should display the leave listen only button for the second attendee' , ELEMENT _WAIT _LONGER _TIME ) ;
2023-07-03 21:01:05 +08:00
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
await this . userPage2 . waitAndClick ( e . leaveListenOnly ) ;
await this . userPage2 . waitAndClick ( e . joinAudio ) ;
await this . userPage2 . joinMicrophone ( ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . hasElement ( e . isTalking , 'should display the is talking element for the second attendee' ) ;
2022-01-29 03:52:22 +08:00
}
2023-07-05 21:05:57 +08:00
async lockSendPublicChatMessages ( ) {
2022-01-29 03:52:22 +08:00
await openLockViewers ( this . modPage ) ;
await this . modPage . waitAndClickElement ( e . lockPublicChat ) ;
await this . modPage . waitAndClick ( e . applyLockSettings ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElementDisabled ( e . chatBox , 'should have the public chat disabled for the first attendee' ) ;
await this . userPage . hasElementDisabled ( e . sendButton , 'should have the send button on the public chat disabled for the first attendee' ) ;
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( true ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . hasElementDisabled ( e . chatBox , 'should have the public chat disabled for the second attendee' ) ;
await this . userPage2 . hasElementDisabled ( e . sendButton , 'should have the send button on the public chat disabled for the second attendee' ) ;
2022-01-29 03:52:22 +08:00
await this . modPage . type ( e . chatBox , e . message ) ;
await this . modPage . waitAndClick ( e . sendButton ) ;
2023-07-03 21:01:05 +08:00
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . hasElementEnabled ( e . chatBox , 'should have the public chat enabled for the second attendee' , ELEMENT _WAIT _LONGER _TIME ) ;
2023-07-03 21:01:05 +08:00
await this . userPage2 . type ( e . chatBox , e . message ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . typingIndicator , 'should display the typing indicator element for the moderator' ) ;
2023-07-03 21:01:05 +08:00
await this . userPage2 . waitAndClick ( e . sendButton ) ;
2022-01-29 03:52:22 +08:00
await this . userPage . waitForSelector ( e . chatUserMessageText ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . checkElementCount ( e . chatUserMessageText , 2 , 'should display two user messages on the public chat for the first attendee' ) ;
2022-01-29 03:52:22 +08:00
}
2023-07-05 21:05:57 +08:00
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 ) ;
2023-09-27 03:41:58 +08:00
await this . initUserPage2 ( ) ;
await this . modPage . getLocator ( e . userListItem ) . filter ( { hasNotText : this . userPage2 . username } ) . click ( ) ;
await this . modPage . waitAndClick ( e . unlockUserButton ) ;
2023-09-14 04:11:15 +08:00
2023-09-27 03:41:58 +08:00
await this . userPage . getLocator ( e . userListItem ) . filter ( { hasText : this . userPage2 . username } ) . click ( ) ;
await this . userPage . waitAndClick ( ` ${ e . startPrivateChat } >> visible=true ` ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElementEnabled ( e . chatBox , 'should have the private chat enabled for the first attendee' ) ;
await this . userPage . hasElementEnabled ( e . sendButton , 'should have the send button on the private chat enabled for the first attendee' ) ;
2023-09-27 03:41:58 +08:00
await this . userPage . type ( e . chatBox , 'Test' ) ;
await this . userPage . waitAndClick ( e . sendButton ) ;
await this . userPage2 . getLocator ( e . chatButton ) . filter ( { hasText : this . userPage . username } ) . click ( ) ;
await this . userPage2 . waitForSelector ( e . closePrivateChat ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . hasElementDisabled ( e . chatBox , 'should have the private chat disabled for the second attendee' ) ;
await this . userPage2 . hasElementDisabled ( e . sendButton , 'should have the send button on the private chat disabled for the second attendee' ) ;
2022-01-29 03:52:22 +08:00
}
2023-07-05 21:05:57 +08:00
async lockEditSharedNotes ( ) {
2022-01-29 03:52:22 +08:00
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 ) ;
2023-07-03 21:01:05 +08:00
await sharedNotesLocator . type ( e . message , { timeout : ELEMENT _WAIT _LONGER _TIME } ) ;
2024-07-31 06:49:02 +08:00
await expect ( sharedNotesLocator , 'should the shared notes contain the text "Hello World!" for the first attende' ) . 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 ) ;
2023-07-03 21:01:05 +08:00
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( true ) ;
2023-07-03 21:01:05 +08:00
await this . userPage2 . waitAndClick ( e . sharedNotes ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . wasRemoved ( e . etherpadFrame , 'should not display the etherpad frame for the second attendee' ) ;
2023-07-03 21:01:05 +08:00
2022-01-29 03:52:22 +08:00
await this . userPage . waitAndClick ( e . sharedNotes ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . wasRemoved ( e . etherpadFrame , 'should not display the etherpad frame for the first attendee' ) ;
2023-07-03 21:01:05 +08:00
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
2022-01-29 03:52:22 +08:00
}
2023-07-05 21:05:57 +08:00
async lockSeeOtherViewersUserList ( ) {
2022-01-29 03:52:22 +08:00
await openLockViewers ( this . modPage ) ;
await this . modPage . waitAndClickElement ( e . lockUserList ) ;
await this . modPage . waitAndClick ( e . applyLockSettings ) ;
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( true ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . checkElementCount ( e . userListItem , 1 , 'should contain one user on the user list for the second attendee' ) ;
2022-04-27 20:46:15 +08:00
await sleep ( 1000 ) ;
2024-07-31 06:49:02 +08:00
await expect ( await this . userPage . getLocator ( e . userListItem ) . count ( ) , 'should contain one user on the user list for the first attendee' ) . toBe ( 1 ) ;
2023-07-03 21:01:05 +08:00
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . checkElementCount ( e . userListItem , 2 , 'should contain two users on the user list for the second attendee' ) ;
2022-01-29 03:52:22 +08:00
}
2022-02-03 08:45:23 +08:00
2023-07-05 21:05:57 +08:00
async lockSeeOtherViewersAnnotations ( ) {
2023-07-03 21:01:05 +08:00
await this . modPage . waitForSelector ( e . whiteboard ) ;
await this . modPage . waitAndClick ( e . multiUsersWhiteboardOn ) ;
await this . userPage . waitForSelector ( e . whiteboard ) ;
await drawArrow ( this . userPage ) ;
await openLockViewers ( this . modPage ) ;
await this . modPage . waitAndClickElement ( e . hideViewersAnnotation ) ;
await this . modPage . waitAndClick ( e . applyLockSettings ) ;
const screenshotOptions = {
maxDiffPixels : 1000 ,
} ;
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( true ) ;
2023-07-03 21:01:05 +08:00
const userWbLocator = this . userPage2 . getLocator ( e . whiteboard ) ;
await expect ( userWbLocator ) . toHaveScreenshot ( 'viewer2-no-arrow.png' , screenshotOptions ) ;
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
const userWbLocatorArrow = this . userPage2 . getLocator ( e . whiteboard ) ;
await expect ( userWbLocatorArrow ) . toHaveScreenshot ( 'viewer2-arrow.png' , screenshotOptions ) ;
}
2023-07-05 21:05:57 +08:00
async lockSeeOtherViewersCursor ( ) {
2023-07-03 21:01:05 +08:00
await this . modPage . waitForSelector ( e . whiteboard ) ;
await this . modPage . waitAndClick ( e . multiUsersWhiteboardOn ) ;
await this . userPage . waitForSelector ( e . whiteboard ) ;
await drawArrow ( this . userPage ) ;
await openLockViewers ( this . modPage ) ;
await this . modPage . waitAndClickElement ( e . hideViewersCursor ) ;
await this . modPage . waitAndClick ( e . applyLockSettings ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . checkElementCount ( e . whiteboardCursorIndicator , 1 , 'should contain one whiteboard cursor indicator for the moderator' ) ;
2023-07-03 21:01:05 +08:00
2023-07-05 21:05:57 +08:00
await this . initUserPage2 ( true ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . checkElementCount ( e . whiteboardCursorIndicator , 0 , 'should contain zero whiteboard cursor indicator for the second attendee' ) ;
2023-07-03 21:01:05 +08:00
await this . modPage . waitAndClick ( ` ${ e . userListItem } >>nth=1 ` ) ;
await this . modPage . waitAndClick ( ` ${ e . unlockUserButton } >>nth=1 ` ) ;
2023-07-05 02:01:19 +08:00
await drawArrow ( this . userPage ) ;
2024-07-31 06:49:02 +08:00
await this . userPage2 . checkElementCount ( e . whiteboardCursorIndicator , 1 , 'should contain one whiteboard cursor indicator for the second attendee' ) ;
2023-07-03 21:01:05 +08:00
}
2022-01-29 03:52:22 +08:00
}
exports . LockViewers = LockViewers ;