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

135 lines
5.4 KiB
JavaScript
Raw Normal View History

2021-11-27 03:04:28 +08:00
const Page = require('../core/page');
const e = require('../core/elements');
const util = require('./util.js');
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
const { expect } = require('@playwright/test');
class Presentation {
constructor(browser, context) {
this.browser = browser;
this.context = context;
}
async initPages(page1) {
await this.initModPage(page1);
const page2 = await this.context.newPage()
await this.initUserPage(page2);
}
async initModPage(page) {
this.modPage = new Page(this.browser, page);
await this.modPage.init(true, true, { fullName: 'Moderator' });
}
async initUserPage(page) {
this.userPage = new Page(this.browser, page);
await this.userPage.init(false, true, { fullName: 'Attendee', meetingId: this.modPage.meetingId });
}
async skipSlide() {
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
await this.modPage.waitForSelector(e.presentationToolbarWrapper);
await util.checkSvgIndex(this.modPage, '/svg/1');
await this.modPage.waitAndClick(e.nextSlide);
await this.modPage.waitForSelector(e.whiteboard);
await this.modPage.page.waitForTimeout(1000);
await util.checkSvgIndex(this.modPage, '/svg/2');
await this.modPage.waitAndClick(e.prevSlide);
await this.modPage.waitForSelector(e.whiteboard);
await this.modPage.page.waitForTimeout(1000);
await util.checkSvgIndex(this.modPage, '/svg/1');
}
async uploadPresentation() {
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
await this.modPage.waitForSelector(e.skipSlide);
const modSlides0 = await this.modPage.page.evaluate(util.getSvgOuterHtml);
const userSlides0 = await this.userPage.page.evaluate(util.getSvgOuterHtml);
await expect(modSlides0).toEqual(userSlides0);
await util.uploadPresentation(this.modPage, e.uploadPresentationFileName);
const modSlides1 = await this.userPage.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML);
const userSlides1 = await this.modPage.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML);
await expect(modSlides1).toEqual(userSlides1);
await expect(modSlides0).not.toEqual(modSlides1);
await expect(userSlides0).not.toEqual(userSlides1);
}
async allowAndDisallowDownload() {
// 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.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);
// disallow the presentation download
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.uploadPresentation);
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);
await this.modPage.waitAndClick(e.uploadPresentation);
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 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(testName) {
await this.modPage.waitForSelector(e.whiteboard);
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.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');
}
async getFrame(page, frameSelector) {
await page.waitForSelector(frameSelector);
const handleFrame = await page.page.$(frameSelector);
const contentFrame = await handleFrame.contentFrame();
const frame = new Page(page.browser, contentFrame);
await frame.waitForSelector(e.ytFrameTitle);
return frame;
}
}
module.exports = exports = Presentation;