2022-03-29 21:53:07 +08:00
const { expect , default : test } = require ( '@playwright/test' ) ;
2021-12-02 12:12:14 +08:00
const { MultiUsers } = require ( '../user/multiusers' ) ;
2021-11-27 03:04:28 +08:00
const Page = require ( '../core/page' ) ;
const e = require ( '../core/elements' ) ;
2022-12-01 22:15:55 +08:00
const { checkSvgIndex , getSlideOuterHtml , uploadSinglePresentation , uploadMultiplePresentations , getCurrentPresentationHeight } = require ( './util.js' ) ;
2023-09-26 22:15:11 +08:00
const { ELEMENT _WAIT _LONGER _TIME , ELEMENT _WAIT _EXTRA _LONG _TIME , UPLOAD _PDF _WAIT _TIME , ELEMENT _WAIT _TIME } = require ( '../core/constants' ) ;
2021-12-04 01:01:36 +08:00
const { sleep } = require ( '../core/helpers' ) ;
2022-03-29 21:53:07 +08:00
const { getSettings } = require ( '../core/settings' ) ;
2024-05-15 05:07:58 +08:00
const { waitAndClearNotification } = require ( '../notifications/util.js' ) ;
2024-07-31 02:10:11 +08:00
const CI = process . env . CI === 'true' ;
2021-11-27 03:04:28 +08:00
2023-04-20 00:24:30 +08:00
const defaultZoomLevel = '100%' ;
2021-12-02 12:12:14 +08:00
class Presentation extends MultiUsers {
2021-11-27 03:04:28 +08:00
constructor ( browser , context ) {
2021-12-02 12:12:14 +08:00
super ( browser , context ) ;
2021-11-27 03:04:28 +08:00
}
async skipSlide ( ) {
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . whiteboard , 'should display the whiteboard when the moderator joins the meeting' , ELEMENT _WAIT _LONGER _TIME ) ;
2021-11-27 03:04:28 +08:00
2021-12-02 12:12:14 +08:00
await checkSvgIndex ( this . modPage , '/svg/1' ) ;
2021-11-27 03:04:28 +08:00
await this . modPage . waitAndClick ( e . nextSlide ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . whiteboard , 'should display the next slide on the whiteboard' ) ;
2022-07-02 04:55:32 +08:00
await sleep ( 1000 ) ;
2021-11-27 03:04:28 +08:00
2021-12-02 12:12:14 +08:00
await checkSvgIndex ( this . modPage , '/svg/2' ) ;
2021-11-27 03:04:28 +08:00
await this . modPage . waitAndClick ( e . prevSlide ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . whiteboard , 'should display the previous slide on the whiteboard' ) ;
2022-07-02 04:55:32 +08:00
await sleep ( 1000 ) ;
2021-11-27 03:04:28 +08:00
2021-12-02 12:12:14 +08:00
await checkSvgIndex ( this . modPage , '/svg/1' ) ;
2021-11-27 03:04:28 +08:00
}
2023-10-17 20:32:36 +08:00
async shareCameraAsContent ( ) {
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . whiteboard , 'should display the whiteboard whent then moderator joins the meeting' , ELEMENT _WAIT _LONGER _TIME ) ;
2023-10-17 20:32:36 +08:00
await this . modPage . waitAndClick ( e . actions ) ;
await this . modPage . waitAndClick ( e . shareCameraAsContent ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . videoPreview , 'should display the camera preview when sharing camera as content' ) ;
2023-10-17 20:32:36 +08:00
await this . modPage . waitAndClick ( e . startSharingWebcam ) ;
2024-05-15 05:07:58 +08:00
await this . modPage . hasElement ( e . screenShareVideo ) ;
2024-05-16 02:12:45 +08:00
// close all notifications displayed before comparing screenshots
for ( const closeButton of await this . modPage . getLocator ( e . closeToastBtn ) . all ( ) ) {
await closeButton . click ( ) ;
}
2023-10-17 20:32:36 +08:00
const modWhiteboardLocator = this . modPage . getLocator ( e . screenShareVideo ) ;
2024-07-31 06:49:02 +08:00
await expect ( modWhiteboardLocator , 'should display the same screenshot as taken before' ) . toHaveScreenshot ( 'moderator-share-camera-as-content.png' , {
2023-10-17 20:32:36 +08:00
maxDiffPixels : 1000 ,
} ) ;
2024-05-15 05:07:58 +08:00
await this . userPage . wasRemoved ( e . screenshareConnecting ) ;
await this . userPage . hasElement ( e . screenShareVideo ) ;
2024-05-16 02:12:45 +08:00
// close all notifications displayed before comparing screenshots
for ( const closeButton of await this . userPage . getLocator ( e . closeToastBtn ) . all ( ) ) {
await closeButton . click ( ) ;
}
2024-05-15 05:07:58 +08:00
const viewerWhiteboardLocator = this . userPage . getLocator ( e . screenShareVideo ) ;
await expect ( viewerWhiteboardLocator ) . toHaveScreenshot ( 'viewer-share-camera-as-content.png' , {
maxDiffPixels : 1000 ,
} ) ;
2023-10-17 20:32:36 +08:00
}
2022-01-20 03:50:59 +08:00
async hideAndRestorePresentation ( ) {
2022-03-29 21:53:07 +08:00
const { presentationHidden } = getSettings ( ) ;
if ( ! presentationHidden ) {
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . whiteboard , 'should display the whiteboard when the moderator joins the meeting' , ELEMENT _WAIT _LONGER _TIME ) ;
2022-03-29 21:53:07 +08:00
await this . modPage . waitAndClick ( e . minimizePresentation ) ;
}
2024-07-31 06:49:02 +08:00
await this . modPage . wasRemoved ( e . presentationContainer , 'should not display the presentation container since the presentation is minimized' ) ;
2022-01-20 03:50:59 +08:00
await this . modPage . waitAndClick ( e . restorePresentation ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . presentationContainer , 'should display the presentation container since the presentation was restored' ) ;
2022-01-20 03:50:59 +08:00
}
async startExternalVideo ( ) {
2022-03-29 21:53:07 +08:00
const { externalVideoPlayer } = getSettings ( ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . whiteboard , 'should display the whiteboard when the moderator joins the meeting' ) ;
2022-01-20 03:50:59 +08:00
await this . modPage . waitAndClick ( e . actions ) ;
2023-11-08 19:50:16 +08:00
if ( ! externalVideoPlayer ) {
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . managePresentations , 'should display the manage presentation options on the actions button' ) ;
return this . modPage . wasRemoved ( e . shareExternalVideoBtn , 'should not display the option to share an external video, since is deactivated' ) ;
2023-11-08 19:50:16 +08:00
}
2022-01-20 21:03:18 +08:00
await this . modPage . waitAndClick ( e . shareExternalVideoBtn ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . closeModal , 'should display the close modal button after the moderator opens the modal for sharing external video' ) ;
2022-01-20 03:50:59 +08:00
await this . modPage . type ( e . videoModalInput , e . youtubeLink ) ;
await this . modPage . waitAndClick ( e . startShareVideoBtn ) ;
2024-04-20 03:05:13 +08:00
const modFrame = await this . modPage . getYoutubeFrame ( ) ;
const userFrame = await this . userPage . getYoutubeFrame ( ) ;
2022-01-20 03:50:59 +08:00
2024-07-31 06:49:02 +08:00
await modFrame . hasElement ( 'video' , 'should display the element frame for the video that is being shared for the moderator' ) ;
await userFrame . hasElement ( 'video' , 'should display the element frame for the video that is being shared for the attendee' ) ;
2022-01-20 03:50:59 +08:00
}
2022-06-21 07:02:10 +08:00
async uploadSinglePresentationTest ( ) {
2022-11-26 03:54:32 +08:00
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
2021-11-27 03:04:28 +08:00
await this . modPage . waitForSelector ( e . skipSlide ) ;
2023-08-01 21:32:53 +08:00
await this . modPage . wasRemoved ( e . smallToastMsg , ELEMENT _WAIT _EXTRA _LONG _TIME ) ;
2024-07-31 02:10:11 +08:00
const imageURLFirstPresentation = await this . modPage . page . evaluate ( ( ) => {
const element = document . querySelector ( 'div[id="whiteboard-element"] div[class="tl-image"]' ) ;
const style = element . getAttribute ( 'style' )
const urlMatch = style . match ( /background-image: url\("([^"]+)"\)/ ) ;
return urlMatch ? urlMatch [ 1 ] : null ;
} ) ;
2023-03-15 21:57:49 +08:00
await uploadSinglePresentation ( this . modPage , e . pdfFileName , UPLOAD _PDF _WAIT _TIME ) ;
2024-02-02 19:37:28 +08:00
await this . modPage . closeAllToastNotifications ( ) ;
2024-07-31 02:10:11 +08:00
await this . userPage . closeAllToastNotifications ( ) ;
2023-03-15 21:57:49 +08:00
const modWhiteboardLocator = this . modPage . getLocator ( e . whiteboard ) ;
2024-07-31 06:49:02 +08:00
2024-07-31 02:10:11 +08:00
await this . modPage . setHeightWidthViewPortSize ( ) ;
// Skip check for screenshot on ci, due to the ci and the local machine generating two different image sizes
if ( ! CI ) {
await expect ( modWhiteboardLocator ) . toHaveScreenshot ( 'moderator-new-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
}
const imageURLSecondPresentation = await this . modPage . page . evaluate ( ( ) => {
const element = document . querySelector ( 'div[id="whiteboard-element"] div[class="tl-image"]' ) ;
const style = element . getAttribute ( 'style' )
const urlMatch = style . match ( /background-image: url\("([^"]+)"\)/ ) ;
return urlMatch ? urlMatch [ 1 ] : null ;
2023-03-10 21:50:49 +08:00
} ) ;
2023-03-15 21:57:49 +08:00
2024-02-02 19:37:28 +08:00
await this . userPage . reloadPage ( ) ;
await this . userPage . closeAudioModal ( ) ;
await this . userPage . closeAllToastNotifications ( ) ;
2023-03-15 21:57:49 +08:00
const userWhiteboardLocator = this . userPage . getLocator ( e . whiteboard ) ;
2024-07-31 02:10:11 +08:00
await this . userPage . setHeightWidthViewPortSize ( ) ;
await expect ( imageURLFirstPresentation ) . not . toBe ( imageURLSecondPresentation ) ;
// Skip check for screenshot on ci, due to the ci and the local machine generating two different image sizes
if ( ! CI ) {
await expect ( userWhiteboardLocator ) . toHaveScreenshot ( 'viewer-new-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
}
2021-11-27 03:04:28 +08:00
}
2023-08-09 00:05:09 +08:00
async uploadOtherPresentationsFormat ( ) {
2024-07-31 02:10:11 +08:00
await this . modPage . hasElement ( e . whiteboard ) ;
const imageURLFirstPresentation = await this . modPage . page . evaluate ( ( ) => {
const element = document . querySelector ( 'div[id="whiteboard-element"] div[class="tl-image"]' ) ;
const style = element . getAttribute ( 'style' )
const urlMatch = style . match ( /background-image: url\("([^"]+)"\)/ ) ;
return urlMatch ? urlMatch [ 1 ] : null ;
} ) ;
2023-08-01 21:32:53 +08:00
await uploadSinglePresentation ( this . modPage , e . uploadPresentationFileName , UPLOAD _PDF _WAIT _TIME ) ;
2024-07-31 02:10:11 +08:00
await this . modPage . closeAllToastNotifications ( ) ;
await this . userPage . closeAllToastNotifications ( ) ;
2023-08-01 21:32:53 +08:00
2023-08-09 00:05:09 +08:00
const modWhiteboardLocator = this . modPage . getLocator ( e . whiteboard ) ;
const userWhiteboardLocator = this . userPage . getLocator ( e . whiteboard ) ;
2024-07-31 02:10:11 +08:00
await this . modPage . setHeightWidthViewPortSize ( ) ;
await this . userPage . setHeightWidthViewPortSize ( ) ;
const imageURLSecondPresentation = await this . modPage . page . evaluate ( ( ) => {
const element = document . querySelector ( 'div[id="whiteboard-element"] div[class="tl-image"]' ) ;
const style = element . getAttribute ( 'style' )
const urlMatch = style . match ( /background-image: url\("([^"]+)"\)/ ) ;
return urlMatch ? urlMatch [ 1 ] : null ;
2023-08-01 21:32:53 +08:00
} ) ;
2024-07-31 02:10:11 +08:00
await expect ( imageURLFirstPresentation ) . not . toBe ( imageURLSecondPresentation ) ;
2023-08-01 21:32:53 +08:00
2024-07-31 02:10:11 +08:00
// Skip check for screenshot on ci, due to the ci and the local machine generating two different image sizes
if ( ! CI ) {
await expect ( modWhiteboardLocator ) . toHaveScreenshot ( 'moderator-png-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
await expect ( userWhiteboardLocator ) . toHaveScreenshot ( 'viewer-png-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
}
await uploadSinglePresentation ( this . modPage , e . presentationPPTX , UPLOAD _PDF _WAIT _TIME ) ;
await this . modPage . closeAllToastNotifications ( ) ;
await this . userPage . closeAllToastNotifications ( ) ;
const imageURLThirdPresentation = await this . modPage . page . evaluate ( ( ) => {
const element = document . querySelector ( 'div[id="whiteboard-element"] div[class="tl-image"]' ) ;
const style = element . getAttribute ( 'style' )
const urlMatch = style . match ( /background-image: url\("([^"]+)"\)/ ) ;
return urlMatch ? urlMatch [ 1 ] : null ;
2023-08-01 21:32:53 +08:00
} ) ;
2024-07-31 02:10:11 +08:00
await expect ( imageURLSecondPresentation ) . not . toBe ( imageURLThirdPresentation ) ;
await this . modPage . setHeightWidthViewPortSize ( ) ;
await this . userPage . setHeightWidthViewPortSize ( ) ;
// Skip check for screenshot on ci, due to the ci and the local machine generating two different image sizes
if ( ! CI ) {
await expect ( modWhiteboardLocator ) . toHaveScreenshot ( 'moderator-pptx-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
await expect ( userWhiteboardLocator ) . toHaveScreenshot ( 'viewer-pptx-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
}
2023-08-01 21:32:53 +08:00
await uploadSinglePresentation ( this . modPage , e . presentationTXT , UPLOAD _PDF _WAIT _TIME ) ;
2024-07-31 02:10:11 +08:00
await this . modPage . closeAllToastNotifications ( ) ;
await this . userPage . closeAllToastNotifications ( ) ;
2023-08-01 21:32:53 +08:00
2024-07-31 02:10:11 +08:00
const imageURLForthPresentation = await this . modPage . page . evaluate ( ( ) => {
const element = document . querySelector ( 'div[id="whiteboard-element"] div[class="tl-image"]' ) ;
const style = element . getAttribute ( 'style' )
const urlMatch = style . match ( /background-image: url\("([^"]+)"\)/ ) ;
return urlMatch ? urlMatch [ 1 ] : null ;
2023-08-01 21:32:53 +08:00
} ) ;
2024-07-31 02:10:11 +08:00
await expect ( imageURLThirdPresentation ) . not . toBe ( imageURLForthPresentation ) ;
await this . modPage . setHeightWidthViewPortSize ( ) ;
await this . userPage . setHeightWidthViewPortSize ( ) ;
// Skip check for screenshot on ci, due to the ci and the local machine generating two different image sizes
if ( ! CI ) {
await expect ( modWhiteboardLocator ) . toHaveScreenshot ( 'moderator-txt-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
await expect ( userWhiteboardLocator ) . toHaveScreenshot ( 'viewer-txt-presentation-screenshot.png' , {
maxDiffPixels : 1000 ,
} ) ;
}
2021-11-27 03:04:28 +08:00
}
2022-06-21 07:02:10 +08:00
async uploadMultiplePresentationsTest ( ) {
2023-02-14 21:59:46 +08:00
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
2022-06-21 07:02:10 +08:00
2022-11-26 03:54:32 +08:00
const modSlides0 = await getSlideOuterHtml ( this . modPage ) ;
const userSlides0 = await getSlideOuterHtml ( this . userPage ) ;
2022-06-21 07:02:10 +08:00
await expect ( modSlides0 ) . toEqual ( userSlides0 ) ;
await uploadMultiplePresentations ( this . modPage , [ e . uploadPresentationFileName , e . questionSlideFileName ] ) ;
2022-11-26 03:54:32 +08:00
const modSlides1 = await getSlideOuterHtml ( this . modPage ) ;
const userSlides1 = await getSlideOuterHtml ( this . userPage ) ;
2024-07-31 06:49:02 +08:00
await expect ( modSlides1 , 'moderator slide 1 should be equal to the user slide 1' ) . toEqual ( userSlides1 ) ;
await expect ( modSlides0 , 'moderator slide 0 should not be equal to moderator slide 1' ) . not . toEqual ( modSlides1 ) ;
await expect ( userSlides0 , 'user slide 0 should not be equal to the user slide 1' ) . not . toEqual ( userSlides1 ) ;
2022-06-21 07:02:10 +08:00
}
async fitToWidthTest ( ) {
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
2022-07-05 23:13:46 +08:00
await this . modPage . waitAndClick ( e . userListToggleBtn ) ;
2023-02-14 21:59:46 +08:00
const width1 = ( await this . modPage . getElementBoundingBox ( e . whiteboard ) ) . width ;
2023-07-21 20:43:52 +08:00
// check if its off
const fitToWidthButtonLocator = this . modPage . getLocator ( ` ${ e . fitToWidthButton } > span>>nth=0 ` ) ;
const fitToWidthBorderColorOff = await fitToWidthButtonLocator . evaluate ( ( elem ) => getComputedStyle ( elem ) . borderColor ) ;
2024-07-31 06:49:02 +08:00
await expect ( fitToWidthBorderColorOff , 'should match the white color' ) . toBe ( 'rgba(0, 0, 0, 0)' ) ;
2023-07-21 20:43:52 +08:00
2022-06-21 07:02:10 +08:00
await this . modPage . waitAndClick ( e . fitToWidthButton ) ;
2023-07-25 00:52:15 +08:00
await sleep ( 500 ) ;
2023-07-24 20:22:28 +08:00
2023-07-21 20:43:52 +08:00
//check if its on
const fitToWidthBorderColorOn = await fitToWidthButtonLocator . evaluate ( ( elem ) => getComputedStyle ( elem ) . borderColor ) ;
2024-07-31 06:49:02 +08:00
await expect ( fitToWidthBorderColorOn , 'should match the color dark blue' ) . toBe ( 'rgb(6, 23, 42)' ) ;
2023-07-21 20:43:52 +08:00
2023-02-14 21:59:46 +08:00
const width2 = ( await this . modPage . getElementBoundingBox ( e . whiteboard ) ) . width ;
2024-07-31 06:49:02 +08:00
await expect ( Number ( width2 ) , 'should the last width be greater than the first one' ) . toBeGreaterThan ( Number ( width1 ) ) ;
2022-06-21 07:02:10 +08:00
}
2023-07-04 23:10:38 +08:00
async enableAndDisablePresentationDownload ( testInfo ) {
2023-08-04 02:05:56 +08:00
const { originalPresentationDownloadable } = getSettings ( ) ;
2022-03-29 21:53:07 +08:00
2021-11-27 03:04:28 +08:00
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
2023-07-04 23:10:38 +08:00
// enable original presentation download
2021-11-27 03:04:28 +08:00
await this . modPage . waitAndClick ( e . actions ) ;
2022-01-20 21:03:18 +08:00
await this . modPage . waitAndClick ( e . managePresentations ) ;
2023-11-08 19:50:16 +08:00
if ( ! originalPresentationDownloadable ) {
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . presentationOptionsDownloadBtn , 'should display the option download button for the presentation' ) ;
return this . modPage . wasRemoved ( e . enableOriginalPresentationDownloadBtn , 'should the original presentation download presentation be removed' ) ;
2023-11-08 19:50:16 +08:00
}
2023-07-04 23:10:38 +08:00
await this . modPage . waitAndClick ( e . presentationOptionsDownloadBtn ) ;
await this . modPage . waitAndClick ( e . enableOriginalPresentationDownloadBtn ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . smallToastMsg , 'should display the small toast message for the attendee' ) ;
await this . userPage . hasElement ( e . presentationDownloadBtn , 'should display the presentation download button for the attendee' ) ;
2023-07-04 23:10:38 +08:00
await this . userPage . waitForSelector ( e . whiteboard ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . presentationDownloadBtn , 'should display the presentation download button for the attendee' ) ;
2023-07-04 23:10:38 +08:00
/ * *
* the following steps throwing "Error: ENOENT: no such file or directory" at the end of execution
* due to somehow it ' s trying to take the screenshot of the tab that opened for the file download
* /
//! await this.modPage.handleDownload(this.modPage.getLocator(e.presentationDownloadBtn), testInfo);
//! await this.userPage.handleDownload(this.userPage.getLocator(e.presentationDownloadBtn), testInfo);
// disable original presentation download
await this . modPage . waitAndClick ( e . actions ) ;
await this . modPage . waitAndClick ( e . managePresentations ) ;
await this . modPage . waitAndClick ( e . presentationOptionsDownloadBtn ) ;
await this . modPage . waitAndClick ( e . disableOriginalPresentationDownloadBtn ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . whiteboard , 'should display the whiteboard for the moderator' ) ;
await this . modPage . wasRemoved ( e . presentationDownloadBtn , 'should not display the presentation download button for the moderator' ) ;
await this . userPage . wasRemoved ( e . presentationDownloadBtn , 'should not display the presentation download button for the attendee' ) ;
2023-07-04 23:10:38 +08:00
}
async sendPresentationToDownload ( testInfo ) {
2023-08-04 02:05:56 +08:00
const { presentationWithAnnotationsDownloadable } = getSettings ( ) ;
2023-07-04 23:10:38 +08:00
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
await this . modPage . waitAndClick ( e . actions ) ;
await this . modPage . waitAndClick ( e . managePresentations ) ;
await this . modPage . waitAndClick ( e . presentationOptionsDownloadBtn ) ;
2023-11-08 19:50:16 +08:00
if ( ! presentationWithAnnotationsDownloadable ) {
2023-11-16 20:00:22 +08:00
await this . modPage . hasElement ( e . presentationOptionsDownloadBtn ) ;
2023-11-15 04:15:26 +08:00
return this . modPage . wasRemoved ( e . sendPresentationInCurrentStateBtn ) ;
2023-11-08 19:50:16 +08:00
}
2023-07-04 23:10:38 +08:00
await this . modPage . waitAndClick ( e . sendPresentationInCurrentStateBtn ) ;
await this . modPage . hasElement ( e . downloadPresentationToast ) ;
2023-08-23 04:25:50 +08:00
await this . userPage . hasElement ( e . downloadPresentation , ELEMENT _WAIT _EXTRA _LONG _TIME ) ;
2023-02-16 02:41:21 +08:00
const downloadPresentationLocator = this . userPage . getLocator ( e . downloadPresentation ) ;
await this . userPage . handleDownload ( downloadPresentationLocator , testInfo ) ;
2021-11-27 03:04:28 +08:00
}
async removeAllPresentation ( ) {
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
await this . modPage . waitAndClick ( e . actions ) ;
2022-01-20 21:03:18 +08:00
await this . modPage . waitAndClick ( e . managePresentations ) ;
2021-11-27 03:04:28 +08:00
await this . modPage . waitAndClick ( e . removePresentation ) ;
await this . modPage . waitAndClick ( e . confirmManagePresentation ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . wasRemoved ( e . whiteboard , 'should not display the whiteboard for the moderator' ) ;
await this . modPage . wasRemoved ( e . minimizePresentation , 'should not display the minimize presentation button for the moderator' ) ;
await this . userPage . wasRemoved ( e . whiteboard , 'should not display the whiteboard for the attendee' ) ;
await this . userPage . wasRemoved ( e . minimizePresentation , 'should not display the minimize presentation button for the attendee' ) ;
2021-11-27 03:04:28 +08:00
}
2022-08-30 19:16:09 +08:00
async uploadAndRemoveAllPresentations ( ) {
await uploadSinglePresentation ( this . modPage , e . uploadPresentationFileName ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
const modSlides1 = await getSlideOuterHtml ( this . modPage ) ;
const userSlides1 = await getSlideOuterHtml ( this . userPage ) ;
2024-07-31 06:49:02 +08:00
await expect ( modSlides1 , 'should the moderator slide and the attendee slide to be equal' ) . toEqual ( userSlides1 ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
// Remove
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
await this . modPage . waitAndClick ( e . actions ) ;
await this . modPage . waitAndClick ( e . managePresentations ) ;
await this . modPage . waitAndClick ( e . removePresentation ) ;
await this . modPage . waitAndClick ( e . removePresentation ) ;
await this . modPage . waitAndClick ( e . confirmManagePresentation ) ;
2022-11-26 03:54:32 +08:00
2024-07-31 06:49:02 +08:00
await this . modPage . wasRemoved ( e . whiteboard , 'should not display the whiteboard for the moderator' ) ;
await this . modPage . wasRemoved ( e . minimizePresentation , 'should not display the minimize presentation button for the moderator' ) ;
await this . userPage . wasRemoved ( e . whiteboard , 'should not display the whiteboard for the attendee' ) ;
await this . userPage . wasRemoved ( e . minimizePresentation , 'should not display the minimize presentation button for the attendee' ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
// Check removed presentations inside the Manage Presentations
await this . modPage . waitAndClick ( e . actions ) ;
await this . modPage . waitAndClick ( e . managePresentations ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . wasRemoved ( e . presentationsList , 'should not display the presentation list for the moderator' ) ;
2022-08-30 19:16:09 +08:00
await this . modPage . waitAndClick ( e . confirmManagePresentation ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
// Making viewer a presenter
await this . modPage . waitAndClick ( e . userListItem ) ;
await this . modPage . waitAndClick ( e . makePresenter ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
await this . userPage . waitAndClick ( e . actions ) ;
await this . userPage . waitAndClick ( e . managePresentations ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . wasRemoved ( e . presentationsList , 'should not display the presentation list for the attendee' ) ;
2022-08-30 19:16:09 +08:00
}
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
async removePreviousPresentationFromPreviousPresenter ( ) {
await uploadSinglePresentation ( this . modPage , e . uploadPresentationFileName ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
const modSlides1 = await getSlideOuterHtml ( this . modPage ) ;
const userSlides1 = await getSlideOuterHtml ( this . userPage ) ;
2024-07-31 06:49:02 +08:00
await expect ( modSlides1 , 'should the moderator slide and the attendee slide to be equal' ) . toEqual ( userSlides1 ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
await this . modPage . waitAndClick ( e . userListItem ) ;
await this . modPage . waitAndClick ( e . makePresenter ) ;
2022-11-26 03:54:32 +08:00
2022-08-30 19:16:09 +08:00
await this . userPage . waitAndClick ( e . actions ) ;
await this . userPage . waitAndClick ( e . managePresentations ) ;
await this . userPage . waitAndClick ( e . removePresentation ) ;
await this . userPage . waitAndClick ( e . removePresentation ) ;
await this . userPage . waitAndClick ( e . confirmManagePresentation ) ;
2022-11-26 03:54:32 +08:00
2024-07-31 06:49:02 +08:00
await this . userPage . wasRemoved ( e . whiteboard , 'should not display the whiteboard for the attendee' ) ;
2022-08-30 19:16:09 +08:00
await this . userPage . waitAndClick ( e . actions ) ;
await this . userPage . waitAndClick ( e . managePresentations ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . wasRemoved ( e . presentationsList , 'should not display the presentation list for the attendee' ) ;
2022-08-30 19:16:09 +08:00
}
2022-11-22 23:01:09 +08:00
async presentationFullscreen ( ) {
2023-02-14 21:59:46 +08:00
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
2023-04-06 22:43:50 +08:00
const presentationLocator = this . modPage . getLocator ( e . presentationContainer ) ;
2022-12-01 22:15:55 +08:00
const height = parseInt ( await getCurrentPresentationHeight ( presentationLocator ) ) ;
2022-11-22 23:01:09 +08:00
await this . modPage . waitAndClick ( e . whiteboardOptionsButton ) ;
await this . modPage . waitAndClick ( e . presentationFullscreen ) ;
2022-12-01 22:15:55 +08:00
// Gets fullscreen mode height
const heightFullscreen = parseInt ( await getCurrentPresentationHeight ( presentationLocator ) ) ;
2022-11-22 23:01:09 +08:00
2024-07-31 06:49:02 +08:00
await expect ( heightFullscreen , 'should the height of the presentation fullscreen to be greater than the normal presentation height' ) . toBeGreaterThan ( height ) ;
2022-11-22 23:01:09 +08:00
}
async presentationSnapshot ( testInfo ) {
2023-02-14 21:59:46 +08:00
await this . modPage . waitForSelector ( e . whiteboard , ELEMENT _WAIT _LONGER _TIME ) ;
2022-11-22 23:01:09 +08:00
await this . modPage . waitAndClick ( e . whiteboardOptionsButton ) ;
2023-02-16 02:41:21 +08:00
const presentationSnapshotLocator = this . modPage . getLocator ( e . presentationSnapshot ) ;
await this . modPage . handleDownload ( presentationSnapshotLocator , testInfo ) ;
2022-11-22 23:01:09 +08:00
}
2023-04-20 00:24:30 +08:00
async hidePresentationToolbar ( ) {
await this . modPage . waitAndClick ( e . whiteboardOptionsButton ) ;
await this . modPage . waitAndClick ( e . toolVisibility ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . wasRemoved ( e . wbToolbar , 'should not display the whiteboard toolbar for the moderator' ) ;
await this . modPage . wasRemoved ( e . wbStyles , 'should not display the whiteboard styles menu' ) ;
await this . modPage . wasRemoved ( e . wbUndo , 'should not display the whiteboard undo button' ) ;
await this . modPage . wasRemoved ( e . wbRedo , 'should not display the whiteboard redo button' ) ;
2023-04-20 00:24:30 +08:00
}
async zoom ( ) {
await this . modPage . waitForSelector ( e . resetZoomButton , ELEMENT _WAIT _LONGER _TIME ) ;
const wbBox = await this . modPage . getLocator ( e . whiteboard ) ;
const zoomOutButtonLocator = this . modPage . getLocator ( e . zoomOutButton ) ;
2024-07-31 06:49:02 +08:00
await expect ( zoomOutButtonLocator , 'should hte zoom out button be disabled' ) . toBeDisabled ( ) ;
2023-04-20 00:24:30 +08:00
const resetZoomButtonLocator = this . modPage . getLocator ( e . resetZoomButton ) ;
2024-07-31 06:49:02 +08:00
await expect ( resetZoomButtonLocator , 'should the reset zoom button contain the default value text' ) . toContainText ( defaultZoomLevel ) ;
2023-04-20 00:24:30 +08:00
//Zoom In 150%
2024-09-11 01:38:55 +08:00
await expect ( wbBox ) . toHaveScreenshot ( 'moderator1-no-zoom.png' ) ;
2023-04-20 00:24:30 +08:00
await this . modPage . waitAndClick ( e . zoomInButton ) ;
2024-09-11 01:38:55 +08:00
await expect ( zoomOutButtonLocator , 'should the zoom out button to be enabled' ) . toBeEnabled ( ) ;
2024-07-31 06:49:02 +08:00
await expect ( resetZoomButtonLocator , 'should the reset zoom button to contain the text 125%' ) . toContainText ( /125%/ ) ;
2023-07-14 04:31:39 +08:00
await this . modPage . waitAndClick ( e . zoomInButton ) ;
2024-07-31 06:49:02 +08:00
await expect ( resetZoomButtonLocator , 'should the reset zoom button to contain the text 150%' ) . toContainText ( /150%/ ) ;
2024-09-11 01:38:55 +08:00
await expect ( wbBox ) . not . toHaveScreenshot ( 'moderator1-no-zoom.png' ) ;
2023-04-20 00:24:30 +08:00
//Zoom out 125%
await this . modPage . waitAndClick ( e . zoomOutButton ) ;
2024-07-31 06:49:02 +08:00
await expect ( resetZoomButtonLocator , 'should the reset zoom button to contain the text 125%' ) . toContainText ( /125%/ ) ;
2023-06-08 10:17:42 +08:00
await expect ( wbBox ) . toHaveScreenshot ( 'moderator1-zoom125.png' ) ;
2023-04-20 00:24:30 +08:00
//Reset Zoom 100%
2023-07-14 04:31:39 +08:00
await this . modPage . waitAndClick ( e . zoomInButton ) ;
2024-07-31 06:49:02 +08:00
await expect ( resetZoomButtonLocator , 'should the reset zoom button to contain the text 150%' ) . toContainText ( /150%/ ) ;
2023-04-20 00:24:30 +08:00
await this . modPage . waitAndClick ( e . resetZoomButton ) ;
2024-07-31 06:49:02 +08:00
await expect ( resetZoomButtonLocator , 'should the reset zoom button to contain the text 100%' ) . toContainText ( /100%/ ) ;
await expect ( zoomOutButtonLocator , 'should the zoom out button to be disabled' ) . toBeDisabled ( ) ;
2023-06-08 10:17:42 +08:00
await expect ( wbBox ) . toHaveScreenshot ( 'moderator1-zoom100.png' ) ;
2023-04-20 00:24:30 +08:00
}
async selectSlide ( ) {
await this . modPage . waitForSelector ( e . skipSlide ) ;
const wbBox = await this . modPage . getLocator ( e . whiteboard ) ;
2023-04-25 00:33:00 +08:00
await this . modPage . selectSlide ( 'Slide 10' ) ;
2023-06-08 10:17:42 +08:00
await expect ( wbBox ) . toHaveScreenshot ( 'moderator1-select-slide10.png' ) ;
2023-04-24 22:09:46 +08:00
2023-04-25 00:33:00 +08:00
await this . modPage . selectSlide ( 'Slide 5' ) ;
2023-06-08 10:17:42 +08:00
await expect ( wbBox ) . toHaveScreenshot ( 'moderator1-select-slide5.png' ) ;
2023-04-24 22:09:46 +08:00
2023-04-25 00:33:00 +08:00
await this . modPage . selectSlide ( 'Slide 13' ) ;
2023-06-08 10:17:42 +08:00
await expect ( wbBox ) . toHaveScreenshot ( 'moderator1-select-slide13.png' ) ;
2023-04-20 00:24:30 +08:00
}
2021-11-27 03:04:28 +08:00
}
2021-12-04 01:01:36 +08:00
exports . Presentation = Presentation ;