@@ -4008,4 +4008,76 @@ describe('ReactSuspenseWithNoopRenderer', () => {
40084008 ) ;
40094009 } ,
40104010 ) ;
4011+
4012+ // @gate enableLegacyCache
4013+ it ( 'recurring updates in siblings should not block expensive content in suspense boundary from committing' , async ( ) => {
4014+ const { useState} = React ;
4015+
4016+ let setText ;
4017+ function UpdatingText ( ) {
4018+ const [ text , _setText ] = useState ( '1' ) ;
4019+ setText = _setText ;
4020+ return < Text text = { text } /> ;
4021+ }
4022+
4023+ function ExpensiveText ( { text, ms} ) {
4024+ Scheduler . log ( text ) ;
4025+ Scheduler . unstable_advanceTime ( ms ) ;
4026+ return < span prop = { text } /> ;
4027+ }
4028+
4029+ function App ( ) {
4030+ return (
4031+ < >
4032+ < UpdatingText />
4033+ < Suspense fallback = { < Text text = "Loading..." /> } >
4034+ < AsyncText text = "Async" />
4035+ < ExpensiveText text = "A" ms = { 1000 } />
4036+ < ExpensiveText text = "B" ms = { 3999 } />
4037+ < ExpensiveText text = "C" ms = { 100000 } />
4038+ </ Suspense >
4039+ </ >
4040+ ) ;
4041+ }
4042+
4043+ const root = ReactNoop . createRoot ( ) ;
4044+ root . render ( < App /> ) ;
4045+ await waitForAll ( [ '1' , 'Suspend! [Async]' , 'Loading...' ] ) ;
4046+ expect ( root ) . toMatchRenderedOutput (
4047+ < >
4048+ < span prop = "1" />
4049+ < span prop = "Loading..." />
4050+ </ > ,
4051+ ) ;
4052+
4053+ await resolveText ( 'Async' ) ;
4054+ expect ( root ) . toMatchRenderedOutput (
4055+ < >
4056+ < span prop = "1" />
4057+ < span prop = "Loading..." />
4058+ </ > ,
4059+ ) ;
4060+
4061+ await waitFor ( [ 'Async' , 'A' , 'B' ] ) ;
4062+ ReactNoop . expire ( 10000000 ) ;
4063+ await advanceTimers ( 10000000 ) ;
4064+ setText ( '2' ) ;
4065+ await waitForPaint ( [ '2' ] ) ;
4066+
4067+ await waitFor ( [ 'Async' , 'A' , 'B' ] ) ;
4068+ ReactNoop . expire ( 10000000 ) ;
4069+ await advanceTimers ( 10000000 ) ;
4070+ setText ( '3' ) ;
4071+
4072+ // TODO: At this point we want "C" to commit
4073+ await waitForPaint ( [ '3' ] ) ;
4074+ await waitFor ( [ 'Async' , 'A' , 'B' ] ) ;
4075+
4076+ expect ( root ) . toMatchRenderedOutput (
4077+ < >
4078+ < span prop = "3" />
4079+ < span prop = "Loading..." />
4080+ </ > ,
4081+ ) ;
4082+ } ) ;
40114083} ) ;
0 commit comments