openvidu-components: Fixed test when running in CI mode

pull/707/head
csantosm 2022-03-17 12:05:54 +01:00
parent f6d014bef6
commit 1e4571675d
4 changed files with 22 additions and 12 deletions

View File

@ -10,7 +10,6 @@
"lib:test": "ng test openvidu-angular --no-watch --code-coverage", "lib:test": "ng test openvidu-angular --no-watch --code-coverage",
"webcomponent:build": "./node_modules/@angular/cli/bin/ng.js build openvidu-webcomponent --configuration production && node ./openvidu-webcomponent-build.js", "webcomponent:build": "./node_modules/@angular/cli/bin/ng.js build openvidu-webcomponent --configuration production && node ./openvidu-webcomponent-build.js",
"webcomponent:prepare-test-e2e": "npm run lib:build && npm run webcomponent:build", "webcomponent:prepare-test-e2e": "npm run lib:build && npm run webcomponent:build",
"webcomponent:e2e": "npm run --prefix webcomponent-test-e2e test",
"bundle-report": "ng build openvidu-webcomponent --stats-json --configuration production && webpack-bundle-analyzer dist/openvidu-webcomponent/stats.json", "bundle-report": "ng build openvidu-webcomponent --stats-json --configuration production && webpack-bundle-analyzer dist/openvidu-webcomponent/stats.json",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e" "e2e": "ng e2e"

View File

@ -1 +1 @@
export const SELENIUM_SERVER_URL = process.env.SELENIUM_SERVER_URL || ''; export const LAUNCH_MODE = process.env.LAUNCH_MODE || 'DEV';

View File

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"serve": "npx http-server web/", "serve": "npx http-server web/",
"test": "tsc && mocha --recursive --timeout 30000 ./dist/test.js", "test": "tsc && mocha --recursive --timeout 30000 ./dist/test.js",
"test-ci": "cross-env SELENIUM_SERVER_URL=http://localhost:4444/wd/hub npm run test" "test-ci": "cross-env LAUNCH_MODE=CI npm run test"
}, },
"author": "Carlos Santos Morales", "author": "Carlos Santos Morales",
"license": "Apache-2.0", "license": "Apache-2.0",

View File

@ -1,11 +1,12 @@
import { Builder, By, Capabilities, until, WebDriver, logging } from 'selenium-webdriver'; import { Builder, By, Capabilities, until, WebDriver, logging } from 'selenium-webdriver';
import * as chrome from 'selenium-webdriver/chrome'; import * as chrome from 'selenium-webdriver/chrome';
import { expect } from 'chai'; import { expect } from 'chai';
import { SELENIUM_SERVER_URL } from './config'; import { LAUNCH_MODE } from './config';
const url = 'http://localhost:8080/'; const url = 'http://localhost:8080/';
const FIVE_SECONDS = 5000; const FIVE_SECONDS = 5000;
const ONE_SECONDS = 5000;
let SELENIUM_SERVER_URL = '';
describe('Checkout localhost app', () => { describe('Checkout localhost app', () => {
let browser: WebDriver; let browser: WebDriver;
@ -13,7 +14,11 @@ describe('Checkout localhost app', () => {
const chromeOptions = new chrome.Options(); const chromeOptions = new chrome.Options();
const chromeCapabilities = Capabilities.chrome(); const chromeCapabilities = Capabilities.chrome();
chromeOptions.addArguments('--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream'); chromeOptions.addArguments('--window-size=1024,768', '--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream');
if(LAUNCH_MODE === 'CI') {
SELENIUM_SERVER_URL = 'http://localhost:4444/wd/hub';
chromeOptions.addArguments('--headless', '--disable-dev-shm-usage');
}
const prefs = new logging.Preferences(); const prefs = new logging.Preferences();
prefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG); prefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG);
chromeCapabilities.set('acceptInsecureCerts', true); chromeCapabilities.set('acceptInsecureCerts', true);
@ -59,11 +64,17 @@ describe('Checkout localhost app', () => {
let element; let element;
await browser.get(`${url}?minimal=true`); await browser.get(`${url}?minimal=true`);
// Checking if prejoin page exist // Checking if prejoin page exist
element = await browser.wait(until.elementLocated(By.id('prejoin-container')), ONE_SECONDS); element = await browser.wait(until.elementLocated(By.id('prejoin-container')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true;
// Checking if layout is present
element = await browser.wait(until.elementLocated(By.id('layout-container')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true;
element = await browser.wait(until.elementLocated(By.id('layout')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true; expect(await element.isDisplayed()).to.be.true;
// Checking if stream component is present // Checking if stream component is present
element = await browser.wait(until.elementLocated(By.className('OT_widget-container')), FIVE_SECONDS); element = await browser.wait(until.elementLocated(By.css('.OT_widget-container')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true; expect(await element.isDisplayed()).to.be.true;
// Checking if audio detection is not displayed // Checking if audio detection is not displayed
@ -117,13 +128,13 @@ describe('Checkout localhost app', () => {
it('should show the PREJOIN page', async () => { it('should show the PREJOIN page', async () => {
await browser.get(`${url}?prejoin=true`); await browser.get(`${url}?prejoin=true`);
const element = await browser.wait(until.elementLocated(By.id('prejoin-container')), ONE_SECONDS); const element = await browser.wait(until.elementLocated(By.id('prejoin-container')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true; expect(await element.isDisplayed()).to.be.true;
}); });
it('should not show the PREJOIN page', async () => { it('should not show the PREJOIN page', async () => {
let element; let element;
await browser.get(`${url}?prejoin=false`); await browser.get(`${url}?prejoin=false`);
element = await browser.wait(until.elementLocated(By.id('session-container')), ONE_SECONDS); element = await browser.wait(until.elementLocated(By.id('session-container')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true; expect(await element.isDisplayed()).to.be.true;
}); });
@ -164,7 +175,7 @@ describe('Checkout localhost app', () => {
await browser.get(`${url}?prejoin=false&videoMuted=true`); await browser.get(`${url}?prejoin=false&videoMuted=true`);
element = await browser.wait(until.elementLocated(By.id('session-container')), ONE_SECONDS); element = await browser.wait(until.elementLocated(By.id('session-container')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true; expect(await element.isDisplayed()).to.be.true;
// Checking if video is displayed // Checking if video is displayed
@ -218,7 +229,7 @@ describe('Checkout localhost app', () => {
await browser.get(`${url}?prejoin=false&audioMuted=true`); await browser.get(`${url}?prejoin=false&audioMuted=true`);
element = await browser.wait(until.elementLocated(By.id('session-container')), ONE_SECONDS); element = await browser.wait(until.elementLocated(By.id('session-container')), FIVE_SECONDS);
expect(await element.isDisplayed()).to.be.true; expect(await element.isDisplayed()).to.be.true;
// Checking if video is displayed // Checking if video is displayed