From 1ab6ae87415969b0432913d2d9ed0d0b2a2283f0 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 19 Oct 2021 17:12:00 -0300 Subject: [PATCH 01/31] realocates tests to the right file; fixes publishPoll button element; provides closePages util function --- .../components/poll/live-result/component.jsx | 2 +- .../puppeteer/chat/chat.obj.js | 25 +--- bigbluebutton-tests/puppeteer/chat/poll.js | 31 ---- .../puppeteer/core/elements.js | 3 +- bigbluebutton-tests/puppeteer/core/util.js | 7 + .../customparameters/customparameters.obj.js | 23 +++ .../puppeteer/customparameters/util.js | 2 +- .../puppeteer/notifications/notifications.js | 3 +- .../puppeteer/notifications/util.js | 10 -- bigbluebutton-tests/puppeteer/polling/poll.js | 132 ++++++++++++++++-- .../puppeteer/polling/polling.obj.js | 95 +++++-------- bigbluebutton-tests/puppeteer/polling/util.js | 12 ++ .../puppeteer/user/multiusers.js | 99 ++----------- 13 files changed, 214 insertions(+), 230 deletions(-) delete mode 100644 bigbluebutton-tests/puppeteer/chat/poll.js create mode 100644 bigbluebutton-tests/puppeteer/polling/util.js diff --git a/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx b/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx index 01d47bf00f..9b9496e791 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx @@ -206,7 +206,7 @@ class LiveResult extends PureComponent { stopPoll(); }} label={intl.formatMessage(intlMessages.publishLabel)} - data-test="publishLabel" + data-test="publishPollingLabel" color="primary" className={styles.btn} /> diff --git a/bigbluebutton-tests/puppeteer/chat/chat.obj.js b/bigbluebutton-tests/puppeteer/chat/chat.obj.js index edda929922..d69b22819f 100644 --- a/bigbluebutton-tests/puppeteer/chat/chat.obj.js +++ b/bigbluebutton-tests/puppeteer/chat/chat.obj.js @@ -3,7 +3,6 @@ const Send = require('./send'); const Clear = require('./clear'); const Copy = require('./copy'); const Save = require('./save'); -const Poll = require('./poll'); const MultiUsers = require('../user/multiusers'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); const { MAX_CHAT_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported) @@ -152,28 +151,6 @@ const chatTest = () => { expect(response).toBe(true); Page.checkRegression(0.9, screenshot); }); - - // Check for Poll Results chat message and return true when it appears - test('Poll Results chat message', async () => { - const test = new Poll(); - let response; - let screenshot; - try { - const testName = 'pollResultsChatMessage'; - await test.page3.logger('begin of ', testName); - await test.initUser3(testName); - await test.page3.startRecording(testName); - response = await test.test(testName); - await test.page3.startRecording(); - screenshot = await test.page3.page.screenshot(); - await test.page3.logger('end of ', testName); - } catch (err) { - await test.page3.logger(err); - } finally { - await test.closePage(test.page3); - } - expect(response).toBe(true); - Page.checkRegression(0.9, screenshot); - }); }; + module.exports = exports = chatTest; \ No newline at end of file diff --git a/bigbluebutton-tests/puppeteer/chat/poll.js b/bigbluebutton-tests/puppeteer/chat/poll.js deleted file mode 100644 index 3bfb0bec9c..0000000000 --- a/bigbluebutton-tests/puppeteer/chat/poll.js +++ /dev/null @@ -1,31 +0,0 @@ -const Notifications = require('../notifications/notifications'); -const e = require('../core/elements'); -const { checkElementLengthEqualTo } = require('../core/util'); - -class Poll extends Notifications { - constructor() { - super(); - } - - async test(testName) { - try { - // 0 messages - const chat0 = await this.page3.page.evaluate(checkElementLengthEqualTo, e.chatPollMessageText, 0); - await this.page3.screenshot(`${testName}`, `01-before-chat-message-send-[${this.page3.meetingId}]`); - - await this.publishPollResults(testName); - - await this.page3.waitAndClick(e.chatButton); - await this.page3.waitForSelector(e.chatPollMessageText); - - // 1 message - const chat1 = await this.page3.page.evaluate(checkElementLengthEqualTo, e.chatPollMessageText, 1); - return chat0 === chat1; - } catch (err) { - await this.page3.logger(err); - return false; - } - } -} - -module.exports = exports = Poll; diff --git a/bigbluebutton-tests/puppeteer/core/elements.js b/bigbluebutton-tests/puppeteer/core/elements.js index fe30ec7d14..a74346719d 100644 --- a/bigbluebutton-tests/puppeteer/core/elements.js +++ b/bigbluebutton-tests/puppeteer/core/elements.js @@ -120,7 +120,6 @@ exports.fileUploadDropZone = '[data-test="fileUploadDropZone"]'; exports.polling = 'li[data-test="polling"]'; exports.pollYesNoAbstentionBtn = 'button[aria-label="Yes / No / Abstention"]'; exports.yesBtn = 'button[aria-label="Yes"]'; -exports.publishPollingResults = 'button[aria-label="Publish polling results"]'; exports.hidePollDesc = 'button[data-test="hidePollDesc"]'; exports.joinAudioToast = 'You have joined the audio conference'; exports.notificationsTab = 'span[id="notificationTab"]'; @@ -141,7 +140,7 @@ exports.pollSubmitAnswer = 'button[data-test="submitAnswer"]'; exports.startPoll = 'button[data-test="startPoll"]'; exports.restartPoll = 'button[data-test="restartPoll"]'; exports.receivedAnswer = 'td[data-test="receivedAnswer"]'; -exports.publishLabel = 'button[data-test="publishLabel"]'; +exports.publishPollingLabel = 'button[data-test="publishPollingLabel"]'; exports.pollResults = 'g[data-test="pollResultAria"]'; // Presentation diff --git a/bigbluebutton-tests/puppeteer/core/util.js b/bigbluebutton-tests/puppeteer/core/util.js index 51b5b5e44c..2c97f852d7 100644 --- a/bigbluebutton-tests/puppeteer/core/util.js +++ b/bigbluebutton-tests/puppeteer/core/util.js @@ -3,6 +3,12 @@ function checkElement(element, index = 0) { return document.querySelectorAll(element)[index] !== undefined; } +async function closePages(...pages) { + for (const page of pages) { + await page.close(); + } +} + // Text function checkElementText(element, param, index = 0) { return document.querySelectorAll(element)[index].innerText === param; @@ -31,6 +37,7 @@ function getElementLength(element) { } exports.checkElement = checkElement; +exports.closePages = closePages; exports.checkElementText = checkElementText; exports.checkElementTextIncludes = checkElementTextIncludes; exports.getElementText = getElementText; diff --git a/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js b/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js index 8f2a9b599b..62dad12831 100644 --- a/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js +++ b/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js @@ -549,6 +549,29 @@ const customParametersTest = () => { Page.checkRegression(0.5, screenshot); }); + // This test spec sets the userdata-bbb_force_restore_presentation_on_new_events parameter to true + // and checks that the viewers get the presentation restored forcefully when the Moderator zooms + // publishes a poll result + test('Force Restore Presentation On New Poll Result', async () => { + const test = new CustomParameters(); + let response; + let screenshot; + try { + const testName = 'forceRestorePresentationOnNewPollResult'; + await test.page1.logger('begin of ', testName); + response = await test.forceRestorePresentationOnNewPollResult(testName, c.forceRestorePresentationOnNewEvents); + await test.page1.logger('end of ', testName); + await test.page2.stopRecording(); + screenshot = await test.page1.page.screenshot(); + } catch (err) { + await test.page1.logger(err); + } finally { + await test.close(test.page1, test.page2); + } + expect(response).toBe(true); + Page.checkRegression(0.5, screenshot); + }); + // 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 () => { diff --git a/bigbluebutton-tests/puppeteer/customparameters/util.js b/bigbluebutton-tests/puppeteer/customparameters/util.js index c8c48c9f73..9468ef5818 100644 --- a/bigbluebutton-tests/puppeteer/customparameters/util.js +++ b/bigbluebutton-tests/puppeteer/customparameters/util.js @@ -99,7 +99,7 @@ async function poll(page1, page2) { await page1.waitAndClick(e.startPoll); await page2.waitForSelector(e.pollingContainer); await page2.waitAndClick(e.yesBtn); - await page1.waitAndClick(e.publishPollingResults); + await page1.waitAndClick(e.publishPollingLabel); return true; } catch (err) { console.log(err); diff --git a/bigbluebutton-tests/puppeteer/notifications/notifications.js b/bigbluebutton-tests/puppeteer/notifications/notifications.js index 8805725a37..e476250a61 100644 --- a/bigbluebutton-tests/puppeteer/notifications/notifications.js +++ b/bigbluebutton-tests/puppeteer/notifications/notifications.js @@ -2,6 +2,7 @@ const path = require('path'); const MultiUsers = require('../user/multiusers'); const Page = require('../core/page'); const util = require('./util'); +const utilPolling = require('../polling/util'); const utilScreenShare = require('../screenshare/util'); // utils imported from screenshare folder const e = require('../core/elements'); const { ELEMENT_WAIT_LONGER_TIME, UPLOAD_PDF_WAIT_TIME, ELEMENT_WAIT_TIME } = require('../core/constants'); @@ -173,7 +174,7 @@ class Notifications extends MultiUsers { try { await this.page3.screenshot(`${testName}`, `01-page03-audio-modal-closed-${testName}`); await this.page3.waitForSelector(e.whiteboard); - await util.startPoll(this.page3); + await utilPolling.startPoll(this.page3, true); await this.page3.screenshot(`${testName}`, `02-page03-started-poll-${testName}`); await this.page3.waitForSelector(e.smallToastMsg); const resp = await util.getLastToastValue(this.page3); diff --git a/bigbluebutton-tests/puppeteer/notifications/util.js b/bigbluebutton-tests/puppeteer/notifications/util.js index be1799c1cb..9693e02041 100644 --- a/bigbluebutton-tests/puppeteer/notifications/util.js +++ b/bigbluebutton-tests/puppeteer/notifications/util.js @@ -68,15 +68,6 @@ async function uploadFileMenu(test) { await test.waitAndClick(e.uploadPresentation); } -async function startPoll(test) { - await test.waitAndClick(e.actions); - await test.waitAndClick(e.polling); - await test.waitForSelector(e.hidePollDesc); - await test.waitAndClick(e.pollYesNoAbstentionBtn); - await test.waitAndClick(e.startPoll); - await test.waitAndClick(e.publishLabel); -} - exports.privateChatMessageToast = privateChatMessageToast; exports.publicChatMessageToast = publicChatMessageToast; exports.enableUserJoinPopup = enableUserJoinPopup; @@ -87,4 +78,3 @@ exports.uploadFileMenu = uploadFileMenu; exports.saveSettings = saveSettings; exports.waitForToast = waitForToast; exports.popupMenu = popupMenu; -exports.startPoll = startPoll; diff --git a/bigbluebutton-tests/puppeteer/polling/poll.js b/bigbluebutton-tests/puppeteer/polling/poll.js index 5020b7eff7..219abff7f2 100644 --- a/bigbluebutton-tests/puppeteer/polling/poll.js +++ b/bigbluebutton-tests/puppeteer/polling/poll.js @@ -1,22 +1,136 @@ const Page = require('../core/page'); const e = require('../core/elements'); -const util = require('../notifications/util'); +const util = require('./util'); +const { ELEMENT_WAIT_TIME } = require('../core/constants') const { checkElementLengthEqualTo } = require('../core/util'); -class Polling extends Page { +class Polling { constructor() { - super(); + this.modPage = new Page(); + this.userPage = new Page(); } - async test(testName) { - try { - await util.startPoll(this); - await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`); + async initPages(testName) { + await this.initModPage(testName); + await this.initUserPage(testName); + } - const resp = this.page.evaluate(checkElementLengthEqualTo, e.pollMenuButton, 1); + async initModPage(testName) { + await this.modPage.init(true, true, testName, 'Moderator'); + } + + async initUserPage(testName) { + await this.userPage.init(false, true, testName, 'Attendee', this.modPage.meetingId); + } + + async createPoll(testName) { + try { + await util.startPoll(this.modPage); + await this.modPage.screenshot(testName, '01-before-chat-message-send'); + + const resp = this.modPage.page.evaluate(checkElementLengthEqualTo, e.pollMenuButton, 1); return resp; } catch (err) { - await this.logger(err); + await this.modPage.logger(err); + return false; + } + } + + async pollResultsOnChat(testName) { + try { + await this.modPage.screenshot(testName, '01-before-chat-message-send'); + await util.startPoll(this.modPage, true); + await this.modPage.waitAndClick(e.chatButton); + + // Check poll result message + const resp = await this.modPage.hasElement(e.chatPollMessageText); + + return resp === true; + } catch (err) { + await this.modPage.logger(err); + return false; + } + } + + async randomPoll(testName) { + try { + await this.modPage.startRecording(testName); + await this.userPage.startRecording(testName); + + await this.modPage.waitAndClick(e.actions); + await this.modPage.waitAndClick(e.polling); + await this.modPage.waitForSelector(e.pollQuestionArea); + await this.modPage.page.focus(e.pollQuestionArea); + await this.modPage.page.keyboard.type(e.pollQuestion); + + const chosenRandomNb = await this.modPage.page.evaluate((responseTypes) => { + const responseTypesDiv = document.querySelector(responseTypes); + const buttons = responseTypesDiv.querySelectorAll('button'); + const countButtons = buttons.length; + const randomNb = Math.floor(Math.random() * countButtons) + 1; + const chosenRandomNb = randomNb - 1; + responseTypesDiv.querySelectorAll('button')[chosenRandomNb].click(); + return chosenRandomNb; + }, e.responseTypes); + + const customs = { + 0: e.uncertain, + 1: 0, + 2: 'ABSTENTION', + 3: 'All good!', + }; + switch (chosenRandomNb) { + case 0: + // Adding a poll option + await this.modPage.waitForSelector(e.responseChoices); + await this.modPage.waitAndClick(e.addItem); + await this.modPage.waitAndClick(e.pollOptionItem); + await this.modPage.tab(2); + await this.modPage.page.keyboard.type(customs[0]); + break; + + case 1: + // Deleting a poll option + await this.modPage.waitForSelector(e.deletePollOption); + await this.modPage.clickNItem(e.deletePollOption, customs[1]); + break; + + case 2: + // Editing a poll option + await this.modPage.waitForSelector(e.responseChoices); + await this.modPage.clickNItem(e.pollOptionItem, 2); + await this.modPage.hold('Control'); + await this.modPage.press('KeyA'); + await this.modPage.release('Control'); + await this.modPage.page.keyboard.type(customs[2]); + await this.modPage.tab(1); + break; + + case 3: + // Do nothing to let Users write their single response answer + await this.modPage.waitForSelector(e.responseChoices); + break; + } + const condition = chosenRandomNb === 0 || chosenRandomNb === 1 || chosenRandomNb === 2; + await this.modPage.waitAndClick(e.startPoll); + await this.userPage.waitForSelector(e.pollingContainer); + switch (condition) { + case true: + await this.userPage.clickNItem(e.pollAnswerOptionBtn, 2); + break; + case false: + await this.userPage.page.focus(e.pollAnswerOptionInput); + await this.userPage.page.keyboard.type(customs[3]); + await this.userPage.waitAndClick(e.pollSubmitAnswer); + break; + } + const receivedAnswerFound = await this.modPage.hasElement(e.receivedAnswer, true); + await this.modPage.waitAndClick(e.publishPollingLabel, ELEMENT_WAIT_TIME, true); + await this.modPage.waitForSelector(e.restartPoll); + const isPollResultsPublished = await this.modPage.hasElement(e.pollResults, true); + return receivedAnswerFound && isPollResultsPublished; + } catch (err) { + await this.modPage.logger(err); return false; } } diff --git a/bigbluebutton-tests/puppeteer/polling/polling.obj.js b/bigbluebutton-tests/puppeteer/polling/polling.obj.js index 0eb6d30124..f4f6da456f 100644 --- a/bigbluebutton-tests/puppeteer/polling/polling.obj.js +++ b/bigbluebutton-tests/puppeteer/polling/polling.obj.js @@ -1,11 +1,8 @@ -const { toMatchImageSnapshot } = require('jest-image-snapshot'); -const CustomParameters = require('../customparameters/customparameters'); -const Multiusers = require('../user/multiusers'); -const Polling = require('./poll'); const Page = require('../core/page'); -const Poll = require('../chat/poll'); -const ce = require('../customparameters/constants'); +const Poll = require('./poll'); +const { closePages } = require('../core/util'); const { MAX_POLLING_TEST_TIMEOUT, TEST_DURATION_TIME } = require('../core/constants'); // core constants (Timeouts vars imported) +const { toMatchImageSnapshot } = require('jest-image-snapshot'); expect.extend({ toMatchImageSnapshot }); @@ -16,95 +13,73 @@ const pollingTest = () => { // Create Poll test('Create Poll', async () => { - const test = new Polling(); + const test = new Poll(); let response; let screenshot; try { const testName = 'createPoll'; - await test.logger('begin of ', testName); - await test.init(true, testName); - await test.startRecording(testName); - response = await test.test(testName); - await test.logger('end of ', testName); - await test.stopRecording(); - screenshot = await test.page.screenshot(); + await test.modPage.logger('begin of ', testName); + await test.initModPage(true, testName); + await test.modPage.startRecording(testName); + response = await test.createPoll(testName); + await test.modPage.logger('end of ', testName); + await test.modPage.stopRecording(); + screenshot = await test.modPage.page.screenshot(); } catch (err) { - await test.logger(err); + await test.modPage.logger(err); } finally { - await test.close(); + await test.modPage.close(); } expect(response).toBe(true); Page.checkRegression(1.37, screenshot); }, TEST_DURATION_TIME); - // Check for Poll Results chat message and return true when it appears - test('Poll Results chat message', async () => { + // Check for Poll Results in chat message and return true when it appears + test('Poll results in chat message', async () => { const test = new Poll(); let response; let screenshot; try { - const testName = 'pollResultsChatMessage'; - await test.page3.logger('begin of ', testName); - await test.initUser3(true, testName); - await test.page3.startRecording(testName); - response = await test.test(testName); - await test.page3.logger('end of ', testName); - await test.page3.stopRecording(); - screenshot = await test.page3.page.screenshot(); + const testName = 'pollResultsInChatMessage'; + await test.modPage.logger('begin of ', testName); + await test.initModPage(true, testName); + await test.modPage.startRecording(testName); + response = await test.pollResultsOnChat(testName); + await test.modPage.logger('end of ', testName); + await test.modPage.stopRecording(); + screenshot = await test.modPage.page.screenshot(); } catch (err) { - await test.page3.logger(err); + await test.modPage.logger(err); } finally { - await test.closePage(test.page3); + await test.modPage.close(); } expect(response).toBe(true); Page.checkRegression(0.9, screenshot); }, TEST_DURATION_TIME); - // This test spec sets the userdata-bbb_force_restore_presentation_on_new_events parameter to true - // and checks that the viewers get the presentation restored forcefully when the Moderator zooms - // publishes a poll result - test('Force Restore Presentation On New Poll Result', async () => { - const test = new CustomParameters(); - let response; - let screenshot; - try { - const testName = 'forceRestorePresentationOnNewPollResult'; - await test.page1.logger('begin of ', testName); - response = await test.forceRestorePresentationOnNewPollResult(ce.forceRestorePresentationOnNewEvents, testName); - await test.page1.logger('end of ', testName); - await test.page2.stopRecording(); - screenshot = await test.page1.page.screenshot(); - } catch (err) { - await test.page1.logger(err); - } finally { - await test.close(test.page1, test.page2); - } - expect(response).toBe(true); - Page.checkRegression(0.5, screenshot); - }, TEST_DURATION_TIME); - // This Test chooses randomly a polling case, runs it // and expects having it answered by the other user test('Random Poll', async () => { - const test = new Multiusers(); + const test = new Poll(); let response; let screenshot; try { const testName = 'randomPoll'; - await test.page1.logger('begin of ', testName); - await test.init(testName); + await test.modPage.logger('begin of ', testName); + await test.initPages(testName); response = await test.randomPoll(testName); - await test.page1.logger('end of ', testName); - await test.page1.stopRecording(); - await test.page2.stopRecording(); - screenshot = await test.page1.page.screenshot(); + await test.modPage.logger('end of ', testName); + await test.modPage.stopRecording(); + await test.userPage.stopRecording(); + screenshot = await test.modPage.page.screenshot(); } catch (err) { - await test.page1.logger(err); + await test.modPage.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.modPage, test.userPage); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); }, TEST_DURATION_TIME); }; + module.exports = exports = pollingTest; \ No newline at end of file diff --git a/bigbluebutton-tests/puppeteer/polling/util.js b/bigbluebutton-tests/puppeteer/polling/util.js new file mode 100644 index 0000000000..14b3f15d6c --- /dev/null +++ b/bigbluebutton-tests/puppeteer/polling/util.js @@ -0,0 +1,12 @@ +const e = require('../core/elements'); + +async function startPoll(test, shouldPublishPoll = false) { + await test.waitAndClick(e.actions); + await test.waitAndClick(e.polling); + await test.waitForSelector(e.hidePollDesc); + await test.waitAndClick(e.pollYesNoAbstentionBtn); + await test.waitAndClick(e.startPoll); + if (shouldPublishPoll) await test.waitAndClick(e.publishPollingLabel); +} + +exports.startPoll = startPoll; \ No newline at end of file diff --git a/bigbluebutton-tests/puppeteer/user/multiusers.js b/bigbluebutton-tests/puppeteer/user/multiusers.js index 177ea0f7ec..8db45b531f 100644 --- a/bigbluebutton-tests/puppeteer/user/multiusers.js +++ b/bigbluebutton-tests/puppeteer/user/multiusers.js @@ -1,7 +1,7 @@ const Page = require('../core/page'); -const util = require('../chat/util'); -const utilUser = require('./util'); const e = require('../core/elements'); +const util = require('./util'); +const utilChat = require('../chat/util'); const { ELEMENT_WAIT_TIME, ELEMENT_WAIT_LONGER_TIME } = require('../core/constants'); const { getElementLength, checkElementLengthEqualTo } = require('../core/util'); @@ -40,7 +40,7 @@ class MultiUsers { async multiUsersPublicChat(testName) { try { const chat0 = await this.page1.page.evaluate(getElementLength, e.chatUserMessageText); - await util.sendPublicChatMessage(this.page1, this.page2, testName); + await utilChat.sendPublicChatMessage(this.page1, this.page2, testName); const chat1 = await this.page1.page.evaluate(getElementLength, e.chatUserMessageText); return chat0 !== chat1; @@ -52,10 +52,10 @@ class MultiUsers { async multiUsersPrivateChat(testName) { try { - await util.openPrivateChatMessage(this.page1, this.page2); + await utilChat.openPrivateChatMessage(this.page1, this.page2); const chat0 = await this.page1.page.evaluate(checkElementLengthEqualTo, e.chatUserMessageText, 0); - await util.sendPrivateChatMessage(this.page1, this.page2, testName); + await utilChat.sendPrivateChatMessage(this.page1, this.page2, testName); const receivedMessages = await this.page1.hasElement(e.chatUserMessageText, true) && await this.page2.hasElement(e.chatUserMessageText, true); return chat0 && receivedMessages; @@ -75,89 +75,6 @@ class MultiUsers { } } - async randomPoll(testName) { - try { - await this.page1.startRecording(testName); - await this.page2.startRecording(testName); - - await this.page1.waitAndClick(e.actions); - await this.page1.waitAndClick(e.polling); - await this.page1.waitForSelector(e.pollQuestionArea); - await this.page1.page.focus(e.pollQuestionArea); - await this.page1.page.keyboard.type(e.pollQuestion); - - const chosenRandomNb = await this.page1.page.evaluate((responseTypes) => { - const responseTypesDiv = document.querySelector(responseTypes); - const buttons = responseTypesDiv.querySelectorAll('button'); - const countButtons = buttons.length; - const randomNb = Math.floor(Math.random() * countButtons) + 1; - const chosenRandomNb = randomNb - 1; - responseTypesDiv.querySelectorAll('button')[chosenRandomNb].click(); - return chosenRandomNb; - }, e.responseTypes); - - const customs = { - 0: e.uncertain, - 1: 0, - 2: 'ABSTENTION', - 3: 'All good!', - }; - switch (chosenRandomNb) { - case 0: - // Adding a poll option - await this.page1.waitForSelector(e.responseChoices); - await this.page1.waitAndClick(e.addItem); - await this.page1.waitAndClick(e.pollOptionItem); - await this.page1.tab(2); - await this.page1.page.keyboard.type(customs[0]); - break; - - case 1: - // Deleting a poll option - await this.page1.waitForSelector(e.deletePollOption); - await this.page1.clickNItem(e.deletePollOption, customs[1]); - break; - - case 2: - // Editing a poll option - await this.page1.waitForSelector(e.responseChoices); - await this.page1.clickNItem(e.pollOptionItem, 2); - await this.page1.hold('Control'); - await this.page1.press('KeyA'); - await this.page1.release('Control'); - await this.page1.page.keyboard.type(customs[2]); - await this.page1.tab(1); - break; - - case 3: - // Do nothing to let Users write their single response answer - await this.page1.waitForSelector(e.responseChoices); - break; - } - const condition = chosenRandomNb === 0 || chosenRandomNb === 1 || chosenRandomNb === 2; - await this.page1.waitAndClick(e.startPoll); - await this.page2.waitForSelector(e.pollingContainer); - switch (condition) { - case true: - await this.page2.clickNItem(e.pollAnswerOptionBtn, 2); - break; - case false: - await this.page2.page.focus(e.pollAnswerOptionInput); - await this.page2.page.keyboard.type(customs[3]); - await this.page2.waitAndClick(e.pollSubmitAnswer); - break; - } - const receivedAnswerFound = await this.page1.hasElement(e.receivedAnswer, true); - await this.page1.waitAndClick(e.publishLabel, ELEMENT_WAIT_TIME, true); - await this.page1.waitForSelector(e.restartPoll); - const isPollResultsPublished = await this.page1.hasElement(e.pollResults, true); - return receivedAnswerFound && isPollResultsPublished; - } catch (err) { - await this.page1.logger(err); - return false; - } - } - async askModeratorGuestPolicy(testName) { try { await this.initMod1(testName); @@ -291,7 +208,7 @@ class MultiUsers { await this.page2.page.evaluate(() => window.dispatchEvent(new CustomEvent('socketstats', { detail: { rtt: 2000 } }))); await this.page2.page.setOfflineMode(true); await this.page2.close(); - await utilUser.connectionStatus(this.page1); + await util.connectionStatus(this.page1); const connectionStatusItemEmpty = await this.page1.wasRemoved(e.connectionStatusItemEmpty); const connectionStatusOfflineUser = await this.page1.hasElement(e.connectionStatusOfflineUser, true, ELEMENT_WAIT_LONGER_TIME); @@ -324,7 +241,7 @@ class MultiUsers { await this.userPage.screenshot(testName, '03-userPage-after-share-webcam'); await this.userPage.waitAndClick(e.connectionStatusBtn); try { - await this.userPage.page.waitForFunction(utilUser.checkNetworkStatus, { timeout: ELEMENT_WAIT_TIME }, + await this.userPage.page.waitForFunction(util.checkNetworkStatus, { timeout: ELEMENT_WAIT_TIME }, e.connectionDataContainer, e.connectionNetwordData ); await this.userPage.screenshot(testName, '04-connection-network-success'); @@ -344,7 +261,7 @@ class MultiUsers { try { await this.page1.shareWebcam(true, ELEMENT_WAIT_LONGER_TIME); await this.page2.shareWebcam(true, ELEMENT_WAIT_LONGER_TIME); - await utilUser.connectionStatus(this.page1); + await util.connectionStatus(this.page1); await this.page1.waitAndClickElement(e.dataSavingWebcams); await this.page1.waitAndClickElement(e.closeConnectionStatusModal); await this.page1.waitForSelector(e.smallToastMsg); From 9d0b07b3b281c56d667711121e214931ab2e9d3c Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 20 Oct 2021 14:23:24 -0300 Subject: [PATCH 02/31] provide unique closePages function --- .../puppeteer/breakout/breakout.obj.js | 15 ++--- .../puppeteer/breakout/create.js | 19 ------ .../puppeteer/breakout/join.js | 11 ---- .../puppeteer/chat/chat.obj.js | 5 +- .../customparameters/customparameters.js | 19 ------ .../customparameters/customparameters.obj.js | 59 ++++++++++--------- .../puppeteer/notifications/notifications.js | 10 ---- .../notifications/notifications.obj.js | 17 +++--- .../puppeteer/presentation/presentation.js | 13 ++-- .../presentation/presentation.obj.js | 9 +-- .../puppeteer/sharednotes/sharednotes.js | 9 --- .../puppeteer/sharednotes/sharednotes.obj.js | 3 +- .../puppeteer/stress/stress.js | 2 +- .../puppeteer/stress/stress.obj.js | 2 +- .../puppeteer/user/multiusers.js | 20 ------- .../puppeteer/user/user.obj.js | 25 ++++---- .../puppeteer/whiteboard/whiteboard.obj.js | 3 +- 17 files changed, 78 insertions(+), 163 deletions(-) diff --git a/bigbluebutton-tests/puppeteer/breakout/breakout.obj.js b/bigbluebutton-tests/puppeteer/breakout/breakout.obj.js index 38d1d063fa..adbfb64619 100644 --- a/bigbluebutton-tests/puppeteer/breakout/breakout.obj.js +++ b/bigbluebutton-tests/puppeteer/breakout/breakout.obj.js @@ -1,6 +1,7 @@ -const Join = require('./join'); -const Create = require('./create'); const Page = require('../core/page'); +const Create = require('./create'); +const Join = require('./join'); +const { closePages } = require('../core/util'); const { MAX_BREAKOUT_TEST_TIMEOUT } = require('../core/constants'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); @@ -31,7 +32,7 @@ const breakoutTest = () => { } catch (err) { await test.modPage1.logger(err); } finally { - await test.close(); + await closePages(test.modPage1, test.userPage1); } expect(response).toBe(true); Page.checkRegression(8.0, screenshot); @@ -58,7 +59,7 @@ const breakoutTest = () => { } catch (err) { await test.modPage1.logger(err); } finally { - await test.close(); + await closePages(test.modPage1, test.modPage2, test.userPage1); } expect(response).toBe(true); Page.checkRegression(4.0, screenshot); @@ -85,7 +86,7 @@ const breakoutTest = () => { } catch (err) { await test.modPage1.logger(err); } finally { - await test.close(); + await closePages(test.modPage1, test.modPage2, test.userPage1); } expect(response).toBe(true); Page.checkRegression(0.6, screenshot); @@ -112,7 +113,7 @@ const breakoutTest = () => { } catch (err) { await test.modPage1.logger(err); } finally { - await test.close(); + await closePages(test.modPage1, test.modPage2, test.userPage1); } expect(response).toBe(true); Page.checkRegression(0.7, screenshot); @@ -139,7 +140,7 @@ const breakoutTest = () => { } catch (err) { await test.modPage1.logger(err); } finally { - await test.close(); + await closePages(test.modPage1, test.modPage2, test.userPage1); } expect(response).toBe(true); Page.checkRegression(3.6, screenshot); diff --git a/bigbluebutton-tests/puppeteer/breakout/create.js b/bigbluebutton-tests/puppeteer/breakout/create.js index 414a5aec7b..0a02588d78 100644 --- a/bigbluebutton-tests/puppeteer/breakout/create.js +++ b/bigbluebutton-tests/puppeteer/breakout/create.js @@ -146,25 +146,6 @@ class Create { await this.modPage2.logger(err); } } - - // Close pages - async close() { - try { - await this.modPage1.close(); - await this.userPage1.close(); - } catch (err) { - await this.modPage1.logger(err); - } - } - - // Close page - async closePage(page) { - try { - await page.close(); - } catch (err) { - await this.modPage1.logger(err); - } - } } module.exports = exports = Create; \ No newline at end of file diff --git a/bigbluebutton-tests/puppeteer/breakout/join.js b/bigbluebutton-tests/puppeteer/breakout/join.js index 3b4e06c7a2..5fde967d90 100644 --- a/bigbluebutton-tests/puppeteer/breakout/join.js +++ b/bigbluebutton-tests/puppeteer/breakout/join.js @@ -75,17 +75,6 @@ class Join extends Create { return false; } } - - // Close pages - async close() { - try { - await this.modPage1.close(); - await this.userPage1.close(); - await this.modPage2.close(); - } catch (err) { - await this.modPage2.logger(err); - } - } } module.exports = exports = Join; diff --git a/bigbluebutton-tests/puppeteer/chat/chat.obj.js b/bigbluebutton-tests/puppeteer/chat/chat.obj.js index d69b22819f..4b595e8186 100644 --- a/bigbluebutton-tests/puppeteer/chat/chat.obj.js +++ b/bigbluebutton-tests/puppeteer/chat/chat.obj.js @@ -4,6 +4,7 @@ const Clear = require('./clear'); const Copy = require('./copy'); const Save = require('./save'); const MultiUsers = require('../user/multiusers'); +const { closePages } = require('../core/util'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); const { MAX_CHAT_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported) @@ -123,7 +124,7 @@ const chatTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.9, screenshot); @@ -146,7 +147,7 @@ const chatTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.9, screenshot); diff --git a/bigbluebutton-tests/puppeteer/customparameters/customparameters.js b/bigbluebutton-tests/puppeteer/customparameters/customparameters.js index 1dfd8a8338..0787f5945c 100644 --- a/bigbluebutton-tests/puppeteer/customparameters/customparameters.js +++ b/bigbluebutton-tests/puppeteer/customparameters/customparameters.js @@ -756,25 +756,6 @@ class CustomParameters { return false; } } - - async closePage(page) { - try { - await page.close(); - } catch (err) { - await this.page1.logger(err); - return false; - } - } - - async close(page1, page2) { - try { - await page1.close(); - await page2.close(); - } catch (err) { - await this.page1.logger(err); - return false; - } - } } module.exports = exports = CustomParameters; \ No newline at end of file diff --git a/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js b/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js index 62dad12831..666666ed27 100644 --- a/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js +++ b/bigbluebutton-tests/puppeteer/customparameters/customparameters.obj.js @@ -2,6 +2,7 @@ const Page = require('../core/page'); const CustomParameters = require('./customparameters'); const c = require('./constants'); const util = require('./util'); +const { closePages } = require('../core/util'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); const { MAX_CUSTOM_PARAMETERS_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported) @@ -29,7 +30,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -52,7 +53,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -75,7 +76,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page2); + await test.page2.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -98,7 +99,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(53.18, screenshot); @@ -121,7 +122,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(53.18, screenshot); @@ -144,7 +145,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -167,7 +168,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -191,7 +192,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -215,7 +216,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -238,7 +239,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -261,7 +262,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -284,7 +285,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -308,7 +309,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -331,7 +332,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -355,7 +356,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -378,7 +379,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -401,7 +402,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -425,7 +426,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -448,7 +449,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -471,7 +472,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -495,7 +496,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -518,7 +519,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -543,7 +544,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -566,7 +567,7 @@ const customParametersTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -589,7 +590,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -612,7 +613,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -635,7 +636,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -659,7 +660,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); @@ -682,7 +683,7 @@ const customParametersTest = () => { } catch (err) { await page.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(0.5, screenshot); diff --git a/bigbluebutton-tests/puppeteer/notifications/notifications.js b/bigbluebutton-tests/puppeteer/notifications/notifications.js index e476250a61..7a4912ad3c 100644 --- a/bigbluebutton-tests/puppeteer/notifications/notifications.js +++ b/bigbluebutton-tests/puppeteer/notifications/notifications.js @@ -217,16 +217,6 @@ class Notifications extends MultiUsers { return false; } } - - async closePages() { - try { - await this.page3.close(); - await this.page4.close(); - } catch (err) { - await this.page3.logger(err); - return false; - } - } } module.exports = exports = Notifications; \ No newline at end of file diff --git a/bigbluebutton-tests/puppeteer/notifications/notifications.obj.js b/bigbluebutton-tests/puppeteer/notifications/notifications.obj.js index b2e480a7a6..a306cdf858 100644 --- a/bigbluebutton-tests/puppeteer/notifications/notifications.obj.js +++ b/bigbluebutton-tests/puppeteer/notifications/notifications.obj.js @@ -1,5 +1,6 @@ const Notifications = require('./notifications'); const Page = require('../core/page'); +const { closePages } = require('../core/util'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); const { MAX_NOTIFICATIONS_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported) @@ -24,7 +25,7 @@ const notificationsTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); await test.page1.logger('Save Setting notification !'); } expect(response).toBe(true); @@ -45,7 +46,7 @@ const notificationsTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); await test.page1.logger('Public Chat notification !'); } expect(response).toBe(true); @@ -66,7 +67,7 @@ const notificationsTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); await test.page1.logger('Private Chat notification !'); } expect(response).toBe(true); @@ -87,7 +88,7 @@ const notificationsTest = () => { } catch (err) { await test.page3.logger(err); } finally { - await test.closePages(); + await closePages(test.page3, test.page4) await test.page3.logger('User join notification !'); } expect(response).toBe(true); @@ -108,7 +109,7 @@ const notificationsTest = () => { } catch (err) { await test.page3.logger(err); } finally { - await test.closePage(test.page3); + await test.page3.close(); await test.page3.logger('Presentation upload notification !'); } expect(response).toBe(true); @@ -130,7 +131,7 @@ const notificationsTest = () => { } catch (err) { await test.page3.logger(err); } finally { - await test.closePage(test.page3); + await test.page3.close(); await test.page3.logger('Poll results notification !'); } expect(response).toContain('Poll results were published'); @@ -151,7 +152,7 @@ const notificationsTest = () => { } catch (err) { await test.page3.logger(err); } finally { - await test.closePage(test.page3); + await test.page3.close(); await test.page3.logger('Screenshare notification !'); } expect(response).toBe('Screenshare has started'); @@ -172,7 +173,7 @@ const notificationsTest = () => { } catch (err) { await test.page3.logger(err); } finally { - await test.closePage(test.page3); + await test.page3.close(); await test.page3.logger('Audio notification !'); } expect(response).toBe(true); diff --git a/bigbluebutton-tests/puppeteer/presentation/presentation.js b/bigbluebutton-tests/puppeteer/presentation/presentation.js index 90e3796416..47398e5d97 100644 --- a/bigbluebutton-tests/puppeteer/presentation/presentation.js +++ b/bigbluebutton-tests/puppeteer/presentation/presentation.js @@ -23,11 +23,6 @@ class Presentation { await this.userPage.init(false, true, testName, 'Attendee', this.modPage.meetingId); } - async closePages() { - if (this.modPage.page) await this.modPage.close(); - if (this.userPage.page) await this.userPage.close(); - } - async skipSlide() { try { await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME); @@ -76,12 +71,12 @@ class Presentation { await this.modPage.page.waitForSelector(e.upload); await this.modPage.waitAndClick(e.upload); - await this.modPage.logger('\nWaiting for the new presentation to upload...'); + await this.modPage.logger('Waiting for the new presentation to upload...'); await this.modPage.page.waitForFunction(checkElementTextIncludes, { timeout: ELEMENT_WAIT_TIME }, 'body', 'Converting file' ); - await this.modPage.logger('\nPresentation uploaded!'); + await this.modPage.logger('Presentation uploaded!'); await this.modPage.page.waitForFunction(checkElementTextIncludes, { timeout: ELEMENT_WAIT_LONGER_TIME }, 'body', 'Current presentation' @@ -90,9 +85,9 @@ class Presentation { const slides1 = await this.modPage.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML); - await this.modPage.logger('\nSlides before presentation upload:'); + await this.modPage.logger('Slides before presentation upload'); await this.modPage.logger(slides0); - await this.modPage.logger('\nSlides after presentation upload:'); + await this.modPage.logger('Slides after presentation upload'); await this.modPage.logger(slides1); return slides0 !== slides1; diff --git a/bigbluebutton-tests/puppeteer/presentation/presentation.obj.js b/bigbluebutton-tests/puppeteer/presentation/presentation.obj.js index 2d9f121450..fb3a539055 100644 --- a/bigbluebutton-tests/puppeteer/presentation/presentation.obj.js +++ b/bigbluebutton-tests/puppeteer/presentation/presentation.obj.js @@ -1,5 +1,6 @@ const Page = require('../core/page'); const Presentation = require('./presentation'); +const { closePages } = require('../core/util'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); const { MAX_PRESENTATION_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported) @@ -26,7 +27,7 @@ const presentationTest = () => { } catch (err) { await test.modPage.logger(err); } finally { - await test.closePages(); + await test.modPage.close(); } expect(response).toBe(true); Page.checkRegression(0.81, screenshot); @@ -48,7 +49,7 @@ const presentationTest = () => { } catch (err) { await test.modPage.logger(err); } finally { - await test.closePages(); + await test.modPage.close(); } expect(response).toBe(true); Page.checkRegression(24.62, screenshot); @@ -70,7 +71,7 @@ const presentationTest = () => { } catch (e) { await test.modPage.logger(e); } finally { - await test.closePages(); + await closePages(test.modPage, test.userPage); } expect(response).toBe(true); Page.checkRegression(24.62, screenshot); @@ -92,7 +93,7 @@ const presentationTest = () => { } catch (e) { await test.modPage.logger(e); } finally { - await test.closePages(); + await closePages(test.modPage, test.userPage); } expect(response).toBe(true); Page.checkRegression(24.62, screenshot); diff --git a/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.js b/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.js index 40c2f3f4fe..048f06b0bd 100644 --- a/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.js +++ b/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.js @@ -10,15 +10,6 @@ class SharedNotes extends Create { const response = await util.startSharedNotes(this.modPage1); return response; } - - async close() { - try { - await this.modPage1.close(); - await this.userPage1.close(); - } catch (e) { - await this.modPage1.logger(e); - } - } } module.exports = exports = SharedNotes; diff --git a/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.obj.js b/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.obj.js index b10e7cecc2..58efe4e2f8 100644 --- a/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.obj.js +++ b/bigbluebutton-tests/puppeteer/sharednotes/sharednotes.obj.js @@ -1,5 +1,6 @@ const Page = require('../core/page'); const SharedNotes = require('./sharednotes'); +const { closePages } = require('../core/util'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); const { MAX_SHARED_NOTES_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported) @@ -28,7 +29,7 @@ const sharedNotesTest = () => { } catch (err) { await test.modPage1.logger(err); } finally { - await test.close(); + await closePages(test.modPage1, test.userPage1); } expect(response).toBe(true); Page.checkRegression(0.1, screenshot); diff --git a/bigbluebutton-tests/puppeteer/stress/stress.js b/bigbluebutton-tests/puppeteer/stress/stress.js index a776dfb83a..0a3b5ed7f4 100644 --- a/bigbluebutton-tests/puppeteer/stress/stress.js +++ b/bigbluebutton-tests/puppeteer/stress/stress.js @@ -96,7 +96,7 @@ class Stress { } } - async closeUserPages() { + async closeUsersPages() { for (const page of this.userPages) { try { await page.close(); diff --git a/bigbluebutton-tests/puppeteer/stress/stress.obj.js b/bigbluebutton-tests/puppeteer/stress/stress.obj.js index a9a592219d..ad522c0853 100644 --- a/bigbluebutton-tests/puppeteer/stress/stress.obj.js +++ b/bigbluebutton-tests/puppeteer/stress/stress.obj.js @@ -31,7 +31,7 @@ const stressTest = () => { await test.modPage.logger(err); } finally { await test.modPage.close(); - await test.closeUserPages(); + await test.closeUsersPages(); } expect(response).toBe(true); }); diff --git a/bigbluebutton-tests/puppeteer/user/multiusers.js b/bigbluebutton-tests/puppeteer/user/multiusers.js index 8db45b531f..5517f9323b 100644 --- a/bigbluebutton-tests/puppeteer/user/multiusers.js +++ b/bigbluebutton-tests/puppeteer/user/multiusers.js @@ -303,26 +303,6 @@ class MultiUsers { return false; } } - - // Close all Pages - async close(page1, page2) { - try { - await page1.close(); - await page2.close(); - } catch (err) { - await this.page1.logger(err); - return false; - } - } - - async closePage(page) { - try { - await page.close(); - } catch (err) { - await this.page1.logger(err); - return false; - } - } } module.exports = exports = MultiUsers; \ No newline at end of file diff --git a/bigbluebutton-tests/puppeteer/user/user.obj.js b/bigbluebutton-tests/puppeteer/user/user.obj.js index 0e4229c90c..a4fb5049bc 100644 --- a/bigbluebutton-tests/puppeteer/user/user.obj.js +++ b/bigbluebutton-tests/puppeteer/user/user.obj.js @@ -2,6 +2,7 @@ const { toMatchImageSnapshot } = require('jest-image-snapshot'); const Page = require('../core/page'); const Status = require('./status'); const MultiUsers = require('./multiusers'); +const { closePages } = require('../core/util'); const { MAX_MULTIUSERS_TEST_TIMEOUT, TEST_DURATION_TIME } = require('../core/constants'); // core constants (Timeouts vars imported) const { NETWORK_PRESETS } = require('../core/profiles'); const devices = require('../core/devices'); @@ -80,7 +81,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -127,7 +128,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -199,7 +200,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.closePage(test.page1); + await test.page1.close(); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -221,7 +222,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.userPage); + await closePages(test.page1, test.userPage); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -251,7 +252,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -274,7 +275,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.userPage); + await closePages(test.page1, test.userPage); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -297,7 +298,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.userPage); + await closePages(test.page1, test.userPage); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -320,7 +321,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.userPage); + await closePages(test.page1, test.userPage); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -347,7 +348,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -374,7 +375,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -401,7 +402,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); @@ -428,7 +429,7 @@ const userTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(2.0, screenshot); diff --git a/bigbluebutton-tests/puppeteer/whiteboard/whiteboard.obj.js b/bigbluebutton-tests/puppeteer/whiteboard/whiteboard.obj.js index 2c70edd6d9..ff4d19822e 100644 --- a/bigbluebutton-tests/puppeteer/whiteboard/whiteboard.obj.js +++ b/bigbluebutton-tests/puppeteer/whiteboard/whiteboard.obj.js @@ -1,6 +1,7 @@ const Page = require('../core/page'); const Draw = require('./draw'); const Multiusers = require('../user/multiusers'); +const { closePages } = require('../core/util'); const { toMatchImageSnapshot } = require('jest-image-snapshot'); const { MAX_WHITEBOARD_TEST_TIMEOUT } = require('../core/constants'); @@ -55,7 +56,7 @@ const whiteboardTest = () => { } catch (err) { await test.page1.logger(err); } finally { - await test.close(test.page1, test.page2); + await closePages(test.page1, test.page2); } expect(response).toBe(true); Page.checkRegression(0.9, screenshot); From 22ecd395ebb9e67f3ee960f2e847c05fa91ea074 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 20 Oct 2021 14:39:36 -0300 Subject: [PATCH 03/31] add Polling test: Poll results in whiteboard --- bigbluebutton-tests/puppeteer/polling/poll.js | 16 +++++++++++++ .../puppeteer/polling/polling.obj.js | 23 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/bigbluebutton-tests/puppeteer/polling/poll.js b/bigbluebutton-tests/puppeteer/polling/poll.js index 219abff7f2..356dfc5c60 100644 --- a/bigbluebutton-tests/puppeteer/polling/poll.js +++ b/bigbluebutton-tests/puppeteer/polling/poll.js @@ -52,6 +52,22 @@ class Polling { } } + async pollResultsOnWhiteboard(testName) { + try { + await this.modPage.waitForSelector(e.whiteboard); + await this.modPage.screenshot(testName, '01-before-start-poll'); + await util.startPoll(this.modPage, true); + + // Check poll result on whiteboard + const resp = await this.modPage.hasElement(e.pollResults); + + return resp === true; + } catch (err) { + await this.modPage.logger(err); + return false; + } + } + async randomPoll(testName) { try { await this.modPage.startRecording(testName); diff --git a/bigbluebutton-tests/puppeteer/polling/polling.obj.js b/bigbluebutton-tests/puppeteer/polling/polling.obj.js index f4f6da456f..d3fc6fcdee 100644 --- a/bigbluebutton-tests/puppeteer/polling/polling.obj.js +++ b/bigbluebutton-tests/puppeteer/polling/polling.obj.js @@ -57,6 +57,29 @@ const pollingTest = () => { Page.checkRegression(0.9, screenshot); }, TEST_DURATION_TIME); + // Check for Poll Results in whiteboard and return true when it appears + test('Poll results in whiteboard', async () => { + const test = new Poll(); + let response; + let screenshot; + try { + const testName = 'pollResultsInWhiteboard'; + await test.modPage.logger('begin of ', testName); + await test.initModPage(true, testName); + await test.modPage.startRecording(testName); + response = await test.pollResultsOnWhiteboard(testName); + await test.modPage.logger('end of ', testName); + await test.modPage.stopRecording(); + screenshot = await test.modPage.page.screenshot(); + } catch (err) { + await test.modPage.logger(err); + } finally { + await test.modPage.close(); + } + expect(response).toBe(true); + Page.checkRegression(0.9, screenshot); + }, TEST_DURATION_TIME); + // This Test chooses randomly a polling case, runs it // and expects having it answered by the other user test('Random Poll', async () => { From 8995740659bfa023d80527419ef4bbe74b89bada Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 21 Oct 2021 11:11:43 -0300 Subject: [PATCH 04/31] add pollAnonymous test --- .../puppeteer/core/elements.js | 1 + bigbluebutton-tests/puppeteer/polling/poll.js | 22 ++++++++++++++++-- .../puppeteer/polling/polling.obj.js | 23 +++++++++++++++++++ bigbluebutton-tests/puppeteer/polling/util.js | 3 ++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/bigbluebutton-tests/puppeteer/core/elements.js b/bigbluebutton-tests/puppeteer/core/elements.js index a74346719d..c360aa360c 100644 --- a/bigbluebutton-tests/puppeteer/core/elements.js +++ b/bigbluebutton-tests/puppeteer/core/elements.js @@ -142,6 +142,7 @@ exports.restartPoll = 'button[data-test="restartPoll"]'; exports.receivedAnswer = 'td[data-test="receivedAnswer"]'; exports.publishPollingLabel = 'button[data-test="publishPollingLabel"]'; exports.pollResults = 'g[data-test="pollResultAria"]'; +exports.anonymousPoll = 'input[aria-label="Anonymous Poll"]'; // Presentation exports.startScreenSharing = 'button[data-test="startScreenShare"]'; diff --git a/bigbluebutton-tests/puppeteer/polling/poll.js b/bigbluebutton-tests/puppeteer/polling/poll.js index 356dfc5c60..6d0aca8156 100644 --- a/bigbluebutton-tests/puppeteer/polling/poll.js +++ b/bigbluebutton-tests/puppeteer/polling/poll.js @@ -1,8 +1,8 @@ const Page = require('../core/page'); const e = require('../core/elements'); const util = require('./util'); -const { ELEMENT_WAIT_TIME } = require('../core/constants') -const { checkElementLengthEqualTo } = require('../core/util'); +const { ELEMENT_WAIT_TIME } = require('../core/constants'); +const { checkElement, checkElementLengthEqualTo } = require('../core/util'); class Polling { constructor() { @@ -36,6 +36,24 @@ class Polling { } } + async pollAnonymous(testName) { + try { + await this.modPage.waitForSelector(e.whiteboard); + await this.modPage.screenshot(testName, '01-before-start-anonymous-poll'); + await util.startPoll(this.modPage, false, true); + await this.modPage.screenshot(testName, '02-after-start-anonymous-poll'); + await this.modPage.waitForSelector(e.publishPollingLabel); + await this.userPage.waitAndClick(e.pollAnswerOptionBtn); + await this.modPage.screenshot(testName, '03-after-receive-answer'); + const resp = !await this.modPage.page.evaluate(checkElement, e.receivedAnswer); + + return resp === true; + } catch (err) { + await this.modPage.logger(err); + return false; + } + } + async pollResultsOnChat(testName) { try { await this.modPage.screenshot(testName, '01-before-chat-message-send'); diff --git a/bigbluebutton-tests/puppeteer/polling/polling.obj.js b/bigbluebutton-tests/puppeteer/polling/polling.obj.js index d3fc6fcdee..d98156426f 100644 --- a/bigbluebutton-tests/puppeteer/polling/polling.obj.js +++ b/bigbluebutton-tests/puppeteer/polling/polling.obj.js @@ -34,6 +34,29 @@ const pollingTest = () => { Page.checkRegression(1.37, screenshot); }, TEST_DURATION_TIME); + // Create anonymous poll and check if its possible to see the user's response + test('Create anonymous poll', async () => { + const test = new Poll(); + let response; + let screenshot; + try { + const testName = 'pollAnonymous'; + await test.modPage.logger('begin of ', testName); + await test.initPages(testName); + await test.modPage.startRecording(testName); + response = await test.pollAnonymous(testName); + await test.modPage.logger('end of ', testName); + await test.modPage.stopRecording(); + screenshot = await test.modPage.page.screenshot(); + } catch (err) { + await test.modPage.logger(err); + } finally { + await closePages(test.modPage, test.userPage); + } + expect(response).toBe(true); + Page.checkRegression(0.9, screenshot); + }, TEST_DURATION_TIME); + // Check for Poll Results in chat message and return true when it appears test('Poll results in chat message', async () => { const test = new Poll(); diff --git a/bigbluebutton-tests/puppeteer/polling/util.js b/bigbluebutton-tests/puppeteer/polling/util.js index 14b3f15d6c..242855a3db 100644 --- a/bigbluebutton-tests/puppeteer/polling/util.js +++ b/bigbluebutton-tests/puppeteer/polling/util.js @@ -1,10 +1,11 @@ const e = require('../core/elements'); -async function startPoll(test, shouldPublishPoll = false) { +async function startPoll(test, shouldPublishPoll = false, isAnonymous = false) { await test.waitAndClick(e.actions); await test.waitAndClick(e.polling); await test.waitForSelector(e.hidePollDesc); await test.waitAndClick(e.pollYesNoAbstentionBtn); + if (isAnonymous) test.waitAndClickElement(e.anonymousPoll); await test.waitAndClick(e.startPoll); if (shouldPublishPoll) await test.waitAndClick(e.publishPollingLabel); } From 61f2745c7feb21bcc3e7dbf60eef0fae656c5934 Mon Sep 17 00:00:00 2001 From: Joao Victor Date: Fri, 22 Oct 2021 09:13:33 -0300 Subject: [PATCH 05/31] fix: unable to mute from talking indicator bar --- .../ui/components/nav-bar/talking-indicator/component.jsx | 3 +-- .../ui/components/nav-bar/talking-indicator/container.jsx | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/nav-bar/talking-indicator/component.jsx b/bigbluebutton-html5/imports/ui/components/nav-bar/talking-indicator/component.jsx index f1e5a391d8..07a6bca242 100644 --- a/bigbluebutton-html5/imports/ui/components/nav-bar/talking-indicator/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/nav-bar/talking-indicator/component.jsx @@ -56,7 +56,6 @@ class TalkingIndicator extends PureComponent { const { talking, color, - voiceUserId, muted, callerName, } = talkers[`${id}`]; @@ -82,7 +81,7 @@ class TalkingIndicator extends PureComponent {