33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- import { render } from '@testing-library/react' ;
6+ import { render , act , fireEvent , waitFor } from '@testing-library/react' ;
77import { configure } from 'enzyme' ;
8- import Adapter from 'enzyme-adapter-react-16 ' ;
8+ import Adapter from '@cfaester/ enzyme-adapter-react-18 ' ;
99import React from 'react' ;
1010import { MOCK_DATA } from '../../../../test/mocks/mockData' ;
1111import {
@@ -36,7 +36,7 @@ describe('<ChannelDetailsActions /> spec', () => {
3636 expect ( utils . container . firstChild ) . toMatchSnapshot ( ) ;
3737 } ) ;
3838
39- it ( 'opens popover' , ( ) => {
39+ it ( 'opens popover' , async ( ) => {
4040 const channel = MOCK_DATA . chime ;
4141 const utils = render (
4242 < ServicesContext . Provider value = { notificationServiceMock } >
@@ -45,11 +45,11 @@ describe('<ChannelDetailsActions /> spec', () => {
4545 </ CoreServicesContext . Provider >
4646 </ ServicesContext . Provider >
4747 ) ;
48- utils . getByText ( 'Actions' ) . click ( ) ;
48+ await act ( async ( ) => fireEvent . click ( utils . getByText ( 'Actions' ) ) ) ;
4949 expect ( utils . container . firstChild ) . toMatchSnapshot ( ) ;
5050 } ) ;
5151
52- it ( 'clicks buttons in popover' , ( ) => {
52+ it ( 'clicks buttons in popover' , async ( ) => {
5353 const channel = MOCK_DATA . chime ;
5454 const utils = render (
5555 < ServicesContext . Provider value = { notificationServiceMock } >
@@ -58,12 +58,15 @@ describe('<ChannelDetailsActions /> spec', () => {
5858 </ CoreServicesContext . Provider >
5959 </ ServicesContext . Provider >
6060 ) ;
61- utils . getByText ( 'Actions' ) . click ( ) ;
62- utils . getByText ( 'Edit' ) . click ( ) ;
63- utils . getByText ( 'Actions' ) . click ( ) ;
64- utils . getByText ( 'Send test message' ) . click ( ) ;
65- utils . getByText ( 'Actions' ) . click ( ) ;
66- utils . getByText ( 'Delete' ) . click ( ) ;
61+ await act ( async ( ) => fireEvent . click ( utils . getByText ( 'Actions' ) ) ) ;
62+ await waitFor ( ( ) => expect ( utils . getByText ( 'Edit' ) ) . toBeTruthy ( ) ) ;
63+ await act ( async ( ) => fireEvent . click ( utils . getByText ( 'Edit' ) ) ) ;
64+ await act ( async ( ) => fireEvent . click ( utils . getByText ( 'Actions' ) ) ) ;
65+ await waitFor ( ( ) => expect ( utils . getByText ( 'Send test message' ) ) . toBeTruthy ( ) ) ;
66+ await act ( async ( ) => fireEvent . click ( utils . getByText ( 'Send test message' ) ) ) ;
67+ await act ( async ( ) => fireEvent . click ( utils . getByText ( 'Actions' ) ) ) ;
68+ await waitFor ( ( ) => expect ( utils . getByText ( 'Delete' ) ) . toBeTruthy ( ) ) ;
69+ await act ( async ( ) => fireEvent . click ( utils . getByText ( 'Delete' ) ) ) ;
6770 expect ( utils . container . firstChild ) . toMatchSnapshot ( ) ;
6871 } ) ;
6972} ) ;
0 commit comments