bigbluebutton-Github/bigbluebutton-tests/puppeteer/breakout/create.js

173 lines
7.0 KiB
JavaScript
Raw Normal View History

const Page = require('../core/page');
const e = require('../core/elements');
2021-09-23 04:20:02 +08:00
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
2020-02-22 02:06:05 +08:00
class Create {
constructor() {
this.modPage1 = new Page();
this.modPage2 = new Page();
this.userPage1 = new Page();
2020-02-22 02:06:05 +08:00
}
2021-04-15 00:16:41 +08:00
// Join BigBlueButton meeting with a Moderator and a Viewer
2021-09-30 20:36:08 +08:00
async init(testName) {
await this.modPage1.init(true, true, testName, 'Moderator1');
await this.userPage1.init(false, true, testName, 'Viewer1', this.modPage1.meetingId);
}
2021-04-15 00:16:41 +08:00
// Join BigBlueButton meeting with a Viewer only
async initViewer(testName) {
2021-09-30 20:36:08 +08:00
await this.userPage1.init(false, true, testName, 'Viewer2', this.modPage1.meetingId);
2021-04-15 00:16:41 +08:00
}
// Create Breakoutrooms
async create(testName) {
try {
await this.modPage1.screenshot(testName, '01-page01-initialized');
await this.userPage1.screenshot(testName, '01-page02-initialized');
await this.modPage1.waitAndClick(e.manageUsers);
await this.modPage1.waitAndClick(e.createBreakoutRooms);
await this.modPage1.screenshot(testName, '02-page01-creating-breakoutrooms');
await this.modPage1.waitAndClick(e.randomlyAssign);
await this.modPage1.screenshot(testName, '03-page01-randomly-assign-user');
await this.modPage1.waitAndClick(e.modalConfirmButton, ELEMENT_WAIT_LONGER_TIME);
await this.modPage1.screenshot(testName, '04-page01-confirm-breakoutrooms-creation');
2021-09-23 04:20:02 +08:00
// Join breakout room
await this.userPage1.waitAndClick(e.modalConfirmButton, ELEMENT_WAIT_LONGER_TIME);
await this.userPage1.screenshot(testName, '02-page02-accept-invite-breakoutrooms');
await this.userPage1.bringToFront();
await this.userPage1.waitAndClick(e.chatButton);
await this.userPage1.waitAndClick(e.breakoutRoomsItem);
await this.userPage1.waitForSelector(e.alreadyConnected, ELEMENT_WAIT_LONGER_TIME);
2021-09-23 04:20:02 +08:00
const breakoutUserPage1 = await this.userPage1.getLastTargetPage();
await breakoutUserPage1.bringToFront();
2021-09-23 04:20:02 +08:00
await breakoutUserPage1.screenshot(testName, '03-breakout-page02-before-closing-audio-modal');
await breakoutUserPage1.closeAudioModal();
2021-09-23 04:20:02 +08:00
await breakoutUserPage1.screenshot(testName, '04-breakout-page02-after-closing-audio-modal');
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.modPage1.logger(err);
2021-08-31 11:07:17 +08:00
return false;
}
2020-02-22 02:06:05 +08:00
}
// Check if Breakoutrooms have been created
async testCreatedBreakout(testName) {
try {
2021-10-07 22:29:18 +08:00
const resp = await this.modPage1.hasElement(e.breakoutRoomsItem);
if (resp === true) {
await this.modPage1.screenshot(`${testName}`, `05-page01-success-${testName}`);
return true;
}
await this.modPage1.screenshot(`${testName}`, `05-page01-fail-${testName}`);
return false;
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.modPage1.logger(err);
return false;
}
}
// Initialize a Moderator session
async joinWithMod2(testName) {
try {
if (testName === 'joinBreakoutroomsWithAudio') {
2021-09-30 20:36:08 +08:00
await this.modPage2.init(true, true, testName, 'Moderator2', this.modPage1.meetingId);
await this.modPage2.waitAndClick(e.breakoutRoomsButton);
await this.modPage2.waitForSelector(e.breakoutRoomsItem);
await this.modPage2.waitAndClick(e.chatButton);
await this.modPage2.waitAndClick(e.breakoutRoomsItem);
await this.modPage2.waitAndClick(e.generateRoom1);
await this.modPage2.waitAndClick(e.joinGeneratedRoom1);
await this.modPage2.waitForSelector(e.alreadyConnected, ELEMENT_WAIT_LONGER_TIME);
const breakoutModPage2 = await this.modPage2.getLastTargetPage();
await breakoutModPage2.screenshot(testName, `00-breakout-page03-user-joined-no-mic-before-check`);
await breakoutModPage2.bringToFront();
await breakoutModPage2.waitAndClick(e.microphoneButton);
await breakoutModPage2.waitForSelector(e.connectingStatus);
const parsedSettings = await this.modPage1.getSettingsYaml();
const listenOnlyCallTimeout = parseInt(parsedSettings.public.media.listenOnlyCallTimeout);
await breakoutModPage2.waitAndClick(e.echoYesButton, listenOnlyCallTimeout);
await breakoutModPage2.waitForSelector(e.whiteboard);
await breakoutModPage2.screenshot(testName, '00-breakout-page03-user-joined-with-mic-before-check');
} else if (testName === 'joinBreakoutroomsWithVideo') {
2021-09-30 20:36:08 +08:00
await this.modPage2.init(true, true, testName, 'Moderator2', this.modPage1.meetingId);
await this.modPage2.waitAndClick(e.breakoutRoomsButton);
await this.modPage2.waitAndClick(e.generateRoom1);
await this.modPage2.waitAndClick(e.joinGeneratedRoom1);
await this.modPage2.waitForSelector(e.alreadyConnected);
const breakoutModPage2 = await this.modPage2.getLastTargetPage();
await breakoutModPage2.screenshot(testName, '00-breakout-page03-user-joined-no-webcam-before-check');
await breakoutModPage2.bringToFront();
await breakoutModPage2.closeAudioModal();
const parsedSettings = await this.modPage2.getSettingsYaml();
const videoPreviewTimeout = parseInt(parsedSettings.public.kurento.gUMTimeout);
await breakoutModPage2.shareWebcam(true, videoPreviewTimeout);
2021-09-23 04:20:02 +08:00
await breakoutModPage2.screenshot(testName, '00-breakout-page03-user-joined-with-webcam-before-check');
} else if (testName === 'joinBreakoutroomsAndShareScreen') {
2021-09-30 20:36:08 +08:00
await this.modPage2.init(true, true, testName, 'Moderator2', this.modPage1.meetingId);
await this.modPage2.waitAndClick(e.breakoutRoomsButton);
await this.modPage2.waitAndClick(e.generateRoom1);
await this.modPage2.waitAndClick(e.joinGeneratedRoom1);
await this.modPage2.waitForSelector(e.alreadyConnected);
const breakoutModPage2 = await this.modPage2.getLastTargetPage();
await breakoutModPage2.screenshot(testName, '00-breakout-page03-user-joined-with-screenshare-before-check');
await breakoutModPage2.bringToFront();
await breakoutModPage2.closeAudioModal();
// Take Presenter
await breakoutModPage2.waitAndClick(e.firstUser);
await breakoutModPage2.waitAndClick(e.setPresenter);
// Start Share Screen
await breakoutModPage2.waitAndClick(e.startScreenSharing);
await breakoutModPage2.page.on('dialog', async (dialog) => {
await dialog.accept();
});
await breakoutModPage2.screenshot(testName, '00-breakout-page03-user-joined-with-screenshare-after-check');
} else {
2021-09-30 20:36:08 +08:00
await this.modPage2.init(true, true, testName, 'Moderator2', this.modPage1.meetingId);
}
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.modPage2.logger(err);
}
}
// Close pages
async close() {
try {
await this.modPage1.close();
await this.userPage1.close();
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.modPage1.logger(err);
}
2020-02-22 02:06:05 +08:00
}
2021-04-15 00:16:41 +08:00
// Close page
async closePage(page) {
try {
await page.close();
2021-08-26 22:13:18 +08:00
} catch (err) {
await this.modPage1.logger(err);
}
2021-04-15 00:16:41 +08:00
}
2020-02-22 02:06:05 +08:00
}
2021-09-30 20:36:08 +08:00
module.exports = exports = Create;