Skip to content

Commit 6421c79

Browse files
Try mitigate flakey tooltips showing in UI tests (#1133)
1 parent b8def0a commit 6421c79

5 files changed

Lines changed: 43 additions & 14 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "Try mitigate flakey tests",
4+
"packageName": "@internal/react-composites",
5+
"email": "2684369+JamesBurnside@users.noreply.github.com",
6+
"dependentChangeType": "none"
7+
}

packages/react-composites/tests/browser/call/CallComposite.test.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
3-
import { buildUrl, dataUiId, loadCallPageWithParticipantVideos, waitForCallCompositeToLoad } from '../common/utils';
3+
import {
4+
buildUrl,
5+
dataUiId,
6+
loadCallPageWithParticipantVideos,
7+
pageClick,
8+
waitForCallCompositeToLoad
9+
} from '../common/utils';
410
import { test } from './fixture';
511
import { expect, Page } from '@playwright/test';
612
import { v1 as generateGUID } from 'uuid';
@@ -47,8 +53,8 @@ test.describe('Call Composite E2E Configuration Screen Tests', () => {
4753

4854
test('local device settings can toggle camera & audio', async ({ pages }) => {
4955
const page = pages[0];
50-
await page.click(dataUiId('call-composite-local-device-settings-microphone-button'));
51-
await page.click(dataUiId('call-composite-local-device-settings-camera-button'));
56+
await pageClick(page, dataUiId('call-composite-local-device-settings-microphone-button'));
57+
await pageClick(page, dataUiId('call-composite-local-device-settings-camera-button'));
5258
await page.waitForFunction(() => {
5359
const videoNode = document.querySelector('video');
5460
const videoLoaded = videoNode?.readyState === 4;
@@ -124,7 +130,7 @@ test.describe('Call Composite E2E CallPage Tests', () => {
124130
const page = pages[idx];
125131
await page.bringToFront();
126132

127-
await page.click(dataUiId('call-composite-participants-button'));
133+
await pageClick(page, dataUiId('call-composite-participants-button'));
128134
const buttonCallOut = await page.waitForSelector('.ms-Callout');
129135
// This will ensure no animation is happening for the callout
130136
await buttonCallOut.waitForElementState('stable');
@@ -137,7 +143,7 @@ test.describe('Call Composite E2E CallPage Tests', () => {
137143
const page = pages[0];
138144

139145
await page.bringToFront();
140-
await page.click(dataUiId('call-composite-camera-button'));
146+
await pageClick(page, dataUiId('call-composite-camera-button'));
141147
await page.waitForFunction(() => {
142148
return document.querySelectorAll('video').length === 1;
143149
});
@@ -167,7 +173,7 @@ test.describe('Call Composite E2E Call Ended Pages', () => {
167173
test('Left call page should show when end call button clicked', async ({ pages }) => {
168174
const page = pages[0];
169175
await page.bringToFront();
170-
await page.click(dataUiId('call-composite-hangup-button'));
176+
await pageClick(page, dataUiId('call-composite-hangup-button'));
171177
await page.waitForSelector(dataUiId('left-call-page'));
172178
expect(await page.screenshot()).toMatchSnapshot(`left-call-page.png`);
173179
});
@@ -220,11 +226,11 @@ test.describe('Call composite participant menu items injection tests', () => {
220226
await page.bringToFront();
221227

222228
// Open participants flyout.
223-
await page.click(dataUiId('call-composite-participants-button'), { timeout: PER_STEP_TIMEOUT_MS });
229+
await pageClick(page, dataUiId('call-composite-participants-button'), { timeout: PER_STEP_TIMEOUT_MS });
224230
// Open participant list flyout
225-
await page.click(dataUiId(IDS.participantButtonPeopleMenuItem), { timeout: PER_STEP_TIMEOUT_MS });
231+
await pageClick(page, dataUiId(IDS.participantButtonPeopleMenuItem), { timeout: PER_STEP_TIMEOUT_MS });
226232
// There shouldbe at least one participant. Just click on the first.
227-
await page.click(dataUiId(IDS.participantItemMenuButton) + ' >> nth=0', {
233+
await pageClick(page, dataUiId(IDS.participantItemMenuButton) + ' >> nth=0', {
228234
timeout: PER_STEP_TIMEOUT_MS
229235
});
230236

@@ -241,7 +247,7 @@ test.describe('Call composite participant menu items injection tests', () => {
241247
const turnOffAllVideos = async (pages: Page[], timeout?: number): Promise<void> => {
242248
const options = timeout ? { timeout } : undefined;
243249
for (const page of pages) {
244-
await page.click(dataUiId('call-composite-camera-button'), options);
250+
await pageClick(page, dataUiId('call-composite-camera-button'), options);
245251
}
246252
for (const page of pages) {
247253
await page.bringToFront();
Loading

packages/react-composites/tests/browser/common/utils.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ import { ChatUserType, CallUserType, MeetingUserType } from './fixtureTypes';
88
/** Selector string to get element by data-ui-id property */
99
export const dataUiId = (id: string): string => `[data-ui-id="${id}"]`;
1010

11+
/**
12+
* Page click helper function - USE INSTEAD OF PAGE.CLICK
13+
*
14+
* This functions clicks the elements then moves the mouse away to prevent
15+
* hover behavior appearing non-deterministically in snapshots.
16+
* Examples of this are tooltips for control bar buttons would show, as well
17+
* as buttons would show their onHover state.
18+
*/
19+
export const pageClick = async (page: Page, selector: string): Promise<void> => {
20+
await page.click(selector);
21+
22+
// Move the mouse off the screen
23+
await page.mouse.move(-1, -1);
24+
};
25+
1126
/**
1227
* Wait for the ChatComposite on a page to fully load.
1328
*/
@@ -48,7 +63,7 @@ export const waitForMeetingCompositeToLoad = async (page: Page): Promise<void> =
4863
export const loadCallPage = async (pages: Page[]): Promise<void> => {
4964
for (const page of pages) {
5065
await page.bringToFront();
51-
await page.click(dataUiId('call-composite-start-call-button'));
66+
await pageClick(page, dataUiId('call-composite-start-call-button'));
5267

5368
// Wait for call page to load (i.e. wait for connecting screen to have passed)
5469
await page.waitForSelector(dataUiId('call-page'));
@@ -75,8 +90,8 @@ export const loadCallPageWithParticipantVideos = async (pages: Page[]): Promise<
7590
// Start local camera and start the call
7691
for (const page of pages) {
7792
await page.bringToFront();
78-
await page.click(dataUiId('call-composite-local-device-settings-camera-button'));
79-
await page.click(dataUiId('call-composite-start-call-button'));
93+
await pageClick(page, dataUiId('call-composite-local-device-settings-camera-button'));
94+
await pageClick(page, dataUiId('call-composite-start-call-button'));
8095

8196
// Wait for call page to load (i.e. wait for connecting screen to have passed)
8297
await page.waitForSelector(dataUiId('call-page'));

packages/react-composites/tests/browser/meeting/MeetingComposite.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
buildUrl,
77
dataUiId,
88
loadCallPageWithParticipantVideos,
9+
pageClick,
910
stubMessageTimestamps,
1011
waitForMeetingCompositeToLoad
1112
} from '../common/utils';
@@ -88,7 +89,7 @@ test.describe('Meeting Composite Meeting Page Tests', () => {
8889

8990
test('People pane opens and displays correctly', async ({ pages }) => {
9091
const page = pages[1];
91-
await page.click(dataUiId('meeting-composite-people-button'));
92+
await pageClick(page, dataUiId('meeting-composite-people-button'));
9293
await page.waitForSelector(dataUiId('meeting-composite-people-pane'));
9394
expect(await page.screenshot()).toMatchSnapshot(`meeting-gallery-screen-with-people-pane.png`);
9495
});

0 commit comments

Comments
 (0)