From 4d468e65c244d9e93a935aa274f41bdabacb6633 Mon Sep 17 00:00:00 2001 From: Mohamed Amine Ben Salah Date: Thu, 21 May 2020 13:45:52 -0300 Subject: [PATCH] enableScreenSharing() test spec --- .../tests/puppeteer/.env-template | 19 ++- .../tests/puppeteer/.gitignore | 3 +- .../tests/puppeteer/core/page.js | 54 +++---- .../tests/puppeteer/customparameters.test.js | 99 +++++++++--- .../puppeteer/customparameters/constants.js | 4 + .../customparameters/customparameters.js | 143 +++++++++++++++--- .../puppeteer/customparameters/elements.js | 3 + .../tests/puppeteer/customparameters/util.js | 12 +- 8 files changed, 257 insertions(+), 80 deletions(-) diff --git a/bigbluebutton-html5/tests/puppeteer/.env-template b/bigbluebutton-html5/tests/puppeteer/.env-template index e98532835e..bdb481f5b5 100644 --- a/bigbluebutton-html5/tests/puppeteer/.env-template +++ b/bigbluebutton-html5/tests/puppeteer/.env-template @@ -3,22 +3,25 @@ BBB_SERVER_URL="" BBB_SHARED_SECRET="" # browserless credentials -BROWSERLESS_ENABLED=false # true/false -BROWSERLESS_URL= # ip:port -BROWSERLESS_TOKEN= # token +BROWSERLESS_ENABLED=false # true/false +BROWSERLESS_URL= # ip:port +BROWSERLESS_TOKEN= # token # collecting metrics -BBB_COLLECT_METRICS=true # (true/false): true to collect metrics -METRICS_FOLDER=/tmp/bbb-metrics # the metrics output folder +BBB_COLLECT_METRICS=true # (true/false): true to collect metrics +TEST_FOLDER=data # the metrics output folder +GENERATE_EVIDENCES=true # (true/false): true to generate evidences +DEBUG=true # (true/false): true to enable console debugging # webcams test -LOOP_INTERVAL=1000 # time to loop in the webcams test in milliseconds +LOOP_INTERVAL=1000 # time to loop in the webcams test in milliseconds CAMERA_SHARE_FAILED_WAIT_TIME=15000 # this is set by default in the BBB server # audio test -IS_AUDIO_TEST=false # (true/false): true if the test will require enabling audio +IS_AUDIO_TEST=false # (true/false): true if the test will require enabling audio USER_LIST_VLIST_BOTS_TALKING=1 USER_LIST_VLIST_BOTS_LISTENING=100 -TEST_DURATION_TIME=3600000 # Basic test duration time \ No newline at end of file +TEST_DURATION_TIME=3600000 # Basic test duration time +GENERATE_EVIDENCES=true # (true/false): true means it will generate sceenshots during the test \ No newline at end of file diff --git a/bigbluebutton-html5/tests/puppeteer/.gitignore b/bigbluebutton-html5/tests/puppeteer/.gitignore index a7b53d8b62..e4eda523df 100644 --- a/bigbluebutton-html5/tests/puppeteer/.gitignore +++ b/bigbluebutton-html5/tests/puppeteer/.gitignore @@ -5,4 +5,5 @@ downloads/* !downloads/downloads.txt .directory .env -media/* \ No newline at end of file +media/* +data/ diff --git a/bigbluebutton-html5/tests/puppeteer/core/page.js b/bigbluebutton-html5/tests/puppeteer/core/page.js index 4b1fbcb549..c24c0df57f 100644 --- a/bigbluebutton-html5/tests/puppeteer/core/page.js +++ b/bigbluebutton-html5/tests/puppeteer/core/page.js @@ -22,7 +22,7 @@ class Page { } // Join BigBlueButton meeting - async init(args, meetingId, newParams, customParameter) { + async init(args, meetingId, newParams, customParameter, testFolderName) { try { this.effectiveParams = newParams || params; const isModerator = this.effectiveParams.moderatorPW; @@ -54,7 +54,7 @@ class Page { const checkForGetMetrics = async () => { if (process.env.BBB_COLLECT_METRICS === 'true') { await this.page.waitForSelector('[data-test^="userListItem"]'); - await this.getMetrics(); + await this.getMetrics(testFolderName); } }; // if (process.env.IS_AUDIO_TEST !== 'true') { @@ -234,25 +234,24 @@ class Page { await this.page.type(element, text); } - async screenshot(testName, relief = false) { + async screenshot(testFolderName, testFileName, relief = false) { if (process.env.GENERATE_EVIDENCES === 'true') { - const today = moment().format('D MMM, YYYY'); - const dir = `../${process.env.TEST_FOLDER}`; - if (!fs.existsSync(path.join(__dirname, `${dir}`))) { - fs.mkdirSync(path.join(__dirname, `${dir}`)); + const today = moment().format('DD-MM-YYYY'); + const dir = path.join(__dirname, `../${process.env.TEST_FOLDER}`); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); } - const testResultsFolder = `${dir}/test-${today}`; - if (!fs.existsSync(path.join(__dirname, `${testResultsFolder}`))) { - fs.mkdirSync(path.join(__dirname, `${testResultsFolder}`)); + const testResultsFolder = `${dir}/test-${today}-${testFolderName}`; + if (!fs.existsSync(testResultsFolder)) { + fs.mkdirSync(testResultsFolder); } const screenshots = `${testResultsFolder}/screenshots`; - if (!fs.existsSync(path.join(__dirname, `${screenshots}`))) { - fs.mkdirSync(path.join(__dirname, `${screenshots}`)); + if (!fs.existsSync(screenshots)) { + fs.mkdirSync(screenshots); } if (relief) await helper.sleep(1000); - const filename = `${testName}.png`; - const dirTest = `${this.parentDir}/${screenshots}/${filename}`; - await this.page.screenshot({ dirTest }); + const filename = `${testFileName}.png`; + await this.page.screenshot({ path: `${screenshots}/${filename}` }); this.screenshotIndex++; } } @@ -268,20 +267,20 @@ class Page { await this.page.waitForSelector(element, { timeout: 0 }); } - async getMetrics(testName) { + async getMetrics(testFolderName) { const pageMetricsObj = {}; - const dir = `../${process.env.TEST_FOLDER}`; - const today = moment().format('D MMM, YYYY'); - const testExecutionResults = testName ? `${dir}/${testName}-${today}` : `${dir}/test-${today}`; - const metricsFolder = `${dir}/${testExecutionResults}/metrics`; - if (!fs.existsSync(path.join(__dirname, `${dir}`))) { - fs.mkdirSync(path.join(__dirname, `${dir}`)); + const today = moment().format('DD-MM-YYYY'); + const dir = path.join(__dirname, `../${process.env.TEST_FOLDER}`); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); } - if (!fs.existsSync(path.join(__dirname, `${testExecutionResults}`))) { - fs.mkdirSync(path.join(__dirname, `${testExecutionResults}`)); + const testExecutionResultsName = `${dir}/test-${today}-${testFolderName}`; + if (!fs.existsSync(testExecutionResultsName)) { + fs.mkdirSync(testExecutionResultsName); } - if (!fs.existsSync(path.join(__dirname, `${metricsFolder}`))) { - fs.mkdirSync(path.join(__dirname, `${metricsFolder}`)); + const metricsFolder = `${testExecutionResultsName}/metrics`; + if (!fs.existsSync(metricsFolder)) { + fs.mkdirSync(metricsFolder); } await this.waitForSelector('[data-test^="userListItem"]'); const totalNumberOfUsersMongo = await this.page.evaluate(() => { @@ -295,9 +294,10 @@ class Page { pageMetricsObj.totalNumberOfUsersMongoObj = totalNumberOfUsersMongo; pageMetricsObj.totalNumberOfUsersDomObj = totalNumberOfUsersDom; pageMetricsObj[`metricObj-${this.meetingId}`] = metric; + const metricsFile = path.join(__dirname, `../${process.env.TEST_FOLDER}/test-${today}-${testFolderName}/metrics/metrics-${this.effectiveParams.fullName}-${this.meetingId}.json`); const createFile = () => { try { - fs.appendFileSync(path.join(__dirname, `${metricsFolder}/metrics-${this.effectiveParams.fullName}-${this.meetingId}.json`), `${JSON.stringify(pageMetricsObj)},\n`); + fs.appendFileSync(metricsFile, `${JSON.stringify(pageMetricsObj)},\n`); } catch (error) { console.log(error); } diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters.test.js b/bigbluebutton-html5/tests/puppeteer/customparameters.test.js index 93b21b74e0..8162a9aeca 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters.test.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters.test.js @@ -7,14 +7,15 @@ describe('Custom parameters', () => { jest.setTimeout(30000); }); - // This test spec sets the userdata-autoJoin parameter to false - // and checks if the users don't get audio modal on login + // This test spec sets the userdata-autoJoin parameter to false + // and checks that the users don't get audio modal on login test('Auto join', async () => { const test = new CustomParameters(); let response; try { console.log('before'); - response = await test.autoJoin(Page.getArgs(), undefined, c.autoJoin); + const testName = 'autoJoin'; + response = await test.autoJoin(testName, Page.getArgs(), undefined, c.autoJoin); console.log('after'); } catch (e) { console.log(e); @@ -24,14 +25,15 @@ describe('Custom parameters', () => { expect(response).toBe(true); }); - // This test spec sets the userdata-listenOnlyMode parameter to false - // and checks if the users can't see or use listen Only mode + // This test spec sets the userdata-listenOnlyMode parameter to false + // and checks that the users can't see or use listen Only mode test('Listen Only Mode', async () => { const test = new CustomParameters(); let response; try { console.log('before'); - response = await test.listenOnlyMode(Page.getArgs(), undefined, c.listenOnlyMode); + const testName = 'listenOnlyMode'; + response = await test.listenOnlyMode(testName, Page.getArgs(), undefined, c.listenOnlyMode); console.log('after'); } catch (e) { console.log(e); @@ -41,31 +43,33 @@ describe('Custom parameters', () => { expect(response).toBe(true); }); - // This test spec sets the userdata-forceListenOnly parameter to false - // and checks if the Viewers can only use listen only mode + // This test spec sets the userdata-forceListenOnly parameter to false + // and checks that the Viewers can only use listen only mode test('Force Listen Only', async () => { const test = new CustomParameters(); let response; try { console.log('before'); - response = await test.forceListenOnly(Page.getArgs(), undefined, c.forceListenOnly); + const testName = 'forceListenOnly'; + response = await test.forceListenOnly(testName, Page.getArgs(), undefined, c.forceListenOnly); console.log('after'); } catch (e) { console.log(e); } finally { - await test.close(test.page1, test.page2); + await test.closePage(test.page2); } expect(response).toBe(true); }); - // This test spec sets the userdata-skipCheck parameter to true - // and checks if the users automatically skip audio check when clicking on Microphone + // This test spec sets the userdata-skipCheck parameter to true + // and checks that the users automatically skip audio check when clicking on Microphone test('Skip audio check', async () => { const test = new CustomParameters(); let response; try { console.log('before'); - response = await test.skipCheck(Page.getArgs(), undefined, c.skipCheck); + const testName = 'skipCheck'; + response = await test.skipCheck(testName, Page.getArgs(), undefined, c.skipCheck); console.log('after'); } catch (e) { console.log(e); @@ -75,14 +79,15 @@ describe('Custom parameters', () => { expect(response).toBe(true); }); - // This test spec sets the userdata-clientTitle parameter to some value - // and checks if the meeting window contains that value + // This test spec sets the userdata-clientTitle parameter to some value + // and checks that the meeting window name starts with that value test('Client title', async () => { const test = new CustomParameters(); let response; try { console.log('before'); - response = await test.clientTitle(Page.getArgs(), undefined, c.clientTitle); + const testName = 'clientTitle'; + response = await test.clientTitle(testName, Page.getArgs(), undefined, c.clientTitle); console.log('after'); } catch (e) { console.log(e); @@ -92,14 +97,70 @@ describe('Custom parameters', () => { expect(response).toBe(true); }); - // This test spec sets the userdata-askForFeedbackOnLogout parameter to true - // and checks if the users automatically get asked for feedback on logout page + // This test spec sets the userdata-askForFeedbackOnLogout parameter to true + // and checks that the users automatically get asked for feedback on logout page test('Ask For Feed back On Logout', async () => { const test = new CustomParameters(); let response; try { console.log('before'); - response = await test.askForFeedbackOnLogout(Page.getArgs(), undefined, c.askForFeedbackOnLogout); + const testName = 'askForFeedbackOnLogout'; + response = await test.askForFeedbackOnLogout(testName, Page.getArgs(), undefined, c.askForFeedbackOnLogout); + console.log('after'); + } catch (e) { + console.log(e); + } finally { + await test.closePage(test.page1); + } + expect(response).toBe(true); + }); + + // This test spec sets the userdata-displayBrandingArea parameter to true and add a logo link + // and checks that the users see the logo displaying in the meeting + test('Display Branding Area', async () => { + const test = new CustomParameters(); + let response; + try { + console.log('before'); + const testName = 'displayBrandingArea'; + const parameterWithLogo = `${c.displayBrandingArea}&${c.logo}`; + response = await test.displayBrandingArea(testName, Page.getArgs(), undefined, parameterWithLogo); + console.log('after'); + } catch (e) { + console.log(e); + } finally { + await test.closePage(test.page1); + } + expect(response).toBe(true); + }); + + // This test spec sets the userdata-shortcuts parameter to one or a list of shortcuts parameters + // and checks that the users can use those shortcuts + test('Shortcuts', async () => { + const test = new CustomParameters(); + let response; + try { + console.log('before'); + const testName = 'shortcuts'; + response = await test.shortcuts(testName, Page.getArgs(), undefined, c.shortcuts); + console.log('after'); + } catch (e) { + console.log(e); + } finally { + await test.closePage(test.page1); + } + expect(response).toBe(true); + }); + + // This test spec sets the userdata-enableScreensharing parameter to false + // and checks that the Moderator can not see the Screen sharing button + test('Enable Screensharing', async () => { + const test = new CustomParameters(); + let response; + try { + console.log('before'); + const testName = 'enableScreensharing'; + response = await test.enableScreensharing(testName, Page.getArgs(), undefined, c.enableScreensharing); console.log('after'); } catch (e) { console.log(e); diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js b/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js index 647c2691ad..bafe5fdd2e 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters/constants.js @@ -6,3 +6,7 @@ const docTitle = 'puppeteer'; exports.docTitle = docTitle; exports.clientTitle = `userdata-clientTitle=${docTitle}`; exports.askForFeedbackOnLogout = 'userdata-askForFeedbackOnLogout=true'; +exports.displayBrandingArea = 'userdata-displayBrandingArea=true'; +exports.logo = 'logo=https://bigbluebutton.org/wp-content/themes/bigbluebutton/library/images/bigbluebutton-logo.png'; +exports.shortcuts = 'userdata-shortcuts=["openOptions", "toggleUserList", "toggleMute", "joinAudio", "leaveAudio", "togglePublicChat", "hidePrivateChat", "closePrivateChat", "openActions", "openStatus"]'; +exports.enableScreensharing = 'userdata-enableScreensharing=false'; diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js b/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js index 519bac3f22..fd25898374 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters/customparameters.js @@ -1,5 +1,7 @@ +const path = require('path'); const Page = require('../core/page'); const params = require('../params'); +const helper = require('../core/helper'); const cpe = require('./elements'); const util = require('./util'); const c = require('./constants'); @@ -8,99 +10,194 @@ class CustomParameters { constructor() { this.page1 = new Page(); this.page2 = new Page(); + this.name = name; + this.screenshotIndex = 0; + this.parentDir = this.getParentDir(__dirname); } - async autoJoin(args, meetingId, customParameter) { - console.log('before init'); - await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter); - console.log('after init'); - await this.page1.waitForSelector('div[class^="spinner--"]', { timeout: 5000 }); - console.log('after spinner'); - await this.page1.waitForSelector(cpe.whiteboard, { timeout: 5000 }); - const resp = await util.autoJoinTest(this.page1); - console.log(resp, 'response'); - return resp; + getParentDir(dir) { + const tmp = dir.split('/'); + tmp.pop(); + return tmp.join('/'); } - async listenOnlyMode(args, meetingId, customParameter) { + async autoJoin(testName, args, meetingId, customParameter) { console.log('before init'); - await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter); - await this.page2.init(args, this.page1.meetingId, { ...params, fullName: 'Attendee', moderatorPW: '' }, customParameter); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); console.log('after init'); - if (await this.page1.page.$('[data-test="audioModalHeader"]')) { + await this.page1.waitForSelector('div[data-test="chatMessages"]', { timeout: 5000 }); + if (await this.page1.page.evaluate(util.getTestElement, cpe.audioModal) === false) { + await this.page1.screenshot(`${testName}`, `02-fail-${testName}`); + return false; + } + const resp = await this.page1.page.evaluate(util.getTestElement, cpe.audioModal) === true; + await this.page1.screenshot(`${testName}`, `02-success-${testName}`); + return resp === true; + } + + async listenOnlyMode(testName, args, meetingId, customParameter) { + console.log('before init'); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-page1-${testName}`); + await this.page2.init(args, this.page1.meetingId, { ...params, fullName: 'Attendee', moderatorPW: '' }, customParameter, testName); + await this.page2.screenshot(`${testName}`, `01-page2-${testName}`); + console.log('after init'); + if (await this.page2.page.$('[data-test="audioModalHeader"]')) { + await this.page2.screenshot(`${testName}`, `02-fail-${testName}`); return false; } await this.page1.page.waitFor(cpe.echoTestYesButton); + await this.page1.screenshot(`${testName}`, `02-success-page1-${testName}`); await this.page2.page.waitFor(cpe.echoTestYesButton); + await this.page2.screenshot(`${testName}`, `02-success-page2-${testName}`); const resp1 = await util.listenOnlyMode(this.page1); + await this.page1.screenshot(`${testName}`, `03-success-page1-${testName}`); const resp2 = await util.listenOnlyMode(this.page2); + await this.page2.screenshot(`${testName}`, `03-success-page2-${testName}`); console.log({ resp1, resp2 }); return resp1 === true && resp2 === true; } - async forceListenOnly(args, meetingId, customParameter) { + async forceListenOnly(testName, args, meetingId, customParameter) { console.log('before init'); - await this.page2.init(args, meetingId, { ...params, fullName: 'Attendee', moderatorPW: '' }, customParameter); + await this.page2.init(args, meetingId, { ...params, fullName: 'Attendee', moderatorPW: '' }, customParameter, testName); + await this.page2.screenshot(`${testName}`, `01-${testName}`); console.log('after init'); if (await this.page2.page.$('[data-test="audioModalHeader"]')) { + await this.page2.screenshot(`${testName}`, `02-fail-${testName}`); return false; } - await this.page2.page.waitFor(cpe.audioNotification); + await this.page2.waitForSelector(cpe.audioNotification); + await this.page2.screenshot(`${testName}`, `02-success-${testName}`); const resp = await util.forceListenOnly(this.page2); + await this.page2.screenshot(`${testName}`, `03-success-${testName}`); console.log(resp); return resp === true; } - async skipCheck(args, meetingId, customParameter) { + async skipCheck(testName, args, meetingId, customParameter) { console.log('before init'); - await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); console.log('after init'); console.log('connecting with microphone'); await this.page1.joinMicrophoneWithoutEchoTest(); + await this.page1.screenshot(`${testName}`, `02-${testName}`); await this.page1.elementRemoved('div[class^="connecting--"]'); + await this.page1.screenshot(`${testName}`, `03-${testName}`); console.log('before if condition'); if (await this.page1.page.evaluate(util.countTestElements, cpe.echoTestYesButton) === true) { + await this.page1.screenshot(`${testName}`, `04-fail-${testName}`); console.log('fail'); return false; } console.log('before skipCheck'); const resp = await this.page1.page.evaluate(util.countTestElements, cpe.echoTestYesButton) === false; + await this.page1.screenshot(`${testName}`, `04-success-${testName}`); console.log('after skipCheck'); console.log(resp); return resp === true; } - async clientTitle(args, meetingId, customParameter) { + async clientTitle(testName, args, meetingId, customParameter) { + testName = 'clientTitle'; console.log('before init'); - await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); console.log('after init'); await this.page1.waitForSelector('button[aria-label="Microphone"]'); + await this.page1.screenshot(`${testName}`, `02-${testName}`); if (await !(await this.page1.page.title()).includes(c.docTitle)) { + await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); console.log('fail'); return false; } const resp = await (await this.page1.page.title()).includes(c.docTitle); + await this.page1.screenshot(`${testName}`, `03-success-${testName}`); console.log(resp); return resp === true; } - async askForFeedbackOnLogout(args, meetingId, customParameter) { + async askForFeedbackOnLogout(testName, args, meetingId, customParameter) { console.log('before init'); - await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); console.log('after init'); await this.page1.closeAudioModal(); + await this.page1.screenshot(`${testName}`, `02-${testName}`); await this.page1.logoutFromMeeting(); + await this.page1.screenshot(`${testName}`, `03-${testName}`); await this.page1.waitForSelector(cpe.meetingEndedModal); + await this.page1.screenshot(`${testName}`, `04-${testName}`); console.log('audio modal closed'); if (await this.page1.page.evaluate(util.countTestElements, cpe.rating) === false) { + await this.page1.screenshot(`${testName}`, `05-fail-${testName}`); console.log('fail'); return false; } const resp = await this.page1.page.evaluate(util.countTestElements, cpe.rating) === true; + await this.page1.screenshot(`${testName}`, `05-success-${testName}`); console.log(resp); return resp === true; } + async displayBrandingArea(testName, args, meetingId, customParameter) { + console.log('before init'); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); + console.log('after init'); + await this.page1.closeAudioModal(); + await this.page1.screenshot(`${testName}`, `02-${testName}`); + console.log('audio modal closed'); + await this.page1.waitForSelector('div[data-test="userListContent"]'); + if (await this.page1.page.evaluate(util.countTestElements, cpe.brandingAreaLogo) === false) { + console.log('fail'); + await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); + return false; + } + const resp = await this.page1.page.evaluate(util.countTestElements, cpe.brandingAreaLogo) === true; + console.log(resp); + await this.page1.screenshot(`${testName}`, `03-success-${testName}`); + return resp === true; + } + + async shortcuts(testName, args, meetingId, customParameter) { + console.log('before init'); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-${testName}`); + console.log('after init'); + await this.page1.closeAudioModal(); + await this.page1.screenshot(`${testName}`, `02-${testName}`); + console.log('audio modal closed'); + await this.page1.waitForSelector('button[aria-label="Options"]'); + await this.page1.page.keyboard.down('Alt'); + await this.page1.page.keyboard.press('O'); + if (await this.page1.page.evaluate(util.getTestElement, cpe.verticalListOptions) === false) { + console.log('fail'); + await this.page1.screenshot(`${testName}`, `03-fail-${testName}`); + return false; + } + const resp = await this.page1.page.evaluate(util.getTestElement, cpe.verticalListOptions) === true; + console.log(resp); + await this.page1.screenshot(`${testName}`, `03-success-${testName}`); + return resp === true; + } + + async enableScreensharing(testName, args, meetingId, customParameter) { + console.log('before init'); + await this.page1.init(args, meetingId, { ...params, fullName: 'Moderator' }, customParameter, testName); + await this.page1.screenshot(`${testName}`, `01-page1-${testName}`); + console.log('after init'); + if (await this.page1.page.evaluate(util.getTestElement, cpe.screenShareButton) === false) { + await this.page1.screenshot(`${testName}`, `02-fail-${testName}`); + return false; + } + const resp = await this.page1.page.evaluate(util.getTestElement, cpe.screenShareButton) === true; + await this.page1.screenshot(`${testName}`, `02-success-${testName}`); + 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 59d1437ebc..f23601eabc 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters/elements.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters/elements.js @@ -8,3 +8,6 @@ exports.options = 'button[aria-label="Options"]'; exports.logout = 'li[data-test="logout"]'; exports.meetingEndedModal = 'div[data-test="meetingEndedModal"]'; exports.rating = 'div[data-test="rating"]'; +exports.brandingAreaLogo = 'div[class^="branding--"]'; +exports.verticalListOptions = 'div[aria-expanded="true"] > div[class^="scrollable--"] > ul[class^="verticalList"]'; +exports.screenShareButton = 'button[aria-label="Share your screen"]'; diff --git a/bigbluebutton-html5/tests/puppeteer/customparameters/util.js b/bigbluebutton-html5/tests/puppeteer/customparameters/util.js index ce53ee646c..ec1f9c9cea 100644 --- a/bigbluebutton-html5/tests/puppeteer/customparameters/util.js +++ b/bigbluebutton-html5/tests/puppeteer/customparameters/util.js @@ -1,5 +1,8 @@ async function autoJoinTest(test) { - const resp = await test.page.evaluate(async () => await document.querySelectorAll('div[aria-label="Join audio modal"]').length === 0) !== false; + const resp = await test.page.evaluate(async () => { + const rep = await document.querySelectorAll('div[aria-label="Join audio modal"]').length === 0; + return rep !== false; + }); return resp; } @@ -21,7 +24,7 @@ async function forceListenOnly(test) { try { const resp = await test.page.evaluate(async () => { await document.querySelectorAll('div[class^="connecting--"]')[0]; - if (await test.page.$('button[aria-label="Echo is audible"]')) { + if (await document.querySelectorAll('button[aria-label="Echo is audible"]').length > 0) { return false; } const audibleNotification = await document.querySelectorAll('div[class^="toastContainer--"]')[0].innerText === 'You have joined the audio conference'; @@ -53,6 +56,11 @@ async function countTestElements(element) { return document.querySelectorAll(element).length !== 0; } +async function getTestElement(element) { + return document.querySelectorAll(element).length === 0; +} + +exports.getTestElement = getTestElement; exports.countTestElements = countTestElements; exports.autoJoinTest = autoJoinTest; exports.listenOnlyMode = listenOnlyMode;