2021-12-02 12:12:14 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
|
|
|
const { MultiUsers } = require('../user/multiusers');
|
2021-11-27 03:04:28 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const e = require('../core/elements');
|
2021-12-02 12:12:14 +08:00
|
|
|
const { checkSvgIndex, getSvgOuterHtml, uploadPresentation } = require('./util.js');
|
2021-11-27 03:04:28 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
2021-12-04 01:01:36 +08:00
|
|
|
const { sleep } = require('../core/helpers');
|
2021-11-27 03:04:28 +08:00
|
|
|
|
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);
|
|
|
|
await this.modPage.waitForSelector(e.presentationToolbarWrapper);
|
|
|
|
|
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);
|
|
|
|
await this.modPage.page.waitForTimeout(1000);
|
|
|
|
|
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);
|
|
|
|
await this.modPage.page.waitForTimeout(1000);
|
|
|
|
|
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() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
await this.modPage.waitAndClick(e.minimizePresentation);
|
|
|
|
await this.modPage.wasRemoved(e.presentationContainer);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.restorePresentation);
|
|
|
|
await this.modPage.hasElement(e.presentationContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
async startExternalVideo() {
|
|
|
|
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-01-20 03:50:59 +08:00
|
|
|
await this.modPage.waitForSelector(e.externalVideoModalHeader);
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:12:14 +08:00
|
|
|
async uploadPresentationTest() {
|
2021-11-27 03:04:28 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.waitForSelector(e.skipSlide);
|
|
|
|
|
2021-12-02 12:12:14 +08:00
|
|
|
const modSlides0 = await this.modPage.page.evaluate(getSvgOuterHtml);
|
|
|
|
const userSlides0 = await this.userPage.page.evaluate(getSvgOuterHtml);
|
2021-11-27 03:04:28 +08:00
|
|
|
await expect(modSlides0).toEqual(userSlides0);
|
|
|
|
|
2021-12-02 12:12:14 +08:00
|
|
|
await uploadPresentation(this.modPage, e.uploadPresentationFileName);
|
2021-11-27 03:04:28 +08:00
|
|
|
|
2021-12-02 13:30:38 +08:00
|
|
|
const modSlides1 = await this.userPage.page.evaluate(async () => document.querySelector('svg g g g').outerHTML);
|
|
|
|
const userSlides1 = await this.modPage.page.evaluate(async () => document.querySelector('svg g g g').outerHTML);
|
2021-11-27 03:04:28 +08:00
|
|
|
await expect(modSlides1).toEqual(userSlides1);
|
|
|
|
|
|
|
|
await expect(modSlides0).not.toEqual(modSlides1);
|
|
|
|
await expect(userSlides0).not.toEqual(userSlides1);
|
|
|
|
}
|
|
|
|
|
2022-03-21 23:04:43 +08:00
|
|
|
async allowAndDisallowDownload(testInfo) {
|
2021-11-27 03:04:28 +08:00
|
|
|
// allow the presentation download
|
|
|
|
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.allowPresentationDownload);
|
|
|
|
await this.userPage.wasRemoved(e.smallToastMsg);
|
|
|
|
await this.modPage.waitAndClick(e.confirmManagePresentation);
|
|
|
|
await this.userPage.waitForSelector(e.toastDownload);
|
|
|
|
// check download button in presentation after ALLOW it - should be true
|
|
|
|
await this.userPage.hasElement(e.presentationDownloadBtn);
|
2022-03-21 23:04:43 +08:00
|
|
|
await this.userPage.handleDownload(e.presentationDownloadBtn, testInfo);
|
2021-11-27 03:04:28 +08:00
|
|
|
|
|
|
|
// disallow the presentation download
|
|
|
|
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.disallowPresentationDownload);
|
|
|
|
await this.modPage.waitAndClick(e.confirmManagePresentation);
|
|
|
|
await this.userPage.wasRemoved(e.toastDownload);
|
|
|
|
// check download button in presentation after DISALLOW it - should be false
|
2021-12-01 22:02:26 +08:00
|
|
|
await this.userPage.wasRemoved(e.presentationDownloadBtn);
|
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);
|
|
|
|
|
|
|
|
await this.modPage.waitForSelector(e.presentationPlaceholder);
|
|
|
|
await this.modPage.hasText(e.presentationPlaceholder, e.presentationPlaceholderLabel);
|
|
|
|
await this.userPage.waitForSelector(e.presentationPlaceholder);
|
|
|
|
await this.userPage.hasText(e.presentationPlaceholder, e.presentationPlaceholderLabel);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-04 01:01:36 +08:00
|
|
|
exports.Presentation = Presentation;
|