From dac9238fc17fa7f37484434dc2ab0f881c24c681 Mon Sep 17 00:00:00 2001 From: Anton B Date: Fri, 1 Mar 2024 13:43:48 -0300 Subject: [PATCH 1/6] test: fix parameter on layout tess --- .../playwright/core/fixtures.js | 29 +++++++++++++++++++ .../playwright/layouts/layouts.spec.js | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 bigbluebutton-tests/playwright/core/fixtures.js diff --git a/bigbluebutton-tests/playwright/core/fixtures.js b/bigbluebutton-tests/playwright/core/fixtures.js new file mode 100644 index 0000000000..631d9f751a --- /dev/null +++ b/bigbluebutton-tests/playwright/core/fixtures.js @@ -0,0 +1,29 @@ +const base = require('@playwright/test'); +const { fullyParallel } = require('../playwright.config'); +const { initializePages } = require('./helpers'); + +module.exports = base.test.extend({ + sharedBeforeAll: [ async ({}, use) => { + console.log('Before All'); + if (!fullyParallel) { + const { context } = await initializePages(chat, browser, { isMultiUser: true }); + testContext = context; + } + await use(); + console.log('After All'); + }, { scope: 'worker', auto: true } ], + + sharedBeforeEach: [ async ({ context }, use) => { + if (fullyParallel) { + const { context: innerContext } = await initializePages(chat, browser, { isMultiUser: true }); + testContext = innerContext; + } + console.log('Before Each'); + await use(); + if (fullyParallel) { + console.log(`contexts size: ${context.browser.contexts().length}`) + await context.browser.contexts()[0].close(); + } + console.log('After Each'); + }, { scope: 'test', auto: true } ], +}); diff --git a/bigbluebutton-tests/playwright/layouts/layouts.spec.js b/bigbluebutton-tests/playwright/layouts/layouts.spec.js index b2e4af44a4..48ef95635a 100644 --- a/bigbluebutton-tests/playwright/layouts/layouts.spec.js +++ b/bigbluebutton-tests/playwright/layouts/layouts.spec.js @@ -12,7 +12,7 @@ test.describe("Layout management", () => { test.describe.configure({ mode: fullyParallel ? 'parallel' : 'serial' }); test[fullyParallel ? 'beforeEach' : 'beforeAll'](async ({ browser }) => { - await initializePages(layouts, browser, true, { isMultiUser: true, createParameter: hidePresentationToast }); + await initializePages(layouts, browser, { isMultiUser: true, createParameter: hidePresentationToast }); await layouts.modPage.shareWebcam(); await layouts.userPage.shareWebcam(); }); From 7c4446560f79d43eb6e0b530399b87a4294a4cda Mon Sep 17 00:00:00 2001 From: Anton B Date: Fri, 1 Mar 2024 13:44:46 -0300 Subject: [PATCH 2/6] test: fix logout meeting function --- .../ui/components/nav-bar/leave-meeting-button/component.jsx | 2 +- .../ui/components/nav-bar/options-dropdown/component.jsx | 2 +- bigbluebutton-tests/playwright/core/elements.js | 3 ++- bigbluebutton-tests/playwright/core/page.js | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/nav-bar/leave-meeting-button/component.jsx b/bigbluebutton-html5/imports/ui/components/nav-bar/leave-meeting-button/component.jsx index 8c6f1e9379..f78b11c472 100644 --- a/bigbluebutton-html5/imports/ui/components/nav-bar/leave-meeting-button/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/nav-bar/leave-meeting-button/component.jsx @@ -93,7 +93,7 @@ class LeaveMeetingButton extends PureComponent { this.menuItems.push( { key: 'list-item-logout', - dataTest: 'logoutButton', + dataTest: 'directLogoutButton', icon: 'logout', label: intl.formatMessage(intlMessages.leaveSessionLabel), description: intl.formatMessage(intlMessages.leaveSessionDesc), diff --git a/bigbluebutton-html5/imports/ui/components/nav-bar/options-dropdown/component.jsx b/bigbluebutton-html5/imports/ui/components/nav-bar/options-dropdown/component.jsx index 43113f6b0c..ed3cd68d1e 100644 --- a/bigbluebutton-html5/imports/ui/components/nav-bar/options-dropdown/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/nav-bar/options-dropdown/component.jsx @@ -359,7 +359,7 @@ class OptionsDropdown extends PureComponent { if (allowLogoutSetting) { bottomItems.push({ key: 'list-item-logout', - dataTest: 'logout', + dataTest: 'optionsLogoutButton', icon: 'logout', label: intl.formatMessage(intlMessages.leaveSessionLabel), description: intl.formatMessage(intlMessages.leaveSessionDesc), diff --git a/bigbluebutton-tests/playwright/core/elements.js b/bigbluebutton-tests/playwright/core/elements.js index 1900e16644..0896558ce7 100644 --- a/bigbluebutton-tests/playwright/core/elements.js +++ b/bigbluebutton-tests/playwright/core/elements.js @@ -17,7 +17,8 @@ exports.lowerHandBtn = 'div[data-test="lowerHandBtn"]'; exports.raiseHandRejection = 'button[data-test="raiseHandRejection"]'; exports.meetingEndedModal = 'div[data-test="meetingEndedModal"]'; exports.leaveMeetingDropdown = 'button[data-test="leaveMeetingDropdown"]'; -exports.logoutBtn = 'li[data-test="logoutButton"]'; +exports.directLogoutButton = 'li[data-test="directLogoutButton"]'; +exports.optionsLogoutButton = 'li[data-test="optionsLogoutButton"]'; exports.rating = 'div[data-test="rating"]'; exports.errorScreenMessage = 'h1[data-test="errorScreenMessage"]'; exports.errorMessageLabel = 'span[id="error-message"]'; diff --git a/bigbluebutton-tests/playwright/core/page.js b/bigbluebutton-tests/playwright/core/page.js index 87d8ebc059..137b8228a1 100644 --- a/bigbluebutton-tests/playwright/core/page.js +++ b/bigbluebutton-tests/playwright/core/page.js @@ -92,10 +92,11 @@ class Page { if (directLeaveButton) { await this.waitAndClick(e.leaveMeetingDropdown); + await this.waitAndClick(e.directLogoutButton); } else { await this.waitAndClick(e.optionsButton); + await this.waitAndClick(e.optionsLogoutButton); } - await this.waitAndClick(e.logoutBtn); } async shareWebcam(shouldConfirmSharing = true, videoPreviewTimeout = ELEMENT_WAIT_TIME) { From 24ff4d2a502130715cf5151e6edcae7c115e0953 Mon Sep 17 00:00:00 2001 From: Anton B Date: Tue, 5 Mar 2024 15:57:16 -0300 Subject: [PATCH 3/6] test: always keep trace viewer and remove DEBUG_MODE env variable --- bigbluebutton-tests/playwright/.env.template | 1 - bigbluebutton-tests/playwright/playwright.config.js | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/bigbluebutton-tests/playwright/.env.template b/bigbluebutton-tests/playwright/.env.template index 2e5e961387..ce22bed4f6 100644 --- a/bigbluebutton-tests/playwright/.env.template +++ b/bigbluebutton-tests/playwright/.env.template @@ -2,5 +2,4 @@ BBB_URL="" # https://DOMAIN_NAME/bigbluebutton/api BBB_SECRET="" -DEBUG_MODE="" # (true / false|empty) Enable or disable debug features TIMEOUT_MULTIPLIER=1 # (number / empty) Apply a multiplier on default timeouts - depending the server strength (not recommended to use greater values than 3) diff --git a/bigbluebutton-tests/playwright/playwright.config.js b/bigbluebutton-tests/playwright/playwright.config.js index 2e997b8cb4..f4a6ad59eb 100644 --- a/bigbluebutton-tests/playwright/playwright.config.js +++ b/bigbluebutton-tests/playwright/playwright.config.js @@ -3,7 +3,6 @@ const { chromiumConfig, firefoxConfig, webkitConfig } = require('./core/browsers const { ELEMENT_WAIT_TIME } = require('./core/constants'); const CI = process.env.CI === 'true'; -const DEBUG_MODE = process.env.DEBUG_MODE === 'true'; const config = { workers: CI ? 1 : 2, @@ -16,9 +15,7 @@ const config = { fullyParallel: CI, use: { headless: true, - trace: DEBUG_MODE ? 'on' - : CI ? 'retain-on-failure' - : 'off', + trace: 'on', screenshot: 'on', video: 'on', }, From 712e12283b906db13019ea645881f99dbbd5476c Mon Sep 17 00:00:00 2001 From: Anton B Date: Wed, 6 Mar 2024 11:26:03 -0300 Subject: [PATCH 4/6] test: add an auto-run global hook for each test to close the context used at the end of the execution and dinamically set the context property in the Page object --- bigbluebutton-tests/playwright/api/api.spec.js | 2 +- .../playwright/audio/audio.spec.js | 2 +- .../playwright/breakout/breakout.spec.js | 2 +- bigbluebutton-tests/playwright/chat/chat.js | 4 ++-- bigbluebutton-tests/playwright/chat/chat.spec.js | 10 ++++------ .../connectionFailure/connectionFailure.spec.js | 5 ++--- .../connectionStatus/connectionStatus.spec.js | 2 +- bigbluebutton-tests/playwright/core/helpers.js | 4 ---- bigbluebutton-tests/playwright/core/page.js | 1 + bigbluebutton-tests/playwright/fixtures.js | 15 +++++++++++++++ .../playwright/layouts/layouts.spec.js | 2 +- .../learningdashboard/learningdashboard.spec.js | 2 +- .../notifications/notifications.spec.js | 2 +- bigbluebutton-tests/playwright/options/options.js | 4 ++-- .../playwright/options/options.spec.js | 8 +++----- .../playwright/parameters/parameters.spec.js | 2 +- .../playwright/polling/polling.spec.js | 2 +- .../playwright/presentation/presentation.spec.js | 2 +- .../playwright/reconnection/reconnection.spec.js | 2 +- .../playwright/screenshare/screenshare.spec.js | 3 ++- .../playwright/sharednotes/sharednotes.spec.js | 2 +- .../playwright/stress/stress.spec.js | 2 +- bigbluebutton-tests/playwright/user/user.spec.js | 3 ++- .../virtualizedlist/virtualizedlist.spec.js | 2 +- .../playwright/webcam/webcam.spec.js | 2 +- .../playwright/whiteboard/whiteboard.spec.js | 2 +- 26 files changed, 49 insertions(+), 40 deletions(-) create mode 100644 bigbluebutton-tests/playwright/fixtures.js diff --git a/bigbluebutton-tests/playwright/api/api.spec.js b/bigbluebutton-tests/playwright/api/api.spec.js index f8b05e252f..8098f50bb5 100644 --- a/bigbluebutton-tests/playwright/api/api.spec.js +++ b/bigbluebutton-tests/playwright/api/api.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { API } = require('./api.js'); const { APIBreakout } = require('./breakout.js'); diff --git a/bigbluebutton-tests/playwright/audio/audio.spec.js b/bigbluebutton-tests/playwright/audio/audio.spec.js index 732f399b42..c18af965d0 100644 --- a/bigbluebutton-tests/playwright/audio/audio.spec.js +++ b/bigbluebutton-tests/playwright/audio/audio.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { fullyParallel } = require('../playwright.config'); const { Audio } = require('./audio'); const { initializePages } = require('../core/helpers'); diff --git a/bigbluebutton-tests/playwright/breakout/breakout.spec.js b/bigbluebutton-tests/playwright/breakout/breakout.spec.js index 698760bcef..12a9983bb2 100644 --- a/bigbluebutton-tests/playwright/breakout/breakout.spec.js +++ b/bigbluebutton-tests/playwright/breakout/breakout.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { Create } = require('./create'); const { Join } = require('./join'); diff --git a/bigbluebutton-tests/playwright/chat/chat.js b/bigbluebutton-tests/playwright/chat/chat.js index c95631fd7f..ee36de6abb 100644 --- a/bigbluebutton-tests/playwright/chat/chat.js +++ b/bigbluebutton-tests/playwright/chat/chat.js @@ -66,7 +66,7 @@ class Chat extends MultiUsers { await this.modPage.hasText(e.chatUserMessageText, 'The public chat history was cleared by a moderator'); } - async copyChat(context) { + async copyChat() { const { publicChatOptionsEnabled } = getSettings(); await openPublicChat(this.modPage); @@ -85,7 +85,7 @@ class Chat extends MultiUsers { await this.modPage.waitForSelector(e.chatUserMessageText); await this.modPage.waitAndClick(e.chatCopy); // enable access to browser context clipboard - const copiedText = await this.modPage.getCopiedText(context); + const copiedText = await this.modPage.getCopiedText(this.modPage.context); const check = copiedText.includes(`${p.fullName}: ${e.message}`); await expect(check).toBeTruthy(); } diff --git a/bigbluebutton-tests/playwright/chat/chat.spec.js b/bigbluebutton-tests/playwright/chat/chat.spec.js index 0d63de8c3a..0f796fee17 100644 --- a/bigbluebutton-tests/playwright/chat/chat.spec.js +++ b/bigbluebutton-tests/playwright/chat/chat.spec.js @@ -1,16 +1,14 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { fullyParallel } = require('../playwright.config'); const { linkIssue, initializePages } = require('../core/helpers'); const { Chat } = require('./chat'); test.describe('Chat', () => { const chat = new Chat(); - let context; test.describe.configure({ mode: fullyParallel ? 'parallel' : 'serial' }); test[fullyParallel ? 'beforeEach' : 'beforeAll'](async ({ browser }) => { - const { context: innerContext } = await initializePages(chat, browser, { isMultiUser: true }); - context = innerContext; + await initializePages(chat, browser, { isMultiUser: true }); }); // https://docs.bigbluebutton.org/2.6/release-tests.html#public-message-automated @@ -28,7 +26,7 @@ test.describe('Chat', () => { }); test.skip('Copy chat', async () => { - await chat.copyChat(context); + await chat.copyChat(); }); test('Save chat @ci', async ({}, testInfo) => { @@ -78,7 +76,7 @@ test.describe('Chat', () => { await chat.autoConvertEmojiCopyChat(); }); - test('Auto convert emoji save chat', async ({ context }, testInfo) => { + test('Auto convert emoji save chat', async ({}, testInfo) => { await chat.autoConvertEmojiSaveChat(testInfo); }); diff --git a/bigbluebutton-tests/playwright/connectionFailure/connectionFailure.spec.js b/bigbluebutton-tests/playwright/connectionFailure/connectionFailure.spec.js index ed51ae9494..6c09d4dbdf 100644 --- a/bigbluebutton-tests/playwright/connectionFailure/connectionFailure.spec.js +++ b/bigbluebutton-tests/playwright/connectionFailure/connectionFailure.spec.js @@ -1,9 +1,8 @@ -const { test, devices } = require('@playwright/test'); +const { test } = require('../fixtures'); const { ScreenShare, MultiUserScreenShare } = require('../screenshare/screenshare'); -const { sleep, checkRootPermission } = require('../core/helpers'); +const { checkRootPermission } = require('../core/helpers'); const e = require('../core/elements'); const { getCurrentTCPSessions, killTCPSessions } = require('./util'); -const notificationsUtil = require('../notifications/util'); const deepEqual = require('deep-equal'); test.describe.parallel('Connection failure', () => { diff --git a/bigbluebutton-tests/playwright/connectionStatus/connectionStatus.spec.js b/bigbluebutton-tests/playwright/connectionStatus/connectionStatus.spec.js index 151349a2c5..fd03fab255 100644 --- a/bigbluebutton-tests/playwright/connectionStatus/connectionStatus.spec.js +++ b/bigbluebutton-tests/playwright/connectionStatus/connectionStatus.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { ConnectionStatus } = require('./connectionStatus'); test.describe.parallel('Connection Status', () => { diff --git a/bigbluebutton-tests/playwright/core/helpers.js b/bigbluebutton-tests/playwright/core/helpers.js index 700ae53c6d..4cff6d8039 100644 --- a/bigbluebutton-tests/playwright/core/helpers.js +++ b/bigbluebutton-tests/playwright/core/helpers.js @@ -168,10 +168,6 @@ async function initializePages(testInstance, browser, initOptions) { const page = await context.newPage(); await testInstance.initModPage(page, true, { createParameter, joinParameter }); if (isMultiUser) await testInstance.initUserPage(true, context, { createParameter, joinParameter }); - - return { - context, - }; } exports.getRandomInt = getRandomInt; diff --git a/bigbluebutton-tests/playwright/core/page.js b/bigbluebutton-tests/playwright/core/page.js index 137b8228a1..61f4b6da34 100644 --- a/bigbluebutton-tests/playwright/core/page.js +++ b/bigbluebutton-tests/playwright/core/page.js @@ -13,6 +13,7 @@ const { generateSettingsData, getSettings } = require('./settings'); class Page { constructor(browser, page) { this.browser = browser; + this.context = page.context(); this.page = page; this.initParameters = Object.assign({}, parameters); } diff --git a/bigbluebutton-tests/playwright/fixtures.js b/bigbluebutton-tests/playwright/fixtures.js new file mode 100644 index 0000000000..fcc7fb4b4f --- /dev/null +++ b/bigbluebutton-tests/playwright/fixtures.js @@ -0,0 +1,15 @@ +const base = require('@playwright/test'); +const { fullyParallel } = require('./playwright.config'); + +exports.test = base.test.extend({ + sharedEachTestHook: [ async ({ browser }, use) => { + // before test + await use(); + // after test + if (fullyParallel) { + while (browser.contexts().length > 0) { + await browser.contexts()[0].close(); + } + } + }, { scope: 'test', auto: true }], +}); diff --git a/bigbluebutton-tests/playwright/layouts/layouts.spec.js b/bigbluebutton-tests/playwright/layouts/layouts.spec.js index 48ef95635a..9db0776680 100644 --- a/bigbluebutton-tests/playwright/layouts/layouts.spec.js +++ b/bigbluebutton-tests/playwright/layouts/layouts.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { fullyParallel } = require('../playwright.config'); const { encodeCustomParams } = require('../parameters/util'); const { PARAMETER_HIDE_PRESENTATION_TOAST } = require('../core/constants'); diff --git a/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js b/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js index 470c84010b..e98ac77f53 100644 --- a/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js +++ b/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { fullyParallel } = require('../playwright.config'); const { LearningDashboard } = require('./learningdashboard'); const c = require('../parameters/constants'); diff --git a/bigbluebutton-tests/playwright/notifications/notifications.spec.js b/bigbluebutton-tests/playwright/notifications/notifications.spec.js index 8fb60005af..71bde15efd 100644 --- a/bigbluebutton-tests/playwright/notifications/notifications.spec.js +++ b/bigbluebutton-tests/playwright/notifications/notifications.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { Notifications } = require('./notifications'); const { ChatNotifications } = require('./chatNotifications'); const { PresenterNotifications } = require('./presenterNotifications'); diff --git a/bigbluebutton-tests/playwright/options/options.js b/bigbluebutton-tests/playwright/options/options.js index ba81fd5de2..fc3a655ba7 100644 --- a/bigbluebutton-tests/playwright/options/options.js +++ b/bigbluebutton-tests/playwright/options/options.js @@ -16,9 +16,9 @@ class Options extends MultiUsers { await this.modPage.waitAndClick(e.closeModal); } - async openHelp(context) { + async openHelp() { await this.modPage.waitAndClick(e.optionsButton); - const newPage = await this.modPage.handleNewTab(e.helpButton, context); + const newPage = await this.modPage.handleNewTab(e.helpButton, this.modPage.context); await expect(newPage).toHaveTitle(/Tutorials/); await newPage.close(); await this.modPage.hasElement(e.whiteboard); diff --git a/bigbluebutton-tests/playwright/options/options.spec.js b/bigbluebutton-tests/playwright/options/options.spec.js index f73dee0056..57e0e8af33 100644 --- a/bigbluebutton-tests/playwright/options/options.spec.js +++ b/bigbluebutton-tests/playwright/options/options.spec.js @@ -1,16 +1,14 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { fullyParallel } = require('../playwright.config'); const { Options } = require('./options'); const { initializePages } = require('../core/helpers'); test.describe('Options', () => { const options = new Options(); - let context; test.describe.configure({ mode: fullyParallel ? 'parallel' : 'serial' }); test[fullyParallel ? 'beforeEach' : 'beforeAll'](async ({ browser }) => { - const { context: innerContext } = await initializePages(options, browser); - context = innerContext; + await initializePages(options, browser); }); test('Open about modal', async () => { @@ -18,7 +16,7 @@ test.describe('Options', () => { }); test('Open Help Button', async () => { - await options.openHelp(context); + await options.openHelp(); }); test('Locales test', async () => { diff --git a/bigbluebutton-tests/playwright/parameters/parameters.spec.js b/bigbluebutton-tests/playwright/parameters/parameters.spec.js index 2a1161fc7f..04fd009896 100644 --- a/bigbluebutton-tests/playwright/parameters/parameters.spec.js +++ b/bigbluebutton-tests/playwright/parameters/parameters.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { CustomParameters } = require('./customparameters'); const { DisabledFeatures } = require('./disabledFeatures'); const c = require('./constants'); diff --git a/bigbluebutton-tests/playwright/polling/polling.spec.js b/bigbluebutton-tests/playwright/polling/polling.spec.js index fb6dba3abc..bddde2de5d 100644 --- a/bigbluebutton-tests/playwright/polling/polling.spec.js +++ b/bigbluebutton-tests/playwright/polling/polling.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { fullyParallel } = require('../playwright.config'); const { Polling } = require('./poll'); const { initializePages } = require('../core/helpers'); diff --git a/bigbluebutton-tests/playwright/presentation/presentation.spec.js b/bigbluebutton-tests/playwright/presentation/presentation.spec.js index c30b649097..e47501302f 100644 --- a/bigbluebutton-tests/playwright/presentation/presentation.spec.js +++ b/bigbluebutton-tests/playwright/presentation/presentation.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { encodeCustomParams } = require('../parameters/util'); const { Presentation } = require('./presentation'); const { linkIssue } = require('../core/helpers'); diff --git a/bigbluebutton-tests/playwright/reconnection/reconnection.spec.js b/bigbluebutton-tests/playwright/reconnection/reconnection.spec.js index 2d328e0853..9e8f6da00a 100644 --- a/bigbluebutton-tests/playwright/reconnection/reconnection.spec.js +++ b/bigbluebutton-tests/playwright/reconnection/reconnection.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { Reconnection } = require('./reconnection'); const { checkRootPermission } = require('../core/helpers'); diff --git a/bigbluebutton-tests/playwright/screenshare/screenshare.spec.js b/bigbluebutton-tests/playwright/screenshare/screenshare.spec.js index e92e104107..b6c66fc621 100644 --- a/bigbluebutton-tests/playwright/screenshare/screenshare.spec.js +++ b/bigbluebutton-tests/playwright/screenshare/screenshare.spec.js @@ -1,4 +1,5 @@ -const { test, devices } = require('@playwright/test'); +const { test } = require('../fixtures'); +const { devices } = require('@playwright/test'); const { ScreenShare } = require('./screenshare'); test.describe.parallel('Screenshare', () => { diff --git a/bigbluebutton-tests/playwright/sharednotes/sharednotes.spec.js b/bigbluebutton-tests/playwright/sharednotes/sharednotes.spec.js index 198928ef34..512ac9bac0 100644 --- a/bigbluebutton-tests/playwright/sharednotes/sharednotes.spec.js +++ b/bigbluebutton-tests/playwright/sharednotes/sharednotes.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { SharedNotes } = require('./sharednotes'); const { initializePages } = require('../core/helpers'); const { fullyParallel } = require('../playwright.config'); diff --git a/bigbluebutton-tests/playwright/stress/stress.spec.js b/bigbluebutton-tests/playwright/stress/stress.spec.js index b0ccc77e61..db9e808bf0 100644 --- a/bigbluebutton-tests/playwright/stress/stress.spec.js +++ b/bigbluebutton-tests/playwright/stress/stress.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { Stress } = require('./stress.js'); test.describe.parallel('Stress', () => { diff --git a/bigbluebutton-tests/playwright/user/user.spec.js b/bigbluebutton-tests/playwright/user/user.spec.js index b7c0e83816..4642de92df 100644 --- a/bigbluebutton-tests/playwright/user/user.spec.js +++ b/bigbluebutton-tests/playwright/user/user.spec.js @@ -1,4 +1,5 @@ -const { test, devices } = require('@playwright/test'); +const { devices } = require('@playwright/test'); +const { test } = require('../fixtures'); const { Status } = require('./status'); const { MultiUsers } = require('./multiusers'); const { GuestPolicy } = require('./guestPolicy'); diff --git a/bigbluebutton-tests/playwright/virtualizedlist/virtualizedlist.spec.js b/bigbluebutton-tests/playwright/virtualizedlist/virtualizedlist.spec.js index 084e51ad40..ae8f72c0e6 100644 --- a/bigbluebutton-tests/playwright/virtualizedlist/virtualizedlist.spec.js +++ b/bigbluebutton-tests/playwright/virtualizedlist/virtualizedlist.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { VirtualizeList } = require('./virtualize'); test.describe.parallel('Virtualize list', () => { diff --git a/bigbluebutton-tests/playwright/webcam/webcam.spec.js b/bigbluebutton-tests/playwright/webcam/webcam.spec.js index 505acf44b1..18c081c79f 100644 --- a/bigbluebutton-tests/playwright/webcam/webcam.spec.js +++ b/bigbluebutton-tests/playwright/webcam/webcam.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { MultiUsers } = require('../user/multiusers'); const { Webcam } = require('./webcam'); diff --git a/bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.js b/bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.js index 14df6ab655..7778bb9c5d 100644 --- a/bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.js +++ b/bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.js @@ -1,4 +1,4 @@ -const { test } = require('@playwright/test'); +const { test } = require('../fixtures'); const { Draw } = require('./draw'); const { DrawRectangle } = require('./drawRectangle'); const { DrawEllipse } = require('./drawEllipse'); From e89950dc3e246fdf2994d7cdd68958d1381381e4 Mon Sep 17 00:00:00 2001 From: Anton B Date: Wed, 6 Mar 2024 11:32:19 -0300 Subject: [PATCH 5/6] test: remove file --- .../playwright/core/fixtures.js | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 bigbluebutton-tests/playwright/core/fixtures.js diff --git a/bigbluebutton-tests/playwright/core/fixtures.js b/bigbluebutton-tests/playwright/core/fixtures.js deleted file mode 100644 index 631d9f751a..0000000000 --- a/bigbluebutton-tests/playwright/core/fixtures.js +++ /dev/null @@ -1,29 +0,0 @@ -const base = require('@playwright/test'); -const { fullyParallel } = require('../playwright.config'); -const { initializePages } = require('./helpers'); - -module.exports = base.test.extend({ - sharedBeforeAll: [ async ({}, use) => { - console.log('Before All'); - if (!fullyParallel) { - const { context } = await initializePages(chat, browser, { isMultiUser: true }); - testContext = context; - } - await use(); - console.log('After All'); - }, { scope: 'worker', auto: true } ], - - sharedBeforeEach: [ async ({ context }, use) => { - if (fullyParallel) { - const { context: innerContext } = await initializePages(chat, browser, { isMultiUser: true }); - testContext = innerContext; - } - console.log('Before Each'); - await use(); - if (fullyParallel) { - console.log(`contexts size: ${context.browser.contexts().length}`) - await context.browser.contexts()[0].close(); - } - console.log('After Each'); - }, { scope: 'test', auto: true } ], -}); From 35c9b0f5091f019a48defd77b9f1da0bb91323da Mon Sep 17 00:00:00 2001 From: Anton B Date: Wed, 6 Mar 2024 17:11:17 -0300 Subject: [PATCH 6/6] test: handle error when iframe does not have context and fix learning dashboard tests --- bigbluebutton-tests/playwright/core/page.js | 7 ++++--- .../playwright/learningdashboard/learningdashboard.js | 6 +++--- .../learningdashboard/learningdashboard.spec.js | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bigbluebutton-tests/playwright/core/page.js b/bigbluebutton-tests/playwright/core/page.js index 61f4b6da34..4d2e49321e 100644 --- a/bigbluebutton-tests/playwright/core/page.js +++ b/bigbluebutton-tests/playwright/core/page.js @@ -1,21 +1,22 @@ require('dotenv').config(); const { expect, default: test } = require('@playwright/test'); const { readFileSync } = require('fs'); - const parameters = require('./parameters'); const helpers = require('./helpers'); const e = require('./elements'); const { env } = require('node:process'); const { ELEMENT_WAIT_TIME, ELEMENT_WAIT_LONGER_TIME, VIDEO_LOADING_WAIT_TIME } = require('./constants'); const { checkElement, checkElementLengthEqualTo } = require('./util'); -const { generateSettingsData, getSettings } = require('./settings'); +const { generateSettingsData } = require('./settings'); class Page { constructor(browser, page) { this.browser = browser; - this.context = page.context(); this.page = page; this.initParameters = Object.assign({}, parameters); + try { + this.context = page.context(); + } catch { } // page doesn't have context - likely an iframe } async bringToFront() { diff --git a/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.js b/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.js index 907bfd75aa..d64a0c1c86 100644 --- a/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.js +++ b/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.js @@ -13,16 +13,16 @@ class LearningDashboard extends MultiUsers { super(browser, context); } - async getDashboardPage(context) { + async getDashboardPage() { await this.modPage.waitAndClick(e.manageUsers); const [dashboardPage] = await Promise.all([ - context.waitForEvent('page'), + this.modPage.context.waitForEvent('page'), this.modPage.waitAndClick(e.learningDashboard), ]); await expect(dashboardPage).toHaveTitle(/Dashboard/); - this.dashboardPage = new Page(context, dashboardPage); + this.dashboardPage = new Page(this.modPage.context, dashboardPage); } async writeOnPublicChat() { diff --git a/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js b/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js index e98ac77f53..6ae18fc7c2 100644 --- a/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js +++ b/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.spec.js @@ -9,8 +9,8 @@ test.describe('Learning Dashboard', async () => { test.describe.configure({ mode: fullyParallel ? 'parallel' : 'serial' }); test[fullyParallel ? 'beforeEach' : 'beforeAll'](async ({ browser }) => { - const { context } = await initializePages(learningDashboard, browser, { createParameter: c.recordMeeting }); - await learningDashboard.getDashboardPage(context); + await initializePages(learningDashboard, browser, { createParameter: c.recordMeeting }); + await learningDashboard.getDashboardPage(); }); test('Check message', async() => { @@ -21,8 +21,8 @@ test.describe('Learning Dashboard', async () => { await learningDashboard.userTimeOnMeeting(); }); - test('Polls @ci', async ({ context }) => { - await learningDashboard.initUserPage(true, context, { isRecording: true }); + test('Polls @ci', async () => { + await learningDashboard.initUserPage(true, learningDashboard.modPage.context, { isRecording: true }); await learningDashboard.polls(); }); @@ -34,7 +34,7 @@ test.describe('Learning Dashboard', async () => { await learningDashboard.overview(); }); - test('Download Session Learning Dashboard @ci', async ({ context }, testInfo) => { + test('Download Session Learning Dashboard @ci', async ({}, testInfo) => { await learningDashboard.downloadSessionLearningDashboard(testInfo); }); });