Skip to content

Commit 8f82209

Browse files
Add UI test for custom composite call control options (#2324)
1 parent f1d6c74 commit 8f82209

19 files changed

Lines changed: 87 additions & 10 deletions

packages/react-composites/tests/app/call/BaseApp.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ export function BaseApp(props: { queryArgs: QueryArgs; callAdapter?: CallAdapter
4646
queryArgs.injectParticipantMenuItems ? onFetchParticipantMenuItems : undefined
4747
}
4848
options={
49-
queryArgs.injectCustomButtons
49+
queryArgs.customCallCompositeOptions
50+
? queryArgs.customCallCompositeOptions
51+
: queryArgs.injectCustomButtons
5052
? {
5153
callControls: {
5254
onFetchCustomButtonProps,

packages/react-composites/tests/app/call/QueryArgs.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license.
33

44
import { Role } from '@internal/react-components';
5+
import { CallCompositeOptions } from '../../../src';
56
import { MockCallAdapterState } from '../../common';
67

78
export interface QueryArgs {
@@ -12,6 +13,7 @@ export interface QueryArgs {
1213
injectParticipantMenuItems: boolean;
1314
injectCustomButtons: boolean;
1415
role?: Role;
16+
customCallCompositeOptions?: CallCompositeOptions;
1517

1618
// These are only set for live tests.
1719
// TODO: Separate the args out better.
@@ -34,6 +36,9 @@ export function parseQueryArgs(): QueryArgs {
3436
groupId: params.groupId ?? '',
3537
token: params.token ?? '',
3638
displayName: params.displayName ?? '',
37-
role: (params.role as Role) ?? undefined
39+
role: (params.role as Role) ?? undefined,
40+
customCallCompositeOptions: params.customCallCompositeOptions
41+
? JSON.parse(params.customCallCompositeOptions)
42+
: undefined
3843
};
3944
}

packages/react-composites/tests/app/callwithchat/BaseApp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function BaseApp(props: { queryArgs: CommonQueryArgs; adapter?: CallWithC
2323
adapter={adapter}
2424
formFactor={isMobile() ? 'mobile' : 'desktop'}
2525
joinInvitationURL={window.location.href}
26+
options={props.queryArgs.customCompositeOptions}
2627
/>
2728
</_IdentifierProvider>
2829
</div>

packages/react-composites/tests/app/callwithchat/QueryArgs.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4+
import type { CallWithChatCompositeOptions } from '../../../src';
45
import type { FakeChatAdapterArgs, MockCallAdapterState } from '../../common';
56

67
/**
@@ -28,20 +29,20 @@ export interface HermeticQueryArgs {
2829
}
2930

3031
/**
31-
* Common arguments (e.g. to control composite behavior).
32-
*
33-
* Unknown for now.
32+
* Common arguments (e.g. to control composite behavior) for both live and hermetic tests.
3433
*
3534
* @private
3635
*/
37-
export type CommonQueryArgs = unknown;
36+
export interface CommonQueryArgs {
37+
customCompositeOptions?: CallWithChatCompositeOptions;
38+
}
3839

3940
/**
4041
* All query arguments accepted by the test app.
4142
*
4243
* @private
4344
*/
44-
export type QueryArgs = Partial<LiveQueryArgs> & Partial<HermeticQueryArgs> & CommonQueryArgs;
45+
export type QueryArgs = Partial<LiveQueryArgs> & Partial<HermeticQueryArgs> & Partial<CommonQueryArgs>;
4546

4647
export function parseQueryArgs(): QueryArgs {
4748
const urlSearchParams = new URLSearchParams(window.location.search);
@@ -55,6 +56,8 @@ export function parseQueryArgs(): QueryArgs {
5556
userId: params.userId ?? '',
5657

5758
fakeChatAdapterArgs: params.fakeChatAdapterArgs ? JSON.parse(params.fakeChatAdapterArgs) : undefined,
58-
mockCallAdapterState: params.mockCallAdapterState ? JSON.parse(params.mockCallAdapterState) : undefined
59+
mockCallAdapterState: params.mockCallAdapterState ? JSON.parse(params.mockCallAdapterState) : undefined,
60+
61+
customCompositeOptions: params.customCompositeOptions ? JSON.parse(params.customCompositeOptions) : undefined
5962
};
6063
}

packages/react-composites/tests/browser/call/hermetic/CallControls.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { buildUrlWithMockAdapter, defaultMockCallAdapterState, defaultMockRemote
55
import { expect } from '@playwright/test';
66
import { dataUiId, stableScreenshot, waitForSelector } from '../../common/utils';
77
import { IDS } from '../../common/constants';
8+
import type { CallCompositeOptions } from '../../../../src';
89

910
test.describe('CallControls tests', async () => {
1011
test('CallControls when number of mics drops to zero', async ({ page, serverUrl }) => {
@@ -31,3 +32,29 @@ test.describe('Call composite custom button injection tests', () => {
3132
expect(await stableScreenshot(page)).toMatchSnapshot(`custom-buttons.png`);
3233
});
3334
});
35+
36+
test.describe('Call composite custom call control options tests', () => {
37+
test('Control bar buttons correctly show as compact with camera disabled and end call button hidden', async ({
38+
page,
39+
serverUrl
40+
}) => {
41+
const initialState = defaultMockCallAdapterState([defaultMockRemoteParticipant('Paul Bridges')]);
42+
const testOptions: CallCompositeOptions = {
43+
callControls: {
44+
displayType: 'compact',
45+
cameraButton: {
46+
disabled: true
47+
},
48+
microphoneButton: true,
49+
endCallButton: false,
50+
devicesButton: undefined
51+
}
52+
};
53+
await page.goto(
54+
buildUrlWithMockAdapter(serverUrl, initialState, {
55+
customCallCompositeOptions: JSON.stringify(testOptions)
56+
})
57+
);
58+
expect(await stableScreenshot(page)).toMatchSnapshot(`user-set-control-bar-button-options.png`);
59+
});
60+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { loadCallPage, test } from './fixture';
5+
import { expect } from '@playwright/test';
6+
import { stableScreenshot } from '../../common/utils';
7+
import type { CallWithChatCompositeOptions } from '../../../../src';
8+
import { defaultMockCallAdapterState, defaultMockRemoteParticipant } from '../../call/hermetic/fixture';
9+
10+
test.describe('Custom call control options tests', () => {
11+
test('Control bar buttons correctly show as compact with camera disabled and end call button hidden', async ({
12+
page,
13+
serverUrl
14+
}) => {
15+
const paul = defaultMockRemoteParticipant('Paul Bridges');
16+
const testOptions: CallWithChatCompositeOptions = {
17+
callControls: {
18+
displayType: 'compact',
19+
cameraButton: {
20+
disabled: true
21+
},
22+
endCallButton: false,
23+
microphoneButton: true,
24+
moreButton: undefined
25+
}
26+
};
27+
const callState = defaultMockCallAdapterState([paul]);
28+
await loadCallPage(page, serverUrl, callState, {
29+
customCompositeOptions: JSON.stringify(testOptions)
30+
});
31+
32+
expect(await stableScreenshot(page)).toMatchSnapshot(`user-set-control-bar-button-options.png`);
33+
});
34+
});

packages/react-composites/tests/browser/callwithchat/hermetic/fixture.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ export const test = base.extend<TestFixture>({
7171
* - load the hermetic CallWithChat test app on the page.
7272
* - wait for the page to have completely loaded.
7373
*/
74-
export async function loadCallPage(page: Page, serverUrl: string, callState: MockCallAdapterState): Promise<void> {
74+
export async function loadCallPage(
75+
page: Page,
76+
serverUrl: string,
77+
callState: MockCallAdapterState,
78+
qArgs?: { [key: string]: string } // TODO: more strongly type this with a type like: `Partial<Record<keyof QueryArgs, string>>`
79+
): Promise<void> {
7580
const chatArgs = fakeChatAdapterArgsForCallAdapterState(callState);
76-
await page.goto(buildUrlForApp(serverUrl, callState, chatArgs));
81+
await page.goto(buildUrlForApp(serverUrl, callState, chatArgs, qArgs));
7782
await waitForPageFontsLoaded(page);
7883
await waitForSelector(page, dataUiId('call-composite-hangup-button'));
7984
}
Loading

0 commit comments

Comments
 (0)