From 9fd1c5b7463b4eb71626133a9d24e2eaa7e9e04f Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 30 Jul 2024 15:48:13 +0200 Subject: [PATCH] ov-components: Fixed webcomponent directives e2e tests --- openvidu-components-angular/e2e/config.ts | 2 +- .../e2e/selenium.conf.ts | 2 +- .../e2e/webcomponent-app/app.js | 17 +-- .../webcomponent-e2e/api-directives.test.ts | 113 +++--------------- 4 files changed, 18 insertions(+), 116 deletions(-) diff --git a/openvidu-components-angular/e2e/config.ts b/openvidu-components-angular/e2e/config.ts index 612e0948..8b1fffc0 100644 --- a/openvidu-components-angular/e2e/config.ts +++ b/openvidu-components-angular/e2e/config.ts @@ -1,3 +1,3 @@ export const LAUNCH_MODE = process.env.LAUNCH_MODE || 'DEV'; -export const OPENVIDU_CALL_SERVER = process.env.OPENVIDU_CALL_SERVER || 'http://localhost:5000'; +export const OPENVIDU_CALL_SERVER = process.env.OPENVIDU_CALL_SERVER || 'http://localhost:6080'; diff --git a/openvidu-components-angular/e2e/selenium.conf.ts b/openvidu-components-angular/e2e/selenium.conf.ts index 9446b444..2ac48122 100644 --- a/openvidu-components-angular/e2e/selenium.conf.ts +++ b/openvidu-components-angular/e2e/selenium.conf.ts @@ -48,7 +48,7 @@ const chromeArgumentsWithoutMediaDevicesCI = [ export const WebComponentConfig: BrowserConfig = { appUrl: 'http://localhost:8080/', - seleniumAddress: LAUNCH_MODE === 'CI' ? 'http://localhost:3000/webdriver' : '', + seleniumAddress: LAUNCH_MODE === 'CI' ? 'http://localhost:4444/wd/hub' : '', browserName: 'chrome', browserCapabilities: Capabilities.chrome().set('acceptInsecureCerts', true), browserOptions: new chrome.Options().addArguments(...(LAUNCH_MODE === 'CI' ? chromeArgumentsCI : chromeArguments)) diff --git a/openvidu-components-angular/e2e/webcomponent-app/app.js b/openvidu-components-angular/e2e/webcomponent-app/app.js index 946010af..0064dfa7 100644 --- a/openvidu-components-angular/e2e/webcomponent-app/app.js +++ b/openvidu-components-angular/e2e/webcomponent-app/app.js @@ -25,8 +25,6 @@ var PARTICIPANT_MUTE_BUTTON; var PARTICIPANTS_PANEL_BUTTON; var ACTIVITIES_RECORDING_ACTIVITY; var ACTIVITIES_BROADCASTING_ACTIVITY; -var RECORDING_ERROR; -var BROADCASTING_ERROR; var TOOLBAR_SETTINGS_BUTTON; var CAPTIONS_BUTTON; @@ -37,13 +35,11 @@ var FAKE_RECORDINGS; var PARTICIPANT_NAME; var OPENVIDU_CALL_SERVER_URL; -// var OPENVIDU_SECRET; document.addEventListener('DOMContentLoaded', () => { var url = new URL(window.location.href); - OPENVIDU_CALL_SERVER_URL = url.searchParams.get('OV_URL'); - // OPENVIDU_SECRET = url.searchParams.get('OV_SECRET'); + OPENVIDU_CALL_SERVER_URL = url.searchParams.get('OPENVIDU_CALL_SERVER_URL') || 'http://localhost:6080'; FAKE_DEVICES = url.searchParams.get('fakeDevices') === null ? false : url.searchParams.get('fakeDevices') === 'true'; @@ -69,10 +65,6 @@ document.addEventListener('DOMContentLoaded', () => { BROADCASTING_BUTTON = url.searchParams.get('toolbarBroadcastingButton') === null ? true : url.searchParams.get('toolbarBroadcastingButton') === 'true'; - if (url.searchParams.get('broadcastingError') !== null) { - BROADCASTING_ERROR = url.searchParams.get('broadcastingError'); - } - TOOLBAR_SETTINGS_BUTTON = url.searchParams.get('toolbarSettingsBtn') === null ? true : url.searchParams.get('toolbarSettingsBtn') === 'true'; CAPTIONS_BUTTON = url.searchParams.get('toolbarCaptionsBtn') === null ? true : url.searchParams.get('toolbarCaptionsBtn') === 'true'; @@ -91,9 +83,6 @@ document.addEventListener('DOMContentLoaded', () => { url.searchParams.get('activitiesPanelRecordingActivity') === null ? true : url.searchParams.get('activitiesPanelRecordingActivity') === 'true'; - if (url.searchParams.get('recordingError') !== null) { - RECORDING_ERROR = url.searchParams.get('recordingError'); - } DISPLAY_LOGO = url.searchParams.get('displayLogo') === null ? true : url.searchParams.get('displayLogo') === 'true'; DISPLAY_ROOM_NAME = url.searchParams.get('displayRoomName') === null ? true : url.searchParams.get('displayRoomName') === 'true'; @@ -217,9 +206,6 @@ function setWebcomponentAttributes() { webComponent.recordingActivityRecordingsList = [{ status: 'ready', filename: 'fakeRecording' }]; } - if (BROADCASTING_ERROR) { - webComponent.broadcastingActivityBroadcastingError = { message: BROADCASTING_ERROR, broadcastAvailable: true }; - } webComponent.prejoin = PREJOIN; webComponent.videoEnabled = VIDEO_ENABLED; webComponent.audioEnabled = AUDIO_ENABLED; @@ -243,7 +229,6 @@ function setWebcomponentAttributes() { webComponent.activitiesPanelRecordingActivity = ACTIVITIES_RECORDING_ACTIVITY; webComponent.activitiesPanelBroadcastingActivity = ACTIVITIES_BROADCASTING_ACTIVITY; - webComponent.recordingActivityRecordingError = RECORDING_ERROR; } function appendElement(id) { diff --git a/openvidu-components-angular/e2e/webcomponent-e2e/api-directives.test.ts b/openvidu-components-angular/e2e/webcomponent-e2e/api-directives.test.ts index 21717968..a572424f 100644 --- a/openvidu-components-angular/e2e/webcomponent-e2e/api-directives.test.ts +++ b/openvidu-components-angular/e2e/webcomponent-e2e/api-directives.test.ts @@ -224,18 +224,17 @@ describe('Testing API Directives', () => { await utils.checkPrejoinIsPresent(); // Checking if video is displayed - expect(await utils.getNumberOfElements('video')).equals(1); - - // Checking if virtual background button is disabled - // const button = await utils.waitForElement('#background-effects-btn'); - // expect(await button.isEnabled()).to.be.false; + await utils.waitForElement('#video-poster'); + expect(await utils.getNumberOfElements('video')).equals(0); await utils.waitForElement('#videocam_off'); + await utils.clickOn('#join-button'); await utils.checkSessionIsPresent(); - expect(await utils.getNumberOfElements('video')).equals(1); + await utils.waitForElement('#video-poster'); + expect(await utils.getNumberOfElements('video')).equals(0); await utils.waitForElement('#videocam_off'); expect(await utils.isPresent('#videocam_off')).to.be.true; @@ -249,7 +248,8 @@ describe('Testing API Directives', () => { await utils.checkLayoutPresent(); // Checking if video is displayed - expect(await utils.getNumberOfElements('video')).equals(1); + await utils.waitForElement('#video-poster'); + expect(await utils.getNumberOfElements('video')).equals(0); expect(await utils.getNumberOfElements('#video-poster')).equals(1); await utils.waitForElement('#videocam_off'); @@ -257,48 +257,38 @@ describe('Testing API Directives', () => { }); it('should run the app with AUDIO DISABLED in prejoin page', async () => { - // let isAudioEnabled; - // const script = 'return document.getElementsByTagName("video")[0].srcObject.getAudioTracks()[0].enabled;'; - await browser.get(`${url}&audioEnabled=false`); await utils.checkPrejoinIsPresent(); // Checking if video is displayed await utils.checkVideoElementIsPresent(); + expect(await utils.getNumberOfElements('video')).equals(1); - // Checking if audio track is disabled/muted - // isAudioEnabled = await browser.executeScript(script); - // expect(isAudioEnabled).to.be.false; - + expect(await utils.getNumberOfElements('audio')).equals(0); await utils.waitForElement('#mic_off'); expect(await utils.isPresent('#mic_off')).to.be.true; await utils.clickOn('#join-button'); await utils.checkSessionIsPresent(); - // isAudioEnabled = await browser.executeScript(script); - // expect(isAudioEnabled).to.be.false; + expect(await utils.getNumberOfElements('video')).equals(1); + expect(await utils.getNumberOfElements('audio')).equals(0); await utils.waitForElement('#mic_off'); expect(await utils.isPresent('#mic_off')).to.be.true; }); it('should run the app with AUDIO DISABLED and WITHOUT PREJOIN page', async () => { - // let isAudioEnabled; - // const audioEnableScript = 'return document.getElementsByTagName("video")[0].srcObject.getAudioTracks()[0].enabled;'; - await browser.get(`${url}&prejoin=false&audioEnabled=false`); await utils.checkSessionIsPresent(); // Checking if video is displayed await utils.checkVideoElementIsPresent(); + expect(await utils.getNumberOfElements('video')).equals(1); - // Checking if audio track is disabled/muted - // isAudioEnabled = await browser.executeScript(audioEnableScript); - // expect(isAudioEnabled).to.be.false; - + expect(await utils.getNumberOfElements('audio')).equals(0); await utils.waitForElement('#mic_off'); expect(await utils.isPresent('#mic_off')).to.be.true; }); @@ -327,7 +317,7 @@ describe('Testing API Directives', () => { expect(await utils.getNumberOfElements('#fullscreen-btn')).equals(0); }); - it('should HIDE the CAPTIONS button', async () => { + it.skip('should HIDE the CAPTIONS button', async () => { await browser.get(`${url}&prejoin=false&toolbarCaptionsBtn=false`); await utils.checkSessionIsPresent(); @@ -456,7 +446,7 @@ describe('Testing API Directives', () => { expect(await utils.isPresent('#branding-logo')).to.be.false; }); - it('should HIDE the SESSION NAME', async () => { + it('should HIDE the ROOM NAME', async () => { await browser.get(`${url}&prejoin=false&displayRoomName=false`); await utils.checkSessionIsPresent(); @@ -576,79 +566,6 @@ describe('Testing API Directives', () => { expect(await utils.isPresent('ov-recording-activity')).to.be.false; }); - it('should SHOW a RECORDING ERROR in activities panel', async () => { - let element; - const fixedUrl = `${url}&prejoin=false&recordingError=TEST_ERROR`; - await browser.get(fixedUrl); - - await utils.checkSessionIsPresent(); - - // Checking if toolbar is present - await utils.checkToolbarIsPresent(); - - element = await utils.waitForElement('#activities-panel-btn'); - await element.click(); - - // Checking if participatns panel is displayed - await utils.waitForElement('#default-activities-panel'); - expect(await utils.isPresent('#default-activities-panel')).to.be.true; - - // Checking if recording activity exists - await utils.waitForElement('#activities-container'); - await utils.waitForElement('.activities-body-container'); - - await utils.waitForElement('ov-recording-activity'); - expect(await utils.isPresent('ov-recording-activity')).to.be.true; - - await utils.waitForElement('.failed'); - expect(await utils.isPresent('.failed')).to.be.true; - - // Open recording - await browser.sleep(500); - await utils.waitForElement('ov-recording-activity'); - await utils.clickOn('ov-recording-activity'); - await browser.sleep(500); - element = await utils.waitForElement('.recording-error'); - expect(await element.getAttribute('innerText')).equal('"TEST_ERROR"'); - expect(await utils.isPresent('.recording-error')).to.be.true; - }); - - it('should SHOW a BROADCASTING ERROR in activities panel', async () => { - let element; - const fixedUrl = `${url}&prejoin=false&broadcastingError=TEST_ERROR`; - await browser.get(fixedUrl); - - await utils.checkSessionIsPresent(); - - // Checking if toolbar is present - await utils.checkToolbarIsPresent(); - - element = await utils.waitForElement('#activities-panel-btn'); - await element.click(); - - // Checking if participatns panel is displayed - await utils.waitForElement('#default-activities-panel'); - expect(await utils.isPresent('#default-activities-panel')).to.be.true; - - // Checking if broadcasting activity exists - await utils.waitForElement('#activities-container'); - await utils.waitForElement('.activities-body-container'); - - await utils.waitForElement('ov-broadcasting-activity'); - expect(await utils.isPresent('ov-broadcasting-activity')).to.be.true; - - const status = await utils.waitForElement('#broadcasting-status'); - expect(await status.getAttribute('innerText')).equals('FAILED'); - - // Open broadcasting - await browser.sleep(500); - await utils.clickOn('ov-broadcasting-activity'); - await browser.sleep(500); - - element = await utils.waitForElement('#broadcasting-error'); - expect(await element.getAttribute('innerText')).equal('TEST_ERROR'); - }); - it('should HIDE the BROADCASTING ACTIVITY in activities panel', async () => { await browser.get(`${url}&prejoin=false&activitiesPanelBroadcastingActivity=false`);