Carlos Santos fbcb70dbc2
Add OpenVidu Meet Console implementation (#4)
* frontend: update icons for Rooms and Recordings in console navigation

* frontend: enhance overview component with user stats and improved layout

* frontend: implement theme service and design tokens for light/dark mode support

- Added ThemeService to manage theme preferences and system theme detection.
- Introduced design tokens for consistent styling across light and dark themes.
- Updated components to utilize the new navigation service for routing.
- Replaced SecurityPreferencesComponent with PreferencesComponent for settings.
- Enhanced UI with new styles and improved navigation structure.
- Added tests for ThemeService to ensure functionality.

* frontend: enhance overview component with title styling and icon integration

* frontend: remove unused Router import from overview component

* frontend: implement developers settings with API key and webhook configuration

* frontend: update styles and structure for console navigation and overview components

* frontend: simplify API key checks and integrate notification service for user feedback

* frontend: update openvidu-components-angular to version 3.3.0-dev2 and simplify Material Symbols stylesheet link

* frontend: adjust padding and gap for stat card and actions in overview component

* frontend: update import paths to use relative paths for better module resolution

* frontend: enhance sync-types.sh script with advanced options and detailed usage instructions

* typings: update TypeScript declaration files and improve sync-types.sh script for better clarity and functionality

* webcomponent: webcomponent typings are now moved to typings directory

* Revert "typings: update TypeScript declaration files and improve sync-types.sh script for better clarity and functionality"

This reverts commit 7da952bc44be20c3f74ffb82bf941b96b78ad019.

* typings: improve sync-types.sh script for clarity and consistency

* test: update error message for empty downloaded file check

* frontend: update outbound event message types in video room and web component manager services

* frontend: enhance styling for console component and adjust nav item border radius

* style: update comments in disabled class for clarity and consistency; refactor import paths in room-form component

* typings: update import paths in message.type.ts to include file extensions

* frontend: enhance rooms management interface with improved loading states, search functionality, and table features

* frontend: enhance loading state with improved UI and animations for room loading process

* frontend: enhance rooms table with auto-deletion feature and improve status display

* frontend: update import paths for services and add containsRoute method to NavigationService

* frontend: remove unused components and associated files from shared-meet-components

* frontend: add logo selector component and enhance preferences settings with access controls

* frontend: add SessionStorageService import to extract query params guard

* frontend: add margin-bottom utility class to overview container

* frontend: update description for creating a room in the overview component

* frontend: Added recording list component

* frontend: update padding in mat-sidenav entry to use spacing variable

* frontend: update text for delete room button to use lowercase

* frontend: enhance console navigation with tooltips and active item styling

* frontend: refactor styles in console navigation for consistency and improved theming

* frontend: add border to card header for improved visual separation

* frontend: created room list reusable component

* frontend: adjust vertical alignment of table cells in recording lists

* frontend: enhance room status and auto-deletion indicators with tooltips and improved styling

* frontend: enhance HTTP service methods to include status codes in responses

* frontend: fix duration formatting to use integer seconds instead of fixed-point

* frontend: refactor icon styles in status badge for consistency

* Add modular SCSS structure for design tokens, mixins, animations, and utility classes

- Introduced _animations.scss for keyframes and animation utility classes.
- Refactored _design-tokens.scss to import modular design system files for better maintainability.
- Created _mixins-components.scss for component-specific mixins like cards and buttons.
- Added _mixins-layout.scss for layout-related mixins and responsive design utilities.
- Established _mixins-responsive.scss for breakpoint mixins to facilitate responsive design.
- Introduced _tokens-core.scss for core design tokens including colors, spacing, and typography.
- Created _tokens-themes.scss for theme-specific design tokens for light and dark modes.
- Added _utilities.scss for reusable utility classes to streamline common styling patterns.

* frontend: Refactor styles for settings preferences component and enhance utility classes

- Simplified SCSS for preferences.component.scss by utilizing utility classes for layout and styling.
- Introduced new utility classes for Material components, including slide toggle and navigation list.
- Enhanced form section styling with consistent spacing and layout adjustments.
- Added responsive design patterns for toolbar and table components.
- Improved loading and empty state styles for better user experience.

* frontend: standardize page layout and loading states across components

* frontend: enhance status badge and action button styles for consistency

* ci: update unit test workflow to include typings setup

* test: update import path for WebComponentCommand to typings directory

* frontend: refactor dialog component structure and enhance styles for improved accessibility and responsiveness

* frontend: rename batchDelete methods to bulkDelete for consistency

* frontend: implement confirmation dialog for room deletion with improved error handling

* frontend: extract feature-specific API logic from HttpService into dedicated services

* frontend: extract common recording actions into RecordingManagerService

* frontend: refactor navigation handling for improved consistency

* backend: add endpoint to download multiple recordings in a zip file and refactor bulkDeleteRecordings to delete only recordings from the same room if recording token is provided

* openapi: add download endpoint for recordings and update bulk delete logic to enforce room constraints

* frontend: enhance recording media URL generation and add bulk delete and download functionalities

* frontend: rename 'batchDownload' to 'bulkDownload' for consistency and implement missing methods in RecordingsComponent

* frontend: Implement Room Creation Wizard with Step Indicator and Navigation

- Added StepIndicatorComponent for visual step tracking in the wizard.
- Created WizardNavComponent for navigation controls (Next, Previous, Cancel, Finish).
- Developed RoomWizardComponent to manage the wizard's state and steps.
- Introduced WizardStateService to handle the wizard's data and navigation logic.
- Defined WizardStep and WizardNavigationConfig models for step management.
- Implemented basic structure for individual steps: Basic Info, Recording Settings, Recording Trigger, Recording Layout, and Preferences.
- Integrated components into the room creation flow, allowing users to navigate through steps.
- Added unit tests for all new components and services to ensure functionality.

* feat(wizard): enhance wizard functionality and UI

- Added validation form groups to WizardStep interface for better form handling.
- Updated WizardNavigationConfig to include customizable button labels and states.
- Implemented step navigation with event handling in room-wizard component.
- Refactored basic info step into a standalone component with reactive form support.
- Improved styling for the basic info step and action buttons.
- Enhanced wizard state management to handle dynamic step visibility based on user input.
- Added methods for loading existing data and saving form changes automatically.
- Updated tests to reflect changes in component structure and functionality.

* feat(recording-preferences): implement recording preferences step with form and options

* feat(room-wizard): add recording trigger step with selectable options and form handling

* feat(recording-preferences): refactor option selection to use SelectableCard component and update styles

* test: add tests for download recordings endpoint and update tests for bulk delete recordings

* openapi: improve descriptions for bulk delete operations and add new response for marked rooms

* frontend: update bulk actions and add sharing functionality in RecordingsComponent, and enhace RecordingListsComponent

* frontend: implement bulkDeleteRooms method and enhace RoomsComponent and RoomListsComponent

* typings: add MeetApiKey interface

* backend: update API key handling to use MeetApiKey type

* openapi: create API key schema and update response references

* backend: add webhook URL testing functionality and validation

* frontend: simplify HTTP request methods by removing response observation

* frontend: streamline OverviewComponent by removing unused observables and simplifying data loading

* frontend: add API key management methods to AuthService

* frontend: enhance GlobalPreferencesService by adding webhook preferences management

* frontend: refactor DevelopersSettingsComponent to improve API key handling and streamline webhook configuration

* openapi: add webhook URL testing endpoint with request and response schemas

* test: add tests for webhook URL validation

* frontend: enhance PreferencesComponent and add changePassword method in AuthService

* feat(recording-preferences): add recording access control options and enhance UI animations

* feat(recording-layout): implement recording layout selection step with form handling and visual options

* feat(room-preferences): implement room preferences step with form handling and toggle options

* feat(room-wizard): enhance form handling and default value saving across components

* feat(layouts): add new layout images for grid, single speaker, and speaker configurations

* feat(developers): adjust API key field button padding and update spacing in API key display

* feat(rooms-lists): enhance button formatting and add tooltips for room status and auto-deletion

* feat(room-wizard): update room creation logic and form field names for consistency

* feat(room-wizard): add skip button functionality and enhance navigation handling

* feat(basic-info): simplify form layout by removing action buttons and related styles

* fix(wizard-navigation): change currentStepId type from string to number for consistency

* feat(styles): enhance button padding and hover effect in batch actions for improved usability

* fix(wizard-navigation): adjust padding for improved layout consistency

* feat(basic-info): add clear button for deletion date and enhance time selection layout

* feat(rooms-list): enhance deletion date display with new styling and structure

* fix(basic-info): remove debugger statement from saveFormData method

* refactor(step-indicator): remove commented-out styles for cleaner code

* feat(step-indicator): enhance responsive layout handling and emit layout changes

* feat(overview): improve loading state handling and update stats management

* feat(step-indicator): enable navigation between steps and improve layout handling

* feat(room-wizard): refactor state management to use MeetRoomOptions and improve data handling across components

* feat(step-indicator): enhance layout handling and improve text overflow management for better responsiveness

* feat(step-indicator): update step properties to enhance navigation and state management

* feat(room-wizard): add 'Create Room' label to finish button in navigation config

* openapi: add force-deletion parameter to delete room endpoint

* frontend: split code in ContextService into domain specific services and rename it to AppDataSerivce

* frontend: enhace FeatureConfigurationService to use signal-based approach and remove unused preferences and permissions

* feat(basic-info): update deletion hint icon and improve warning color consistency

* feat(room-service): rename saveRoomPreferences to updateRoom and adjust API path for preference updates

* feat(room-wizard): implement edit mode for room configuration, allowing users to update existing room settings

* feat(pro-feature-badge): create ProFeatureBadge component and integrate into logo selector and selectable card

* fix(recording): adjust compression level for zip archive in downloadRecordingsZip

* fix(internal-config): remove FIXME comments related to LK bug for meeting timeouts

* frontend: reorganize imports and remove unused components

* refactor(console): rename 'Developers' to 'Embedded' in navigation and update related routes

* fix(console-nav): update toolbar title from 'OpenVidu Console' to 'OpenVidu Meet'

* feat(users-permissions): create UsersPermissions component and update routing

* feat(users-permissions): add pro feature badge to user authentication section

* fix(overview): update navigation and text from 'Developers' to 'Embedded'

* feat(overview): update authentication configuration card and navigation

* frontend: refactor RoomRecordingsComponent to use RecordingListsComponent

* refactor: update API paths to remove 'meet' prefix for consistency

* frontend: update navigation paths to remove 'console' prefix for consistency

* feat(video-room): add leave and end meeting functionality with toolbar buttons

* fix(overview): remove unnecessary comment on initial loading state

* feat(wizard): enable quick create functionality in wizard navigation

* feat(step-indicator): implement safe current step index handling for edit mode

* feat(wizard): update quick create visibility to show only on first step in edit mode

* feat(users-permissions): refactor admin password handling and validation

* webcomponent: update Playwright dependencies and refactor leaveRoom functionality

- Updated Playwright and Playwright Test versions in package.json to 1.53.2.
- Refactored leaveRoom function to accept a role parameter, allowing for different behavior based on user role (moderator or publisher).
- Updated E2E tests to utilize the new leaveRoom function, ensuring proper cleanup and behavior for both roles.
- Removed unnecessary afterEach cleanup in UI Feature Preferences tests.

* frontend: add IDs to leave and end meeting buttons for better accessibility

* testapp: update package-lock.json and refactor ConfigService constructor for improved environment variable handling

* frontend: update background colors for improved visual consistency

* chore: add tslib dependency and enhance target directory validation in sync-types.sh

* frontend: enhance accessibility by adding IDs to toolbar and form elements

---------

Co-authored-by: juancarmore <juancar_more2@hotmail.com>
2025-07-02 17:00:43 +02:00

428 lines
14 KiB
TypeScript

import { MeetRecordingAccess, MeetRoomPreferences } from '../../../../typings/src/room-preferences';
import { Page, Locator, FrameLocator } from '@playwright/test';
import { expect } from '@playwright/test';
import { PNG } from 'pngjs';
import * as fs from 'fs';
/**
* Gets a FrameLocator for an iframe inside a Shadow DOM
* @param page - Playwright page object
* @param componentSelector - Selector for the web component with Shadow DOM
* @param iframeSelector - Selector for the iframe within the Shadow DOM
* @returns FrameLocator that can be used to access iframe contents
*/
export async function getIframeInShadowDom(
page: Page,
componentSelector: string = 'openvidu-meet',
iframeSelector: string = 'iframe'
): Promise<FrameLocator> {
// Verify the component exists
await page.waitForSelector(componentSelector);
// Use frameLocator to access the iframe contents
return page.frameLocator(`${componentSelector} >>> ${iframeSelector}`);
}
/**
* Waits for an element inside an iframe within Shadow DOM
* @param page - Playwright page object
* @param elementSelector - Selector for the element inside the iframe
* @param options - Optional configuration
* @returns Locator for the found element
*/
export async function waitForElementInIframe(
page: Page,
elementSelector: string,
options: {
componentSelector?: string;
iframeSelector?: string;
timeout?: number;
state?: 'attached' | 'detached' | 'visible' | 'hidden';
} = {}
): Promise<Locator> {
const {
componentSelector = 'openvidu-meet',
iframeSelector = 'iframe',
timeout = 30000,
state = 'visible'
} = options;
// Get the iframe
const frameLocator = await getIframeInShadowDom(page, componentSelector, iframeSelector);
// Get element locator
const elementLocator = frameLocator.locator(elementSelector);
// Wait for the element with the specified state
await elementLocator.waitFor({ state, timeout });
return elementLocator;
}
// Interacti with an element inside an iframe within Shadow DOM
export async function interactWithElementInIframe(
page: Page,
elementSelector: string,
options: {
action: 'click' | 'fill' | 'type';
value?: string; // Only needed for 'fill' or 'type' actions
timeout?: number;
} = {
action: 'click',
value: '',
timeout: 30000
}
): Promise<void> {
const { action, value = '', timeout = 30000 } = options;
const element = await waitForElementInIframe(page, elementSelector);
// Perform the specified action
switch (action) {
case 'click':
await element.click();
break;
case 'fill':
await element.fill(value);
break;
default:
throw new Error(`Unsupported action: ${action}`);
}
}
// Helper function to get default room preferences
const getDefaultRoomPreferences = (): MeetRoomPreferences => ({
recordingPreferences: {
enabled: true,
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER
},
chatPreferences: { enabled: true },
virtualBackgroundPreferences: { enabled: true }
});
// Helper function to create a room for testing
export const createTestRoom = async (
roomIdPrefix: string,
preferences: MeetRoomPreferences = getDefaultRoomPreferences()
) => {
const response = await fetch(`http://localhost:6080/api/v1/rooms`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'meet-api-key'
},
body: JSON.stringify({
roomIdPrefix,
autoDeletionDate: new Date(Date.now() + 61 * 60 * 1000).getTime(), // 1 hour from now
preferences
})
});
if (!response.ok) {
const errorResponse = await response.json();
console.error('Error creating room:', errorResponse);
throw new Error(`Failed to create room: ${response.status}`);
}
const room = await response.json();
return room.roomId;
};
// Helper function to update room preferences via REST API
export const updateRoomPreferences = async (roomId: string, preferences: any, adminCookie: string) => {
const response = await fetch(`http://localhost:6080/internal-api/v1/rooms/${roomId}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Cookie: adminCookie
},
body: JSON.stringify(preferences)
});
if (!response.ok) {
throw new Error(`Failed to update room preferences: ${response.status} ${await response.text()}`);
}
return response.json();
};
// Helper function to login and get admin cookie
export const loginAsAdmin = async (): Promise<string> => {
const response = await fetch(`http://localhost:6080/internal-api/v1/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: 'admin',
password: 'admin'
})
});
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 (roomIdToDelete: string) => {
await fetch(`http://localhost:6080/api/v1/rooms/${roomIdToDelete}`, {
method: 'DELETE',
headers: {
'x-api-key': 'meet-api-key'
}
});
};
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') => {
const buttonSelector = action === 'start' ? '#recording-btn' : '#stop-recording-btn';
if (action === 'start') {
await openMoreOptionsMenu(page);
}
await waitForElementInIframe(page, buttonSelector, { state: 'visible' });
await interactWithElementInIframe(page, buttonSelector, { action: 'click' });
await page.waitForTimeout(500); // Wait for recording action to complete
if (action === 'start') {
await page.waitForSelector('.webhook-recordingUpdated', { timeout: 10000 });
}
if (action === 'stop') {
await page.waitForSelector('.webhook-recordingEnded', { timeout: 10000 });
}
};
export const prepareForJoiningRoom = async (page: Page, url: string, roomPrefix: string) => {
await page.goto(url);
await page.waitForSelector('.rooms-container');
await page.waitForSelector(`#${roomPrefix}`);
await page.click('.dropdown-button');
await page.waitForSelector('#join-as-moderator');
await page.waitForSelector('#join-as-publisher');
};
export const joinRoomAs = async (role: 'moderator' | 'publisher', pName: string, page: Page) => {
await page.click('#join-as-' + role);
const component = page.locator('openvidu-meet');
await expect(component).toBeVisible();
// Wait for participant name input and fill it
await waitForElementInIframe(page, '#participant-name-input', { state: 'visible' });
await interactWithElementInIframe(page, '#participant-name-input', {
action: 'fill',
value: pName
});
await interactWithElementInIframe(page, '#participant-name-submit', { action: 'click' });
// wait for prejoin page to load and join the room
await waitForElementInIframe(page, 'ov-pre-join', { state: 'visible' });
await interactWithElementInIframe(page, '#join-button', { action: 'click' });
await waitForElementInIframe(page, 'ov-session', { state: 'visible' });
};
export const viewRecordingsAs = async (role: 'moderator' | 'publisher', page: Page) => {
await page.click('#join-as-' + role);
const component = page.locator('openvidu-meet');
await expect(component).toBeVisible();
await interactWithElementInIframe(page, '#view-recordings-btn', { action: 'click' });
};
export const leaveRoom = async (page: Page, role: 'moderator' | 'publisher' = 'publisher') => {
const button = await waitForElementInIframe(page, '#leave-btn');
await button.click();
if (role === 'moderator') {
await page.waitForTimeout(500); // Wait for leave animation
const option = await waitForElementInIframe(page, '#leave-option');
await option.click();
}
await page.waitForSelector('.event-LEFT');
};
export const startScreenSharing = async (page: Page) => {
await interactWithElementInIframe(page, '#screenshare-btn', { action: 'click' });
await waitForElementInIframe(page, '#local-element-screen_share', { state: 'visible' });
};
export const stopScreenSharing = async (page: Page) => {
await interactWithElementInIframe(page, '#screenshare-btn', { action: 'click' });
await page.waitForTimeout(200); // Wait for screen menu
await interactWithElementInIframe(page, '#disable-screen-button', { action: 'click' });
await page.waitForTimeout(500); // Wait for screen to stop sharing
};
export const applyVirtualBackground = async (page: Page, backgroundId: string) => {
await interactWithElementInIframe(page, '#more-options-btn', { action: 'click' });
await page.waitForTimeout(500);
await interactWithElementInIframe(page, '#virtual-bg-btn', { action: 'click' });
await waitForElementInIframe(page, 'ov-background-effects-panel', { state: 'visible' });
await interactWithElementInIframe(page, `#effect-${backgroundId}`, { action: 'click' });
await interactWithElementInIframe(page, '.panel-close-button', { action: 'click' });
};
export const removeVirtualBackground = async (page: Page) => {
await interactWithElementInIframe(page, '#more-options-btn', { action: 'click' });
await page.waitForTimeout(500);
await interactWithElementInIframe(page, '#virtual-bg-btn', { action: 'click' });
await interactWithElementInIframe(page, '#no_effect-btn', { action: 'click' });
await page.waitForTimeout(500); // Wait for background to be removed
};
/**
* Analyzes the current video frame to determine if the virtual background has been applied
* by checking if most pixels are different from Chrome's synthetic green background
*/
export const isVirtualBackgroundApplied = async (
page: Page,
videoSelector: string = '.OV_video-element',
options: {
minChangedPixelsPercent?: number; // Minimum % of non-green pixels to consider background applied
saveDebugImages?: boolean; // Save images for debugging
} = {}
): Promise<boolean> => {
const {
minChangedPixelsPercent = 70, // At least 20% of pixels should be non-green
saveDebugImages = false
} = options;
try {
// Capture current video frame
const screenshotPath = `test-results/vbg_check_${Date.now()}.png`;
await saveScreenshot(page, screenshotPath, videoSelector);
// Read the captured image
const currentFrame = PNG.sync.read(fs.readFileSync(screenshotPath));
const { width, height } = currentFrame;
// Count green pixels (sample every 5th pixel for performance)
let greenPixels = 0;
let totalSampled = 0;
for (let y = 0; y < height; y += 5) {
for (let x = 0; x < width; x += 5) {
const idx = (width * y + x) << 2;
const r = currentFrame.data[idx];
const g = currentFrame.data[idx + 1];
const b = currentFrame.data[idx + 2];
totalSampled++;
if (isChromeSyntheticGreen(r, g, b)) {
greenPixels++;
}
}
}
const greenPercentage = (greenPixels / totalSampled) * 100;
const nonGreenPercentage = 100 - greenPercentage;
const backgroundApplied = nonGreenPercentage >= minChangedPixelsPercent;
console.log(
`Video Analysis: ${nonGreenPercentage.toFixed(1)}% non-green pixels - Background applied: ${backgroundApplied}`
);
// Cleanup
if (!saveDebugImages) {
fs.unlinkSync(screenshotPath);
}
return backgroundApplied;
} catch (error) {
console.error('Error checking virtual background:', error);
return false;
}
};
/**
* Detects if a pixel is part of Chrome's synthetic green screen
* Chrome's fake video can vary, but typically has these characteristics:
* - Green channel is dominant
* - Overall brightness suggests synthetic content
* - Color tends to be uniformly distributed
*/
const isChromeSyntheticGreen = (r: number, g: number, b: number): boolean => {
// Method 1: Classic bright green detection (loose tolerances)
const isBrightGreen = g > 150 && g > r + 50 && g > b + 50 && r < 100 && b < 100;
// Method 2: Detect greenish hues with high saturation
const isGreenish = g > Math.max(r, b) && g > 100;
const hasLowRedBlue = r + b < g * 0.6;
const isGreenDominant = isGreenish && hasLowRedBlue;
// Method 3: Check for uniform synthetic-looking colors
// Chrome often uses specific green values
const isTypicalChromeGreen =
(g >= 240 && r <= 50 && b <= 50) || // Very bright green
(g >= 200 && r <= 80 && b <= 80) || // Bright green
(g >= 160 && r <= 60 && b <= 60); // Medium green
// Method 4: HSV-like check - high green saturation
const max = Math.max(r, g, b);
const min = Math.min(r, g, b);
const saturation = max > 0 ? (max - min) / max : 0;
const isHighSaturationGreen = g === max && saturation > 0.5 && g > 120;
// Return true if any of the methods detect green
return isBrightGreen || isGreenDominant || isTypicalChromeGreen || isHighSaturationGreen;
};
/**
* Helper function that waits for virtual background to be applied
*/
export const waitForVirtualBackgroundToApply = async (page: Page, maxWaitTime: number = 5000): Promise<boolean> => {
const startTime = Date.now();
while (Date.now() - startTime < maxWaitTime) {
const isApplied = await isVirtualBackgroundApplied(page);
if (isApplied) {
console.log('✅ Virtual background detected');
return true;
}
await page.waitForTimeout(500); // Check every 500ms
}
console.log('❌ Virtual background not detected after waiting');
return false;
};
export const saveScreenshot = async (page: Page, filename: string, selector: string) => {
const element = await waitForElementInIframe(page, selector);
await element.screenshot({ path: filename });
};
export const openMoreOptionsMenu = async (page: Page) => {
await waitForElementInIframe(page, '#toolbar', { state: 'visible' });
// Open more options menu
await interactWithElementInIframe(page, '#more-options-btn', { action: 'click' });
await page.waitForTimeout(500); // Wait for menu animation
};
export const closeMoreOptionsMenu = async (page: Page) => {
await interactWithElementInIframe(page, 'body', { action: 'click' });
await page.waitForTimeout(500); // Wait for menu to close
};