From f94817433c160dc46fa22651379c1cc6b44fd745 Mon Sep 17 00:00:00 2001 From: ismail Date: Wed, 24 Apr 2024 19:21:49 +0200 Subject: [PATCH] modified: Tests/TutorialTests/openvidu-react-web-tutorial.spec.js --- .../openvidu-react-web-tutorial.spec.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Tests/TutorialTests/openvidu-react-web-tutorial.spec.js b/Tests/TutorialTests/openvidu-react-web-tutorial.spec.js index 81c80da7..38eb49f8 100644 --- a/Tests/TutorialTests/openvidu-react-web-tutorial.spec.js +++ b/Tests/TutorialTests/openvidu-react-web-tutorial.spec.js @@ -1,4 +1,4 @@ -// Import necessary Playwright libraries for testing. +// TEST OPENVIDU-REACT tutorial const { test, expect, chromium } = require('@playwright/test'); // Define a test case for checking the presence of two active webcams in an OpenVidu session. @@ -6,8 +6,8 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a // Launch a headless Chromium browser with specific settings. const browser = await chromium.launch({ headless: true, - deviceScaleFactor: 1, - userAgent: 'Chrome/88.0.4324.182', + deviceScaleFactor: 1, // Specify the page's scale factor + userAgent: 'Chrome/88.0.4324.182', // Specify the user agent args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"] }); @@ -25,13 +25,13 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a // Navigate to a specific URL on page1. await page1.goto('http://localhost:3000'); - // Fill in the username field, click the join button, and wait for the session to become visible. + // Fill in the '#userName' field with 'Page1', click the 'JOIN' button, and wait for the '#session' element to become visible. await page1.fill('#userName', 'User1'); await page1.click('#join input[type="submit"]'); await page1.waitForSelector('#session', { visible: true }); - await page1.waitForTimeout(5000); + await page1.waitForTimeout(1000); -/* var videoElements = await page1.$$('video'); + var videoElements = await page1.$$('video'); expect(videoElements.length).toEqual(2); @@ -42,25 +42,25 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a expect(isPaused).not.toBe(true); } - */ - // Capture a screenshot of page1 and save it to a file. - await page1.screenshot({ path: '../../results/screenshots/page1_screenshot.png' }); + + // 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, click the join button, and wait for the session to become visible. + // 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', 'User2'); await page2.click('#join input[type="submit"]'); await page2.waitForSelector('#session', { visible: true }); - await page2.waitForTimeout(5000); + await page2.waitForTimeout(1000); // 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. - var videoElements = await page2.$$('video'); + videoElements = await page2.$$('video'); // Check that there are exactly three elements found. expect(videoElements.length).toEqual(3); @@ -73,7 +73,8 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a } - await page2.screenshot({ path: '../../results/screenshots/page2_screenshot.png' }); + + await Promise.all([page1.close(), page2.close()]); await browser.close();