Repository: facebook/react
Pull request: Fix devtools tests after internal test changes

## Overview

- In older React versions (16, 17), there's no need to use act. So if it's not available, don't use it.
- TimelineProfiler tests need to use internal act. But if we patch in an old version of the scheduler (v18.0-18.2) then the scheduler mock wont work with the internal test harness. We could support all versions of the scheduler in the internal helpers, but it's probably fine to just bump the version of React supported to 18.3 since there weren't many related changes in 18.0-18.2.

Changed files:
filename: packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js
patch: @@ -1324,7 +1324,7 @@ describe('Timeline profiler', () => {
         expect(timelineData.batchUIDToMeasuresMap.size).toBe(2);
       });
 
-      // @reactVersion >=18.0
+      // @reactVersion >=18.2
       it('should mark render yields', async () => {
         function Bar() {
           Scheduler.log('Bar');
@@ -1409,7 +1409,7 @@ describe('Timeline profiler', () => {
         expect(timelineData.componentMeasures).toHaveLength(2);
       });
 
-      // @reactVersion >=18.0
+      // @reactVersion >=18.2
       it('should mark sync render with suspense that rejects', async () => {
         let rejectFn;
         let rejected = false;
@@ -1467,7 +1467,7 @@ describe('Timeline profiler', () => {
         expect(timelineData.componentMeasures).toHaveLength(2);
       });
 
-      // @reactVersion >=18.0
+      // @reactVersion >=18.2
       it('should mark concurrent render with suspense that resolves', async () => {
         let resolveFn;
         let resolved = false;
@@ -1525,7 +1525,7 @@ describe('Timeline profiler', () => {
         expect(timelineData.componentMeasures).toHaveLength(2);
       });
 
-      // @reactVersion >=18.0
+      // @reactVersion >=18.2
       it('should mark concurrent render with suspense that rejects', async () => {
         let rejectFn;
         let rejected = false;

filename: packages/react-devtools-shared/src/__tests__/preprocessData-test.js
patch: @@ -1349,7 +1349,7 @@ describe('Timeline profiler', () => {
             );
           });
 
-          // @reactVersion >= 18.0
+          // @reactVersion >= 18.2
           it('should not warn when React finishes a previously long (async) update with a short (sync) update inside of an event', async () => {
             function Yield({id, value}) {
               Scheduler.log(`${id}:${value}`);
@@ -1411,7 +1411,7 @@ describe('Timeline profiler', () => {
         });
 
         describe('nested updates', () => {
-          // @reactVersion >= 18.0
+          // @reactVersion >= 18.2
           it('should not warn about short nested (state) updates during layout effects', async () => {
             function Component() {
               const [didMount, setDidMount] = React.useState(false);
@@ -1442,7 +1442,7 @@ describe('Timeline profiler', () => {
             expect(event.warning).toBe(null);
           });
 
-          // @reactVersion >= 18.0
+          // @reactVersion >= 18.2
           it('should not warn about short (forced) updates during layout effects', async () => {
             class Component extends React.Component {
               _didMount: boolean = false;
@@ -1595,7 +1595,7 @@ describe('Timeline profiler', () => {
             );
           });
 
-          // @reactVersion >= 18.0
+          // @reactVersion >= 18.2
           it('should not warn about transition updates scheduled during commit phase', async () => {
             function Component() {
               const [value, setValue] = React.useState(0);
@@ -1781,10 +1781,10 @@ describe('Timeline profiler', () => {
         });
 
         describe('suspend during an update', () => {
-          // This also tests an edge case where the a component suspends while profiling
+          // This also tests an edge case where a component suspends while profiling
           // before the first commit is logged (so the lane-to-labels map will not yet exist).
-          // @reactVersion >= 18.0
-          it('should warn about suspending during an udpate', async () => {
+          // @reactVersion >= 18.2
+          it('should warn about suspending during an update', async () => {
             let promise = null;
             let resolvedValue = null;
             function readValue(value) {
@@ -1841,7 +1841,7 @@ describe('Timeline profiler', () => {
             );
           });
 
-          // @reactVersion >= 18.0
+          // @reactVersion >= 18.2
           it('should not warn about suspending during an transition', async () => {
             let promise = null;
             let resolvedValue = null;

filename: packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js
patch: @@ -19,7 +19,12 @@ describe('Store component filters', () => {
   let utils;
 
   const act = async (callback: Function) => {
-    await React.unstable_act(callback);
+    if (React.unstable_act != null) {
+      await React.unstable_act(callback);
+    } else {
+      callback();
+    }
+
     jest.runAllTimers(); // Flush Bridge operations
   };