-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathCallWithChatComposite.test.ts
More file actions
109 lines (95 loc) · 3.53 KB
/
CallWithChatComposite.test.ts
File metadata and controls
109 lines (95 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { TEST_PARTICIPANTS } from '../../common/constants';
import {
buildUrl,
dataUiId,
isTestProfileDesktop,
loadCallPageWithParticipantVideos,
pageClick,
stableScreenshot,
waitForCallWithChatCompositeToLoad,
waitForPiPiPToHaveLoaded,
waitForSelector
} from '../../common/utils';
import { test } from './fixture';
import { expect, Page } from '@playwright/test';
import { createCallWithChatObjectsAndUsers } from '../../common/fixtureHelpers';
import { CallWithChatUserType } from '../../common/fixtureTypes';
test.describe('CallWithChat Composite Pre-Join Tests', () => {
test.beforeEach(async ({ pages, users, serverUrl }) => {
await callWithChatTestSetup({ pages, users, serverUrl });
});
test('Pre-join screen loads correctly', async ({ pages }) => {
const page = pages[0];
if (!page) {
throw new Error('Pages[0] not found');
}
expect(await stableScreenshot(page)).toMatchSnapshot(`call-with-chat-pre-join-screen.png`);
});
});
test.describe('CallWithChat Composite CallWithChat Page Tests', () => {
test.beforeEach(async ({ pages, users, serverUrl }) => {
await callWithChatTestSetup({ pages, users, serverUrl });
await loadCallPageWithParticipantVideos(pages);
});
test('People pane opens and displays correctly', async ({ pages }, testInfo) => {
const page = pages[1];
if (!page) {
throw new Error('Pages[1] not found');
}
if (isTestProfileDesktop(testInfo)) {
await pageClick(page, dataUiId('common-call-composite-people-button'));
} else {
await pageClick(page, dataUiId('common-call-composite-more-button'));
const drawerPeopleMenuDiv = await page.$('div[role="menu"] >> text=People');
await drawerPeopleMenuDiv?.click();
}
await waitForSelector(page, dataUiId('people-pane-content'));
if (!isTestProfileDesktop(testInfo)) {
await waitForPiPiPToHaveLoaded(page);
}
expect(await stableScreenshot(page)).toMatchSnapshot(`call-with-chat-gallery-screen-with-people-pane.png`);
});
test('More Drawer menu opens and can choose to be on hold', async ({ pages }) => {
const page = pages[1];
if (!page) {
throw new Error('Pages[1] not found');
}
await pageClick(page, dataUiId('common-call-composite-more-button'));
const moreButtonHoldCallButton = await page.$('div[role="menu"] >> text="Hold call"');
await moreButtonHoldCallButton?.click();
await waitForSelector(page, dataUiId('hold-page'));
expect(await stableScreenshot(page)).toMatchSnapshot(`call-with-chat-more-drawer-hold-call.png`);
});
});
/**
*
* Loads the CallWithChat Composite test app on the given pages with unique users.
* This function creates unique call and chat objects for each user, navigates to the
* specified server URL, and waits for the CallWithChat Composite to load.
*/
export const callWithChatTestSetup = async ({
pages,
users,
serverUrl,
qArgs
}: {
pages: Page[];
users: CallWithChatUserType[];
serverUrl: string;
/** optional query parameters for the page url */
qArgs?: { [key: string]: string };
}): Promise<void> => {
// ensure calls and chats are always unique per test
users = await createCallWithChatObjectsAndUsers(TEST_PARTICIPANTS);
for (const i in pages) {
const page = pages[i];
const user = users[i];
if (!page || !user) {
throw new Error('Page and user must be defined');
}
await page.goto(buildUrl(serverUrl, user, qArgs));
await waitForCallWithChatCompositeToLoad(page);
}
};