@@ -617,27 +617,29 @@ describe('<DateInput/>', () => {
617617
618618 cy . get ( 'table' ) . should ( 'be.visible' )
619619
620- cy . contains ( 'button' , dayForSelect )
621- . should ( 'be.enabled' )
622- . click ( )
623- . wait ( 500 )
624-
625- cy . get ( 'input' )
626- . invoke ( 'val' )
627- . then ( ( inputValue ) => {
628- const inputValueRTLFree = removeRtlMarkers ( inputValue )
629- const hasCorrectDirection =
630- ( textDirection === 'rtl' ) === hasRtlMarkers ( inputValue as string )
631-
632- cy . wrap ( hasCorrectDirection ) . should ( 'be.true' )
633- cy . wrap ( inputValueRTLFree ) . should ( 'equal' , expectedFormattedValue )
634- cy . wrap ( onChange ) . should (
635- 'have.been.calledWith' ,
636- Cypress . sinon . match . any ,
637- expectedOnChangeValue ,
638- expectedDateIsoString
639- )
640- } )
620+ cy . contains ( 'button' , dayForSelect ) . should ( 'be.enabled' ) . click ( )
621+
622+ // Retryable assertion instead of a fixed `.wait(500)` + one-shot
623+ // `.then()` read: Cypress re-runs this callback until the input value
624+ // settles after the click-driven onChange/state update.
625+ cy . get ( 'input' ) . should ( ( $input ) => {
626+ const inputValue = $input . val ( ) as string
627+ const inputValueRTLFree = removeRtlMarkers ( inputValue )
628+ const hasCorrectDirection =
629+ ( textDirection === 'rtl' ) === hasRtlMarkers ( inputValue )
630+
631+ expect ( hasCorrectDirection , 'text direction matches locale' ) . to . equal (
632+ true
633+ )
634+ expect ( inputValueRTLFree ) . to . equal ( expectedFormattedValue )
635+ } )
636+
637+ cy . wrap ( onChange ) . should (
638+ 'have.been.calledWith' ,
639+ Cypress . sinon . match . any ,
640+ expectedOnChangeValue ,
641+ expectedDateIsoString
642+ )
641643 } )
642644 } )
643645 } )
0 commit comments