From 4f2764ce65359cdf1081f8e6e9deff7b0d34e873 Mon Sep 17 00:00:00 2001 From: Anton Barboza Date: Mon, 4 Oct 2021 17:42:58 -0300 Subject: [PATCH] fix webcam tests and provides shareWebcam function in page.js --- .../puppeteer/breakout/create.js | 4 +--- bigbluebutton-tests/puppeteer/core/page.js | 13 ++++++++++++- .../customparameters/customparameters.js | 19 +++++-------------- .../puppeteer/user/multiusers.js | 5 ++--- bigbluebutton-tests/puppeteer/user/status.js | 4 ++-- bigbluebutton-tests/puppeteer/webcam/check.js | 2 +- bigbluebutton-tests/puppeteer/webcam/share.js | 7 ++++--- bigbluebutton-tests/puppeteer/webcam/util.js | 13 ------------- .../puppeteer/webcam/webcam.obj.js | 2 -- 9 files changed, 27 insertions(+), 42 deletions(-) diff --git a/bigbluebutton-tests/puppeteer/breakout/create.js b/bigbluebutton-tests/puppeteer/breakout/create.js index 61d9a79a1c..4011a041d7 100644 --- a/bigbluebutton-tests/puppeteer/breakout/create.js +++ b/bigbluebutton-tests/puppeteer/breakout/create.js @@ -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') { diff --git a/bigbluebutton-tests/puppeteer/core/page.js b/bigbluebutton-tests/puppeteer/core/page.js index 13576f4edf..f0c2b0ecc2 100644 --- a/bigbluebutton-tests/puppeteer/core/page.js +++ b/bigbluebutton-tests/puppeteer/core/page.js @@ -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); diff --git a/bigbluebutton-tests/puppeteer/customparameters/customparameters.js b/bigbluebutton-tests/puppeteer/customparameters/customparameters.js index 85b3b778f6..7000607b99 100644 --- a/bigbluebutton-tests/puppeteer/customparameters/customparameters.js +++ b/bigbluebutton-tests/puppeteer/customparameters/customparameters.js @@ -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; } diff --git a/bigbluebutton-tests/puppeteer/user/multiusers.js b/bigbluebutton-tests/puppeteer/user/multiusers.js index f34f44ae7a..229f52b7d3 100644 --- a/bigbluebutton-tests/puppeteer/user/multiusers.js +++ b/bigbluebutton-tests/puppeteer/user/multiusers.js @@ -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 { diff --git a/bigbluebutton-tests/puppeteer/user/status.js b/bigbluebutton-tests/puppeteer/user/status.js index 321a326e82..b639c3182f 100644 --- a/bigbluebutton-tests/puppeteer/user/status.js +++ b/bigbluebutton-tests/puppeteer/user/status.js @@ -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); diff --git a/bigbluebutton-tests/puppeteer/webcam/check.js b/bigbluebutton-tests/puppeteer/webcam/check.js index 7ebfb269a8..6543d7e7f8 100644 --- a/bigbluebutton-tests/puppeteer/webcam/check.js +++ b/bigbluebutton-tests/puppeteer/webcam/check.js @@ -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) { diff --git a/bigbluebutton-tests/puppeteer/webcam/share.js b/bigbluebutton-tests/puppeteer/webcam/share.js index db4b0adb06..672fdc02b3 100644 --- a/bigbluebutton-tests/puppeteer/webcam/share.js +++ b/bigbluebutton-tests/puppeteer/webcam/share.js @@ -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); } diff --git a/bigbluebutton-tests/puppeteer/webcam/util.js b/bigbluebutton-tests/puppeteer/webcam/util.js index 8aedf7f4a4..e4f1baa395 100644 --- a/bigbluebutton-tests/puppeteer/webcam/util.js +++ b/bigbluebutton-tests/puppeteer/webcam/util.js @@ -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; diff --git a/bigbluebutton-tests/puppeteer/webcam/webcam.obj.js b/bigbluebutton-tests/puppeteer/webcam/webcam.obj.js index 4563888660..2d069f54d7 100644 --- a/bigbluebutton-tests/puppeteer/webcam/webcam.obj.js +++ b/bigbluebutton-tests/puppeteer/webcam/webcam.obj.js @@ -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();