diff --git a/packages/jest-presets/package.json b/packages/jest-presets/package.json index 64a511b3de5c..b8649b4caa0a 100644 --- a/packages/jest-presets/package.json +++ b/packages/jest-presets/package.json @@ -16,6 +16,7 @@ "@swc/core": "~1.7.26", "@swc/jest": "~0.2.36", "@testing-library/jest-dom": "~6.4.8", + "@testing-library/react": "~16.0.1", "@types/jest-axe": "~3.5.9", "identity-obj-proxy": "~3.0.0", "jest-axe": "~9.0.0", diff --git a/packages/jest-presets/src/client/jest-setup.ts b/packages/jest-presets/src/client/jest-setup.ts index 87fe139acb29..bec26ced5b1e 100644 --- a/packages/jest-presets/src/client/jest-setup.ts +++ b/packages/jest-presets/src/client/jest-setup.ts @@ -1,5 +1,6 @@ import { TextEncoder, TextDecoder } from 'node:util'; +import { configure } from '@testing-library/react'; import { toHaveNoViolations } from 'jest-axe'; import * as uuid from 'uuid'; @@ -7,6 +8,8 @@ import '@testing-library/jest-dom'; expect.extend(toHaveNoViolations); +configure({ reactStrictMode: true }); + const urlByBlob = new WeakMap(); const blobByUrl = new Map(); diff --git a/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx b/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx index 72a8eecec4d0..c23d993dfc5b 100644 --- a/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx +++ b/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx @@ -17,8 +17,7 @@ type UserAutoCompleteProps = Omit, 'filter'> conditions?: { [key: string]: unknown }; }; -const UserAutoComplete = ({ value, onChange, ...props }: UserAutoCompleteProps): ReactElement => { - const { conditions = {} } = props; +const UserAutoComplete = ({ conditions = {}, value, onChange, ...props }: UserAutoCompleteProps): ReactElement => { const [filter, setFilter] = useState(''); const debouncedFilter = useDebouncedValue(filter, 1000); const usersAutoCompleteEndpoint = useEndpoint('GET', '/v1/users.autocomplete'); diff --git a/packages/ui-client/src/helpers/anchors.ts b/packages/ui-client/src/helpers/anchors.ts index 6cbc6d454846..a428168df598 100644 --- a/packages/ui-client/src/helpers/anchors.ts +++ b/packages/ui-client/src/helpers/anchors.ts @@ -20,6 +20,9 @@ const setAnchorRefCount = (anchorElement: HTMLElement, refCount: number): void = export const refAnchorElement = (anchorElement: HTMLElement): void => { setAnchorRefCount(anchorElement, getAnchorRefCount(anchorElement) + 1); + if (!anchorElement.parentElement) { + document.body.appendChild(anchorElement); + } }; export const unrefAnchorElement = (anchorElement: HTMLElement): void => { diff --git a/packages/ui-voip/src/components/VoipPopup/VoipPopup.spec.tsx b/packages/ui-voip/src/components/VoipPopup/VoipPopup.spec.tsx index 715acb8f7cc2..8a75a36e3d25 100644 --- a/packages/ui-voip/src/components/VoipPopup/VoipPopup.spec.tsx +++ b/packages/ui-voip/src/components/VoipPopup/VoipPopup.spec.tsx @@ -21,14 +21,18 @@ const mockedUseVoipSession = jest.mocked(useVoipSession); const appRoot = mockAppRoot(); it('should properly render incoming popup', async () => { - mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' })); + mockedUseVoipSession + .mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' })) + .mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' })); render(, { wrapper: appRoot.build() }); expect(screen.getByTestId('vc-popup-incoming')).toBeInTheDocument(); }); it('should properly render ongoing popup', async () => { - mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'ONGOING' })); + mockedUseVoipSession + .mockImplementationOnce(() => createMockVoipSession({ type: 'ONGOING' })) + .mockImplementationOnce(() => createMockVoipSession({ type: 'ONGOING' })); render(, { wrapper: appRoot.build() }); @@ -36,7 +40,9 @@ it('should properly render ongoing popup', async () => { }); it('should properly render outgoing popup', async () => { - mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'OUTGOING' })); + mockedUseVoipSession + .mockImplementationOnce(() => createMockVoipSession({ type: 'OUTGOING' })) + .mockImplementationOnce(() => createMockVoipSession({ type: 'OUTGOING' })); render(, { wrapper: appRoot.build() }); @@ -44,7 +50,9 @@ it('should properly render outgoing popup', async () => { }); it('should properly render error popup', async () => { - mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'ERROR' })); + mockedUseVoipSession + .mockImplementationOnce(() => createMockVoipSession({ type: 'ERROR' })) + .mockImplementationOnce(() => createMockVoipSession({ type: 'ERROR' })); render(, { wrapper: appRoot.build() }); @@ -58,7 +66,9 @@ it('should properly render dialer popup', async () => { }); it('should prioritize session over dialer', async () => { - mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' })); + mockedUseVoipSession + .mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' })) + .mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' })); render(, { wrapper: appRoot.build() }); diff --git a/packages/ui-voip/src/components/VoipPopup/__snapshots__/VoipPopup.spec.tsx.snap b/packages/ui-voip/src/components/VoipPopup/__snapshots__/VoipPopup.spec.tsx.snap index 8c8df4a661ec..b9dfc64de6dd 100644 --- a/packages/ui-voip/src/components/VoipPopup/__snapshots__/VoipPopup.spec.tsx.snap +++ b/packages/ui-voip/src/components/VoipPopup/__snapshots__/VoipPopup.spec.tsx.snap @@ -82,7 +82,7 @@ exports[`renders ErrorCall without crashing 1`] = ` class="rcx-box rcx-box--full rcx-css-dqa7fo rcx-css-keglju" >