fix webcam tests and provides shareWebcam function in page.js

This commit is contained in:
Anton Barboza 2021-10-04 17:42:58 -03:00
parent 1fa3955c28
commit 4f2764ce65
9 changed files with 27 additions and 42 deletions

View File

@ -116,11 +116,9 @@ class Create {
await breakoutModPage2.bringToFront();
await breakoutModPage2.closeAudioModal();
await breakoutModPage2.waitAndClick(e.joinVideo);
const parsedSettings = await this.modPage2.getSettingsYaml();
const videoPreviewTimeout = parseInt(parsedSettings.public.kurento.gUMTimeout);
await breakoutModPage2.waitAndClick(e.videoPreview, videoPreviewTimeout);
await breakoutModPage2.waitAndClick(e.startSharingWebcam);
await breakoutModPage2.shareWebcam(true, videoPreviewTimeout);
await breakoutModPage2.screenshot(testName, '00-breakout-page03-user-joined-with-webcam-before-check');
} else if (testName === 'joinBreakoutroomsAndShareScreen') {

View File

@ -8,7 +8,7 @@ const path = require('path');
const PuppeteerVideoRecorder = require('puppeteer-video-recorder');
const helper = require('./helper');
const params = require('./params');
const { ELEMENT_WAIT_TIME } = require('./constants');
const { ELEMENT_WAIT_TIME, VIDEO_LOADING_WAIT_TIME } = require('./constants');
const { getElementLength } = require('./util');
const e = require('./elements');
const { NETWORK_PRESETS } = require('./profiles');
@ -104,6 +104,17 @@ class Page {
await this.waitForSelector(e.isTalking);
}
async shareWebcam(shouldConfirmSharing, videoPreviewTimeout = ELEMENT_WAIT_TIME) {
await this.waitAndClick(e.joinVideo);
if (shouldConfirmSharing) {
await this.waitForSelector(e.videoPreview, videoPreviewTimeout);
await this.waitAndClick(e.startSharingWebcam);
}
await this.waitForSelector(e.webcamConnecting);
await this.waitForSelector(e.webcamVideo, VIDEO_LOADING_WAIT_TIME);
await this.waitForSelector(e.leaveVideo, VIDEO_LOADING_WAIT_TIME);
}
// Joining audio with microphone
async joinMicrophoneWithoutEchoTest() {
await this.waitAndClick(e.joinAudio);

View File

@ -267,7 +267,7 @@ class CustomParameters {
await this.page1.init(true, true, testName, 'Moderator', undefined, customParameter);
await this.page1.startRecording(testName);
await this.page1.screenshot(`${testName}`, `01-${testName}`);
const resp = await this.page1.page.evaluate(checkElementLengthEqualTo, e.joinVideo, 0);
const resp = await this.page1.wasRemoved(e.joinVideo);
if (!resp) {
await this.page1.screenshot(`${testName}`, `02-fail-${testName}`);
await this.page1.logger(testName, ' failed');
@ -681,31 +681,22 @@ class CustomParameters {
await this.page1.init(true, true, testName, 'Moderator1', undefined, customParameter);
await this.page1.startRecording(testName);
await this.page1.screenshot(`${testName}`, `01-${testName}`);
await this.page1.waitAndClick(e.joinVideo);
const firstCheck = await this.page1.page.evaluate(checkElementLengthEqualTo, e.webcamSettingsModal, 0);
await this.page1.shareWebcam(false);
await this.page1.waitAndClick(e.leaveVideo, VIDEO_LOADING_WAIT_TIME);
await this.page1.waitForElementHandleToBeRemoved(e.webcamVideo, ELEMENT_WAIT_LONGER_TIME);
await this.page1.waitForElementHandleToBeRemoved(e.leaveVideo, ELEMENT_WAIT_LONGER_TIME);
await this.page1.waitAndClick(e.joinVideo);
const parsedSettings = await this.page1.getSettingsYaml();
const videoPreviewTimeout = parseInt(parsedSettings.public.kurento.gUMTimeout);
await this.page1.waitForSelector(e.videoPreview, videoPreviewTimeout);
await this.page1.waitForSelector(e.startSharingWebcam);
const secondCheck = await this.page1.page.evaluate(checkElementLengthDifferentTo, e.webcamSettingsModal, 0);
await this.page1.waitAndClick(e.startSharingWebcam);
await this.page1.waitForSelector(e.webcamConnecting);
await this.page1.shareWebcam(true, videoPreviewTimeout);
if (firstCheck !== secondCheck) {
await this.page1.screenshot(`${testName}`, `02-fail-${testName}`);
await this.page1.logger(testName, ' failed');
return false;
}
await this.page1.screenshot(`${testName}`, `02-success-${testName}`);
await this.page1.logger(testName, ' passed');
return true;
} catch (err) {
await this.page1.screenshot(`${testName}`, `02-fail-${testName}`);
await this.page1.logger(err);
return false;
}

View File

@ -1,7 +1,6 @@
const Page = require('../core/page');
const util = require('../chat/util');
const utilUser = require('./util');
const utilWebcam = require('../webcam/util');
const e = require('../core/elements');
const { ELEMENT_WAIT_TIME } = require('../core/constants');
const { getElementLength, checkElementLengthEqualTo, checkElementLengthDifferentTo } = require('../core/util');
@ -316,12 +315,12 @@ class MultiUsers {
async usersConnectionStatus(testName) {
try {
await utilWebcam.enableWebcam(this.page1, ELEMENT_WAIT_TIME);
await this.page1.shareWebcam();
await this.page1.screenshot(testName, '01-page1-after-share-webcam');
await this.initUserPage(false, testName);
await this.userPage.joinMicrophone();
await this.userPage.screenshot(testName, '02-userPage-after-join-microhpone');
await utilWebcam.enableWebcam(this.userPage);
await this.userPage.shareWebcam();
await this.userPage.screenshot(testName, '03-userPage-after-share-webcam');
await this.userPage.waitAndClick(e.connectionStatusBtn);
try {

View File

@ -54,7 +54,7 @@ class Status extends Page {
async disableWebcamsFromConnectionStatus() {
try {
await utilWebcam.enableWebcam(this, ELEMENT_WAIT_LONGER_TIME);
await this.shareWebcam(ELEMENT_WAIT_LONGER_TIME);
await util.connectionStatus(this);
await this.waitAndClickElement(e.dataSavingWebcams);
await this.waitAndClickElement(e.closeConnectionStatusModal);
@ -87,7 +87,7 @@ class Status extends Page {
try {
await this.page.evaluate(() => window.dispatchEvent(new CustomEvent('socketstats', { detail: { rtt: 2000 } })));
await this.joinMicrophone();
await utilWebcam.enableWebcam(this, ELEMENT_WAIT_LONGER_TIME);
await this.shareWebcam(ELEMENT_WAIT_LONGER_TIME);
await utilScreenshare.startScreenshare(this);
await utilScreenshare.waitForScreenshareContainer(this);
await util.connectionStatus(this);

View File

@ -22,7 +22,7 @@ class Check extends Share {
const parsedSettings = await this.getSettingsYaml();
const videoPreviewTimeout = parseInt(parsedSettings.public.kurento.gUMTimeout);
await util.enableWebcam(this, videoPreviewTimeout);
await this.shareWebcam(true, videoPreviewTimeout);
const respUser = await util.webcamContentCheck(this);
return respUser === true;
} catch (err) {

View File

@ -13,8 +13,9 @@ class Share extends Page {
try {
const parsedSettings = await this.getSettingsYaml();
const videoPreviewTimeout = parseInt(parsedSettings.public.kurento.gUMTimeout);
const response = await util.enableWebcam(this, videoPreviewTimeout);
return response;
await this.shareWebcam(true, videoPreviewTimeout);
return true;
} catch (err) {
await this.logger(err);
return false;
@ -26,7 +27,7 @@ class Share extends Page {
await this.joinMicrophone();
const parsedSettings = await this.getSettingsYaml();
const videoPreviewTimeout = parseInt(parsedSettings.public.kurento.gUMTimeout);
await util.enableWebcam(this, videoPreviewTimeout);
await this.shareWebcam(true, videoPreviewTimeout);
} catch (err) {
await this.logger(err);
}

View File

@ -3,21 +3,9 @@ const { sleep } = require('../core/helper');
const { checkElement, checkElementLengthDifferentTo } = require('../core/util');
const {
LOOP_INTERVAL,
VIDEO_LOADING_WAIT_TIME,
ELEMENT_WAIT_LONGER_TIME,
} = require('../core/constants');
async function enableWebcam(test, videoPreviewTimeout) {
// Enabling webcam
await test.waitAndClick(e.joinVideo);
await test.waitForSelector(e.videoPreview, videoPreviewTimeout);
await test.waitAndClick(e.startSharingWebcam);
await test.waitForSelector(e.webcamConnecting);
await test.waitForSelector(e.webcamVideo, VIDEO_LOADING_WAIT_TIME);
await test.waitForSelector(e.leaveVideo, VIDEO_LOADING_WAIT_TIME);
return test.page.evaluate(checkElementLengthDifferentTo, e.webcamVideo, 0);
}
async function evaluateCheck(test) {
await test.waitForSelector(e.videoContainer);
return test.page.evaluate(checkElement, e.presentationFullscreenButton, 1);
@ -69,4 +57,3 @@ async function webcamContentCheck(test) {
exports.startAndCheckForWebcams = startAndCheckForWebcams;
exports.webcamContentCheck = webcamContentCheck;
exports.evaluateCheck = evaluateCheck;
exports.enableWebcam = enableWebcam;

View File

@ -19,7 +19,6 @@ const webcamTest = () => {
const testName = 'shareWebcam';
await test.logger('begin of ', testName);
await test.init(true, true, testName);
await test.closeAudioModal();
await test.startRecording(testName);
response = await test.test();
await test.stopRecording();
@ -42,7 +41,6 @@ const webcamTest = () => {
const testName = 'checkWebcamContent';
await test.logger('begin of ', testName);
await test.init(true, true, testName);
await test.closeAudioModal();
await test.startRecording(testName);
response = await test.test();
await test.stopRecording();