Skip to content

Commit

Permalink
Merge pull request #427 from ant-media/fixAudioIsFalseInMediaConstraints
Browse files Browse the repository at this point in the history
Remove default media constraints
  • Loading branch information
mustafaboleken authored Dec 6, 2024
2 parents 5355bd8 + e3741d1 commit 790bf10
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function ParticipantListButton({ footer }) {
>
<SvgIcon size={32} color={conference?.participantListDrawerOpen ? '#000' : '#fff'} name={'participants'} />
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a style={{color: conference?.participantListDrawerOpen ? '#000' : '#fff'}}>{Object.keys(conference.allParticipants).length}</a>
<a style={{color: conference?.participantListDrawerOpen ? '#000' : '#fff'}}>{conference.participantCount}</a>
</CustomizedBtn>
</Tooltip>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// src/EndCallButton.test.js
import React from 'react';
import { render } from '@testing-library/react';
import { ConferenceContext } from 'pages/AntMedia';
import EndCallButton from "../../../../Components/Footer/Components/EndCallButton";

// Mock the context value
const contextValue = {
setLeftTheRoom: jest.fn(),
};

// Mock the useContext hook
jest.mock('react', () => ({
...jest.requireActual('react'),
useContext: jest.fn(),
}));

describe('End Call Button Component', () => {

beforeEach(() => {
// Reset the mock implementation before each test
jest.clearAllMocks();

React.useContext.mockImplementation(input => {
if (input === ConferenceContext) {
return contextValue;
}
return jest.requireActual('react').useContext(input);
});
});


it('renders without crashing', () => {
render(
<EndCallButton />
);
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// src/FakeParticipantButton.test.js
import React from 'react';
import { render } from '@testing-library/react';
import { ConferenceContext } from 'pages/AntMedia';
import EndCallButton from "../../../../Components/Footer/Components/EndCallButton";
import FakeParticipantButton from "../../../../Components/Footer/Components/FakeParticipantButton";

// Mock the context value
const contextValue = {
setLeftTheRoom: jest.fn(),
};

// Mock the useContext hook
jest.mock('react', () => ({
...jest.requireActual('react'),
useContext: jest.fn(),
}));

describe('Fake Participant Button Component', () => {

beforeEach(() => {
// Reset the mock implementation before each test
jest.clearAllMocks();

React.useContext.mockImplementation(input => {
if (input === ConferenceContext) {
return contextValue;
}
return jest.requireActual('react').useContext(input);
});
});


it('renders without crashing', () => {
render(
<FakeParticipantButton />
);
});

});
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// src/Button.test.js
import React from 'react';
import { render } from '@testing-library/react';
import {act, render} from '@testing-library/react';
import { ConferenceContext } from 'pages/AntMedia';
import ParticipantListButton from 'Components/Footer/Components/ParticipantListButton';
import { random } from 'lodash';

// Mock the context value
const contextValue = {
allParticipants: {},
participantCount: 0,
setParticipantCount: jest.fn()
};

// Mock the useContext hook
Expand Down Expand Up @@ -37,11 +39,14 @@ describe('ParticipantList Button Component', () => {
);
});

it('check the count on button', () => {
it('check the count on button', async () => {
var noOfParticipants = random(1, 10);
for (let i = 0; i < noOfParticipants; i++) {
contextValue.allParticipants[`k${i}`] = `v${i}`;
}

await act(()=>
{
contextValue.setParticipantCount(noOfParticipants)
contextValue.participantCount = noOfParticipants;
});

const { container, getByText, getByRole } = render(
<ParticipantListButton />
Expand Down
48 changes: 48 additions & 0 deletions react/src/__tests__/pages/LeftTheRoom.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// src/LeftTheRoom.test.js
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { ConferenceContext } from 'pages/AntMedia';
import theme from "styles/theme";
import { ThemeProvider } from '@mui/material/styles';
import {ThemeList} from "styles/themeList";
import LeftTheRoom from "../../pages/LeftTheRoom";

// Mock the context value
const contextValue = {
allParticipants: {},
videoTrackAssignments: [{id: 1, name: 'test'}],
globals: {desiredTileCount: 10},
handleLeaveFromRoom: jest.fn(),
};

// Mock the useContext hook
jest.mock('react', () => ({
...jest.requireActual('react'),
useContext: jest.fn(),
}));

describe('Left The Room Component', () => {

beforeEach(() => {
// Reset the mock implementation before each test
jest.clearAllMocks();

React.useContext.mockImplementation(input => {
if (input === ConferenceContext) {
return contextValue;
}
return jest.requireActual('react').useContext(input);
});
});


it('renders without crashing', () => {
const { container, getByText, getByRole } = render(
<ThemeProvider theme={theme(ThemeList.Green)}>
<LeftTheRoom />
</ThemeProvider>
);

console.log(container.outerHTML);
});
});
2 changes: 0 additions & 2 deletions react/src/pages/AntMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ function getMediaConstraints(videoSendResolution, frameRate) {
};
break;
default:
constraint = { video: true };
break;
}

Expand Down Expand Up @@ -1274,7 +1273,6 @@ function AntMedia(props) {
if (devices.length > 0) {
checkAndUpdateVideoAudioSources();
} else {
mediaConstraints = getMediaConstraints(null, 20);
navigator.mediaDevices.enumerateDevices().then(devices => {
setDevices(devices);
});
Expand Down

0 comments on commit 790bf10

Please sign in to comment.