forked from codeurjc-students/openvidu-tutorials-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec2bfac
commit 8572240
Showing
3 changed files
with
73 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: openvidu-js-tutorial-test | |
|
||
on: | ||
workflow_dispatch: {} | ||
push: | ||
|
||
|
||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,65 @@ | ||
//Test for Angular, React & Vue tutorials. | ||
// Import necessary Playwright libraries for testing. | ||
const { test, expect, chromium } = require('@playwright/test'); | ||
|
||
// Define a test case for checking the presence of two active webcams in an OpenVidu session. | ||
test('Checking for the presence of two active webcams in an OpenVidu session', async () => { | ||
// Launch a headless Chromium browser with specific settings. | ||
const browser = await chromium.launch({ | ||
headless: true, | ||
deviceScaleFactor: 1, // Specify the page's scale factor | ||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36', // Specify the user agent | ||
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"] | ||
}); | ||
|
||
// Create a new context with camera and microphone permissions. | ||
const context = await browser.newContext({ | ||
permissions: ['camera', 'microphone'], | ||
}); | ||
|
||
test('Checking for the presence of two active webcams in an OpenVidu session', async () => { | ||
const browser = await chromium.launch({ headless: true , deviceScaleFactor: 1, | ||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36', | ||
args : ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"] | ||
}); | ||
|
||
const context = await browser.newContext({ | ||
permissions: ['camera', 'microphone'], | ||
}); | ||
|
||
const page1 = await context.newPage(); | ||
await page1.goto('http://localhost:3000'); | ||
await page1.fill('#userName', 'Page1'); | ||
await page1.click('#join input[type="submit"]'); | ||
await page1.waitForSelector('#session', { visible: true }); | ||
|
||
const page2 = await context.newPage(); | ||
|
||
await page2.goto('http://localhost:3000'); | ||
await page2.fill('#userName', 'Page2'); | ||
await page2.click('#join input[type="submit"]'); | ||
await page2.waitForSelector('#session', { visible: true }); | ||
await page2.waitForTimeout(5000); | ||
|
||
await page1.screenshot({ path: 'page1.png' }); | ||
await page2.screenshot({ path: 'page2.png' }); | ||
|
||
// Buscar los elementos HTML que contienen los streams de video | ||
const videoElements = await page2.$$('video'); | ||
|
||
// Comprobar que hay exactamente dos elementos encontrados | ||
expect(videoElements.length).toEqual(3); | ||
|
||
// Cerrar las páginas y el navegador. | ||
|
||
await Promise.all([page1.close(), page2.close()]); | ||
await browser.close(); | ||
// Create two new pages within the context. | ||
const page1 = await context.newPage(); | ||
const page2 = await context.newPage(); | ||
|
||
try { | ||
// Navigate to a specific URL on page1. | ||
await page1.goto('http://localhost:3000'); | ||
|
||
// Fill in the '#userName' field with 'Page1', click the 'JOIN' button, and wait for the '#session' element to become visible. | ||
await page1.fill('#userName', 'Page1'); | ||
await page1.click('#join input[type="submit"]'); | ||
await page1.waitForSelector('#session', { visible: true }); | ||
await page1.waitForTimeout(5000); | ||
|
||
// Capture a screenshot of page1 and save it to a specific location. | ||
await page1.screenshot({ path: '../results/screenshots/page1.png' }); | ||
|
||
// Navigate to a specific URL on page2. | ||
await page2.goto('http://localhost:3000'); | ||
|
||
// Fill in the '#userName' field with 'Page2', click the 'JOIN' button, wait for the '#session' element to become visible, and wait for 5 seconds. | ||
await page2.fill('#userName', 'Page2'); | ||
await page2.click('#join input[type="submit"]'); | ||
await page2.waitForSelector('#session', { visible: true }); | ||
await page2.waitForTimeout(5000); | ||
|
||
// Capture a screenshot of page2 and save it to a specific location. | ||
await page2.screenshot({ path: '../results/screenshots/page2.png' }); | ||
|
||
// Find HTML elements within page2 that contain video streams. | ||
const videoElements = await page2.$$('video'); | ||
|
||
// Check that there are exactly three elements found. | ||
expect(videoElements.length).toEqual(3); | ||
|
||
// Close the pages and the browser. | ||
await Promise.all([page1.close(), page2.close()]); | ||
await browser.close(); | ||
} catch (error) { | ||
// In case of an error or timeout, capture screenshots. | ||
await page1.screenshot({ path: '../results/screenshots/error_page1_screenshot.png' }); | ||
await page2.screenshot({ path: '../results/screenshots/error_page2_screenshot.png' }); | ||
|
||
// Rethrow the error to make the test fail. | ||
throw error; | ||
} | ||
}); |