From f7a53403eba1300679f59926071a5ac64360334c Mon Sep 17 00:00:00 2001 From: juancarmore Date: Thu, 9 Oct 2025 19:14:50 +0200 Subject: [PATCH] e2e-test: remove admin authentication from tests and update room config function --- frontend/webcomponent/tests/config.ts | 2 - .../tests/e2e/recording-access.test.ts | 113 +++++------- .../tests/e2e/ui-feature-config.test.ts | 167 +++++++----------- .../tests/helpers/function-helpers.ts | 38 +--- 4 files changed, 108 insertions(+), 212 deletions(-) diff --git a/frontend/webcomponent/tests/config.ts b/frontend/webcomponent/tests/config.ts index 332f358..ef08c64 100644 --- a/frontend/webcomponent/tests/config.ts +++ b/frontend/webcomponent/tests/config.ts @@ -1,6 +1,4 @@ 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'; diff --git a/frontend/webcomponent/tests/e2e/recording-access.test.ts b/frontend/webcomponent/tests/e2e/recording-access.test.ts index e9a6d38..c73ff80 100644 --- a/frontend/webcomponent/tests/e2e/recording-access.test.ts +++ b/frontend/webcomponent/tests/e2e/recording-access.test.ts @@ -8,7 +8,6 @@ import { deleteAllRooms, joinRoomAs, leaveRoom, - loginAsAdmin, prepareForJoiningRoom, startStopRecording, updateRoomConfig, @@ -22,12 +21,8 @@ let recordingCreated = false; test.describe('Recording Access Tests', () => { let roomId: string; let participantName: string; - let adminCookie: string; test.beforeAll(async () => { - // Login as admin to get authentication cookie - adminCookie = await loginAsAdmin(); - // Create a test room before all tests roomId = await createTestRoom('test-room'); }); @@ -72,18 +67,14 @@ test.describe('Recording Access Tests', () => { }); test('should moderator not be able to access recording when access level is set to admin', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -93,18 +84,14 @@ test.describe('Recording Access Tests', () => { }); test('should speaker not be able to access recording when access level is set to admin', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -114,18 +101,14 @@ test.describe('Recording Access Tests', () => { }); test('should allow moderator to access recording when access level is set to moderator', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -135,18 +118,14 @@ test.describe('Recording Access Tests', () => { }); test('should speaker not be able to access recording when access level is set to moderator', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -156,18 +135,14 @@ test.describe('Recording Access Tests', () => { }); test('should allow moderator to access recording when access level is set to speaker', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -177,18 +152,14 @@ test.describe('Recording Access Tests', () => { }); test('should allow speaker to access recording when access level is set to speaker', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); diff --git a/frontend/webcomponent/tests/e2e/ui-feature-config.test.ts b/frontend/webcomponent/tests/e2e/ui-feature-config.test.ts index 59b4db7..615e805 100644 --- a/frontend/webcomponent/tests/e2e/ui-feature-config.test.ts +++ b/frontend/webcomponent/tests/e2e/ui-feature-config.test.ts @@ -11,7 +11,6 @@ import { isVirtualBackgroundApplied, joinRoomAs, leaveRoom, - loginAsAdmin, openMoreOptionsMenu, prepareForJoiningRoom, updateRoomConfig, @@ -24,16 +23,12 @@ let subscribedToAppErrors = false; test.describe('UI Feature Config Tests', () => { let roomId: string; let participantName: string; - let adminCookie: string; // ========================================== // SETUP & TEARDOWN // ========================================== test.beforeAll(async () => { - // Login as admin to get authentication cookie - adminCookie = await loginAsAdmin(); - // Create a test room before all tests roomId = await createTestRoom('test-room'); }); @@ -73,18 +68,14 @@ test.describe('UI Feature Config Tests', () => { }); test('should show chat button when chat is enabled', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -97,18 +88,14 @@ test.describe('UI Feature Config Tests', () => { test('should hide chat button when chat is disabled', async ({ page }) => { // Disable chat via API - await updateRoomConfig( - roomId, - { - chat: { enabled: false }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: false }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -126,18 +113,14 @@ test.describe('UI Feature Config Tests', () => { test.describe('Recording Feature', () => { test('should show recording button for moderators', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -160,18 +143,14 @@ test.describe('UI Feature Config Tests', () => { }); test('should not show recording button for speaker', async ({ page }) => { - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -185,18 +164,14 @@ test.describe('UI Feature Config Tests', () => { test('should not show recording button for moderators when recording is disabled', async ({ page }) => { // Disable recording via API - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: false, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: false, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -226,18 +201,14 @@ test.describe('UI Feature Config Tests', () => { }); test('should show virtual background button when enabled', async ({ page }) => { // Ensure virtual backgrounds are enabled - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -255,18 +226,14 @@ test.describe('UI Feature Config Tests', () => { test('should hide virtual background button when disabled', async ({ page }) => { // Disable virtual backgrounds via API - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: false } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: false } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -284,18 +251,14 @@ test.describe('UI Feature Config Tests', () => { page }) => { // Ensure virtual backgrounds are enabled - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: true } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: true } + }); await page.goto(MEET_TESTAPP_URL); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, roomId); @@ -305,18 +268,14 @@ test.describe('UI Feature Config Tests', () => { await waitForVirtualBackgroundToApply(page); // Now disable virtual backgrounds - await updateRoomConfig( - roomId, - { - chat: { enabled: true }, - recording: { - enabled: true, - allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER - }, - virtualBackground: { enabled: false } + await updateRoomConfig(roomId, { + chat: { enabled: true }, + recording: { + enabled: true, + allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, - adminCookie - ); + virtualBackground: { enabled: false } + }); await leaveRoom(page); await page.reload(); diff --git a/frontend/webcomponent/tests/helpers/function-helpers.ts b/frontend/webcomponent/tests/helpers/function-helpers.ts index 738719e..759784f 100644 --- a/frontend/webcomponent/tests/helpers/function-helpers.ts +++ b/frontend/webcomponent/tests/helpers/function-helpers.ts @@ -2,7 +2,7 @@ import { expect, FrameLocator, Locator, Page } from '@playwright/test'; import * as fs from 'fs'; import { PNG } from 'pngjs'; import { MeetRecordingAccess, MeetRoomConfig } from '../../../../typings/src/room-config'; -import { MEET_ADMIN_PASSWORD, MEET_ADMIN_USER, MEET_API_KEY, MEET_API_URL, MEET_TESTAPP_URL } from '../config'; +import { MEET_API_KEY, MEET_API_URL, MEET_TESTAPP_URL } from '../config'; /** * Gets a FrameLocator for an iframe inside a Shadow DOM @@ -124,12 +124,12 @@ export const createTestRoom = async (roomName: string, config: MeetRoomConfig = }; // Helper function to update room config via REST API -export const updateRoomConfig = async (roomId: string, config: any, adminCookie: string) => { +export const updateRoomConfig = async (roomId: string, config: any) => { const response = await fetch(`${MEET_API_URL}/api/v1/rooms/${roomId}/config`, { method: 'PUT', headers: { 'Content-Type': 'application/json', - Cookie: adminCookie + 'x-api-key': MEET_API_KEY }, body: JSON.stringify({ config }) }); @@ -141,38 +141,6 @@ export const updateRoomConfig = async (roomId: string, config: any, adminCookie: return response.json(); }; -// Helper function to login and get admin cookie -export const loginAsAdmin = async (): Promise => { - const response = await fetch(`${MEET_API_URL}/internal-api/v1/auth/login`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - username: MEET_ADMIN_USER, - password: MEET_ADMIN_PASSWORD - }) - }); - - if (!response.ok || response.status !== 200) { - console.error('Login failed:', await response.text()); - throw new Error(`Failed to login: ${response.status}`); - } - - const cookies = response.headers.get('set-cookie') || ''; - if (!cookies) { - throw new Error('No cookies received from login'); - } - - // Extract the access token cookie - const accessTokenCookie = cookies.split(';').find((cookie) => cookie.trim().startsWith('OvMeetAccessToken=')); - if (!accessTokenCookie) { - throw new Error('Access token cookie not found'); - } - - return accessTokenCookie.trim(); -}; - // Helper function to delete a room export const deleteTestRoom = async (roomId: string) => { await fetch(`${MEET_API_URL}/api/v1/rooms/${roomId}`, {