2022-12-31 05:49:18 +08:00
const { default : test } = require ( '@playwright/test' ) ;
2021-12-02 12:12:14 +08:00
const { Create } = require ( './create' ) ;
2021-11-30 21:42:57 +08:00
const utilScreenShare = require ( '../screenshare/util' ) ;
const e = require ( '../core/elements' ) ;
2023-04-05 22:06:00 +08:00
const { ELEMENT _WAIT _LONGER _TIME } = require ( '../core/constants' ) ;
2022-06-08 02:52:22 +08:00
const { getSettings } = require ( '../core/settings' ) ;
2022-09-30 19:17:15 +08:00
const { expect } = require ( '@playwright/test' ) ;
2022-11-26 03:54:32 +08:00
const { sleep } = require ( '../core/helpers' ) ;
2022-12-31 05:49:18 +08:00
const { getNotesLocator } = require ( '../sharednotes/util' ) ;
2021-11-30 21:42:57 +08:00
class Join extends Create {
constructor ( browser , context ) {
super ( browser , context ) ;
}
async joinRoom ( shouldJoinAudio = false ) {
2021-12-02 12:12:14 +08:00
await this . userPage . bringToFront ( ) ;
2021-11-30 21:42:57 +08:00
if ( shouldJoinAudio ) {
2021-12-02 12:12:14 +08:00
await this . userPage . waitAndClick ( e . joinAudio ) ;
await this . userPage . joinMicrophone ( ) ;
2021-11-30 21:42:57 +08:00
}
2021-12-02 12:12:14 +08:00
await this . userPage . waitAndClick ( e . breakoutRoomsItem ) ;
await this . userPage . waitAndClick ( e . joinRoom1 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . alreadyConnected , 'should display the element alreadyConnected' , ELEMENT _WAIT _LONGER _TIME ) ;
2021-11-30 21:42:57 +08:00
2021-12-02 12:12:14 +08:00
const breakoutUserPage = await this . userPage . getLastTargetPage ( this . context ) ;
await breakoutUserPage . bringToFront ( ) ;
2021-11-30 21:42:57 +08:00
2022-07-02 04:55:32 +08:00
if ( shouldJoinAudio ) {
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . joinAudio , 'should display the join audio button' ) ;
2022-07-02 04:55:32 +08:00
} else {
await breakoutUserPage . closeAudioModal ( ) ;
}
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle , 'should display the presentation title on the breakout room' ) ;
2021-12-02 12:12:14 +08:00
return breakoutUserPage ;
2021-11-30 21:42:57 +08:00
}
async joinAndShareWebcam ( ) {
const breakoutPage = await this . joinRoom ( ) ;
2024-05-15 05:07:58 +08:00
const { videoPreviewTimeout } = this . userPage . settings ;
2022-03-29 21:53:07 +08:00
await breakoutPage . shareWebcam ( true , videoPreviewTimeout ) ;
2021-11-30 21:42:57 +08:00
}
async joinAndShareScreen ( ) {
const breakoutPage = await this . joinRoom ( ) ;
await utilScreenShare . startScreenshare ( breakoutPage ) ;
}
async joinWithAudio ( ) {
2021-12-02 12:12:14 +08:00
const breakoutUserPage = await this . joinRoom ( true ) ;
2021-11-30 21:42:57 +08:00
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . talkingIndicator , 'should display the talking indicator element' ) ;
await breakoutUserPage . hasElement ( e . isTalking , 'should have the element isTalking active' ) ;
2021-11-30 21:42:57 +08:00
}
2022-09-16 02:31:10 +08:00
async messageToAllRooms ( ) {
const breakoutUserPage = await this . joinRoom ( ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle , 'should have the presentation title once the user is on the breakout room.' ) ;
2022-09-16 02:31:10 +08:00
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
2024-04-23 22:23:34 +08:00
await this . modPage . hasElement ( e . breakoutRemainingTime ) ;
2022-09-23 04:17:15 +08:00
await this . modPage . type ( e . chatBox , "test" ) ;
2022-09-16 02:31:10 +08:00
await this . modPage . waitAndClick ( e . sendButton ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . chatUserMessageText , 'should have a test message on the public chat.' ) ;
2022-09-16 02:31:10 +08:00
}
async changeDurationTime ( ) {
const breakoutUserPage = await this . joinRoom ( ) ;
2022-09-23 04:17:15 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle ) ;
2022-09-16 02:31:10 +08:00
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
await this . modPage . waitAndClick ( e . breakoutOptionsMenu ) ;
await this . modPage . waitAndClick ( e . openBreakoutTimeManager ) ;
await this . modPage . getLocator ( e . inputSetTimeSelector ) . press ( 'Backspace' ) ;
await this . modPage . type ( e . inputSetTimeSelector , '2' ) ;
await this . modPage . waitAndClick ( e . sendButtonDurationTime ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasText ( e . breakoutRemainingTime , /[11-12]:[0-5][0-9]/ , 'should have the breakout room time remaining counting down on the main meeting' ) ;
2022-09-16 02:31:10 +08:00
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasText ( e . timeRemaining , /[11-12]:[0-5][0-9]/ , 'should have the time remaining counting down on the breakout room' ) ;
2022-09-16 02:31:10 +08:00
}
async inviteUserAfterCreatingRooms ( ) {
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
await this . modPage . waitAndClick ( e . breakoutOptionsMenu ) ;
await this . modPage . waitAndClick ( e . openUpdateBreakoutUsersModal ) ;
2023-11-29 04:10:46 +08:00
await this . modPage . dragDropSelector ( e . attendeeNotAssigned , e . breakoutBox1 ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasText ( e . breakoutBox1 , /Attendee/ , 'should have the attende name on the second breakout room box.' ) ;
2022-09-16 02:31:10 +08:00
await this . modPage . waitAndClick ( e . modalConfirmButton ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . modalConfirmButton , 'should display the modal confirm button for the attende to join the meeting' ) ;
2022-09-16 02:31:10 +08:00
await this . userPage . waitAndClick ( e . modalDismissButton ) ;
}
async usernameShowsBelowRoomsName ( ) {
const breakoutUserPage = await this . joinRoom ( ) ;
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasText ( e . userNameBreakoutRoom , /Attendee/ , 'should have the attende name on the breakout room below a room on the main breakout panel' ) ;
2022-09-16 02:31:10 +08:00
}
async showBreakoutRoomTimeRemaining ( ) {
const breakoutUserPage = await this . joinRoom ( ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle , 'should display the presentation title on the breakout room' ) ;
2022-09-16 02:31:10 +08:00
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
await this . modPage . waitAndClick ( e . breakoutOptionsMenu ) ;
await this . modPage . waitAndClick ( e . openBreakoutTimeManager ) ;
await this . modPage . getLocator ( e . inputSetTimeSelector ) . press ( 'Backspace' ) ;
await this . modPage . type ( e . inputSetTimeSelector , '2' ) ;
await this . modPage . waitAndClick ( e . sendButtonDurationTime ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasText ( e . breakoutRemainingTime , /[11-12]:[0-5][0-9]/ , 'should have the breakout room time remaining counting down on the breakout main panel.' ) ;
2022-09-16 02:31:10 +08:00
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasText ( e . timeRemaining , /[11-12]:[0-5][0-9]/ , 'should display the remaining time inside the breakout rooom' ) ;
2022-09-16 02:31:10 +08:00
}
async endAllBreakoutRooms ( ) {
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
await this . modPage . waitAndClick ( e . breakoutOptionsMenu ) ;
await this . modPage . waitAndClick ( e . endAllBreakouts ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . wasRemoved ( e . breakoutRoomsItem , 'should not have the breakout rooms item displayed anymore' ) ;
2022-09-16 02:31:10 +08:00
}
2022-09-30 19:17:15 +08:00
async moveUserToOtherRoom ( ) {
const breakoutUserPage = await this . joinRoom ( ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle , 'should display the presentation title inside the breakout room' ) ;
2022-09-30 19:17:15 +08:00
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasText ( e . userNameBreakoutRoom , /Attendee/ , 'should display the user name below the first breakout room name' ) ;
2022-09-30 19:17:15 +08:00
await this . modPage . waitAndClick ( e . breakoutOptionsMenu ) ;
await this . modPage . waitAndClick ( e . openUpdateBreakoutUsersModal ) ;
await this . modPage . dragDropSelector ( e . moveUser , e . breakoutBox2 ) ;
await this . modPage . waitAndClick ( e . modalConfirmButton ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . modalConfirmButton , 'should display the modal confirm button for the user to join the breakout room' ) ;
2023-02-14 21:59:46 +08:00
await breakoutUserPage . page . isClosed ( ) ;
2022-09-30 19:17:15 +08:00
await this . userPage . waitAndClick ( e . modalConfirmButton ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasText ( e . userNameBreakoutRoom2 , /Attendee/ , 'should display the user name below the first breakout room name' , ELEMENT _WAIT _LONGER _TIME ) ;
2022-09-30 19:17:15 +08:00
}
2022-12-31 05:49:18 +08:00
async exportBreakoutNotes ( ) {
const { sharedNotesEnabled } = getSettings ( ) ;
2023-10-31 01:04:34 +08:00
if ( ! sharedNotesEnabled ) {
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . chatButton , 'should display the chat button to access the public chat' ) ;
return this . modPage . wasRemoved ( e . sharedNotes , 'should have removed the shared notes.' ) ;
2023-10-31 01:04:34 +08:00
}
2022-12-31 05:49:18 +08:00
const breakoutUserPage = await this . joinRoom ( ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle , 'should display the presentation title inside the breakout room.' ) ;
2022-12-31 05:49:18 +08:00
await breakoutUserPage . waitAndClick ( e . sharedNotes ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . hideNotesLabel , 'should display the hide notes element when shared notes is opened' ) ;
2022-12-31 05:49:18 +08:00
const notesLocator = getNotesLocator ( breakoutUserPage ) ;
await notesLocator . type ( e . message ) ;
await sleep ( 1000 ) ; // making sure there's enough time for the typing to finish
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
await this . modPage . waitAndClick ( e . breakoutOptionsMenu ) ;
2023-07-31 22:24:25 +08:00
// close all notifications displayed before ending rooms
for ( const closeButton of await this . modPage . getLocator ( e . closeToastBtn ) . all ( ) ) {
await closeButton . click ( ) ;
}
2022-12-31 05:49:18 +08:00
await this . modPage . waitAndClick ( e . endAllBreakouts ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . presentationUploadProgressToast , 'should display the presentation upload progress toast' ) ;
2022-12-31 05:49:18 +08:00
await this . modPage . waitAndClick ( e . actions ) ;
2023-04-05 22:06:00 +08:00
const shareNotesPDF = await this . modPage . getLocatorByIndex ( e . actionsItem , 1 ) ;
2024-07-31 06:49:02 +08:00
await expect ( shareNotesPDF , 'should have the Notes name on the share notes pdf' ) . toHaveText ( /Notes/ , { timeout : 30000 } ) ;
2023-04-05 22:06:00 +08:00
await expect ( this . modPage . getLocatorByIndex ( e . actionsItem , 2 ) ) . toHaveText ( "Upload/Manage presentations" ) ; //This checks if no other content was exported.
2024-06-07 03:15:36 +08:00
await this . modPage . checkElementCount ( e . actionsItem , 8 ) ;
2023-04-05 22:06:00 +08:00
await shareNotesPDF . click ( ) ;
const wbBox = await this . modPage . getLocator ( e . whiteboard ) ;
await expect ( wbBox ) . toHaveScreenshot ( 'capture-breakout-notes.png' , {
2022-12-31 05:49:18 +08:00
maxDiffPixels : 1000 ,
} ) ;
}
async exportBreakoutWhiteboard ( ) {
const { sharedNotesEnabled } = getSettings ( ) ;
2023-10-31 20:31:01 +08:00
if ( ! sharedNotesEnabled ) {
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . chatButton , 'should display the chat button to access the public chat' ) ;
return this . modPage . wasRemoved ( e . sharedNotes , 'should have removed the shared notes' ) ;
2023-10-31 20:31:01 +08:00
}
2022-12-31 05:49:18 +08:00
const breakoutUserPage = await this . joinRoom ( ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle , 'should have the presentation title displayed on the breakout room' ) ;
2022-12-31 05:49:18 +08:00
await breakoutUserPage . waitAndClick ( e . sharedNotes ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . hideNotesLabel , 'should display the hide notes element when shared notes is opened' ) ;
2022-12-31 05:49:18 +08:00
// draw a line
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . whiteboard , 'should display the whiteboard on breakout room' , ELEMENT _WAIT _LONGER _TIME ) ;
2022-12-31 05:49:18 +08:00
await breakoutUserPage . waitAndClick ( e . wbShapesButton ) ;
await breakoutUserPage . waitAndClick ( e . wbLineShape ) ;
const wbBreakout = await breakoutUserPage . page . $ ( e . whiteboard ) ;
const wbBoxBreakout = await wbBreakout . boundingBox ( ) ;
await breakoutUserPage . page . mouse . move ( wbBoxBreakout . x + 0.3 * wbBoxBreakout . width , wbBoxBreakout . y + 0.3 * wbBoxBreakout . height ) ;
await breakoutUserPage . page . mouse . down ( ) ;
await breakoutUserPage . page . mouse . move ( wbBoxBreakout . x + 0.7 * wbBoxBreakout . width , wbBoxBreakout . y + 0.7 * wbBoxBreakout . height ) ;
await breakoutUserPage . page . mouse . up ( ) ;
await sleep ( 1000 ) ; // making sure there's enough time for the typing to finish
await this . modPage . waitAndClick ( e . breakoutRoomsItem ) ;
await this . modPage . waitAndClick ( e . breakoutOptionsMenu ) ;
2023-07-31 22:24:25 +08:00
// close all notifications displayed before ending rooms
for ( const closeButton of await this . modPage . getLocator ( e . closeToastBtn ) . all ( ) ) {
await closeButton . click ( ) ;
}
2022-12-31 05:49:18 +08:00
await this . modPage . waitAndClick ( e . endAllBreakouts ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . presentationUploadProgressToast , 'should display the presentation upload progress toast' , ELEMENT _WAIT _LONGER _TIME ) ;
2022-12-31 05:49:18 +08:00
await this . modPage . waitAndClick ( e . actions ) ;
2023-04-05 22:06:00 +08:00
const whiteboardPDF = await this . modPage . getLocatorByIndex ( e . actionsItem , 1 ) ;
await expect ( whiteboardPDF ) . toHaveText ( /Whiteboard/ , { timeout : 30000 } ) ;
await expect ( this . modPage . getLocatorByIndex ( e . actionsItem , 2 ) ) . toHaveText ( "Upload/Manage presentations" ) ; //This checks if no other content was exported.
2024-06-07 03:15:36 +08:00
await this . modPage . checkElementCount ( e . actionsItem , 8 ) ;
2023-04-05 22:06:00 +08:00
await whiteboardPDF . click ( ) ;
await this . modPage . waitAndClick ( 'i[type="info"]' ) ;
2023-04-11 22:53:01 +08:00
await this . modPage . waitAndClick ( e . currentPresentationToast ) ;
2023-04-05 22:06:00 +08:00
2024-06-07 03:15:36 +08:00
//! avoiding the following screenshot comparison due to https://github.com/microsoft/playwright/issues/18827
2023-07-31 22:24:25 +08:00
// const wbBox = await this.modPage.getLocator(e.whiteboard);
// await expect(wbBox).toHaveScreenshot('capture-breakout-whiteboard.png', {
2024-06-07 03:15:36 +08:00
// maxDiffPixels: 1500,
2023-07-31 22:24:25 +08:00
// });
2022-12-31 05:49:18 +08:00
}
2023-01-31 22:01:56 +08:00
2023-02-10 03:43:49 +08:00
async userCanChooseRoom ( ) {
2023-01-31 22:01:56 +08:00
await this . userPage . bringToFront ( ) ;
2023-02-10 03:43:49 +08:00
2024-04-23 22:57:41 +08:00
await this . userPage . hasElementEnabled ( e . selectBreakoutRoomBtn ) ;
await this . userPage . hasElementEnabled ( e . modalConfirmButton ) ;
2023-02-10 03:43:49 +08:00
await this . userPage . checkElementCount ( e . roomOption , 2 ) ;
2023-01-31 22:01:56 +08:00
2023-02-13 21:37:14 +08:00
await this . userPage . getLocator ( ` ${ e . fullscreenModal } >> select ` ) . selectOption ( { index : 1 } ) ;
2023-01-31 22:01:56 +08:00
await this . userPage . waitAndClick ( e . modalConfirmButton ) ;
const breakoutUserPage = await this . userPage . getLastTargetPage ( this . context ) ;
await breakoutUserPage . bringToFront ( ) ;
2024-07-31 06:49:02 +08:00
await breakoutUserPage . hasElement ( e . presentationTitle , 'should display the presentation title on the breakout room' , ELEMENT _WAIT _LONGER _TIME ) ;
2023-01-31 22:01:56 +08:00
}
2021-11-30 21:42:57 +08:00
}
2021-12-02 12:12:14 +08:00
exports . Join = Join ;