Skip to content

Commit 02fd3f4

Browse files
czoli1976claude
andcommitted
VIDSOL-619: Fix tests for Mirror Self View Toggle feature
- Add mirrorSelfView: true to user.spec.tsx expected defaultSettings - Add UserProvider wrapper to BackgroundVideoContainer.spec.tsx (component now uses useUserContext) - Update DeviceSettingsMenu.spec.tsx: add providers.user and userContext to RenderOptions, use queryAllByTestId for dropdown-separator (two separators now rendered) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 17f2148 commit 02fd3f4

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

frontend/src/Context/tests/user.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe('UserContext', () => {
4343
audioSource: undefined,
4444
videoSource: undefined,
4545
publishCaptions: true,
46+
mirrorSelfView: true,
4647
},
4748
issues: {
4849
reconnections: 0,

frontend/src/components/BackgroundEffects/BackgroundVideoContainer/BackgroundVideoContainer.spec.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import { act, render, screen, waitFor } from '@testing-library/react';
22
import { describe, expect, it, vi } from 'vitest';
3+
import { ReactNode } from 'react';
4+
import UserProvider from '../../../Context/user';
35
import BackgroundVideoContainer from './BackgroundVideoContainer';
46

57
vi.mock('../../../utils/waitUntilPlaying', () => ({
68
__esModule: true,
79
default: vi.fn(() => Promise.resolve()),
810
}));
911

12+
const wrapper = ({ children }: { children: ReactNode }) => <UserProvider>{children}</UserProvider>;
13+
1014
describe('BackgroundVideoContainer', () => {
1115
it('shows message when video is not enabled', () => {
12-
render(<BackgroundVideoContainer isParentVideoEnabled={false} />);
16+
render(<BackgroundVideoContainer isParentVideoEnabled={false} />, { wrapper });
1317
expect(screen.getByText(/Your camera is turned off/i)).toBeInTheDocument();
1418
});
1519

1620
it('renders video element when video is enabled', async () => {
1721
const videoEl = document.createElement('video');
1822
act(() => {
19-
render(<BackgroundVideoContainer isParentVideoEnabled publisherVideoElement={videoEl} />);
23+
render(<BackgroundVideoContainer isParentVideoEnabled publisherVideoElement={videoEl} />, {
24+
wrapper,
25+
});
2026
});
2127
await waitFor(() => {
2228
expect(videoEl.classList.contains('video__element')).toBe(true);
@@ -27,7 +33,9 @@ describe('BackgroundVideoContainer', () => {
2733
it('shows loading spinner while video is loading', async () => {
2834
const videoEl = document.createElement('video');
2935
act(() => {
30-
render(<BackgroundVideoContainer isParentVideoEnabled publisherVideoElement={videoEl} />);
36+
render(<BackgroundVideoContainer isParentVideoEnabled publisherVideoElement={videoEl} />, {
37+
wrapper,
38+
});
3139
});
3240
await waitFor(() => {
3341
expect(screen.getByRole('progressbar')).toBeInTheDocument();

frontend/src/components/MeetingRoom/DeviceSettingsMenu/DeviceSettingsMenu.spec.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ describe('DeviceSettingsMenu Component', () => {
314314
);
315315

316316
await waitFor(() => {
317-
expect(screen.queryByTestId('dropdown-separator')).toBeVisible();
317+
expect(screen.queryAllByTestId('dropdown-separator')[0]).toBeVisible();
318318
expect(screen.queryByText('Video effects')).toBeVisible();
319319
});
320320
});
321321

322-
it('and does not render the dropdown separator and video effects option when media processor is not supported', async () => {
322+
it('and does not render the video effects option when media processor is not supported', async () => {
323323
render(
324324
<DeviceSettingsMenuComponent
325325
deviceType={deviceType}
@@ -333,12 +333,12 @@ describe('DeviceSettingsMenu Component', () => {
333333
);
334334

335335
await waitFor(() => {
336-
expect(screen.queryByTestId('dropdown-separator')).not.toBeInTheDocument();
337-
expect(screen.queryByText('video effects')).not.toBeInTheDocument();
336+
expect(screen.queryByText('Video effects')).not.toBeInTheDocument();
337+
expect(screen.queryByText('Mirror Self View')).toBeInTheDocument();
338338
});
339339
});
340340

341-
it('and does not render the dropdown separator and video effects option when allowBackgroundEffects is false', async () => {
341+
it('and does not render the video effects option when allowBackgroundEffects is false', async () => {
342342
render(
343343
<DeviceSettingsMenuComponent
344344
deviceType={deviceType}
@@ -364,20 +364,22 @@ describe('DeviceSettingsMenu Component', () => {
364364
);
365365

366366
await waitFor(() => {
367-
expect(screen.queryByTestId('dropdown-separator')).not.toBeInTheDocument();
368-
expect(screen.queryByText('video effects')).not.toBeInTheDocument();
367+
expect(screen.queryByText('Video effects')).not.toBeInTheDocument();
368+
expect(screen.queryByText('Mirror Self View')).toBeInTheDocument();
369369
});
370370
});
371371
});
372372
});
373373

374374
type RenderOptions = {
375375
appConfigContext?: ProviderOptions['AppConfigContext'];
376+
userContext?: ProviderOptions['UserContext'];
376377
};
377378

378-
function render(ui: ReactElement, { appConfigContext }: RenderOptions = {}) {
379-
const { wrapper, ...context } = makeTestProvider([providers.appConfig], {
379+
function render(ui: ReactElement, { appConfigContext, userContext }: RenderOptions = {}) {
380+
const { wrapper, ...context } = makeTestProvider([providers.appConfig, providers.user], {
380381
appConfigContext,
382+
userContext,
381383
});
382384

383385
return {

0 commit comments

Comments
 (0)