2020-07-14 03:03:41 +08:00
|
|
|
const path = require('path');
|
|
|
|
const moment = require('moment');
|
2020-02-22 02:06:05 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const Create = require('./create');
|
|
|
|
const util = require('./util');
|
2021-02-26 23:52:17 +08:00
|
|
|
const utilScreenShare = require('../screenshare/util');
|
2020-02-22 02:06:05 +08:00
|
|
|
const e = require('./elements');
|
2020-06-30 09:25:04 +08:00
|
|
|
const pe = require('../core/elements');
|
2020-07-14 03:03:41 +08:00
|
|
|
const we = require('../webcam/elements');
|
2021-02-17 04:57:10 +08:00
|
|
|
const ae = require('../audio/elements');
|
|
|
|
const { ELEMENT_WAIT_TIME, VIDEO_LOADING_WAIT_TIME } = require('../core/constants'); // core constants (Timeouts vars imported)
|
2020-07-14 03:03:41 +08:00
|
|
|
|
2020-07-14 03:03:41 +08:00
|
|
|
const today = moment().format('DD-MM-YYYY');
|
2020-02-22 02:06:05 +08:00
|
|
|
|
|
|
|
class Join extends Create {
|
|
|
|
constructor() {
|
|
|
|
super('join-breakout');
|
|
|
|
}
|
|
|
|
|
2020-06-30 09:25:04 +08:00
|
|
|
// Join Existing Breakoutrooms
|
|
|
|
async join(testName) {
|
2020-08-05 02:53:34 +08:00
|
|
|
await this.joinWithUser3(testName);
|
2020-02-22 02:06:05 +08:00
|
|
|
}
|
|
|
|
|
2020-06-30 09:25:04 +08:00
|
|
|
// Check if User Joined in Breakoutrooms
|
|
|
|
async testJoined(testName) {
|
2020-07-18 03:12:43 +08:00
|
|
|
this.page3.logger('Now executing: ', testName);
|
2020-07-14 03:03:41 +08:00
|
|
|
if (testName === 'joinBreakoutroomsWithAudio') {
|
2020-07-18 04:08:46 +08:00
|
|
|
try {
|
|
|
|
this.page3.logger('logged in to breakout with audio');
|
2020-07-18 03:12:43 +08:00
|
|
|
|
2020-07-18 04:08:46 +08:00
|
|
|
const page2 = await this.page2.browser.pages();
|
2020-08-05 02:53:34 +08:00
|
|
|
|
|
|
|
await page2[2].bringToFront();
|
|
|
|
|
|
|
|
// Talking indicator bar
|
2021-02-17 04:57:10 +08:00
|
|
|
await page2[2].waitForSelector(ae.talkingIndicator, { timeout: ELEMENT_WAIT_TIME });
|
2020-08-05 02:53:34 +08:00
|
|
|
|
|
|
|
if (process.env.GENERATE_EVIDENCES === 'true') {
|
|
|
|
await page2[2].screenshot({ path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-audio-before-check-${testName}.png`) });
|
|
|
|
}
|
2020-07-18 04:08:46 +08:00
|
|
|
this.page3.logger('before pages check');
|
2020-07-18 03:12:43 +08:00
|
|
|
|
2020-07-18 04:08:46 +08:00
|
|
|
const respTalkingIndicatorElement = await page2[2].evaluate(util.getTestElement, pe.isTalking);
|
|
|
|
const resp = respTalkingIndicatorElement === true;
|
2020-07-18 03:12:43 +08:00
|
|
|
|
2020-08-05 02:53:34 +08:00
|
|
|
if (process.env.GENERATE_EVIDENCES === 'true') {
|
|
|
|
await page2[2].screenshot({ path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/06-breakout-page02-user-joined-with-audio-after-check-${testName}.png`) });
|
|
|
|
}
|
2020-07-18 04:08:46 +08:00
|
|
|
this.page3.logger('after pages check');
|
|
|
|
return resp;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
} else if (testName === 'joinBreakoutroomsWithVideo') {
|
2020-07-14 03:03:41 +08:00
|
|
|
this.page2.logger('logged in to breakout with video');
|
2020-07-18 03:12:43 +08:00
|
|
|
|
2020-07-14 03:03:41 +08:00
|
|
|
const page2 = await this.page2.browser.pages();
|
2021-02-17 04:57:10 +08:00
|
|
|
await page2[2].waitForSelector(we.videoContainer, { timeout: VIDEO_LOADING_WAIT_TIME });
|
2020-08-05 02:53:34 +08:00
|
|
|
if (process.env.GENERATE_EVIDENCES === 'true') {
|
|
|
|
await page2[2].screenshot({ path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-webcam-success-${testName}.png`) });
|
|
|
|
}
|
2020-07-14 03:03:41 +08:00
|
|
|
this.page2.logger('before pages check');
|
2020-07-18 03:12:43 +08:00
|
|
|
|
|
|
|
const respWebcamElement = await page2[2].evaluate(util.getTestElement, we.videoContainer);
|
|
|
|
const resp = respWebcamElement === true;
|
|
|
|
|
2020-08-05 02:53:34 +08:00
|
|
|
if (process.env.GENERATE_EVIDENCES === 'true') {
|
|
|
|
await page2[2].screenshot({ path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/06-breakout-page02-user-joined-webcam-before-check-${testName}.png`) });
|
|
|
|
}
|
2020-07-14 03:03:41 +08:00
|
|
|
this.page2.logger('after pages check');
|
|
|
|
return resp;
|
2020-07-18 04:08:46 +08:00
|
|
|
} else if (testName === 'joinBreakoutroomsAndShareScreen') {
|
2020-07-14 03:03:41 +08:00
|
|
|
this.page2.logger('logged in to breakout with screenshare');
|
2020-07-14 03:03:41 +08:00
|
|
|
const page2 = await this.page2.browser.pages();
|
2020-10-27 23:54:55 +08:00
|
|
|
const page3 = await this.page3.browser.pages();
|
2021-02-26 23:52:17 +08:00
|
|
|
|
2020-08-05 02:53:34 +08:00
|
|
|
if (process.env.GENERATE_EVIDENCES === 'true') {
|
2021-02-26 23:52:17 +08:00
|
|
|
await page2[2].screenshot({ path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-screenshare-before-check-${testName}.png`) });
|
2020-08-05 02:53:34 +08:00
|
|
|
}
|
2020-07-14 03:03:41 +08:00
|
|
|
this.page2.logger('before pages check');
|
2021-02-26 23:52:17 +08:00
|
|
|
const resp = await utilScreenShare.getScreenShareBreakoutContainer(page2[2]);
|
|
|
|
|
2020-08-05 02:53:34 +08:00
|
|
|
if (process.env.GENERATE_EVIDENCES === 'true') {
|
2021-02-26 23:52:17 +08:00
|
|
|
await page2[2].screenshot({ path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/06-breakout-page02-user-joined-screenshare-after-check-${testName}.png`) });
|
2020-08-05 02:53:34 +08:00
|
|
|
}
|
2021-02-26 23:52:17 +08:00
|
|
|
|
2020-07-14 03:03:41 +08:00
|
|
|
this.page2.logger('after pages check');
|
|
|
|
return resp;
|
2020-07-18 04:08:46 +08:00
|
|
|
} else {
|
2020-08-05 02:53:34 +08:00
|
|
|
await this.page3.page.bringToFront();
|
2021-02-17 04:57:10 +08:00
|
|
|
await this.page3.waitForSelector(e.breakoutRoomsItem, ELEMENT_WAIT_TIME);
|
|
|
|
await this.page3.waitForSelector(e.chatButton, ELEMENT_WAIT_TIME);
|
|
|
|
await this.page3.click(e.chatButton, true);
|
|
|
|
await this.page3.click(e.breakoutRoomsItem, true);
|
2021-08-20 04:22:31 +08:00
|
|
|
|
|
|
|
const resp = await this.page3.page.evaluate(async (alreadyConnectedSelector) => {
|
|
|
|
await document.querySelectorAll(alreadyConnectedSelector) !== null
|
|
|
|
}, e.alreadyConnected);
|
2020-07-18 04:08:46 +08:00
|
|
|
return resp;
|
2020-06-30 09:25:04 +08:00
|
|
|
}
|
2020-02-22 02:06:05 +08:00
|
|
|
}
|
|
|
|
|
2020-06-30 09:25:04 +08:00
|
|
|
// Close pages
|
2020-02-22 02:06:05 +08:00
|
|
|
async close() {
|
|
|
|
await this.page1.close();
|
|
|
|
await this.page2.close();
|
|
|
|
await this.page3.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = Join;
|