tests: enhance e2e tests configuration and update test helpers for improved URL handling and participant management

This commit is contained in:
juancarmore 2025-07-09 00:00:16 +02:00
parent 28ac4b0d8c
commit c023fe6521
6 changed files with 97 additions and 123 deletions

View File

@ -1,2 +1,6 @@
export const WEBCOMPONENT_ROOM_URL = 'http://localhost:5080/';
export const RUN_MODE = process.env['RUN_MODE'] || 'development'; export const RUN_MODE = process.env['RUN_MODE'] || 'development';
export const MEET_API_URL = process.env['MEET_API_URL'] || 'http://localhost:6080';
export const MEET_API_KEY = process.env['MEET_API_KEY'] || 'meet-api-key';
export const MEET_ADMIN_USER = process.env['MEET_ADMIN_USER'] || 'admin';
export const MEET_ADMIN_PASSWORD = process.env['MEET_ADMIN_PASSWORD'] || 'admin';
export const MEET_TESTAPP_URL = process.env['MEET_TESTAPP_URL'] || 'http://localhost:5080';

View File

@ -1,27 +1,29 @@
import { test, expect } from '@playwright/test'; import { expect, test } from '@playwright/test';
import { MEET_TESTAPP_URL } from '../../config';
import { import {
deleteAllRecordings, deleteAllRecordings,
deleteAllRooms, deleteAllRooms,
joinRoomAs, joinRoomAs,
leaveRoom, leaveRoom,
waitForElementInIframe prepareForJoiningRoom
} from '../../helpers/function-helpers'; } from '../../helpers/function-helpers';
let subscribedToAppErrors = false; let subscribedToAppErrors = false;
test.describe('Web Component E2E Tests', () => { test.describe('Web Component E2E Tests', () => {
const testAppUrl = 'http://localhost:5080';
const testRoomPrefix = 'test-room'; const testRoomPrefix = 'test-room';
let participantName: string;
test.beforeAll(async ({ browser }) => { test.beforeAll(async ({ browser }) => {
// Create a test room before all tests // Create a test room before all tests
const tempContext = await browser.newContext(); const tempContext = await browser.newContext();
const tempPage = await tempContext.newPage(); const tempPage = await tempContext.newPage();
await tempPage.goto(testAppUrl); await tempPage.goto(MEET_TESTAPP_URL);
await tempPage.waitForSelector('.create-room'); await tempPage.waitForSelector('.create-room');
await tempPage.fill('#room-id-prefix', testRoomPrefix); await tempPage.fill('#room-id-prefix', testRoomPrefix);
await tempPage.click('.create-room-btn'); await tempPage.click('.create-room-btn');
await tempPage.waitForSelector(`#${testRoomPrefix}`); await tempPage.waitForSelector(`#${testRoomPrefix}`);
await tempPage.close(); await tempPage.close();
await tempContext.close(); await tempContext.close();
}); });
@ -35,12 +37,9 @@ test.describe('Web Component E2E Tests', () => {
}); });
subscribedToAppErrors = true; subscribedToAppErrors = true;
} }
await page.goto(testAppUrl);
await page.waitForSelector('.rooms-container'); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await page.waitForSelector(`#${testRoomPrefix}`); participantName = `P-${Math.random().toString(36).substring(2, 9)}`;
await page.click('.dropdown-button');
await page.waitForSelector('#join-as-moderator');
await page.waitForSelector('#join-as-publisher');
}); });
test.afterEach(async ({ context }) => { test.afterEach(async ({ context }) => {
@ -59,21 +58,21 @@ test.describe('Web Component E2E Tests', () => {
test.describe('Event Handling', () => { test.describe('Event Handling', () => {
test('should successfully join as moderator and receive JOIN event', async ({ page }) => { test('should successfully join as moderator and receive JOIN event', async ({ page }) => {
await joinRoomAs('moderator', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('moderator', participantName, page);
await page.waitForSelector('.event-JOIN'); await page.waitForSelector('.event-JOIN');
const joinElements = await page.locator('.event-JOIN').all(); const joinElements = await page.locator('.event-JOIN').all();
expect(joinElements.length).toBe(1); expect(joinElements.length).toBe(1);
}); });
test('should successfully join as publisher and receive JOIN event', async ({ page }) => { test('should successfully join as publisher and receive JOIN event', async ({ page }) => {
await joinRoomAs('publisher', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('publisher', participantName, page);
await page.waitForSelector('.event-JOIN'); await page.waitForSelector('.event-JOIN');
const joinElements = await page.locator('.event-JOIN').all(); const joinElements = await page.locator('.event-JOIN').all();
expect(joinElements.length).toBe(1); expect(joinElements.length).toBe(1);
}); });
test('should successfully join to room and receive LEFT event when using leave command', async ({ page }) => { test('should successfully join to room and receive LEFT event when using leave command', async ({ page }) => {
await joinRoomAs('moderator', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('moderator', participantName, page);
await page.click('#leave-room-btn'); await page.click('#leave-room-btn');
await page.waitForSelector('.event-LEFT'); await page.waitForSelector('.event-LEFT');
@ -84,7 +83,7 @@ test.describe('Web Component E2E Tests', () => {
test('should successfully join to room and receive LEFT event when using disconnect button', async ({ test('should successfully join to room and receive LEFT event when using disconnect button', async ({
page page
}) => { }) => {
await joinRoomAs('moderator', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('moderator', participantName, page);
await leaveRoom(page, 'moderator'); await leaveRoom(page, 'moderator');
await page.waitForSelector('.event-LEFT'); await page.waitForSelector('.event-LEFT');
@ -95,7 +94,7 @@ test.describe('Web Component E2E Tests', () => {
test('should successfully join to room and receive MEETING_ENDED event when using end meeting command', async ({ test('should successfully join to room and receive MEETING_ENDED event when using end meeting command', async ({
page page
}) => { }) => {
await joinRoomAs('moderator', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('moderator', participantName, page);
await page.click('#end-meeting-btn'); await page.click('#end-meeting-btn');
await page.waitForSelector('.event-MEETING_ENDED'); await page.waitForSelector('.event-MEETING_ENDED');

View File

@ -1,7 +1,8 @@
import { test, expect } from '@playwright/test'; import { expect, test } from '@playwright/test';
import * as fs from 'fs'; import * as fs from 'fs';
import { PNG } from 'pngjs';
import pixelmatch from 'pixelmatch'; import pixelmatch from 'pixelmatch';
import { PNG } from 'pngjs';
import { MEET_TESTAPP_URL } from '../../config.js';
import { import {
applyVirtualBackground, applyVirtualBackground,
deleteAllRecordings, deleteAllRecordings,
@ -21,9 +22,8 @@ let subscribedToAppErrors = false;
// Test suite for room functionality in OpenVidu Meet // Test suite for room functionality in OpenVidu Meet
test.describe('Room Functionality Tests', () => { test.describe('Room Functionality Tests', () => {
const testAppUrl = 'http://localhost:5080';
const testRoomPrefix = 'testing-room'; const testRoomPrefix = 'testing-room';
let participantName = `P-${Math.random().toString(36).substring(2, 9)}`; let participantName: string;
// ========================================== // ==========================================
// SETUP & TEARDOWN // SETUP & TEARDOWN
@ -33,11 +33,12 @@ test.describe('Room Functionality Tests', () => {
// Create a test room before all tests // Create a test room before all tests
const tempContext = await browser.newContext(); const tempContext = await browser.newContext();
const tempPage = await tempContext.newPage(); const tempPage = await tempContext.newPage();
await tempPage.goto(testAppUrl); await tempPage.goto(MEET_TESTAPP_URL);
await tempPage.waitForSelector('.create-room'); await tempPage.waitForSelector('.create-room');
await tempPage.fill('#room-id-prefix', testRoomPrefix); await tempPage.fill('#room-id-prefix', testRoomPrefix);
await tempPage.click('.create-room-btn'); await tempPage.click('.create-room-btn');
await tempPage.waitForSelector(`#${testRoomPrefix}`); await tempPage.waitForSelector(`#${testRoomPrefix}`);
await tempPage.close(); await tempPage.close();
await tempContext.close(); await tempContext.close();
}); });
@ -51,7 +52,8 @@ test.describe('Room Functionality Tests', () => {
}); });
subscribedToAppErrors = true; subscribedToAppErrors = true;
} }
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix);
await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
participantName = `P-${Math.random().toString(36).substring(2, 9)}`; participantName = `P-${Math.random().toString(36).substring(2, 9)}`;
}); });
@ -73,9 +75,10 @@ test.describe('Room Functionality Tests', () => {
// ========================================== // ==========================================
// COMPONENT RENDERING TESTS // COMPONENT RENDERING TESTS
// ========================================== // ==========================================
test.describe('Component Rendering', () => { test.describe('Component Rendering', () => {
test('should load the web component with proper iframe', async ({ page }) => { test('should load the web component with proper iframe', async ({ page }) => {
await joinRoomAs('moderator', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('moderator', participantName, page);
const component = page.locator('openvidu-meet'); const component = page.locator('openvidu-meet');
await expect(component).toBeVisible(); await expect(component).toBeVisible();
@ -94,7 +97,7 @@ test.describe('Room Functionality Tests', () => {
test.describe('Basic Room Features', () => { test.describe('Basic Room Features', () => {
test('should show the toolbar and media buttons', async ({ page }) => { test('should show the toolbar and media buttons', async ({ page }) => {
await joinRoomAs('publisher', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('publisher', participantName, page);
await waitForElementInIframe(page, '#toolbar'); await waitForElementInIframe(page, '#toolbar');
// Check media buttons are present // Check media buttons are present
@ -105,7 +108,7 @@ test.describe('Room Functionality Tests', () => {
}); });
test('should start a videoconference and display video elements', async ({ page, browser }) => { test('should start a videoconference and display video elements', async ({ page, browser }) => {
// First participant joins // First participant (publisher) joins
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
// Check local video element // Check local video element
@ -115,7 +118,7 @@ test.describe('Room Functionality Tests', () => {
// Second participant (moderator) joins // Second participant (moderator) joins
const context = await browser.newContext(); const context = await browser.newContext();
const moderatorPage = await context.newPage(); const moderatorPage = await context.newPage();
await prepareForJoiningRoom(moderatorPage, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(moderatorPage, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('moderator', 'moderator', moderatorPage); await joinRoomAs('moderator', 'moderator', moderatorPage);

View File

@ -1,21 +1,29 @@
import { test, expect } from '@playwright/test'; import { expect, test } from '@playwright/test';
import { deleteAllRecordings, deleteAllRooms, joinRoomAs, startStopRecording } from '../../helpers/function-helpers'; import { MEET_TESTAPP_URL } from '../../config.js';
import {
deleteAllRecordings,
deleteAllRooms,
joinRoomAs,
prepareForJoiningRoom,
startStopRecording
} from '../../helpers/function-helpers';
let subscribedToAppErrors = false; let subscribedToAppErrors = false;
test.describe('Web Component E2E Tests', () => { test.describe('Web Component E2E Tests', () => {
const testAppUrl = 'http://localhost:5080';
const testRoomPrefix = 'test-room'; const testRoomPrefix = 'test-room';
let participantName: string;
test.beforeAll(async ({ browser }) => { test.beforeAll(async ({ browser }) => {
// Create a test room before all tests // Create a test room before all tests
const tempContext = await browser.newContext(); const tempContext = await browser.newContext();
const tempPage = await tempContext.newPage(); const tempPage = await tempContext.newPage();
await tempPage.goto(testAppUrl); await tempPage.goto(MEET_TESTAPP_URL);
await tempPage.waitForSelector('.create-room'); await tempPage.waitForSelector('.create-room');
await tempPage.fill('#room-id-prefix', testRoomPrefix); await tempPage.fill('#room-id-prefix', testRoomPrefix);
await tempPage.click('.create-room-btn'); await tempPage.click('.create-room-btn');
await tempPage.waitForSelector(`#${testRoomPrefix}`); await tempPage.waitForSelector(`#${testRoomPrefix}`);
await tempPage.close(); await tempPage.close();
await tempContext.close(); await tempContext.close();
}); });
@ -29,12 +37,9 @@ test.describe('Web Component E2E Tests', () => {
}); });
subscribedToAppErrors = true; subscribedToAppErrors = true;
} }
await page.goto(testAppUrl);
await page.waitForSelector('.rooms-container'); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await page.waitForSelector(`#${testRoomPrefix}`); participantName = `P-${Math.random().toString(36).substring(2, 9)}`;
await page.click('.dropdown-button');
await page.waitForSelector('#join-as-moderator');
await page.waitForSelector('#join-as-publisher');
}); });
test.afterEach(async ({ context }) => { test.afterEach(async ({ context }) => {
@ -53,7 +58,7 @@ test.describe('Web Component E2E Tests', () => {
test.describe('Webhook Handling', () => { test.describe('Webhook Handling', () => {
test('should successfully receive meetingStarted and meetingEnded webhooks', async ({ page }) => { test('should successfully receive meetingStarted and meetingEnded webhooks', async ({ page }) => {
await joinRoomAs('moderator', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('moderator', participantName, page);
await page.waitForSelector('.webhook-meetingStarted'); await page.waitForSelector('.webhook-meetingStarted');
const meetingStartedElements = await page.locator('.webhook-meetingStarted').all(); const meetingStartedElements = await page.locator('.webhook-meetingStarted').all();
@ -69,7 +74,7 @@ test.describe('Web Component E2E Tests', () => {
test('should successfully receive recordingStarted, recordingUpdated and recordingEnded webhooks', async ({ test('should successfully receive recordingStarted, recordingUpdated and recordingEnded webhooks', async ({
page page
}) => { }) => {
await joinRoomAs('moderator', `P-${Math.random().toString(36).substring(2, 9)}`, page); await joinRoomAs('moderator', participantName, page);
// Start recording // Start recording
await startStopRecording(page, 'start'); await startStopRecording(page, 'start');

View File

@ -1,11 +1,12 @@
import { test, expect } from '@playwright/test'; import { expect, test } from '@playwright/test';
import { MeetRecordingAccess } from '../../../../typings/src/room-preferences';
import { MEET_TESTAPP_URL } from '../config';
import { import {
applyVirtualBackground, applyVirtualBackground,
closeMoreOptionsMenu, closeMoreOptionsMenu,
createTestRoom, createTestRoom,
deleteAllRecordings, deleteAllRecordings,
deleteAllRooms, deleteAllRooms,
deleteTestRoom,
interactWithElementInIframe, interactWithElementInIframe,
isVirtualBackgroundApplied, isVirtualBackgroundApplied,
joinRoomAs, joinRoomAs,
@ -17,12 +18,10 @@ import {
waitForElementInIframe, waitForElementInIframe,
waitForVirtualBackgroundToApply waitForVirtualBackgroundToApply
} from '../helpers/function-helpers'; } from '../helpers/function-helpers';
import { MeetRecordingAccess } from '../../../../typings/src/room-preferences';
let subscribedToAppErrors = false; let subscribedToAppErrors = false;
test.describe('UI Feature Preferences Tests', () => { test.describe('UI Feature Preferences Tests', () => {
const testAppUrl = 'http://localhost:5080';
const testRoomPrefix = 'ui-feature-testing-room'; const testRoomPrefix = 'ui-feature-testing-room';
let participantName: string; let participantName: string;
let roomId: string; let roomId: string;
@ -35,7 +34,6 @@ test.describe('UI Feature Preferences Tests', () => {
test.beforeAll(async () => { test.beforeAll(async () => {
// Login as admin to get authentication cookie // Login as admin to get authentication cookie
adminCookie = await loginAsAdmin(); adminCookie = await loginAsAdmin();
// Create test room
}); });
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
@ -83,8 +81,7 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
// Check that chat button is visible // Check that chat button is visible
@ -104,11 +101,11 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
// Check that chat button is not visible // Check that chat button is not visible
const chatButton = page.frameLocator('openvidu-meet >>> iframe').locator('#chat-panel-btn'); const chatButton = await waitForElementInIframe(page, '#chat-panel-btn', { state: 'hidden' });
await expect(chatButton).toBeHidden(); await expect(chatButton).toBeHidden();
}); });
}); });
@ -129,8 +126,7 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('moderator', participantName, page); await joinRoomAs('moderator', participantName, page);
await openMoreOptionsMenu(page); await openMoreOptionsMenu(page);
@ -150,22 +146,21 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
test('should not show recording button for publisher', async ({ page }) => { test('should not show recording button for publisher', async ({ page }) => {
// Ensure recording is enabled but only for moderators
roomId = await createTestRoom(testRoomPrefix, { roomId = await createTestRoom(testRoomPrefix, {
chatPreferences: { enabled: true }, chatPreferences: { enabled: true },
recordingPreferences: { recordingPreferences: {
enabled: true, enabled: true,
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER
}, },
virtualBackgroundPreferences: { enabled: true } virtualBackgroundPreferences: { enabled: true }
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
// Check that recording button is not visible for publisher // Check that recording button is not visible for publisher
const recordingButton = page.frameLocator('openvidu-meet >>> iframe').locator('#recording-btn'); const recordingButton = await waitForElementInIframe(page, '#recording-btn', { state: 'hidden' });
await expect(recordingButton).toBeHidden(); await expect(recordingButton).toBeHidden();
await leaveRoom(page); await leaveRoom(page);
}); });
@ -182,7 +177,7 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('moderator', participantName, page); await joinRoomAs('moderator', participantName, page);
// Check that recording button is not visible // Check that recording button is not visible
@ -219,7 +214,7 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
// Click more options to reveal virtual background button // Click more options to reveal virtual background button
@ -244,7 +239,7 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
// Click more options to reveal virtual background button // Click more options to reveal virtual background button
@ -269,11 +264,10 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
await applyVirtualBackground(page, '2'); await applyVirtualBackground(page, '2');
await waitForVirtualBackgroundToApply(page); await waitForVirtualBackgroundToApply(page);
// Now disable virtual backgrounds // Now disable virtual backgrounds
@ -294,54 +288,12 @@ test.describe('UI Feature Preferences Tests', () => {
await leaveRoom(page); await leaveRoom(page);
await page.reload(); await page.reload();
await prepareForJoiningRoom(page, testAppUrl, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
await joinRoomAs('publisher', participantName, page); await joinRoomAs('publisher', participantName, page);
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
const isVBApplied = await isVirtualBackgroundApplied(page);
const isVBApplied = await isVirtualBackgroundApplied(page);
expect(isVBApplied).toBe(false); expect(isVBApplied).toBe(false);
}); });
}); });
// ==========================================
// ROLE-BASED FEATURE TESTS
// ==========================================
// test.describe('Role-based Feature Access', () => {
// test('should show different features for moderator vs publisher', async ({ page, browser }) => {
// // Setup recording to be available for moderators only
// await updateRoomPreferences({
// ...getDefaultRoomPreferences(),
// recordingPreferences: {
// enabled: true,
// allowAccessTo: 'admin-moderator'
// }
// });
// // Test as moderator
// await joinRoomAs('moderator', `moderator-${participantName}`, page);
// // Moderator should see recording button
// const moderatorRecordingButton = await waitForElementInIframe(page, '#recording-btn', { state: 'visible' });
// await expect(moderatorRecordingButton).toBeVisible();
// await leaveRoom(page);
// // Test as publisher in a new context
// const publisherContext = await browser.newContext();
// const publisherPage = await publisherContext.newPage();
// await prepareForJoiningRoom(publisherPage, testAppUrl, testRoomPrefix);
// await joinRoomAs('publisher', `publisher-${participantName}`, publisherPage);
// // Publisher should not see recording button
// const publisherRecordingButton = publisherPage
// .frameLocator('openvidu-meet >>> iframe')
// .locator('#recording-btn');
// await expect(publisherRecordingButton).toBeHidden();
// await leaveRoom(publisherPage);
// await publisherContext.close();
// });
// });
}); });

View File

@ -1,8 +1,8 @@
import { MeetRecordingAccess, MeetRoomPreferences } from '../../../../typings/src/room-preferences'; import { expect, FrameLocator, Locator, Page } from '@playwright/test';
import { Page, Locator, FrameLocator } from '@playwright/test';
import { expect } from '@playwright/test';
import { PNG } from 'pngjs';
import * as fs from 'fs'; import * as fs from 'fs';
import { PNG } from 'pngjs';
import { MeetRecordingAccess, MeetRoomPreferences } from '../../../../typings/src/room-preferences';
import { MEET_ADMIN_PASSWORD, MEET_ADMIN_USER, MEET_API_KEY, MEET_API_URL, MEET_TESTAPP_URL } from '../config';
/** /**
* Gets a FrameLocator for an iframe inside a Shadow DOM * Gets a FrameLocator for an iframe inside a Shadow DOM
@ -55,11 +55,10 @@ export async function waitForElementInIframe(
// Wait for the element with the specified state // Wait for the element with the specified state
await elementLocator.waitFor({ state, timeout }); await elementLocator.waitFor({ state, timeout });
return elementLocator; return elementLocator;
} }
// Interacti with an element inside an iframe within Shadow DOM // Interact with an element inside an iframe within Shadow DOM
export async function interactWithElementInIframe( export async function interactWithElementInIframe(
page: Page, page: Page,
elementSelector: string, elementSelector: string,
@ -74,7 +73,8 @@ export async function interactWithElementInIframe(
} }
): Promise<void> { ): Promise<void> {
const { action, value = '', timeout = 30000 } = options; const { action, value = '', timeout = 30000 } = options;
const element = await waitForElementInIframe(page, elementSelector); const element = await waitForElementInIframe(page, elementSelector, { timeout });
// Perform the specified action // Perform the specified action
switch (action) { switch (action) {
case 'click': case 'click':
@ -87,6 +87,7 @@ export async function interactWithElementInIframe(
throw new Error(`Unsupported action: ${action}`); throw new Error(`Unsupported action: ${action}`);
} }
} }
// Helper function to get default room preferences // Helper function to get default room preferences
const getDefaultRoomPreferences = (): MeetRoomPreferences => ({ const getDefaultRoomPreferences = (): MeetRoomPreferences => ({
recordingPreferences: { recordingPreferences: {
@ -102,11 +103,11 @@ export const createTestRoom = async (
roomIdPrefix: string, roomIdPrefix: string,
preferences: MeetRoomPreferences = getDefaultRoomPreferences() preferences: MeetRoomPreferences = getDefaultRoomPreferences()
) => { ) => {
const response = await fetch(`http://localhost:6080/api/v1/rooms`, { const response = await fetch(`${MEET_API_URL}/api/v1/rooms`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'x-api-key': 'meet-api-key' 'x-api-key': MEET_API_KEY
}, },
body: JSON.stringify({ body: JSON.stringify({
roomIdPrefix, roomIdPrefix,
@ -127,7 +128,7 @@ export const createTestRoom = async (
// Helper function to update room preferences via REST API // Helper function to update room preferences via REST API
export const updateRoomPreferences = async (roomId: string, preferences: any, adminCookie: string) => { export const updateRoomPreferences = async (roomId: string, preferences: any, adminCookie: string) => {
const response = await fetch(`http://localhost:6080/internal-api/v1/rooms/${roomId}`, { const response = await fetch(`${MEET_API_URL}/internal-api/v1/rooms/${roomId}`, {
method: 'PUT', method: 'PUT',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -145,14 +146,14 @@ export const updateRoomPreferences = async (roomId: string, preferences: any, ad
// Helper function to login and get admin cookie // Helper function to login and get admin cookie
export const loginAsAdmin = async (): Promise<string> => { export const loginAsAdmin = async (): Promise<string> => {
const response = await fetch(`http://localhost:6080/internal-api/v1/auth/login`, { const response = await fetch(`${MEET_API_URL}/internal-api/v1/auth/login`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
username: 'admin', username: MEET_ADMIN_USER,
password: 'admin' password: MEET_ADMIN_PASSWORD
}) })
}); });
@ -168,7 +169,6 @@ export const loginAsAdmin = async (): Promise<string> => {
// Extract the access token cookie // Extract the access token cookie
const accessTokenCookie = cookies.split(';').find((cookie) => cookie.trim().startsWith('OvMeetAccessToken=')); const accessTokenCookie = cookies.split(';').find((cookie) => cookie.trim().startsWith('OvMeetAccessToken='));
if (!accessTokenCookie) { if (!accessTokenCookie) {
throw new Error('Access token cookie not found'); throw new Error('Access token cookie not found');
} }
@ -177,23 +177,23 @@ export const loginAsAdmin = async (): Promise<string> => {
}; };
// Helper function to delete a room // Helper function to delete a room
export const deleteTestRoom = async (roomIdToDelete: string) => { export const deleteTestRoom = async (roomId: string) => {
await fetch(`http://localhost:6080/api/v1/rooms/${roomIdToDelete}`, { await fetch(`${MEET_API_URL}/api/v1/rooms/${roomId}`, {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'x-api-key': 'meet-api-key' 'x-api-key': MEET_API_KEY
} }
}); });
}; };
export const deleteAllRecordings = async (page: Page) => { export const deleteAllRecordings = async (page: Page) => {
await page.goto('http://localhost:5080/'); await page.goto(MEET_TESTAPP_URL);
await page.waitForSelector('#delete-all-recordings-btn', { state: 'visible' }); await page.waitForSelector('#delete-all-recordings-btn', { state: 'visible' });
await page.click('#delete-all-recordings-btn'); await page.click('#delete-all-recordings-btn');
}; };
export const deleteAllRooms = async (page: Page) => { export const deleteAllRooms = async (page: Page) => {
await page.goto('http://localhost:5080/'); await page.goto(MEET_TESTAPP_URL);
await page.waitForSelector('#delete-all-rooms-btn', { state: 'visible' }); await page.waitForSelector('#delete-all-rooms-btn', { state: 'visible' });
await page.click('#delete-all-rooms-btn'); await page.click('#delete-all-rooms-btn');
}; };
@ -203,9 +203,11 @@ export const startStopRecording = async (page: Page, action: 'start' | 'stop') =
if (action === 'start') { if (action === 'start') {
await openMoreOptionsMenu(page); await openMoreOptionsMenu(page);
} }
await waitForElementInIframe(page, buttonSelector, { state: 'visible' }); await waitForElementInIframe(page, buttonSelector, { state: 'visible' });
await interactWithElementInIframe(page, buttonSelector, { action: 'click' }); await interactWithElementInIframe(page, buttonSelector, { action: 'click' });
await page.waitForTimeout(500); // Wait for recording action to complete await page.waitForTimeout(500); // Wait for recording action to complete
if (action === 'start') { if (action === 'start') {
await page.waitForSelector('.webhook-recordingUpdated', { timeout: 10000 }); await page.waitForSelector('.webhook-recordingUpdated', { timeout: 10000 });
} }
@ -213,6 +215,7 @@ export const startStopRecording = async (page: Page, action: 'start' | 'stop') =
await page.waitForSelector('.webhook-recordingEnded', { timeout: 10000 }); await page.waitForSelector('.webhook-recordingEnded', { timeout: 10000 });
} }
}; };
export const prepareForJoiningRoom = async (page: Page, url: string, roomPrefix: string) => { export const prepareForJoiningRoom = async (page: Page, url: string, roomPrefix: string) => {
await page.goto(url); await page.goto(url);
await page.waitForSelector('.rooms-container'); await page.waitForSelector('.rooms-container');
@ -241,6 +244,12 @@ export const joinRoomAs = async (role: 'moderator' | 'publisher', pName: string,
await waitForElementInIframe(page, 'ov-session', { state: 'visible' }); await waitForElementInIframe(page, 'ov-session', { state: 'visible' });
}; };
export const accessRoomAs = async (role: 'moderator' | 'publisher', page: Page) => {
await page.click('#join-as-' + role);
const component = page.locator('openvidu-meet');
await expect(component).toBeVisible();
};
export const viewRecordingsAs = async (role: 'moderator' | 'publisher', page: Page) => { export const viewRecordingsAs = async (role: 'moderator' | 'publisher', page: Page) => {
await page.click('#join-as-' + role); await page.click('#join-as-' + role);
const component = page.locator('openvidu-meet'); const component = page.locator('openvidu-meet');
@ -252,11 +261,13 @@ export const viewRecordingsAs = async (role: 'moderator' | 'publisher', page: Pa
export const leaveRoom = async (page: Page, role: 'moderator' | 'publisher' = 'publisher') => { export const leaveRoom = async (page: Page, role: 'moderator' | 'publisher' = 'publisher') => {
const button = await waitForElementInIframe(page, '#leave-btn'); const button = await waitForElementInIframe(page, '#leave-btn');
await button.click(); await button.click();
if (role === 'moderator') { if (role === 'moderator') {
await page.waitForTimeout(500); // Wait for leave animation await page.waitForTimeout(500); // Wait for leave animation
const option = await waitForElementInIframe(page, '#leave-option'); const option = await waitForElementInIframe(page, '#leave-option');
await option.click(); await option.click();
} }
await page.waitForSelector('.event-LEFT'); await page.waitForSelector('.event-LEFT');
}; };