Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIDEO-12945 Upgrade to twilio-video@2.27.0 and @twilio/video-processors@2.0.0 #808

Merged
merged 5 commits into from
Jun 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
VIDEO-12945 Passing unit tests.
  • Loading branch information
manjeshbhargav committed Jun 30, 2023
commit 9028101ce433911aa110a05f48cc137a4b902246
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const mockLoadModel = jest.fn();
let mockIsSupported = true;
jest.mock('@twilio/video-processors', () => {
return {
Pipeline: {
WebGL2: 'webgl2',
},
GaussianBlurBackgroundProcessor: jest.fn().mockImplementation(() => {
return {
loadModel: mockLoadModel,
Expand Down Expand Up @@ -102,10 +105,16 @@ describe('The useBackgroundSettings hook ', () => {
});
backgroundSettings = renderResult.current[0];
expect(backgroundSettings.type).toEqual('blur');
expect(mockVideoTrack.addProcessor).toHaveBeenCalledWith({
loadModel: mockLoadModel,
name: 'GaussianBlurBackgroundProcessor',
});
expect(mockVideoTrack.addProcessor).toHaveBeenCalledWith(
{
loadModel: mockLoadModel,
name: 'GaussianBlurBackgroundProcessor',
},
{
inputFrameBufferType: 'video',
outputFrameBufferContextType: 'webgl2',
}
);
});

it('should set the background settings correctly and remove the video processor when "none" is selected', async () => {
Expand All @@ -127,11 +136,17 @@ describe('The useBackgroundSettings hook ', () => {
backgroundSettings = renderResult.current[0];
expect(backgroundSettings.type).toEqual('image');
expect(backgroundSettings.index).toEqual(2);
expect(mockVideoTrack.addProcessor).toHaveBeenCalledWith({
backgroundImage: expect.any(Object),
loadModel: mockLoadModel,
name: 'VirtualBackgroundProcessor',
});
expect(mockVideoTrack.addProcessor).toHaveBeenCalledWith(
{
backgroundImage: expect.any(Object),
loadModel: mockLoadModel,
name: 'VirtualBackgroundProcessor',
},
{
inputFrameBufferType: 'video',
outputFrameBufferContextType: 'webgl2',
}
);
});

describe('The setBackgroundSettings function ', () => {
Expand Down Expand Up @@ -165,10 +180,16 @@ describe('The useBackgroundSettings hook ', () => {
await act(async () => {
setBackgroundSettings(imgSettings);
});
expect(mockVideoTrack.addProcessor).not.toHaveBeenCalledWith({
loadModel: mockLoadModel,
name: 'GaussianBlurBackgroundProcessor',
});
expect(mockVideoTrack.addProcessor).not.toHaveBeenCalledWith(
{
loadModel: mockLoadModel,
name: 'GaussianBlurBackgroundProcessor',
},
{
inputFrameBufferType: 'video',
outputFrameBufferContextType: 'webgl2',
}
);
expect(window.localStorage.getItem(SELECTED_BACKGROUND_SETTINGS_KEY)).toEqual(JSON.stringify(imgSettings));
});

Expand All @@ -177,11 +198,17 @@ describe('The useBackgroundSettings hook ', () => {
await act(async () => {
setBackgroundSettings(blurSettings);
});
expect(mockVideoTrack.addProcessor).not.toHaveBeenCalledWith({
loadModel: mockLoadModel,
backgroundImage: expect.any(Object),
name: 'VirtualBackgroundProcessor',
});
expect(mockVideoTrack.addProcessor).not.toHaveBeenCalledWith(
{
loadModel: mockLoadModel,
backgroundImage: expect.any(Object),
name: 'VirtualBackgroundProcessor',
},
{
inputFrameBufferType: 'video',
outputFrameBufferContextType: 'webgl2',
}
);
expect(window.localStorage.getItem(SELECTED_BACKGROUND_SETTINGS_KEY)).toEqual(JSON.stringify(blurSettings));
});

Expand Down