test: implement deleteAllRecordings and deleteAllRooms functions for cleanup in tests

This commit is contained in:
Carlos Santos 2025-06-12 11:27:03 +02:00
parent 21fbeec258
commit 8113b0c986
4 changed files with 50 additions and 18 deletions

View File

@ -4,6 +4,8 @@ import { PNG } from 'pngjs';
import pixelmatch from 'pixelmatch'; import pixelmatch from 'pixelmatch';
import { import {
applyVirtualBackground, applyVirtualBackground,
deleteAllRecordings,
deleteAllRooms,
interactWithElementInIframe, interactWithElementInIframe,
joinRoomAs, joinRoomAs,
leaveRoom, leaveRoom,
@ -58,14 +60,13 @@ test.describe('Room Functionality Tests', () => {
}); });
test.afterAll(async ({ browser }) => { test.afterAll(async ({ browser }) => {
// Cleanup: delete the test room
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 deleteAllRooms(tempPage);
await tempPage.waitForSelector('#delete-all-rooms'); await deleteAllRecordings(tempPage);
await tempPage.click('#delete-all-rooms');
await tempPage.close();
await tempContext.close(); await tempContext.close();
await tempPage.close();
}); });
// ========================================== // ==========================================

View File

@ -2,6 +2,8 @@ import { test, expect } from '@playwright/test';
import { import {
closeMoreOptionsMenu, closeMoreOptionsMenu,
createTestRoom, createTestRoom,
deleteAllRecordings,
deleteAllRooms,
deleteTestRoom, deleteTestRoom,
interactWithElementInIframe, interactWithElementInIframe,
joinRoomAs, joinRoomAs,
@ -62,6 +64,16 @@ test.describe('Recording Access Tests', () => {
} }
}); });
test.afterAll(async ({ browser }) => {
const tempContext = await browser.newContext();
const tempPage = await tempContext.newPage();
await deleteAllRooms(tempPage);
await deleteAllRecordings(tempPage);
await tempContext.close();
await tempPage.close();
});
test('should moderator not be able to access recording when access level is set to admin', async ({ page }) => { test('should moderator not be able to access recording when access level is set to admin', async ({ page }) => {
await updateRoomPreferences( await updateRoomPreferences(
roomId, roomId,

View File

@ -3,11 +3,14 @@ import {
applyVirtualBackground, applyVirtualBackground,
closeMoreOptionsMenu, closeMoreOptionsMenu,
createTestRoom, createTestRoom,
deleteAllRecordings,
deleteAllRooms,
deleteTestRoom, deleteTestRoom,
interactWithElementInIframe, interactWithElementInIframe,
isVirtualBackgroundApplied, isVirtualBackgroundApplied,
joinRoomAs, joinRoomAs,
leaveRoom, leaveRoom,
loginAsAdmin,
openMoreOptionsMenu, openMoreOptionsMenu,
prepareForJoiningRoom, prepareForJoiningRoom,
updateRoomPreferences, updateRoomPreferences,
@ -23,6 +26,7 @@ test.describe('UI Feature Preferences Tests', () => {
const testRoomPrefix = 'ui-feature-testing-room'; const testRoomPrefix = 'ui-feature-testing-room';
let participantName: string; let participantName: string;
let roomId: string; let roomId: string;
let adminCookie: string;
// ========================================== // ==========================================
// SETUP & TEARDOWN // SETUP & TEARDOWN
@ -30,7 +34,7 @@ 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 // Create test room
}); });
@ -48,14 +52,13 @@ test.describe('UI Feature Preferences Tests', () => {
}); });
test.afterAll(async ({ browser }) => { test.afterAll(async ({ browser }) => {
// Cleanup: delete the test room
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 deleteAllRooms(tempPage);
await tempPage.waitForSelector('#delete-all-rooms'); await deleteAllRecordings(tempPage);
await tempPage.click('#delete-all-rooms');
await tempPage.close();
await tempContext.close(); await tempContext.close();
await tempPage.close();
}); });
// ========================================== // ==========================================
@ -277,14 +280,18 @@ test.describe('UI Feature Preferences Tests', () => {
await waitForVirtualBackgroundToApply(page); await waitForVirtualBackgroundToApply(page);
// Now disable virtual backgrounds // Now disable virtual backgrounds
const { preferences: updatedPreferences } = await updateRoomPreferences(roomId, { const { preferences: updatedPreferences } = await updateRoomPreferences(
chatPreferences: { enabled: true }, roomId,
recordingPreferences: { {
enabled: true, chatPreferences: { enabled: true },
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER recordingPreferences: {
enabled: true,
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER
},
virtualBackgroundPreferences: { enabled: false }
}, },
virtualBackgroundPreferences: { enabled: false } adminCookie
}); );
expect(updatedPreferences.virtualBackgroundPreferences.enabled).toBe(false); expect(updatedPreferences.virtualBackgroundPreferences.enabled).toBe(false);
await leaveRoom(page); await leaveRoom(page);

View File

@ -186,6 +186,18 @@ export const deleteTestRoom = async (roomIdToDelete: string) => {
}); });
}; };
export const deleteAllRecordings = async (page: Page) => {
await page.goto('http://localhost:5080/');
await page.waitForSelector('#delete-all-recordings-btn', { state: 'visible' });
await page.click('#delete-all-recordings-btn');
};
export const deleteAllRooms = async (page: Page) => {
await page.goto('http://localhost:5080/');
await page.waitForSelector('#delete-all-rooms-btn', { state: 'visible' });
await page.click('#delete-all-rooms-btn');
};
export const startStopRecording = async (page: Page, action: 'start' | 'stop') => { export const startStopRecording = async (page: Page, action: 'start' | 'stop') => {
const buttonSelector = action === 'start' ? '#recording-btn' : '#stop-recording-btn'; const buttonSelector = action === 'start' ? '#recording-btn' : '#stop-recording-btn';
if (action === 'start') { if (action === 'start') {