2021-08-27 02:42:07 +08:00
|
|
|
const Page = require('../core/page');
|
2021-09-22 11:51:29 +08:00
|
|
|
const e = require('../core/elements');
|
2021-09-08 22:20:57 +08:00
|
|
|
const util = require('./util');
|
2021-10-29 02:37:56 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
|
|
|
const { checkElement, checkElementText } = require('../core/util');
|
2021-08-27 02:42:07 +08:00
|
|
|
|
|
|
|
class Presentation {
|
|
|
|
constructor() {
|
|
|
|
this.modPage = new Page();
|
|
|
|
this.userPage = new Page();
|
|
|
|
}
|
|
|
|
|
2021-11-06 04:16:42 +08:00
|
|
|
async initPages(testName, extraFlags) {
|
|
|
|
await this.initModPage(testName, extraFlags);
|
|
|
|
await this.initUserPage(testName, extraFlags);
|
2021-08-27 02:42:07 +08:00
|
|
|
}
|
|
|
|
|
2021-11-06 04:16:42 +08:00
|
|
|
async initModPage(testName, extraFlags) {
|
|
|
|
await this.modPage.init(true, true, testName, 'Mod', undefined, undefined, undefined, undefined, extraFlags);
|
2021-08-27 02:42:07 +08:00
|
|
|
}
|
|
|
|
|
2021-11-06 04:16:42 +08:00
|
|
|
async initUserPage(testName, extraFlags) {
|
|
|
|
await this.userPage.init(false, true, testName, 'Attendee', this.modPage.meetingId, undefined, undefined, undefined, extraFlags);
|
2021-08-27 02:42:07 +08:00
|
|
|
}
|
|
|
|
|
2021-09-08 22:20:57 +08:00
|
|
|
async skipSlide() {
|
|
|
|
try {
|
2021-09-22 11:51:29 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitForSelector(e.presentationToolbarWrapper);
|
2021-09-08 22:20:57 +08:00
|
|
|
|
|
|
|
const svg0 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/1');
|
|
|
|
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.nextSlide);
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
2021-09-08 22:20:57 +08:00
|
|
|
await this.modPage.page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
const svg1 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/2');
|
|
|
|
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.prevSlide);
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
2021-09-08 22:20:57 +08:00
|
|
|
await this.modPage.page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
const svg2 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/1');
|
|
|
|
|
|
|
|
return svg0 === true && svg1 === true && svg2 === true;
|
|
|
|
} catch (err) {
|
|
|
|
await this.modPage.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async uploadPresentation(testName) {
|
|
|
|
try {
|
2021-09-22 11:51:29 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitForSelector(e.skipSlide);
|
2021-09-08 22:20:57 +08:00
|
|
|
|
|
|
|
const slides0 = await this.modPage.page.evaluate(util.getSvgOuterHtml);
|
|
|
|
|
2021-10-23 03:22:34 +08:00
|
|
|
await util.uploadPresentation(this.modPage, e.uploadPresentationFileName);
|
|
|
|
await this.modPage.screenshot(testName, 'after-presentation-upload');
|
2021-09-08 22:20:57 +08:00
|
|
|
|
|
|
|
const slides1 = await this.modPage.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML);
|
|
|
|
|
2021-10-21 01:23:24 +08:00
|
|
|
await this.modPage.logger('Slides before presentation upload');
|
2021-09-08 22:20:57 +08:00
|
|
|
await this.modPage.logger(slides0);
|
2021-10-21 01:23:24 +08:00
|
|
|
await this.modPage.logger('Slides after presentation upload');
|
2021-09-08 22:20:57 +08:00
|
|
|
await this.modPage.logger(slides1);
|
|
|
|
|
|
|
|
return slides0 !== slides1;
|
|
|
|
} catch (err) {
|
|
|
|
await this.modPage.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
2021-08-27 02:42:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async allowAndDisallowDownload(testName) {
|
|
|
|
try {
|
|
|
|
// allow the presentation download
|
2021-09-22 11:51:29 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.uploadPresentation);
|
2021-08-27 02:42:07 +08:00
|
|
|
await this.modPage.screenshot(testName, `1-modPage-before-allow-download-[${this.modPage.meetingId}]`);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.allowPresentationDownload);
|
2021-08-27 02:42:07 +08:00
|
|
|
await this.userPage.screenshot(testName, `2-userPage-after-allow-download-without-save-[${this.modPage.meetingId}]`);
|
2021-09-22 11:51:29 +08:00
|
|
|
await this.userPage.waitForElementHandleToBeRemoved(e.smallToastMsg);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.confirmManagePresentation);
|
2021-08-27 02:42:07 +08:00
|
|
|
await this.userPage.screenshot(testName, `3-userPage-after-allow-download-and-save-[${this.modPage.meetingId}]`);
|
2021-09-22 11:51:29 +08:00
|
|
|
await this.userPage.waitForSelector(e.toastDownload);
|
2021-08-27 02:42:07 +08:00
|
|
|
// check download button in presentation after ALLOW it - should be true
|
2021-10-07 22:29:18 +08:00
|
|
|
const hasPresentationDownloadBtnAfterAllow = await this.userPage.hasElement(e.presentationDownloadBtn);
|
2021-08-27 02:42:07 +08:00
|
|
|
|
|
|
|
// disallow the presentation download
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.uploadPresentation);
|
2021-08-27 02:42:07 +08:00
|
|
|
await this.modPage.screenshot(testName, `4-modPage-before-disallow-download-[${this.modPage.meetingId}]`);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.disallowPresentationDownload);
|
|
|
|
await this.modPage.waitAndClick(e.confirmManagePresentation);
|
2021-08-27 02:42:07 +08:00
|
|
|
await this.modPage.screenshot(testName, `5-userPage-after-disallow-download-[${this.modPage.meetingId}]`);
|
2021-09-22 11:51:29 +08:00
|
|
|
await this.userPage.waitForElementHandleToBeRemoved(e.toastDownload);
|
2021-08-27 02:42:07 +08:00
|
|
|
// check download button in presentation after DISALLOW it - should be false
|
2021-09-22 11:51:29 +08:00
|
|
|
const hasPresentationDownloadBtnAfterDisallow = await this.userPage.page.evaluate(checkElement, e.presentationDownloadBtn);
|
2021-08-27 02:42:07 +08:00
|
|
|
|
|
|
|
return hasPresentationDownloadBtnAfterAllow && !hasPresentationDownloadBtnAfterDisallow;
|
|
|
|
} catch (err) {
|
2021-09-09 01:18:01 +08:00
|
|
|
await this.modPage.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async removeAllPresentation(testName) {
|
|
|
|
try {
|
2021-09-22 11:51:29 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.uploadPresentation);
|
2021-09-30 19:51:55 +08:00
|
|
|
await this.modPage.screenshot(testName, '1-modPage-before-remove-presentation');
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.modPage.waitAndClick(e.removePresentation);
|
|
|
|
await this.modPage.waitAndClick(e.confirmManagePresentation);
|
2021-09-30 19:51:55 +08:00
|
|
|
|
|
|
|
await this.modPage.waitForSelector(e.presentationPlaceholder);
|
|
|
|
await this.modPage.screenshot(testName, '2-modPage-after-remove-presentation');
|
2021-09-09 01:18:01 +08:00
|
|
|
const modPagePlaceholder = await this.modPage.page.evaluate(checkElementText, e.presentationPlaceholder, e.presentationPlaceholderLabel);
|
2021-09-30 19:51:55 +08:00
|
|
|
await this.userPage.waitForSelector(e.presentationPlaceholder);
|
|
|
|
await this.userPage.screenshot(testName, '3-userPage-after-remove-presentation');
|
2021-09-09 01:18:01 +08:00
|
|
|
const userPagePlaceholder = await this.userPage.page.evaluate(checkElementText, e.presentationPlaceholder, e.presentationPlaceholderLabel);
|
|
|
|
|
|
|
|
return modPagePlaceholder && userPagePlaceholder;
|
|
|
|
} catch (err) {
|
|
|
|
await this.modPage.logger(err);
|
2021-08-27 02:42:07 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-10-27 01:57:40 +08:00
|
|
|
|
|
|
|
async hideAndRestorePresentation(testName) {
|
|
|
|
try {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
await this.modPage.screenshot(testName, '01-after-close-audio-modal');
|
|
|
|
await this.modPage.waitAndClick(e.minimizePresentation);
|
|
|
|
const presentationWasRemoved = await this.modPage.wasRemoved(e.presentationContainer);
|
|
|
|
await this.modPage.screenshot(testName, '02-minimize-presentation');
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.restorePresentation);
|
|
|
|
const presentationWasRestored = await this.modPage.hasElement(e.presentationContainer);
|
|
|
|
await this.modPage.screenshot(testName, '03-restore-presentation');
|
|
|
|
|
|
|
|
return presentationWasRemoved && presentationWasRestored;
|
|
|
|
} catch (err) {
|
|
|
|
await this.modPage.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-10-29 02:37:56 +08:00
|
|
|
|
|
|
|
async startExternalVideo(testName) {
|
|
|
|
try {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
await this.modPage.screenshot(testName, '01-after-close-audio-modal');
|
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.externalVideoBtn);
|
|
|
|
await this.modPage.waitForSelector(e.externalVideoModalHeader);
|
|
|
|
await this.modPage.type(e.videoModalInput, e.youtubeLink);
|
|
|
|
await this.modPage.screenshot(testName, '02-before-start-sharing-video');
|
|
|
|
await this.modPage.waitAndClick(e.startShareVideoBtn);
|
|
|
|
|
|
|
|
const modFrame = await this.getFrame(this.modPage, e.youtubeFrame);
|
|
|
|
await this.modPage.screenshot(testName, '03-modPage-after-rendering-frame');
|
|
|
|
const userFrame = await this.getFrame(this.userPage, e.youtubeFrame);
|
|
|
|
await this.userPage.screenshot(testName, '03-userPage-after-rendering-frame');
|
|
|
|
|
|
|
|
const resp = (await modFrame.hasElement('video')) && (await userFrame.hasElement('video'));
|
|
|
|
|
|
|
|
return resp === true;
|
|
|
|
} catch (err) {
|
|
|
|
await this.modPage.logger(err);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async getFrame(page, frameSelector) {
|
|
|
|
await page.waitForSelector(frameSelector);
|
|
|
|
const handleFrame = await page.page.$(frameSelector);
|
|
|
|
const contentFrame = await handleFrame.contentFrame();
|
|
|
|
const frame = new Page(contentFrame);
|
|
|
|
await frame.waitForSelector(e.ytFrameTitle);
|
|
|
|
return frame;
|
|
|
|
}
|
2021-08-27 02:42:07 +08:00
|
|
|
}
|
|
|
|
|
2023-04-04 04:23:26 +08:00
|
|
|
module.exports = exports = Presentation;
|