11import "@testing-library/jest-dom"
2- import { render , waitFor , screen } from "@testing-library/react"
2+ import { render , waitFor , screen , act } from "@testing-library/react"
33import { ValidationStep } from "../ValidationStep"
44import { defaultRSIProps , defaultTheme } from "../../../ReactSpreadsheetImport"
55import { Providers } from "../../../components/Providers"
@@ -579,23 +579,25 @@ describe("Validation step tests", () => {
579579 } ,
580580 ] as const
581581
582- render (
583- < Providers
584- theme = { defaultTheme }
585- rsiValues = { {
586- ...mockValues ,
587- fields,
588- rowHook : ( value ) => ( {
589- name : value . name ?. toString ( ) ?. split ( / ( \s + ) / ) [ 0 ] ,
590- lastName : value . name ?. toString ( ) ?. split ( / ( \s + ) / ) [ 2 ] ,
591- } ) ,
592- } }
593- >
594- < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
595- < ValidationStep initialData = { initialData } file = { file } />
596- </ ModalWrapper >
597- </ Providers > ,
598- )
582+ await act ( async ( ) => {
583+ render (
584+ < Providers
585+ theme = { defaultTheme }
586+ rsiValues = { {
587+ ...mockValues ,
588+ fields,
589+ rowHook : ( value ) => ( {
590+ name : value . name ?. toString ( ) ?. split ( / ( \s + ) / ) [ 0 ] ,
591+ lastName : value . name ?. toString ( ) ?. split ( / ( \s + ) / ) [ 2 ] ,
592+ } ) ,
593+ } }
594+ >
595+ < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
596+ < ValidationStep initialData = { initialData } file = { file } />
597+ </ ModalWrapper >
598+ </ Providers > ,
599+ )
600+ } )
599601
600602 const nameCell = screen . getByRole ( "gridcell" , {
601603 name : NAME ,
@@ -607,9 +609,11 @@ describe("Validation step tests", () => {
607609 expect ( lastNameCell ) . toBeInTheDocument ( )
608610
609611 // activate input
610- await userEvent . click ( nameCell )
612+ await act ( async ( ) => {
613+ await userEvent . click ( nameCell )
611614
612- await userEvent . keyboard ( NEW_NAME + " " + NEW_LASTNAME + "{enter}" )
615+ await userEvent . keyboard ( NEW_NAME + " " + NEW_LASTNAME + "{enter}" )
616+ } )
613617
614618 const newNameCell = screen . getByRole ( "gridcell" , {
615619 name : NEW_NAME ,
@@ -620,6 +624,7 @@ describe("Validation step tests", () => {
620624 } )
621625 expect ( newLastNameCell ) . toBeInTheDocument ( )
622626 } )
627+
623628 test ( "Row hook raises error" , async ( ) => {
624629 const WRONG_NAME = "Johnny"
625630 const RIGHT_NAME = "Jonathan"
@@ -638,24 +643,26 @@ describe("Validation step tests", () => {
638643 } ,
639644 ] as const
640645
641- render (
642- < Providers
643- theme = { defaultTheme }
644- rsiValues = { {
645- ...mockValues ,
646- fields,
647- rowHook : ( value , setError ) => {
648- if ( value . name === WRONG_NAME ) {
649- setError ( fields [ 0 ] . key , { message : "Wrong name" , level : "error" } )
650- }
651- return value
652- } ,
653- } }
654- >
655- < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
656- < ValidationStep initialData = { initialData } file = { file } />
657- </ ModalWrapper >
658- </ Providers > ,
646+ await act ( async ( ) =>
647+ render (
648+ < Providers
649+ theme = { defaultTheme }
650+ rsiValues = { {
651+ ...mockValues ,
652+ fields,
653+ rowHook : ( value , setError ) => {
654+ if ( value . name === WRONG_NAME ) {
655+ setError ( fields [ 0 ] . key , { message : "Wrong name" , level : "error" } )
656+ }
657+ return value
658+ } ,
659+ } }
660+ >
661+ < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
662+ < ValidationStep initialData = { initialData } file = { file } />
663+ </ ModalWrapper >
664+ </ Providers > ,
665+ ) ,
659666 )
660667
661668 const switchFilter = getFilterSwitch ( )
@@ -702,23 +709,25 @@ describe("Validation step tests", () => {
702709 } ,
703710 ] as const
704711
705- render (
706- < Providers
707- theme = { defaultTheme }
708- rsiValues = { {
709- ...mockValues ,
710- fields,
711- tableHook : ( data ) =>
712- data . map ( ( value ) => ( {
713- name : value . name + ADDITION ,
714- } ) ) ,
715- } }
716- >
717- < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
718- < ValidationStep initialData = { initialData } file = { file } />
719- </ ModalWrapper >
720- </ Providers > ,
721- )
712+ await act ( async ( ) => {
713+ render (
714+ < Providers
715+ theme = { defaultTheme }
716+ rsiValues = { {
717+ ...mockValues ,
718+ fields,
719+ tableHook : ( data ) =>
720+ data . map ( ( value ) => ( {
721+ name : value . name + ADDITION ,
722+ } ) ) ,
723+ } }
724+ >
725+ < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
726+ < ValidationStep initialData = { initialData } file = { file } />
727+ </ ModalWrapper >
728+ </ Providers > ,
729+ )
730+ } )
722731
723732 const nameCell = screen . getByRole ( "gridcell" , {
724733 name : NAME + ADDITION ,
0 commit comments