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-03-15 21:57:49 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME, ELEMENT_WAIT_EXTRA_LONG_TIME, UPLOAD_PDF_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');
|
2023-04-13 21:37:19 +08:00
|
|
|
const { waitAndClearDefaultPresentationNotification, waitAndClearNotification } = require('../notifications/util');
|
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() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
|
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);
|
|
|
|
await this.modPage.waitForSelector(e.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);
|
|
|
|
await this.modPage.waitForSelector(e.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
|
|
|
}
|
|
|
|
|
2022-01-20 03:50:59 +08:00
|
|
|
async hideAndRestorePresentation() {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { presentationHidden } = getSettings();
|
|
|
|
if (!presentationHidden) {
|
2023-02-14 21:59:46 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
2022-03-29 21:53:07 +08:00
|
|
|
await this.modPage.waitAndClick(e.minimizePresentation);
|
|
|
|
}
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.modPage.wasRemoved(e.presentationContainer);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.restorePresentation);
|
|
|
|
await this.modPage.hasElement(e.presentationContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
async startExternalVideo() {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { externalVideoPlayer } = getSettings();
|
|
|
|
test.fail(!externalVideoPlayer, 'External video is disabled');
|
|
|
|
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
await this.modPage.waitAndClick(e.actions);
|
2022-01-20 21:03:18 +08:00
|
|
|
await this.modPage.waitAndClick(e.shareExternalVideoBtn);
|
2022-11-26 03:54:32 +08:00
|
|
|
await this.modPage.waitForSelector(e.closeModal);
|
2022-01-20 03:50:59 +08:00
|
|
|
await this.modPage.type(e.videoModalInput, e.youtubeLink);
|
|
|
|
await this.modPage.waitAndClick(e.startShareVideoBtn);
|
|
|
|
|
|
|
|
const modFrame = await this.getFrame(this.modPage, e.youtubeFrame);
|
|
|
|
const userFrame = await this.getFrame(this.userPage, e.youtubeFrame);
|
|
|
|
|
|
|
|
await modFrame.hasElement('video');
|
|
|
|
await userFrame.hasElement('video');
|
|
|
|
}
|
|
|
|
|
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-03-15 21:57:49 +08:00
|
|
|
await uploadSinglePresentation(this.modPage, e.pdfFileName, UPLOAD_PDF_WAIT_TIME);
|
|
|
|
|
|
|
|
// wait until the notifications disappear
|
|
|
|
await this.modPage.wasRemoved(e.presentationStatusInfo, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.wasRemoved(e.smallToastMsg, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.userPage.wasRemoved(e.presentationStatusInfo);
|
|
|
|
await this.userPage.wasRemoved(e.smallToastMsg);
|
|
|
|
|
|
|
|
const modWhiteboardLocator = this.modPage.getLocator(e.whiteboard);
|
|
|
|
await expect(modWhiteboardLocator).toHaveScreenshot('moderator-new-presentation-screenshot.png', {
|
2023-03-10 21:50:49 +08:00
|
|
|
maxDiffPixels: 1000,
|
|
|
|
});
|
2023-03-15 21:57:49 +08:00
|
|
|
|
|
|
|
const userWhiteboardLocator = this.userPage.getLocator(e.whiteboard);
|
|
|
|
await expect(userWhiteboardLocator).toHaveScreenshot('viewer-new-presentation-screenshot.png', {
|
2023-03-10 21:50:49 +08:00
|
|
|
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);
|
2022-06-21 07:02:10 +08:00
|
|
|
await expect(modSlides1).toEqual(userSlides1);
|
|
|
|
await expect(modSlides0).not.toEqual(modSlides1);
|
|
|
|
await expect(userSlides0).not.toEqual(userSlides1);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2022-06-21 07:02:10 +08:00
|
|
|
await uploadSinglePresentation(this.modPage, e.uploadPresentationFileName);
|
2023-02-14 21:59:46 +08:00
|
|
|
const width1 = (await this.modPage.getElementBoundingBox(e.whiteboard)).width;
|
2022-06-21 07:02:10 +08:00
|
|
|
await this.modPage.waitAndClick(e.fitToWidthButton);
|
2023-02-14 21:59:46 +08:00
|
|
|
const width2 = (await this.modPage.getElementBoundingBox(e.whiteboard)).width;
|
2022-06-30 23:01:00 +08:00
|
|
|
await expect(Number(width2) > Number(width1)).toBeTruthy();
|
2022-06-21 07:02:10 +08:00
|
|
|
}
|
|
|
|
|
2022-11-08 22:32:55 +08:00
|
|
|
async downloadPresentation(testInfo) {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { presentationDownloadable } = getSettings();
|
|
|
|
test.fail(!presentationDownloadable, 'Presentation download is disable');
|
|
|
|
|
2021-11-27 03:04:28 +08:00
|
|
|
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);
|
2022-11-08 22:32:55 +08:00
|
|
|
await this.modPage.waitAndClick(e.exportPresentationToPublicChat);
|
2023-02-14 21:59:46 +08:00
|
|
|
await this.userPage.hasElement(e.smallToastMsg);
|
|
|
|
await this.userPage.hasElement(e.toastDownload);
|
2022-11-08 22:32:55 +08:00
|
|
|
await this.userPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
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);
|
|
|
|
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage.wasRemoved(e.whiteboard);
|
2023-04-13 21:37:19 +08:00
|
|
|
await this.modPage.wasRemoved(e.minimizePresentation);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.userPage.wasRemoved(e.whiteboard);
|
2023-04-13 21:37:19 +08:00
|
|
|
await this.userPage.wasRemoved(e.minimizePresentation);
|
2021-11-27 03:04:28 +08:00
|
|
|
}
|
|
|
|
|
2022-08-30 19:16:09 +08:00
|
|
|
async uploadAndRemoveAllPresentations() {
|
2022-09-16 19:27:29 +08:00
|
|
|
await waitAndClearDefaultPresentationNotification(this.modPage);
|
2022-08-30 19:16:09 +08:00
|
|
|
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);
|
|
|
|
await expect(modSlides1).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
|
|
|
|
2022-08-30 19:16:09 +08:00
|
|
|
await this.modPage.wasRemoved(e.whiteboard);
|
2023-04-13 21:37:19 +08:00
|
|
|
await this.modPage.wasRemoved(e.minimizePresentation);
|
2022-08-30 19:16:09 +08:00
|
|
|
await this.userPage.wasRemoved(e.whiteboard);
|
2023-04-13 21:37:19 +08:00
|
|
|
await this.userPage.wasRemoved(e.minimizePresentation);
|
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);
|
|
|
|
await this.modPage.wasRemoved(e.presentationsList);
|
|
|
|
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);
|
|
|
|
await this.userPage.wasRemoved(e.presentationsList);
|
|
|
|
}
|
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);
|
|
|
|
await expect(modSlides1).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
|
|
|
|
2022-09-17 04:53:17 +08:00
|
|
|
await this.userPage.wasRemoved(e.whiteboard);
|
2022-08-30 19:16:09 +08:00
|
|
|
await this.userPage.waitAndClick(e.actions);
|
|
|
|
await this.userPage.waitAndClick(e.managePresentations);
|
|
|
|
await this.userPage.wasRemoved(e.presentationsList);
|
|
|
|
}
|
|
|
|
|
2021-11-27 03:04:28 +08:00
|
|
|
async getFrame(page, frameSelector) {
|
|
|
|
await page.waitForSelector(frameSelector);
|
2021-12-04 01:01:36 +08:00
|
|
|
await sleep(1000);
|
|
|
|
const handleFrame = await page.page.frame({ url: /youtube/ });
|
|
|
|
const frame = new Page(page.browser, handleFrame);
|
2021-11-27 03:04:28 +08:00
|
|
|
await frame.waitForSelector(e.ytFrameTitle);
|
|
|
|
return frame;
|
|
|
|
}
|
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
|
|
|
|
2022-12-01 22:15:55 +08:00
|
|
|
await expect(heightFullscreen).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);
|
|
|
|
await this.modPage.wasRemoved(e.wbToolbar);
|
|
|
|
await this.modPage.wasRemoved(e.wbStyles);
|
|
|
|
await this.modPage.wasRemoved(e.wbUndo);
|
|
|
|
await this.modPage.wasRemoved(e.wbRedo);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
await expect(zoomOutButtonLocator).toBeDisabled();
|
|
|
|
const resetZoomButtonLocator = this.modPage.getLocator(e.resetZoomButton);
|
|
|
|
await expect(resetZoomButtonLocator).toContainText(defaultZoomLevel);
|
|
|
|
|
|
|
|
//Zoom In 150%
|
|
|
|
await this.modPage.waitAndClick(e.zoomInButton);
|
|
|
|
await expect(zoomOutButtonLocator).toBeEnabled();
|
2023-07-14 04:31:39 +08:00
|
|
|
await expect(resetZoomButtonLocator).toContainText(/125%/);
|
|
|
|
await this.modPage.waitAndClick(e.zoomInButton);
|
2023-04-20 00:24:30 +08:00
|
|
|
await expect(resetZoomButtonLocator).toContainText(/150%/);
|
2023-06-08 10:17:42 +08:00
|
|
|
await expect(wbBox).toHaveScreenshot('moderator1-zoom150.png');
|
2023-04-20 00:24:30 +08:00
|
|
|
|
|
|
|
//Zoom out 125%
|
|
|
|
await this.modPage.waitAndClick(e.zoomOutButton);
|
|
|
|
await expect(resetZoomButtonLocator).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);
|
|
|
|
await expect(resetZoomButtonLocator).toContainText(/150%/);
|
2023-04-20 00:24:30 +08:00
|
|
|
await this.modPage.waitAndClick(e.resetZoomButton);
|
|
|
|
await expect(resetZoomButtonLocator).toContainText(/100%/);
|
2023-07-14 04:31:39 +08:00
|
|
|
await expect(zoomOutButtonLocator).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;
|