bigbluebutton-Github/bigbluebutton-tests/puppeteer/presentation/presentation.js

134 lines
5.8 KiB
JavaScript
Raw Normal View History

const Page = require('../core/page');
const e = require('../core/elements');
2021-09-08 22:20:57 +08:00
const util = require('./util');
2021-10-01 02:38:18 +08:00
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');
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) {
2021-09-30 20:36:08 +08:00
await this.modPage.init(true, true, testName, 'Mod');
}
async initUserPage(testName) {
2021-09-30 20:36:08 +08:00
await this.userPage.init(false, true, testName, 'Attendee', this.modPage.meetingId);
}
2021-09-08 22:20:57 +08:00
async skipSlide() {
try {
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
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');
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');
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 {
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
await this.modPage.waitForSelector(e.skipSlide);
2021-09-08 22:20:57 +08:00
const slides0 = await this.modPage.page.evaluate(util.getSvgOuterHtml);
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;
}
}
async allowAndDisallowDownload(testName) {
try {
// allow the presentation download
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.uploadPresentation);
await this.modPage.screenshot(testName, `1-modPage-before-allow-download-[${this.modPage.meetingId}]`);
await this.modPage.waitAndClick(e.allowPresentationDownload);
await this.userPage.screenshot(testName, `2-userPage-after-allow-download-without-save-[${this.modPage.meetingId}]`);
await this.userPage.waitForElementHandleToBeRemoved(e.smallToastMsg);
await this.modPage.waitAndClick(e.confirmManagePresentation);
await this.userPage.screenshot(testName, `3-userPage-after-allow-download-and-save-[${this.modPage.meetingId}]`);
await this.userPage.waitForSelector(e.toastDownload);
// 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);
// disallow the presentation download
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.uploadPresentation);
await this.modPage.screenshot(testName, `4-modPage-before-disallow-download-[${this.modPage.meetingId}]`);
await this.modPage.waitAndClick(e.disallowPresentationDownload);
await this.modPage.waitAndClick(e.confirmManagePresentation);
await this.modPage.screenshot(testName, `5-userPage-after-disallow-download-[${this.modPage.meetingId}]`);
await this.userPage.waitForElementHandleToBeRemoved(e.toastDownload);
// check download button in presentation after DISALLOW it - should be false
const hasPresentationDownloadBtnAfterDisallow = await this.userPage.page.evaluate(checkElement, e.presentationDownloadBtn);
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(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.uploadPresentation);
await this.modPage.screenshot(testName, '1-modPage-before-remove-presentation');
await this.modPage.waitAndClick(e.removePresentation);
await this.modPage.waitAndClick(e.confirmManagePresentation);
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);
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);
return false;
}
}
}
module.exports = exports = Presentation;