1
1
import '@testing-library/jest-dom'
2
2
import { describe , expect , it } from 'vitest'
3
3
import userEvent from '@testing-library/user-event'
4
- import { render , waitFor , screen } from '@testing-library/react'
4
+ import { render , waitFor , screen , act } from '@testing-library/react'
5
5
import { CapturedEventsList } from './index'
6
6
7
7
describe ( 'CapturedEventsList Component' , ( ) => {
@@ -15,7 +15,10 @@ describe('CapturedEventsList Component', () => {
15
15
it ( 'should open and close the debug window' , async ( ) => {
16
16
render ( < CapturedEventsList /> )
17
17
const toggleButton = screen . getByTestId ( 'toggle-button' )
18
- userEvent . click ( toggleButton )
18
+
19
+ await act ( async ( ) => {
20
+ userEvent . click ( toggleButton )
21
+ } )
19
22
20
23
const debugWindow = await waitFor ( ( ) => {
21
24
const element = screen . getByTestId ( 'debug-window' )
@@ -24,7 +27,10 @@ describe('CapturedEventsList Component', () => {
24
27
} )
25
28
26
29
expect ( debugWindow ) . toBeVisible ( )
27
- userEvent . click ( toggleButton )
30
+
31
+ await act ( async ( ) => {
32
+ userEvent . click ( toggleButton )
33
+ } )
28
34
29
35
await waitFor ( ( ) => {
30
36
expect ( debugWindow ) . not . toBeVisible ( )
@@ -34,16 +40,25 @@ describe('CapturedEventsList Component', () => {
34
40
it ( 'should switch between individual and table view' , async ( ) => {
35
41
render ( < CapturedEventsList /> )
36
42
const toggleButton = screen . getByTestId ( 'toggle-button' )
37
- userEvent . click ( toggleButton )
43
+
44
+ await act ( async ( ) => {
45
+ userEvent . click ( toggleButton )
46
+ } )
38
47
39
48
const toggleViewButton = await waitFor ( ( ) =>
40
49
screen . getByTestId ( 'toggle-view-button' ) ,
41
50
)
42
- userEvent . click ( toggleViewButton )
51
+
52
+ await act ( async ( ) => {
53
+ userEvent . click ( toggleViewButton )
54
+ } )
43
55
44
56
const tableView = await waitFor ( ( ) => screen . getByTestId ( 'table-view' ) )
45
57
expect ( tableView ) . toBeVisible ( )
46
- userEvent . click ( toggleViewButton )
58
+
59
+ await act ( async ( ) => {
60
+ userEvent . click ( toggleViewButton )
61
+ } )
47
62
48
63
const individualView = await waitFor ( ( ) =>
49
64
screen . getByTestId ( 'individual-view' ) ,
@@ -54,10 +69,16 @@ describe('CapturedEventsList Component', () => {
54
69
it ( 'should clear all events' , async ( ) => {
55
70
render ( < CapturedEventsList /> )
56
71
const toggleButton = screen . getByTestId ( 'toggle-button' )
57
- userEvent . click ( toggleButton )
72
+
73
+ await act ( async ( ) => {
74
+ userEvent . click ( toggleButton )
75
+ } )
58
76
59
77
const clearButton = await waitFor ( ( ) => screen . getByTestId ( 'clear-button' ) )
60
- userEvent . click ( clearButton )
78
+
79
+ await act ( async ( ) => {
80
+ userEvent . click ( clearButton )
81
+ } )
61
82
62
83
const noEventsText = await waitFor ( ( ) => screen . getByText ( 'No events yet' ) )
63
84
expect ( noEventsText ) . toBeInTheDocument ( )
0 commit comments