From 4a2fb7249e29e65e9c9426a85e4e5475992c2b17 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Mon, 26 Jun 2023 00:06:36 +0100 Subject: [PATCH] fix[devtools/profilingCache-test]: specify correct version gate for test and add a new one for current version of react --- .../src/__tests__/profilingCache-test.js | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/packages/react-devtools-shared/src/__tests__/profilingCache-test.js b/packages/react-devtools-shared/src/__tests__/profilingCache-test.js index f03bf2391525d..80fcf1c5fb505 100644 --- a/packages/react-devtools-shared/src/__tests__/profilingCache-test.js +++ b/packages/react-devtools-shared/src/__tests__/profilingCache-test.js @@ -938,11 +938,51 @@ describe('ProfilingCache', () => { } }); - // @reactVersion >= 17 - // @reactVersion < 18 + // @reactVersion >= 18.0.0 + // @reactVersion <= 18.2.0 + it('should handle unexpectedly shallow suspense trees for react v[18.0.0 - 18.2.0]', () => { + const container = document.createElement('div'); + + utils.act(() => store.profilerStore.startProfiling()); + utils.act(() => legacyRender(, container)); + utils.act(() => store.profilerStore.stopProfiling()); + + const rootID = store.roots[0]; + const commitData = store.profilerStore.getDataForRoot(rootID).commitData; + expect(commitData).toMatchInlineSnapshot(` + [ + { + "changeDescriptions": Map {}, + "duration": 0, + "effectDuration": null, + "fiberActualDurations": Map { + 1 => 0, + 2 => 0, + }, + "fiberSelfDurations": Map { + 1 => 0, + 2 => 0, + }, + "passiveEffectDuration": null, + "priorityLevel": "Immediate", + "timestamp": 0, + "updaters": [ + { + "displayName": "render()", + "hocDisplayNames": null, + "id": 1, + "key": null, + "type": 11, + }, + ], + }, + ] + `); + }); + + // This test is not gated. + // For this test we use the current version of react, built from source. it('should handle unexpectedly shallow suspense trees', () => { - // This test only runs in v17 because it's a regression test for legacy - // Suspense behavior, and the implementation details changed in v18. const container = document.createElement('div'); utils.act(() => store.profilerStore.startProfiling());