@@ -125,7 +125,22 @@ describe('ReactExpiration', () => {
125
125
}
126
126
127
127
it ( 'increases priority of updates as time progresses' , async ( ) => {
128
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
128
+ if ( gate ( flags => flags . forceConcurrentByDefaultForTesting ) ) {
129
+ ReactNoop . render ( < span prop = "done" /> ) ;
130
+ expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
131
+
132
+ // Nothing has expired yet because time hasn't advanced.
133
+ flushNextRenderIfExpired ( ) ;
134
+ expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
135
+ // Advance time a bit, but not enough to expire the low pri update.
136
+ ReactNoop . expire ( 4500 ) ;
137
+ flushNextRenderIfExpired ( ) ;
138
+ expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
139
+ // Advance by another second. Now the update should expire and flush.
140
+ ReactNoop . expire ( 500 ) ;
141
+ flushNextRenderIfExpired ( ) ;
142
+ expect ( ReactNoop ) . toMatchRenderedOutput ( < span prop = "done" /> ) ;
143
+ } else {
129
144
ReactNoop . render ( < Text text = "Step 1" /> ) ;
130
145
React . startTransition ( ( ) => {
131
146
ReactNoop . render ( < Text text = "Step 2" /> ) ;
@@ -147,21 +162,6 @@ describe('ReactExpiration', () => {
147
162
ReactNoop . expire ( 500 ) ;
148
163
await unstable_waitForExpired ( [ 'Step 2' ] ) ;
149
164
expect ( ReactNoop ) . toMatchRenderedOutput ( 'Step 2' ) ;
150
- } else {
151
- ReactNoop . render ( < span prop = "done" /> ) ;
152
- expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
153
-
154
- // Nothing has expired yet because time hasn't advanced.
155
- flushNextRenderIfExpired ( ) ;
156
- expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
157
- // Advance time a bit, but not enough to expire the low pri update.
158
- ReactNoop . expire ( 4500 ) ;
159
- flushNextRenderIfExpired ( ) ;
160
- expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
161
- // Advance by another second. Now the update should expire and flush.
162
- ReactNoop . expire ( 500 ) ;
163
- flushNextRenderIfExpired ( ) ;
164
- expect ( ReactNoop ) . toMatchRenderedOutput ( < span prop = "done" /> ) ;
165
165
}
166
166
} ) ;
167
167
@@ -187,13 +187,9 @@ describe('ReactExpiration', () => {
187
187
188
188
// First, show what happens for updates in two separate events.
189
189
// Schedule an update.
190
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
191
- React . startTransition ( ( ) => {
192
- ReactNoop . render ( < TextClass text = "A" /> ) ;
193
- } ) ;
194
- } else {
190
+ React . startTransition ( ( ) => {
195
191
ReactNoop . render ( < TextClass text = "A" /> ) ;
196
- }
192
+ } ) ;
197
193
// Advance the timer.
198
194
Scheduler . unstable_advanceTime ( 2000 ) ;
199
195
// Partially flush the first update, then interrupt it.
@@ -248,13 +244,10 @@ describe('ReactExpiration', () => {
248
244
249
245
// First, show what happens for updates in two separate events.
250
246
// Schedule an update.
251
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
252
- React . startTransition ( ( ) => {
253
- ReactNoop . render ( < TextClass text = "A" /> ) ;
254
- } ) ;
255
- } else {
247
+ React . startTransition ( ( ) => {
256
248
ReactNoop . render ( < TextClass text = "A" /> ) ;
257
- }
249
+ } ) ;
250
+
258
251
// Advance the timer.
259
252
Scheduler . unstable_advanceTime ( 2000 ) ;
260
253
// Partially flush the first update, then interrupt it.
@@ -320,13 +313,10 @@ describe('ReactExpiration', () => {
320
313
}
321
314
322
315
// Initial mount
323
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
324
- React . startTransition ( ( ) => {
325
- ReactNoop . render ( < App /> ) ;
326
- } ) ;
327
- } else {
316
+ React . startTransition ( ( ) => {
328
317
ReactNoop . render ( < App /> ) ;
329
- }
318
+ } ) ;
319
+
330
320
await waitForAll ( [
331
321
'initial [A] [render]' ,
332
322
'initial [B] [render]' ,
@@ -339,13 +329,10 @@ describe('ReactExpiration', () => {
339
329
] ) ;
340
330
341
331
// Partial update
342
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
343
- React . startTransition ( ( ) => {
344
- subscribers . forEach ( s => s . setState ( { text : '1' } ) ) ;
345
- } ) ;
346
- } else {
332
+ React . startTransition ( ( ) => {
347
333
subscribers . forEach ( s => s . setState ( { text : '1' } ) ) ;
348
- }
334
+ } ) ;
335
+
349
336
await waitFor ( [ '1 [A] [render]' , '1 [B] [render]' ] ) ;
350
337
351
338
// Before the update can finish, update again. Even though no time has
@@ -371,13 +358,9 @@ describe('ReactExpiration', () => {
371
358
) ;
372
359
}
373
360
374
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
375
- React . startTransition ( ( ) => {
376
- root . render ( < App /> ) ;
377
- } ) ;
378
- } else {
361
+ React . startTransition ( ( ) => {
379
362
root . render ( < App /> ) ;
380
- }
363
+ } ) ;
381
364
382
365
await waitFor ( [ 'A' ] ) ;
383
366
await waitFor ( [ 'B' ] ) ;
@@ -404,13 +387,9 @@ describe('ReactExpiration', () => {
404
387
</ >
405
388
) ;
406
389
}
407
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
408
- React . startTransition ( ( ) => {
409
- root . render ( < App /> ) ;
410
- } ) ;
411
- } else {
390
+ React . startTransition ( ( ) => {
412
391
root . render ( < App /> ) ;
413
- }
392
+ } ) ;
414
393
415
394
await waitFor ( [ 'A' ] ) ;
416
395
await waitFor ( [ 'B' ] ) ;
@@ -429,7 +408,26 @@ describe('ReactExpiration', () => {
429
408
jest . resetModules ( ) ;
430
409
Scheduler = require ( 'scheduler' ) ;
431
410
432
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
411
+ if ( gate ( flags => flags . forceConcurrentByDefaultForTesting ) ) {
412
+ // Before importing the renderer, advance the current time by a number
413
+ // larger than the maximum allowed for bitwise operations.
414
+ const maxSigned31BitInt = 1073741823 ;
415
+ Scheduler . unstable_advanceTime ( maxSigned31BitInt * 100 ) ;
416
+ // Now import the renderer. On module initialization, it will read the
417
+ // current time.
418
+ ReactNoop = require ( 'react-noop-renderer' ) ;
419
+ ReactNoop . render ( 'Hi' ) ;
420
+
421
+ // The update should not have expired yet.
422
+ flushNextRenderIfExpired ( ) ;
423
+ await waitFor ( [ ] ) ;
424
+ expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
425
+ // Advance the time some more to expire the update.
426
+ Scheduler . unstable_advanceTime ( 10000 ) ;
427
+ flushNextRenderIfExpired ( ) ;
428
+ await waitFor ( [ ] ) ;
429
+ expect ( ReactNoop ) . toMatchRenderedOutput ( 'Hi' ) ;
430
+ } else {
433
431
const InternalTestUtils = require ( 'internal-test-utils' ) ;
434
432
waitFor = InternalTestUtils . waitFor ;
435
433
assertLog = InternalTestUtils . assertLog ;
@@ -446,14 +444,10 @@ describe('ReactExpiration', () => {
446
444
React = require ( 'react' ) ;
447
445
448
446
ReactNoop . render ( < Text text = "Step 1" /> ) ;
449
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
450
- React . startTransition ( ( ) => {
451
- ReactNoop . render ( < Text text = "Step 2" /> ) ;
452
- } ) ;
453
- await waitFor ( [ 'Step 1' ] ) ;
454
- } else {
455
- ReactNoop . render ( 'Hi' ) ;
456
- }
447
+ React . startTransition ( ( ) => {
448
+ ReactNoop . render ( < Text text = "Step 2" /> ) ;
449
+ } ) ;
450
+ await waitFor ( [ 'Step 1' ] ) ;
457
451
458
452
// The update should not have expired yet.
459
453
await unstable_waitForExpired ( [ ] ) ;
@@ -464,25 +458,6 @@ describe('ReactExpiration', () => {
464
458
Scheduler . unstable_advanceTime ( 10000 ) ;
465
459
await unstable_waitForExpired ( [ 'Step 2' ] ) ;
466
460
expect ( ReactNoop ) . toMatchRenderedOutput ( 'Step 2' ) ;
467
- } else {
468
- // Before importing the renderer, advance the current time by a number
469
- // larger than the maximum allowed for bitwise operations.
470
- const maxSigned31BitInt = 1073741823 ;
471
- Scheduler . unstable_advanceTime ( maxSigned31BitInt * 100 ) ;
472
- // Now import the renderer. On module initialization, it will read the
473
- // current time.
474
- ReactNoop = require ( 'react-noop-renderer' ) ;
475
- ReactNoop . render ( 'Hi' ) ;
476
-
477
- // The update should not have expired yet.
478
- flushNextRenderIfExpired ( ) ;
479
- await waitFor ( [ ] ) ;
480
- expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
481
- // Advance the time some more to expire the update.
482
- Scheduler . unstable_advanceTime ( 10000 ) ;
483
- flushNextRenderIfExpired ( ) ;
484
- await waitFor ( [ ] ) ;
485
- expect ( ReactNoop ) . toMatchRenderedOutput ( 'Hi' ) ;
486
461
}
487
462
} ) ;
488
463
@@ -494,13 +469,10 @@ describe('ReactExpiration', () => {
494
469
// Before scheduling an update, advance the current time.
495
470
Scheduler . unstable_advanceTime ( 10000 ) ;
496
471
497
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
498
- React . startTransition ( ( ) => {
499
- ReactNoop . render ( 'Hi' ) ;
500
- } ) ;
501
- } else {
472
+ React . startTransition ( ( ) => {
502
473
ReactNoop . render ( 'Hi' ) ;
503
- }
474
+ } ) ;
475
+
504
476
await unstable_waitForExpired ( [ ] ) ;
505
477
expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
506
478
@@ -541,13 +513,9 @@ describe('ReactExpiration', () => {
541
513
542
514
// First demonstrate what happens when there's no starvation
543
515
await act ( async ( ) => {
544
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
545
- React . startTransition ( ( ) => {
546
- updateNormalPri ( ) ;
547
- } ) ;
548
- } else {
516
+ React . startTransition ( ( ) => {
549
517
updateNormalPri ( ) ;
550
- }
518
+ } ) ;
551
519
await waitFor ( [ 'Sync pri: 0' ] ) ;
552
520
updateSyncPri ( ) ;
553
521
assertLog ( [ 'Sync pri: 1' , 'Normal pri: 0' ] ) ;
@@ -565,13 +533,9 @@ describe('ReactExpiration', () => {
565
533
566
534
// Do the same thing, but starve the first update
567
535
await act ( async ( ) => {
568
- if ( gate ( flags => flags . enableSyncDefaultUpdates ) ) {
569
- React . startTransition ( ( ) => {
570
- updateNormalPri ( ) ;
571
- } ) ;
572
- } else {
536
+ React . startTransition ( ( ) => {
573
537
updateNormalPri ( ) ;
574
- }
538
+ } ) ;
575
539
await waitFor ( [ 'Sync pri: 1' ] ) ;
576
540
577
541
// This time, a lot of time has elapsed since the normal pri update
0 commit comments