Merge pull request #8891 from daminebenq/webcams-test-fixes

Webcams test fixes
This commit is contained in:
Anton Georgiev 2020-03-27 08:59:51 -04:00 committed by GitHub
commit 54fa9c8ddb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 92 deletions

View File

@ -159,7 +159,7 @@ class VideoListItem extends Component {
>
{
!videoIsReady
&& <div className={styles.connecting} />
&& <div data-test="webcamConnecting" className={styles.connecting} />
}
<div
className={styles.videoContainer}

View File

@ -1,13 +1,13 @@
const Share = require('./webcam/share');
const Check = require('./webcam/check');
const LoadingTime = require('./webcam/loadtime');
const Page = require('./core/page');
describe('Webcam', () => {
test('Shares webcam', async () => {
const test = new Share();
let response;
try {
await test.init();
await test.init(Page.getArgsWithVideo());
response = await test.test();
} catch (e) {
console.log(e);
@ -17,25 +17,11 @@ describe('Webcam', () => {
expect(response).toBe(true);
});
test('Check Webcam loading time', async () => {
const test = new LoadingTime();
let response;
try {
await test.init();
response = await test.test();
} catch (e) {
console.log(e);
} finally {
await test.close();
}
expect(response).toBeLessThan(parseInt(process.env.CAMERA_SHARE_FAILED_WAIT_TIME));
});
test('Checks content of webcam', async () => {
const test = new Check();
let response;
try {
await test.init();
await test.init(Page.getArgsWithVideo());
response = await test.test();
} catch (e) {
console.log(e);

View File

@ -7,11 +7,9 @@ class Check extends Share {
}
async test() {
await util.startAndCheckForWebcams(this.page1);
await util.startAndCheckForWebcams(this.page2);
const responseUser1 = await util.webcamContentCheck(this.page1);
const responseUser2 = await util.webcamContentCheck(this.page2);
return responseUser1 && responseUser2;
await util.enableWebcam(this.page);
const respUser = await util.webcamContentCheck(this.page);
return respUser === true;
}
}
module.exports = exports = Check;

View File

@ -2,5 +2,4 @@ exports.joinVideo = 'button[data-test="joinVideo"]';
exports.videoPreview = 'video[data-test="videoPreview"]';
exports.startSharingWebcam = 'button[data-test="startSharingWebcam"]';
exports.videoContainer = 'video[data-test="videoContainer"]';
exports.webcamConnectingStatus = '[data-test="webcamConnectingStatus"]';
exports.presentationFullscreenButton = '[data-test="presentationFullscreenButton"]';
exports.webcamConnecting = '[data-test="webcamConnecting"]';

View File

@ -1,19 +0,0 @@
const Share = require('./share');
const util = require('./util');
class LoadingTime extends Share {
constructor() {
super('check-webcam-loading-time');
}
async test() {
await util.enableWebcam(this.page1);
await util.enableWebcam(this.page2);
const now = new Date().getMilliseconds();
await util.waitForWebcamsLoading(this.page1);
await util.waitForWebcamsLoading(this.page2);
const end = new Date().getMilliseconds();
return end - now;
}
}
module.exports = exports = LoadingTime;

View File

@ -1,29 +1,15 @@
const Page = require('../core/page');
const util = require('./util');
const params = require('../params');
class Share {
class Share extends Page{
constructor() {
this.page1 = new Page();
this.page2 = new Page();
}
async init(meetingId) {
await this.page1.init(Page.getArgsWithVideo(), meetingId, { ...params, fullName: 'Streamer1' });
await this.page2.init(Page.getArgsWithVideo(), this.page1.meetingId, { ...params, fullName: 'Streamer2' });
super('webcam-test');
}
async test() {
await util.enableWebcam(this.page1);
await util.enableWebcam(this.page2);
const responseUser1 = await util.evaluateCheck(this.page1);
const responseUser2 = await util.evaluateCheck(this.page2);
return responseUser1 && responseUser2;
}
async close() {
await this.page1.close();
await this.page2.close();
await util.enableWebcam(this.page);
const response = await util.evaluateCheck(this.page);
return response;
}
}

View File

@ -3,10 +3,10 @@ const we = require('./elements');
async function enableWebcam(test) {
// Enabling webcam
await test.waitForSelector(we.joinVideo);
await test.click(we.joinVideo, true);
await test.click(we.joinVideo);
await test.waitForSelector(we.videoPreview);
await test.waitForSelector(we.startSharingWebcam);
await test.click(we.startSharingWebcam, true);
await test.click(we.startSharingWebcam);
}
async function getTestElement(element) {
@ -15,8 +15,7 @@ async function getTestElement(element) {
async function evaluateCheck(test) {
await test.waitForSelector(we.videoContainer);
await test.waitForSelector(we.webcamConnectingStatus);
const videoContainer = await test.page.evaluate(getTestElement, we.presentationFullscreenButton);
const videoContainer = await test.evaluate(getTestElement, we.presentationFullscreenButton);
const response = videoContainer !== null;
return response;
}
@ -27,7 +26,15 @@ async function startAndCheckForWebcams(test) {
return response;
}
async function checkCameras() {
async function webcamContentCheck(test) {
await test.waitForSelector(we.videoContainer);
await test.waitForFunction(() => !document.querySelector('[data-test="webcamConnecting"]'));
const repeats = 5;
let check;
for (let i = repeats; i >= 1; i--) {
console.log(`loop ${i}`);
const checkCameras = function (i) {
const videos = document.querySelectorAll('video');
const lastVideoColor = document.lastVideoColor || {};
document.lastVideoColor = lastVideoColor;
@ -45,17 +52,15 @@ async function checkCameras() {
return false;
}
}
return lastVideoColor[v] !== pixelString === true;
lastVideoColor[v] = pixelString;
return true;
}
}
};
async function webcamContentCheck(test) {
const repeats = 5;
let check;
for (let i = repeats; i >= 0; i--) {
await test.page.waitFor(parseInt(process.env.LOOP_INTERVAL));
return check = await test.page.evaluate(checkCameras);
check = await test.evaluate(checkCameras, i);
await test.waitFor(parseInt(process.env.LOOP_INTERVAL));
}
return check === true;
}
exports.startAndCheckForWebcams = startAndCheckForWebcams;