adds webcams layout test suite

This commit is contained in:
Mohamed Amine Ben Salah 2020-09-09 12:51:56 -03:00
parent 04833ce655
commit b48b82330a
7 changed files with 84 additions and 1 deletions

View File

@ -190,6 +190,34 @@ class Page {
};
}
static getArgsWithAudioAndVideo() {
if (process.env.BROWSERLESS_ENABLED === 'true') {
const args = [
'--no-sandbox',
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
'--lang=en-US',
];
return {
headless: true,
args,
};
}
const args = [
'--no-sandbox',
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
`--use-file-for-fake-audio-capture=${path.join(__dirname, '../media/audio.wav')}`,
`--use-file-for-fake-video-capture=${path.join(__dirname, '../media/video_rgb.y4m')}`,
'--allow-file-access',
'--lang=en-US',
];
return {
headless: true,
args,
};
}
// Returns a Promise that resolves when an element does not exist/is removed from the DOM
elementRemoved(element) {
return this.page.waitFor(element => !document.querySelector(element), {}, element);

View File

@ -6,7 +6,7 @@ usage() {
BBB Health Check
OPTIONS:
-t <test name: whiteboard/webcam/virtualizedlist/user/sharednotes/screenshare/presentation/notifications/customparameters/chat/breakout/audio/all>
-t <test name: webcamlayout/whiteboard/webcam/virtualizedlist/user/sharednotes/screenshare/presentation/notifications/customparameters/chat/breakout/audio/all>
-h <hostname name of BigBlueButton server>
-s <Shared secret>

View File

@ -4,3 +4,5 @@ exports.startSharingWebcam = 'button[aria-label="Start sharing"]';
exports.videoContainer = 'div[class^="videoListItem"]';
exports.webcamConnecting = '[class^="connecting-"]';
exports.presentationFullscreenButton = 'button[data-test="presentationFullscreenButton"]';
exports.webcamItemTalkingUser = 'div[data-test="webcamItemTalkingUser"]';
exports.webcamVideo = 'video[data-test="videoContainer"]';

View File

@ -66,8 +66,13 @@ async function clickTestElement(element) {
document.querySelectorAll(element)[0].click();
}
async function countTestElements(element) {
return await document.querySelectorAll(element).length;
}
exports.startAndCheckForWebcams = startAndCheckForWebcams;
exports.webcamContentCheck = webcamContentCheck;
exports.evaluateCheck = evaluateCheck;
exports.getFullScreenWebcamButton = getFullScreenWebcamButton;
exports.enableWebcam = enableWebcam;
exports.countTestElements = countTestElements;

View File

@ -0,0 +1,21 @@
const util = require('./util');
const wle = require('./elements');
const Page = require('../core/page');
class WebcamLayout extends Page {
constructor() {
super('webcam-layout-test');
}
async share() {
await this.joinMicrophone(this);
await util.enableWebcam(this);
}
async test() {
await this.page.waitForSelector(wle.webcamConnecting);
await this.page.waitForSelector(wle.webcamVideo);
return await this.page.evaluate(util.countTestElements, wle.webcamItemTalkingUser) !== 0;
}
}
module.exports = exports = WebcamLayout;

View File

@ -0,0 +1,24 @@
const Page = require('./core/page');
const webcamLayout = require('./webcam/webcamlayout');
const webcamLayoutTest = () => {
beforeEach(() => {
jest.setTimeout(50000);
});
test('Join Webcam and microphone', async () => {
const test = new webcamLayout();
let response;
try {
await test.init(Page.getArgsWithAudioAndVideo());
await test.share();
response = await test.test();
} catch (e) {
console.log(e);
} finally {
await test.close();
}
expect(response).toBe(true);
});
};
module.exports = exports = webcamLayoutTest;

View File

@ -0,0 +1,3 @@
const webcamLayoutTest = require('./webcamlayout.obj');
describe('Webcams Layout', webcamLayoutTest);