From 1c40b0b8c896713ad53208232ece357f552c93fa Mon Sep 17 00:00:00 2001 From: Mohamed Amine Ben Salah Date: Mon, 21 Sep 2020 15:22:11 -0300 Subject: [PATCH] adds missing custom parameters specs to the custom parameters test suite --- .../tests/puppeteer/breakout.obj.js | 148 ++++++++---------- .../tests/puppeteer/customparameters.obj.js | 78 +++++++++ .../puppeteer/customparameters/constants.js | 4 + .../customparameters/customparameters.js | 109 ++++++++++--- .../puppeteer/customparameters/elements.js | 7 + .../tests/puppeteer/webcam/check.js | 6 + .../tests/puppeteer/webcam/util.js | 38 +++++ 7 files changed, 291 insertions(+), 99 deletions(-) diff --git a/bigbluebutton-html5/tests/puppeteer/breakout.obj.js b/bigbluebutton-html5/tests/puppeteer/breakout.obj.js index 33259d5202..334265894b 100644 --- a/bigbluebutton-html5/tests/puppeteer/breakout.obj.js +++ b/bigbluebutton-html5/tests/puppeteer/breakout.obj.js @@ -10,88 +10,76 @@ const breakoutTest = () => { jest.setTimeout(150000); }); - // // Create Breakout Room - // test('Create Breakout room', async () => { - // const test = new Create(); - // let response; - // let screenshot; - // try { - // const testName = 'createBreakoutrooms'; - // await test.init(undefined); - // await test.create(testName); - // response = await test.testCreatedBreakout(testName); - // const page2 = await test.page2.browser.pages(); - // await page2[2].bringToFront(); - // screenshot = await page2[2].screenshot(); - // } catch (e) { - // console.log(e); - // } finally { - // await test.close(); - // } - // expect(response).toBe(true); - // if (process.env.REGRESSION_TESTING === 'true') { - // expect(screenshot).toMatchImageSnapshot({ - // failureThreshold: 8, - // failureThresholdType: 'percent', - // }); - // } - // }); + // Create Breakout Room + test('Create Breakout room', async () => { + const test = new Create(); + let response; + try { + const testName = 'createBreakoutrooms'; + await test.init(undefined); + await test.create(testName); + response = await test.testCreatedBreakout(testName); + } catch (e) { + console.log(e); + } finally { + await test.close(); + } + expect(response).toBe(true); + }); - // // Join Breakout Room - // test('Join Breakout room', async () => { - // const test = new Join(); - // let response; - // let screenshot; - // try { - // const testName = 'joinBreakoutroomsWithoutFeatures'; - // await test.init(undefined); - // await test.create(testName); - // await test.join(testName); - // response = await test.testJoined(testName); - // const page2 = await test.page2.browser.pages(); - // await page2[2].bringToFront(); - // screenshot = await page2[2].screenshot(); - // } catch (e) { - // console.log(e); - // } finally { - // await test.close(); - // } - // expect(response).toBe(true); - // if (process.env.REGRESSION_TESTING === 'true') { - // expect(screenshot).toMatchImageSnapshot({ - // failureThreshold: 4, - // failureThresholdType: 'percent', - // }); - // } - // }); + // Join Breakout Room + test('Join Breakout room', async () => { + const test = new Join(); + let response; + try { + const testName = 'joinBreakoutroomsWithoutFeatures'; + await test.init(undefined); + 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); + }); - // // Join Breakout Room with Video - // test('Join Breakout room with Video', async () => { - // const test = new Join(); - // let response; - // let screenshot; - // try { - // const testName = 'joinBreakoutroomsWithVideo'; - // await test.init(undefined); - // await test.create(testName); - // await test.join(testName); - // response = await test.testJoined(testName); - // const page2 = await test.page2.browser.pages(); - // await page2[2].bringToFront(); - // screenshot = await page2[2].screenshot(); - // } catch (e) { - // console.log(e); - // } finally { - // await test.close(); - // } - // expect(response).toBe(true); - // if (process.env.REGRESSION_TESTING === 'true') { - // expect(screenshot).toMatchImageSnapshot({ - // failureThreshold: 0.6, - // failureThresholdType: 'percent', - // }); - // } - // }); + // Join Breakout Room with Video + test('Join Breakout room with Video', async () => { + const test = new Join(); + let response; + try { + const testName = 'joinBreakoutroomsWithVideo'; + await test.init(undefined); + 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); + }); + + // Join Breakout Room and start Screen Share + test('Join Breakout room and share screen', async () => { + const test = new Join(); + let response; + try { + const testName = 'joinBreakoutroomsAndShareScreen'; + await test.init(undefined); + 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); + }); // Join Breakout Room and start Screen Share test('Join Breakout room and share screen', async () => { diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters.obj.js b/bigbluebutton-html5/tests/puppeteer/customparameters.obj.js index 70467626e2..b1ccd566d4 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters.obj.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters.obj.js @@ -608,5 +608,83 @@ const customParametersTest = () => { }); } }); + + // This test spec sets the userdata-bbb_record_video parameter to false + // and makes sure that the meeting recording button should not be available + test('Record Meeting', async () => { + const test = new CustomParameters(); + const page = new Page(); + let response; + try { + const testName = 'recordMeeting'; + page.logger('before ', testName); + response = await test.recordMeeting(testName, Page.getArgs(), undefined, `${c.recordMeeting}`); + page.logger('after ', testName); + } catch (e) { + page.logger(e); + } finally { + await test.closePage(test.page1); + } + expect(response).toBe(true); + }); + + // This test spec sets the userdata-bbb_skip_video_preview parameter to true + // and makes sure that the webcam video preview modal should not appear + test('Skip Video Preview', async () => { + const test = new CustomParameters(); + const page = new Page(); + let response; + try { + const testName = 'skipVideoPreview'; + page.logger('before ', testName); + response = await test.skipVideoPreview(testName, Page.getArgsWithVideo(), undefined, `${c.skipVideoPreview}`); + page.logger('after ', testName); + } catch (e) { + page.logger(e); + } finally { + await test.closePage(test.page1); + } + expect(response).toBe(true); + }); + + // This test spec sets the userdata-bbb_mirror_own_webcam parameter to true + // and makes sure that the webcam video preview and the container + // should both appear with mirrored Tag + test('Mirror Own Webcam', async () => { + const test = new CustomParameters(); + const page = new Page(); + let response; + try { + const testName = 'mirrorOwnWebcam'; + page.logger('before ', testName); + response = await test.mirrorOwnWebcam(testName, Page.getArgsWithVideo(), undefined, `${c.mirrorOwnWebcam}`); + page.logger('after ', testName); + } catch (e) { + page.logger(e); + } finally { + await test.closePage(test.page1); + } + expect(response).toBe(true); + }); + + // This test spec sets the userdata-bbb_show_participants_on_login parameter to false + // and makes sure that the user list won't appear on login + test('Show Participants on Login', async () => { + const test = new CustomParameters(); + const page = new Page(); + let response; + try { + const testName = 'showParticipantsOnLogin'; + page.logger('before ', testName); + response = await test.showParticipantsOnLogin(testName, Page.getArgsWithVideo(), undefined, `${c.showParticipantsOnLogin}`); + page.logger('after ', testName); + } catch (e) { + page.logger(e); + } finally { + await test.closePage(test.page1); + } + expect(response).toBe(true); + }); }; + module.exports = exports = customParametersTest; diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js b/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js index cf2b88c19a..dcb9221f5b 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js @@ -27,3 +27,7 @@ exports.forceRestorePresentationOnNewEvents = 'userdata-bbb_force_restore_presen exports.bannerText = 'bannerText=some text'; exports.color = 'FFFF00'; exports.bannerColor = `bannerColor=%23${this.color}`; +exports.recordMeeting = 'userdata-bbb_record_video=false'; +exports.skipVideoPreview = 'userdata-bbb_skip_video_preview=true'; +exports.mirrorOwnWebcam = 'userdata-bbb_mirror_own_webcam=true'; +exports.showParticipantsOnLogin = 'userdata-bbb_show_participants_on_login=false'; diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js b/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js index a9cee89048..2d7075e16a 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js @@ -323,14 +323,12 @@ class CustomParameters { await this.page1.closeAudioModal(); await this.page1.waitForSelector(cpe.whiteboard); await this.page1.screenshot(`${testName}`, `02-${testName}`); - const isHidden = await this.page1.page.$eval('[class="presentationTitle--1LT79g"]', (elem) => { - return elem.offsetHeight == 0 - }); + const isHidden = await this.page1.page.$eval('[class="presentationTitle--1LT79g"]', elem => elem.offsetHeight == 0); if (isHidden === false) { await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); this.page1.logger(testName, ' failed'); return false; - } else if (isHidden === true) { + } if (isHidden === true) { await this.page1.screenshot(`${testName}`, `03-success-${testName}`); const resp = isHidden; this.page1.logger(testName, ' passed'); @@ -345,15 +343,13 @@ class CustomParameters { this.page1.logger('after init ', testName); await this.page1.closeAudioModal(); await this.page1.waitForSelector(cpe.whiteboard); - await this.page1.screenshot(`${testName}`, `02-${testName}`); - const isHidden = await this.page1.page.$eval('[class="presentationTitle--1LT79g"]', (elem) => { - return elem.offsetHeight == 0 - }); + await this.page1.screenshot(`${testName}`, `02-${testName}`); + const isHidden = await this.page1.page.$eval('[class="presentationTitle--1LT79g"]', elem => elem.offsetHeight == 0); if (isHidden === false) { await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); this.page1.logger(testName, ' failed'); return false; - } else if (isHidden === true) { + } if (isHidden === true) { await this.page1.screenshot(`${testName}`, `03-success-${testName}`); const resp = isHidden; this.page1.logger(testName, ' passed'); @@ -369,15 +365,13 @@ class CustomParameters { await this.page1.closeAudioModal(); await this.page1.waitForSelector(cpe.container); await this.page1.screenshot(`${testName}`, `02-${testName}`); - const isNotHidden = await this.page1.page.$eval(cpe.restorePresentation, (elem) => { - return elem.offsetHeight !== 0 - }); + const isNotHidden = await this.page1.page.$eval(cpe.restorePresentation, elem => elem.offsetHeight !== 0); console.log(isNotHidden); if (isNotHidden === false) { await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); this.page1.logger(testName, ' failed'); return false; - } else if (isNotHidden === true) { + } if (isNotHidden === true) { await this.page1.screenshot(`${testName}`, `03-success-${testName}`); const resp = isNotHidden; this.page1.logger(testName, ' passed'); @@ -431,16 +425,14 @@ class CustomParameters { await this.page1.closeAudioModal(); await this.page1.waitForSelector(cpe.notificationBar); await this.page1.screenshot(`${testName}`, `02-${testName}`); - const notificationBarColor = await this.page1.page.$eval('div[class^="notificationsBar--"]', (elem) => { - return getComputedStyle(elem).backgroundColor - }); - console.log('colorToRGB => ', colorToRGB) - console.log('notificationBarColor => ', notificationBarColor) + const notificationBarColor = await this.page1.page.$eval('div[class^="notificationsBar--"]', elem => getComputedStyle(elem).backgroundColor); + console.log('colorToRGB => ', colorToRGB); + console.log('notificationBarColor => ', notificationBarColor); if (notificationBarColor !== colorToRGB) { await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); this.page1.logger(testName, ' failed'); return false; - } else if (notificationBarColor === colorToRGB) { + } if (notificationBarColor === colorToRGB) { await this.page1.screenshot(`${testName}`, `03-success-${testName}`); this.page1.logger(testName, ' passed'); return true; @@ -528,6 +520,85 @@ class CustomParameters { return true; } + async recordMeeting(testName, args, meetingId, customParameter) { + this.page1.logger('before init ', testName); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.closeAudioModal(); + await this.page1.screenshot(`${testName}`, `01-${testName}`); + this.page1.logger('after init ', testName); + if (await this.page1.page.evaluate(util.getTestElement, cpe.recordingIndicator) === false) { + await this.page1.screenshot(`${testName}`, `02-fail-${testName}`); + this.page1.logger(testName, ' failed'); + return false; + } + const resp = await this.page1.page.evaluate(util.getTestElement, cpe.recordingIndicator) === true; + await this.page1.screenshot(`${testName}`, `02-success-${testName}`); + this.page1.logger(testName, ' passed'); + return resp === true; + } + + async skipVideoPreview(testName, args, meetingId, customParameter) { + this.page1.logger('before init ', testName); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); + this.page1.logger('after init ', testName); + await this.page1.closeAudioModal(); + await this.page1.screenshot(`${testName}`, `02-${testName}`); + await this.page1.waitForSelector(cpe.shareWebcamButton); + await this.page1.click(cpe.shareWebcamButton, true); + if (await this.page1.page.evaluate(util.getTestElement, cpe.webcamSettingsModal) === false) { + await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); + this.page1.logger(testName, ' failed'); + return false; + } + const resp = await this.page1.page.evaluate(util.getTestElement, cpe.webcamSettingsModal) === true; + await this.page1.screenshot(`${testName}`, `03-success-${testName}`); + this.page1.logger(testName, ' passed'); + return resp === true; + } + + async mirrorOwnWebcam(testName, args, meetingId, customParameter) { + this.page1.logger('before init ', testName); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); + this.page1.logger('after init ', testName); + await this.page1.closeAudioModal(); + await this.page1.screenshot(`${testName}`, `02-${testName}`); + await this.page1.waitForSelector(cpe.shareWebcamButton); + await this.page1.click(cpe.shareWebcamButton, true); + await this.page1.waitForSelector(cpe.webcamMirroredVideoPreview); + await this.page1.waitForSelector(cpe.startSharingWebcamButton); + await this.page1.click(cpe.startSharingWebcamButton, true); + if (await this.page1.page.evaluate(util.getTestElement, cpe.webcamMirroredVideoContainer) === true) { + await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); + this.page1.logger(testName, ' failed'); + return false; + } + const resp = await this.page1.page.evaluate(util.getTestElement, cpe.webcamMirroredVideoContainer) === false; + await this.page1.screenshot(`${testName}`, `03-success-${testName}`); + this.page1.logger(testName, ' passed'); + return resp === true; + } + + async showParticipantsOnLogin(testName, args, meetingId, customParameter) { + this.page1.logger('before init ', testName); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); + this.page1.logger('after init ', testName); + await this.page1.closeAudioModal(); + await this.page1.screenshot(`${testName}`, `02-${testName}`); + await this.page1.waitForSelector(cpe.whiteboard); + if (await this.page1.page.evaluate(util.getTestElement, cpe.userslistContainer) === false) { + await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); + this.page1.logger(testName, ' failed'); + return false; + } + const resp = await this.page1.page.evaluate(util.getTestElement, cpe.userslistContainer) === true; + await this.page1.screenshot(`${testName}`, `03-success-${testName}`); + this.page1.logger(testName, ' passed'); + return resp === true; + } + async closePage(page) { page.close(); } diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters/elements.js b/bigbluebutton-html5/tests/puppeteer/customparameters/elements.js index 4af8c808fb..e4ddd59ceb 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters/elements.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters/elements.js @@ -23,3 +23,10 @@ exports.defaultContent = 'div[class^="defaultContent--"]'; exports.notificationBar = 'div[class^="notificationsBar--"]'; exports.chat = 'section[aria-label="Chat"]'; exports.hidePresentation = 'button[aria-label="Hide presentation"]'; +exports.recordingIndicator = 'div[class^="recordingIndicator--"]'; +exports.startSharingWebcamButton = 'button[data-test="startSharingWebcam"]'; +exports.webcamVideoPreview = 'video[data-test="videoPreview"]'; +exports.webcamMirroredVideoPreview = 'video[data-test="mirroredVideoPreview"]'; +exports.webcamVideoContainer = 'video[data-test="videoContainer"]'; +exports.webcamMirroredVideoContainer = 'video[data-test="mirroredVideoContainer"]'; +exports.userslistContainer = 'div[aria-label="User list"]'; diff --git a/bigbluebutton-html5/tests/puppeteer/webcam/check.js b/bigbluebutton-html5/tests/puppeteer/webcam/check.js index cc6f986e58..803d03233a 100644 --- a/bigbluebutton-html5/tests/puppeteer/webcam/check.js +++ b/bigbluebutton-html5/tests/puppeteer/webcam/check.js @@ -6,6 +6,12 @@ class Check extends Share { super('webcam-check-content-test'); } + async compare() { + await util.enableWebcam(page1, page2); + const respUser = await util.compareWebcamsContents(this); + return respUser === true; + } + async test() { await util.enableWebcam(this); const respUser = await util.webcamContentCheck(this); diff --git a/bigbluebutton-html5/tests/puppeteer/webcam/util.js b/bigbluebutton-html5/tests/puppeteer/webcam/util.js index 22710e043b..375ea40362 100644 --- a/bigbluebutton-html5/tests/puppeteer/webcam/util.js +++ b/bigbluebutton-html5/tests/puppeteer/webcam/util.js @@ -62,6 +62,44 @@ async function webcamContentCheck(test) { return check === true; } +async function compareWebcamsContents(page1, page2) { + await page1.waitForSelector(we.videoContainer); + await page1.elementRemoved(we.webcamConnecting); + await page2.waitForSelector(we.videoContainer); + await page2.elementRemoved(we.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; + + for (let v = 0; v < videos.length; v++) { + const video = videos[v]; + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); + const pixel = context.getImageData(50, 50, 1, 1).data; + const pixelString = new Array(pixel).join(' ').toString(); + + if (lastVideoColor[v]) { + if (lastVideoColor[v] == pixelString) { + return false; + } + } + lastVideoColor[v] = pixelString; + return true; + } + }; + + check = await test.page.evaluate(checkCameras, i); + await test.page.waitFor(parseInt(process.env.LOOP_INTERVAL)); + } + return check === true; +} + async function clickTestElement(element) { document.querySelectorAll(element)[0].click(); }