Skip to content

Commit be7d399

Browse files
Removed workaround for mouseDown event in jest tests (#3673)
1 parent 9111b49 commit be7d399

5 files changed

Lines changed: 28 additions & 37 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Removed workaround for mouseDown event in jest tests. Removed duplicated strict mode from Calling sample app",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Removed workaround for mouseDown event in jest tests. Removed duplicated strict mode from Calling sample app",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}

packages/react-components/src/components/SendBox.test.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import { render, waitFor, act, fireEvent } from '@testing-library/react';
1212
import userEvent from '@testing-library/user-event';
1313
/* @conditional-compile-remove(mention) */
1414
import { Mention } from './MentionPopover';
15-
/* @conditional-compile-remove(mention) */
16-
import { triggerMouseEvent } from './utils/testUtils';
1715

1816
describe('SendBox strings should be localizable and overridable', () => {
1917
beforeAll(() => {
@@ -206,10 +204,6 @@ describe('Clicks/Touch should select mention', () => {
206204
// Select the suggestion
207205
await selectFirstMention();
208206
expect(input.value).toBe(value + suggestions[0].displayText);
209-
// Fix for mousedown issue in userEvent when `document` become null unexpectedly
210-
await act(async () => {
211-
triggerMouseEvent(input, 'mousedown');
212-
});
213207
};
214208

215209
test('Mouse click on first word in mention should select mention', async () => {
@@ -292,10 +286,6 @@ describe('Clicks/Touch should select mention', () => {
292286
await userEvent.keyboard(' and');
293287
});
294288
const typedValue = trigger + suggestions[0].displayText + ' and';
295-
// Fix for mousedown issue in userEvent when `document` become null unexpectedly
296-
await act(async () => {
297-
triggerMouseEvent(input, 'mousedown');
298-
});
299289
// Triple click a letter at 14-th index
300290
await userEvent.pointer({
301291
keys: '[MouseLeft][MouseLeft][MouseLeft]',
@@ -446,10 +436,6 @@ describe('Keyboard events should be handled for mentions', () => {
446436
// Select the suggestion
447437
await selectMention(0);
448438
expect(input.value).toBe(value + suggestions[0].displayText);
449-
// Fix for mousedown issue in userEvent when `document` become null unexpectedly
450-
await act(async () => {
451-
triggerMouseEvent(input, 'mousedown');
452-
});
453439
};
454440

455441
test('Keyboard navigation with arrows should navigate mention by words', async () => {

packages/react-components/src/components/utils/testUtils.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,3 @@ export const createTestLocale = (testStrings: PartialDeep<ComponentStrings>): Co
5656
});
5757
return { strings };
5858
};
59-
60-
/** @private */
61-
// Trigger a mouse event manually to fix mouseDown event in userEvent
62-
// when `document` become null unexpectedly
63-
// https://github.com/jestjs/jest/issues/12670
64-
export const triggerMouseEvent = (node: HTMLElement, eventType: string): void => {
65-
const clickEvent = new MouseEvent(eventType, {
66-
view: window
67-
});
68-
node.dispatchEvent(clickEvent);
69-
};

samples/Calling/src/app/App.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,16 @@ const App = (): JSX.Element => {
204204
return <Spinner label={'Getting user credentials from server'} ariaLive="assertive" labelPosition="top" />;
205205
}
206206
return (
207-
<React.StrictMode>
208-
<CallScreen
209-
token={token}
210-
userId={userId}
211-
displayName={displayName}
212-
callLocator={callLocator}
213-
/* @conditional-compile-remove(PSTN-calls) */
214-
alternateCallerId={alternateCallerId}
215-
/* @conditional-compile-remove(teams-identity-support) */
216-
isTeamsIdentityCall={isTeamsCall}
217-
/>
218-
</React.StrictMode>
207+
<CallScreen
208+
token={token}
209+
userId={userId}
210+
displayName={displayName}
211+
callLocator={callLocator}
212+
/* @conditional-compile-remove(PSTN-calls) */
213+
alternateCallerId={alternateCallerId}
214+
/* @conditional-compile-remove(teams-identity-support) */
215+
isTeamsIdentityCall={isTeamsCall}
216+
/>
219217
);
220218
}
221219
default:

0 commit comments

Comments
 (0)