2021-08-27 02:42:07 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const e = require('./elements');
|
|
|
|
const ne = require('../notifications/elements');
|
|
|
|
const ce = require('../core/elements');
|
2021-09-08 22:20:57 +08:00
|
|
|
const we = require('../whiteboard/elements');
|
2021-08-27 02:42:07 +08:00
|
|
|
const params = require('../params');
|
2021-09-08 22:20:57 +08:00
|
|
|
const util = require('./util');
|
|
|
|
const { ELEMENT_WAIT_LONGER_TIME, ELEMENT_WAIT_TIME } = require('../core/constants');
|
2021-09-09 01:18:01 +08:00
|
|
|
const { checkElement, checkElementTextIncludes, checkElementText } = require('../core/util');
|
2021-08-27 02:42:07 +08:00
|
|
|
|
|
|
|
class Presentation {
|
|
|
|
constructor() {
|
|
|
|
this.modPage = new Page();
|
|
|
|
this.userPage = new Page();
|
|
|
|
}
|
|
|
|
|
|
|
|
async initPages(testName) {
|
|
|
|
await this.initModPage(testName);
|
|
|
|
await this.initUserPage(testName);
|
|
|
|
}
|
|
|
|
|
|
|
|
async initModPage(testName) {
|
|
|
|
await this.modPage.init(Page.getArgs(), undefined, { ...params, fullName: 'Mod' }, undefined, testName);
|
|
|
|
await this.modPage.closeAudioModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
async initUserPage(testName) {
|
|
|
|
await this.userPage.init(Page.getArgs(), this.modPage.meetingId, { ...params, fullName: 'Attendee', moderatorPW: '' }, undefined, testName);
|
|
|
|
await this.userPage.closeAudioModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
async closePages() {
|
2021-09-08 22:20:57 +08:00
|
|
|
if (this.modPage.page) await this.modPage.close();
|
|
|
|
if (this.userPage.page) await this.userPage.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
async skipSlide() {
|
|
|
|
try {
|
|
|
|
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.waitForSelector(e.presentationToolbarWrapper, ELEMENT_WAIT_TIME);
|
|
|
|
|
|
|
|
const svg0 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/1');
|
|
|
|
|
|
|
|
await this.modPage.waitForSelector(e.nextSlide, ELEMENT_WAIT_TIME);
|
|
|
|
await this.modPage.click(e.nextSlide, true);
|
|
|
|
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_TIME);
|
|
|
|
await this.modPage.page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
const svg1 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/2');
|
|
|
|
|
|
|
|
await this.modPage.waitForSelector(e.prevSlide, ELEMENT_WAIT_TIME);
|
|
|
|
await this.modPage.click(e.prevSlide, true);
|
|
|
|
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_TIME);
|
|
|
|
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 {
|
|
|
|
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.waitForSelector(e.skipSlide, ELEMENT_WAIT_TIME);
|
|
|
|
|
|
|
|
const slides0 = await this.modPage.page.evaluate(util.getSvgOuterHtml);
|
|
|
|
|
|
|
|
await this.modPage.click(ce.actions, true);
|
|
|
|
await this.modPage.click(e.uploadPresentation, true);
|
|
|
|
|
|
|
|
await this.modPage.screenshot(`${testName}`, `01-before-presentation-upload-[${testName}]`);
|
|
|
|
|
|
|
|
await this.modPage.waitForSelector(e.fileUpload, ELEMENT_WAIT_TIME);
|
|
|
|
const fileUpload = await this.modPage.page.$(e.fileUpload);
|
|
|
|
await fileUpload.uploadFile(`${__dirname}/upload-test.png`);
|
|
|
|
await this.modPage.page.waitForFunction(checkElementTextIncludes, {},
|
|
|
|
'body', 'To be uploaded ...'
|
|
|
|
);
|
|
|
|
await this.modPage.page.waitForSelector(e.upload, ELEMENT_WAIT_TIME);
|
|
|
|
|
|
|
|
await this.modPage.page.click(e.upload, true);
|
|
|
|
await this.modPage.logger('\nWaiting for the new presentation to upload...');
|
|
|
|
await this.modPage.page.waitForFunction(checkElementTextIncludes, {},
|
|
|
|
'body', 'Converting file'
|
|
|
|
);
|
|
|
|
await this.modPage.logger('\nPresentation uploaded!');
|
|
|
|
await this.modPage.page.waitForFunction(checkElementTextIncludes, {},
|
|
|
|
'body', 'Current presentation'
|
|
|
|
);
|
|
|
|
await this.modPage.screenshot(`${testName}`, `02-after-presentation-upload-[${testName}]`);
|
|
|
|
|
|
|
|
const slides1 = await this.modPage.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML);
|
|
|
|
|
|
|
|
await this.modPage.logger('\nSlides before presentation upload:');
|
|
|
|
await this.modPage.logger(slides0);
|
|
|
|
await this.modPage.logger('\nSlides after presentation upload:');
|
|
|
|
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-08 22:20:57 +08:00
|
|
|
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
2021-08-27 02:42:07 +08:00
|
|
|
await this.modPage.click(ce.actions);
|
|
|
|
await this.modPage.click(e.uploadPresentation);
|
|
|
|
await this.modPage.screenshot(testName, `1-modPage-before-allow-download-[${this.modPage.meetingId}]`);
|
|
|
|
await this.modPage.click(ce.allowPresentationDownload);
|
|
|
|
await this.userPage.screenshot(testName, `2-userPage-after-allow-download-without-save-[${this.modPage.meetingId}]`);
|
|
|
|
await this.userPage.waitForElementHandleToBeRemoved(ne.smallToastMsg);
|
|
|
|
await this.modPage.click(ce.confirmManagePresentation);
|
|
|
|
await this.userPage.screenshot(testName, `3-userPage-after-allow-download-and-save-[${this.modPage.meetingId}]`);
|
|
|
|
await this.userPage.waitForSelector(ce.toastDownload);
|
|
|
|
// check download button in presentation after ALLOW it - should be true
|
2021-09-08 21:45:31 +08:00
|
|
|
const hasPresentationDownloadBtnAfterAllow = await this.userPage.page.evaluate(checkElement, ce.presentationDownloadBtn);
|
2021-08-27 02:42:07 +08:00
|
|
|
|
|
|
|
// disallow the presentation download
|
|
|
|
await this.modPage.click(ce.actions);
|
|
|
|
await this.modPage.click(e.uploadPresentation);
|
|
|
|
await this.modPage.screenshot(testName, `4-modPage-before-disallow-download-[${this.modPage.meetingId}]`);
|
|
|
|
await this.modPage.click(ce.disallowPresentationDownload);
|
|
|
|
await this.modPage.click(ce.confirmManagePresentation);
|
|
|
|
await this.modPage.screenshot(testName, `5-userPage-after-disallow-download-[${this.modPage.meetingId}]`);
|
|
|
|
await this.userPage.waitForElementHandleToBeRemoved(ce.toastDownload);
|
|
|
|
// check download button in presentation after DISALLOW it - should be false
|
2021-09-08 21:45:31 +08:00
|
|
|
const hasPresentationDownloadBtnAfterDisallow = await this.userPage.page.evaluate(checkElement, ce.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 {
|
|
|
|
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.click(ce.actions);
|
|
|
|
await this.modPage.click(e.uploadPresentation);
|
|
|
|
await this.modPage.screenshot(testName, `1-modPage-before-remove-download-[${this.modPage.meetingId}]`);
|
|
|
|
await this.modPage.click(e.removePresentation);
|
|
|
|
await this.modPage.click(ce.confirmManagePresentation);
|
|
|
|
await this.modPage.waitForSelector(ce.actions, ELEMENT_WAIT_TIME);
|
|
|
|
await this.modPage.screenshot(testName, `2-modPage-after-remove-download-[${this.modPage.meetingId}]`);
|
|
|
|
await this.userPage.screenshot(testName, `3-userPage-after-remove-download-[${this.modPage.meetingId}]`);
|
|
|
|
const modPagePlaceholder = await this.modPage.page.evaluate(checkElementText, e.presentationPlaceholder, e.presentationPlaceholderLabel);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = Presentation;
|