adds audio, webcam and screenshare specs to breakoutrooms test

This commit is contained in:
Mohamed Amine Ben Salah 2020-07-13 16:03:41 -03:00
parent 819a4ea8fb
commit ccb2473f40
5 changed files with 287 additions and 15 deletions

View File

@ -1,9 +1,10 @@
const Join = require('./breakout/join');
const Create = require('./breakout/create');
const Page = require('./core/page');
describe('Breakoutrooms', () => {
beforeEach(() => {
jest.setTimeout(50000);
jest.setTimeout(150000);
});
test('Create Breakout room', async () => {
@ -13,7 +14,7 @@ describe('Breakoutrooms', () => {
const testName = 'createBreakoutrooms';
await test.init();
await test.create(testName);
response = await test.testCreated(testName);
response = await test.testCreatedBreakout(testName);
} catch (e) {
console.log(e);
} finally {
@ -38,4 +39,55 @@ describe('Breakoutrooms', () => {
}
expect(response).toBe(true);
});
test('Join Breakout room with Audio', async () => {
const test = new Join();
let response;
try {
const testName = 'joinBreakoutroomsWithAudio';
await test.init();
await test.create(testName);
await test.join(testName);
response = test.testJoined(testName);
} catch (e) {
console.log(e);
} finally {
await test.close();
}
expect(response).toBe(true);
});
test('Join Breakout room with Video', async () => {
const test = new Join();
let response;
try {
const testName = 'joinBreakoutroomsWithVideo';
await test.init();
await test.create(testName);
await test.join(testName);
response = await test.testJoined(testName);
} catch (e) {
console.log(e);
} finally {
await test.close();
}
expect(response).toBe(true);
});
test('Join Breakout room and share screen', async () => {
const test = new Join();
let response;
try {
const testName = 'joinBreakoutroomsAndShareScreen';
await test.init();
await test.create(testName);
await test.join(testName);
response = await test.testJoined(testName);
} catch (e) {
console.log(e);
} finally {
await test.close();
}
expect(response).toBe(true);
});
});

View File

@ -1,7 +1,13 @@
const Page = require('../core/page');
const params = require('../params');
const moment = require('moment');
const path = require('path');
const util = require('./util');
const be = require('./elements');
const we = require('../webcam/elements');
const e = require('../core/elements');
const { element } = require('prop-types');
const today = moment().format('DD-MM-YYYY');
class Create {
constructor() {
@ -19,35 +25,167 @@ class Create {
// Create Breakoutrooms
async create(testName) {
await this.page1.screenshot(`${testName}`, `01-page01-initialized-${testName}`);
await this.page2.screenshot(`${testName}`, `01-page01-initialized-${testName}`);
await this.page2.screenshot(`${testName}`, `01-page02-initialized-${testName}`);
this.page1.logger('page01 initialized');
this.page2.logger('page02 initialized');
await this.page1.page.evaluate(util.clickTestElement, be.manageUsers);
await this.page1.page.evaluate(util.clickTestElement, be.createBreakoutRooms);
this.page1.logger('page01 breakout rooms menu loaded');
await this.page1.screenshot(`${testName}`, `02-page01-creating-breakoutrooms-${testName}`);
await this.page1.waitForSelector(be.randomlyAssign);
await this.page1.page.evaluate(util.clickTestElement, be.randomlyAssign);
this.page1.logger('page01 randomly assigned users');
await this.page1.screenshot(`${testName}`, `03-page01-randomly-assign-user-${testName}`);
await this.page1.waitForSelector(be.modalConfirmButton);
await this.page1.page.evaluate(util.clickTestElement, be.modalConfirmButton);
this.page1.logger('page01 breakout rooms creation confirmed');
await this.page1.screenshot(`${testName}`, `04-page01-confirm-breakoutrooms-creation-${testName}`);
await this.page2.waitForSelector(be.modalConfirmButton);
await this.page2.page.evaluate(util.clickTestElement, be.modalConfirmButton);
this.page2.logger('page02 breakout rooms join confirmed');
await this.page2.screenshot(`${testName}`, `02-page02-accept-invite-breakoutrooms-${testName}`);
const page2 = await this.page2.browser.pages();
await page2[2].bringToFront();
this.page2.logger('before closing audio modal');
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/03-breakout-page02-before-closing-audio-modal.png`)});
await this.page2.waitForBreakoutElement('button[aria-label="Close Join audio modal"]', 2);
await this.page2.clickBreakoutElement('button[aria-label="Close Join audio modal"]', 2);
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/04-breakout-page02-after-closing-audio-modal.png`)});
this.page2.logger('audio modal closed');
}
// Check if Breakoutrooms have been created
async testCreated(testName) {
async testCreatedBreakout(testName) {
const resp = await this.page1.page.evaluate(() => document.querySelectorAll('div[data-test="breakoutRoomsItem"]').length !== 0);
if (resp === true) {
await this.page1.screenshot(`${testName}`, `05-page01-success-${testName}`);
return true;
}
};
await this.page1.screenshot(`${testName}`, `05-page01-fail-${testName}`);
return false;
}
// Initialize a Moderator session
async joinWithUser3() {
await this.page3.init(Page.getArgs(), this.page1.meetingId, { ...params, fullName: 'Moderator3' }, undefined);
async joinWithUser3(testName) {
if(testName == 'joinBreakoutroomsWithAudio') {
await this.page3.init(Page.getArgsWithAudio(), this.page1.meetingId, { ...params, fullName: 'Moderator3' }, undefined);
await this.page3.closeAudioModal();
await this.page3.waitForSelector(be.breakoutRoomsButton);
await this.page3.click(be.breakoutRoomsButton, true);
await this.page3.waitForSelector(be.joinRoom1);
await this.page3.click(be.joinRoom1, true);
const page3 = await this.page3.browser.pages();
await page3[2].waitForSelector('button[aria-label="Microphone"]');
// await this.page3.waitForBreakoutElement('button[aria-label="Microphone"]', 2);
await this.page3.clickBreakoutElement('button[aria-label="Microphone"]', 2);
await page3[2].waitForSelector('div[class^="connecting--"]');
// await this.page3.waitForBreakoutElement('div[class^="connecting--"]', 2);
await page3[2].waitForSelector('button[aria-label="Echo is audible"]');
// await this.page3.waitForBreakoutElement('button[aria-label="Echo is audible"]', 2);
await this.page3.clickBreakoutElement('button[aria-label="Echo is audible"]', 2);
console.log('with audio');
this.page2.logger('before pages check');
const page2 = await this.page2.browser.pages();
await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
await page2[2].waitForSelector('[data-test="isTalking"]');
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
const foundTalkingIndicatorElement = await document.querySelectorAll('[data-test="isTalking"]').length !== 0;
return foundUserElement && foundTalkingIndicatorElement;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-audio-success.png`)});
this.page2.logger('after pages check');
return resp;
} else if (testName == 'joinBreakoutroomsWithVideo') {
await this.page3.init(Page.getArgsWithVideo(), this.page1.meetingId, { ...params, fullName: 'Moderator3' }, undefined);
await this.page3.closeAudioModal();
await this.page3.waitForSelector(be.breakoutRoomsButton);
await this.page3.click(be.breakoutRoomsButton, true);
await this.page3.waitForSelector(be.joinRoom1);
await this.page3.click(be.joinRoom1, true);
const page3 = await this.page3.browser.pages();
await page3[2].bringToFront();
await page3[2].waitForSelector('button[aria-label="Share webcam"]');
// await this.page3.waitForBreakoutElement('button[aria-label="Share webcam"]', 2);
await this.page3.clickBreakoutElement('button[aria-label="Share webcam"]', 2);
await page3[2].waitForSelector('video[id="preview"]');
// await this.page3.waitForBreakoutElement('video[id="preview"]', 2);
await page3[2].waitForSelector('button[aria-label="Start sharing"]');
// await this.page3.waitForBreakoutElement('button[aria-label="Start sharing"]', 2);
await this.page3.clickBreakoutElement('button[aria-label="Start sharing"]', 2);
console.log('with video');
this.page2.logger('before pages check');
const page2 = await this.page2.browser.pages();
await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
await page2[2].waitForSelector('div[class^="videoListItem"]');
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
const webcamContainerElement = await document.querySelectorAll('div[class^="videoListItem"]').length !== 0;
return foundUserElement && webcamContainerElement;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-webcam-success.png`)});
this.page2.logger('after pages check');
return resp;
} else if (testName === 'joinBreakoutroomsAndShareScreen') {
await this.page3.init(Page.getArgs(), this.page1.meetingId, { ...params, fullName: 'Moderator3' }, undefined);
await this.page3.closeAudioModal();
await this.page3.waitForSelector(be.breakoutRoomsButton);
await this.page3.click(be.breakoutRoomsButton, true);
await this.page3.waitForSelector(be.joinRoom1);
await this.page3.click(be.joinRoom1, true);
const page2 = await this.page2.browser.pages();
const page3 = await this.page3.browser.pages();
await this.page3.waitForSelector('span[class^="usersAssignedNumberLabel"]');
const respCountUsers = await this.page3.page.evaluate(async ()=>
await document.querySelectorAll('span[class^="usersAssignedNumberLabel"]')[0].innerText.includes('2') === true
);
console.log('with screenshare');
await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
await page3[2].evaluate(async ()=> {
await document.querySelectorAll('div[aria-label^="Moderator3"]')[0].click();
await document.querySelectorAll('div[aria-label^="Take presenter"]')[0].click();
});
await page3[2].waitForSelector('button[aria-label="Share your screen"]');
await this.page3.clickBreakoutElement('button[aria-label="Share your screen"]', 2);
await page3[2].on('dialog',async dialog => {
await dialog.accept();
});
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
return foundUserElement;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-success.png`)});
return resp && respCountUsers;
} else {
await this.page3.waitForSelector(be.breakoutRoomsButton);
await this.page3.click(be.breakoutRoomsButton, true);
const page3 = await this.page3.browser.pages();
await page3[2].evaluate(util.clickTestElement, be.breakoutJoin);
await this.page3.init(Page.getArgs(), this.page1.meetingId, { ...params, fullName: 'Moderator3' }, undefined);
console.log('with nothing');
const page2 = await this.page2.browser.pages();
await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
return foundUserElement;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-success.png`)});
return resp;
}
}
// Close pages

View File

@ -7,3 +7,5 @@ exports.breakoutRemainingTime = '[data-test="breakoutRemainingTime"]';
exports.breakoutRoomsItem = '[data-test="breakoutRoomsItem"]';
exports.breakoutJoin = '[data-test="breakoutJoin"]';
exports.userJoined = 'div[aria-label^="Moderator3"]';
exports.breakoutRoomsButton = 'div[aria-label="Breakout Rooms"]';
exports.joinRoom1 = 'button[aria-label="Join room 1"]';

View File

@ -3,6 +3,9 @@ const Create = require('./create');
const util = require('./util');
const e = require('./elements');
const pe = require('../core/elements');
const we = require('../webcam/elements');
const moment = require('moment');
const today = moment().format('DD-MM-YYYY');
class Join extends Create {
constructor() {
@ -11,7 +14,14 @@ class Join extends Create {
// Join Existing Breakoutrooms
async join(testName) {
await this.joinWithUser3();
if(testName === 'joinBreakoutroomsWithAudio') {
await this.joinWithUser3(testName);
} else if (testName === 'joinBreakoutroomsWithVideo'){
await this.joinWithUser3(testName);
} else {
await this.joinWithUser3(testName);
};
await this.page3.screenshot(`${testName}`, `01-page03-initialized-${testName}`);
await this.page3.closeAudioModal();
await this.page3.screenshot(`${testName}`, `02-page03-closed-audioModal-${testName}`);
@ -25,13 +35,67 @@ class Join extends Create {
// Check if User Joined in Breakoutrooms
async testJoined(testName) {
const resp = await this.page2.page.evaluate(util.getTestElement, e.userJoined);
if (resp === true) {
await this.page2.screenshot(`${testName}`, `05-page03-success-${testName}`);
return true;
console.log(testName);
if(testName == 'joinBreakoutroomsWithAudio') {
this.page2.logger('before pages check');
const page2 = await this.page2.browser.pages();
await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
await page2[2].waitForSelector('[data-test="isTalking"]');
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-audio-success.png`)});
this.page2.logger('after pages check');
// await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
// await page2[2].waitForSelector('[data-test="isTalking"]');
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
const foundTalkingIndicatorElement = await document.querySelectorAll('[data-test="isTalking"]').length !== 0;
return foundUserElement && foundTalkingIndicatorElement;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-audio-success.png`)});
this.page2.logger('after pages check');
return resp;
} else if(testName == 'joinBreakoutroomsWithVideo') {
this.page2.logger('before pages check');
const page2 = await this.page2.browser.pages();
// await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
// await page2[2].waitForSelector('div[class^="videoListItem"]');
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-webcam-success.png`)});
this.page2.logger('after pages check');
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
const webcamContainerElement = await document.querySelectorAll('div[class^="videoListItem"]').length !== 0;
return foundUserElement && webcamContainerElement;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-webcam-success.png`)});
this.page2.logger('after pages check');
return resp;
} else if (testName === 'joinBreakoutroomsAndShareScreen') {
this.page2.logger('before pages check');
const page2 = await this.page2.browser.pages();
// await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
// await page2[2].waitForSelector('div[class^="videoListItem"]');
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-webcam-success.png`)});
this.page2.logger('after pages check');
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
const screenshareContainerElement = await document.querySelectorAll('video[id="screenshareVideo"]').length !== 0;
const screenshareButton = await document.querySelectorAll('button[aria-label="Stop sharing your screen"]').length !== 0;
return foundUserElement && screenshareContainerElement && screenshareButton;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-with-webcam-success.png`)});
this.page2.logger('after pages check');
return resp;
} else {
const page2 = await this.page2.browser.pages();
// await page2[2].waitForSelector('div[aria-label^="Moderator3"]');
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-success.png`)});
const resp = await page3[2].evaluate(async ()=>{
const foundUserElement = await document.querySelectorAll('div[aria-label^="Moderator3"]').length !== 0;
return foundUserElement;
});
await page2[2].screenshot({path: path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testName}/screenshots/05-breakout-page02-user-joined-success.png`)});
return resp;
}
await this.page2.screenshot(`${testName}`, `05-page03-fail-${testName}`);
return false;
}
// Close pages

View File

@ -122,7 +122,21 @@ class Page {
// Get the default arguments for creating a page
static getArgs() {
const args = ['--no-sandbox', '--use-fake-ui-for-media-stream', '--lang=en-US'];
return { headless: false, args };
return { headless: false, slowMo: 250, args };
}
async waitForBreakoutElement(element, pageNumber) {
const pageTarget = await this.browser.pages();
await pageTarget[pageNumber].waitForSelector(element, { timeout: 0 });
}
async clickBreakoutElement(element, pageNumber) {
const pageTarget = await this.browser.pages();
await pageTarget[pageNumber].click(element);
}
async returnElement(element) {
return await document.querySelectorAll(element)[0];
}
static getArgsWithAudio() {
@ -149,6 +163,7 @@ class Page {
return {
headless: false,
args,
slowMo: 200,
};
}
@ -176,6 +191,7 @@ class Page {
return {
headless: false,
args,
slowMo: 250,
};
}