From 75d657660369500ae36a2badcc241fcb69225f11 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 20 May 2025 12:38:20 +0200 Subject: [PATCH] ov-components: add end-to-end tests for API directives and implement leaveRoom utility function --- .../api-directives.test.ts | 27 ++++++++++--------- .../e2e/selenium.conf.ts | 9 +++++++ .../e2e/utils.po.test.ts | 7 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) rename openvidu-components-angular/e2e/{webcomponent-e2e => }/api-directives.test.ts (96%) diff --git a/openvidu-components-angular/e2e/webcomponent-e2e/api-directives.test.ts b/openvidu-components-angular/e2e/api-directives.test.ts similarity index 96% rename from openvidu-components-angular/e2e/webcomponent-e2e/api-directives.test.ts rename to openvidu-components-angular/e2e/api-directives.test.ts index 9fcfa5b9..c1d484b6 100644 --- a/openvidu-components-angular/e2e/webcomponent-e2e/api-directives.test.ts +++ b/openvidu-components-angular/e2e/api-directives.test.ts @@ -1,19 +1,18 @@ import { Builder, WebDriver } from 'selenium-webdriver'; -import { OPENVIDU_CALL_SERVER } from '../config'; -import { WebComponentConfig } from '../selenium.conf'; -import { OpenViduComponentsPO } from '../utils.po.test'; +import { TestAppConfig } from './selenium.conf'; +import { OpenViduComponentsPO } from './utils.po.test'; -const url = `${WebComponentConfig.appUrl}?OV_URL=${OPENVIDU_CALL_SERVER}`; +const url = TestAppConfig.appUrl; describe('Testing API Directives', () => { let browser: WebDriver; let utils: OpenViduComponentsPO; async function createChromeBrowser(): Promise { return await new Builder() - .forBrowser(WebComponentConfig.browserName) - .withCapabilities(WebComponentConfig.browserCapabilities) - .setChromeOptions(WebComponentConfig.browserOptions) - .usingServer(WebComponentConfig.seleniumAddress) + .forBrowser(TestAppConfig.browserName) + .withCapabilities(TestAppConfig.browserCapabilities) + .setChromeOptions(TestAppConfig.browserOptions) + .usingServer(TestAppConfig.seleniumAddress) .build(); } @@ -24,6 +23,10 @@ describe('Testing API Directives', () => { afterEach(async () => { // console.log('data:image/png;base64,' + await browser.takeScreenshot()); + try { + // leaving room if connected + await utils.leaveRoom(); + } catch (error) {} await browser.quit(); }); @@ -292,7 +295,7 @@ describe('Testing API Directives', () => { expect(await utils.isPresent('#mic_off')).toBeTrue(); }); - it('should run the app without camera button' , async () => { + it('should run the app without camera button', async () => { await browser.get(`${url}&prejoin=false&cameraBtn=false`); await utils.checkSessionIsPresent(); @@ -304,7 +307,7 @@ describe('Testing API Directives', () => { expect(await utils.isPresent('#camera-btn')).toBeFalse(); }); - it('should run the app without microphone button' , async () => { + it('should run the app without microphone button', async () => { await browser.get(`${url}&prejoin=falseµphoneBtn=false`); await utils.checkSessionIsPresent(); @@ -316,7 +319,6 @@ describe('Testing API Directives', () => { expect(await utils.isPresent('#microphone-btn')).toBeFalse(); }); - it('should HIDE the SCREENSHARE button', async () => { await browser.get(`${url}&prejoin=false&screenshareBtn=false`); @@ -552,8 +554,9 @@ describe('Testing API Directives', () => { expect(await utils.isPresent('#remote-participant-item')).toBeFalse(); // Starting new browser for adding a new participant - const newTabScript = `window.open("${fixedUrl}")`; + const newTabScript = `window.open("${fixedUrl}&participantName=SecondParticipant")`; await browser.executeScript(newTabScript); + await browser.sleep(10000); // Go to first tab const tabs = await browser.getAllWindowHandles(); diff --git a/openvidu-components-angular/e2e/selenium.conf.ts b/openvidu-components-angular/e2e/selenium.conf.ts index 2ac48122..950d28b7 100644 --- a/openvidu-components-angular/e2e/selenium.conf.ts +++ b/openvidu-components-angular/e2e/selenium.conf.ts @@ -54,6 +54,15 @@ export const WebComponentConfig: BrowserConfig = { browserOptions: new chrome.Options().addArguments(...(LAUNCH_MODE === 'CI' ? chromeArgumentsCI : chromeArguments)) }; + +export const TestAppConfig: BrowserConfig = { + appUrl: 'http://localhost:4200/#/call?staticVideos=false', + 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)) +}; + export const NestedConfig: BrowserConfig = { appUrl: 'http://localhost:4200/#/testing', seleniumAddress: LAUNCH_MODE === 'CI' ? 'http://localhost:4444/wd/hub' : '', diff --git a/openvidu-components-angular/e2e/utils.po.test.ts b/openvidu-components-angular/e2e/utils.po.test.ts index 2df9b162..f65af1ed 100644 --- a/openvidu-components-angular/e2e/utils.po.test.ts +++ b/openvidu-components-angular/e2e/utils.po.test.ts @@ -136,6 +136,13 @@ export class OpenViduComponentsPO { await this.clickOn('#fullscreen-btn'); } + async leaveRoom() { + await this.clickOn('body'); + await this.waitForElement('#leave-btn'); + expect(await this.isPresent('#leave-btn')).toBe(true); + await this.clickOn('#leave-btn'); + } + async togglePanel(panelName: string) { switch (panelName) { case 'activities':