@samitouri / QOS-React-2 / commits / a7b192e0f1

Add test gate alias for Offscreen (#24749)

Offscreen is only enabled in the www and experimental channels. Instead of listing these on every Offscreen test, I added a test gate alias called `enableOffscreen`. Makes it easier to grep for these, and edit or remove the channels later.

Andrew Clark committed Jun 30, 2022 at 09:44 UTC a7b192e0f16a5a585796c78cfdb688845d7710a5
3 files changed +13 -12
packages/react-reconciler/src/__tests__/ReactOffscreen-test.js
+10 -11
@@ -30,7 +30,7 @@ describe('ReactOffscreen', () => {
30 return <span prop={props.text} />;
31 }
32
33 - // @gate www
33 + // @gate enableLegacyHidden
34 it('unstable-defer-without-hiding should never toggle the visibility of its children', async () => {
35 function App({mode}) {
36 return (
@@ -180,7 +180,7 @@ describe('ReactOffscreen', () => {
180 );
181 });
182
183 - // @gate experimental || www
183 + // @gate enableOffscreen
184 it('mounts without layout effects when hidden', async () => {
185 function Child({text}) {
186 useLayoutEffect(() => {
@@ -218,7 +218,7 @@ describe('ReactOffscreen', () => {
218 expect(root).toMatchRenderedOutput(<span prop="Child" />);
219 });
220
221 - // @gate experimental || www
221 + // @gate enableOffscreen
222 it('mounts/unmounts layout effects when visibility changes (starting visible)', async () => {
223 function Child({text}) {
224 useLayoutEffect(() => {
@@ -264,7 +264,7 @@ describe('ReactOffscreen', () => {
264 expect(root).toMatchRenderedOutput(<span prop="Child" />);
265 });
266
267 - // @gate experimental || www
267 + // @gate enableOffscreen
268 it('mounts/unmounts layout effects when visibility changes (starting hidden)', async () => {
269 function Child({text}) {
270 useLayoutEffect(() => {
@@ -311,7 +311,7 @@ describe('ReactOffscreen', () => {
311 expect(root).toMatchRenderedOutput(<span hidden={true} prop="Child" />);
312 });
313
314 - // @gate experimental || www
314 + // @gate enableOffscreen
315 it('hides children of offscreen after layout effects are destroyed', async () => {
316 const root = ReactNoop.createRoot();
317 function Child({text}) {
@@ -350,7 +350,7 @@ describe('ReactOffscreen', () => {
350 expect(root).toMatchRenderedOutput(<span hidden={true} prop="Child" />);
351 });
352
353 - // @gate www
353 + // @gate enableLegacyHidden
354 it('does not toggle effects for LegacyHidden component', async () => {
355 // LegacyHidden is meant to be the same as offscreen except it doesn't
356 // do anything to effects. Only used by www, as a temporary migration step.
@@ -398,7 +398,7 @@ describe('ReactOffscreen', () => {
398 expect(Scheduler).toHaveYielded(['Unmount layout']);
399 });
400
401 - // @gate experimental || www
401 + // @gate enableOffscreen
402 it('hides new insertions into an already hidden tree', async () => {
403 const root = ReactNoop.createRoot();
404 await act(async () => {
@@ -428,7 +428,7 @@ describe('ReactOffscreen', () => {
428 );
429 });
430
431 - // @gate experimental || www
431 + // @gate enableOffscreen
432 it('hides updated nodes inside an already hidden tree', async () => {
433 const root = ReactNoop.createRoot();
434 await act(async () => {
@@ -474,7 +474,7 @@ describe('ReactOffscreen', () => {
474 expect(root).toMatchRenderedOutput(<span>Hi</span>);
475 });
476
477 - // @gate experimental || www
477 + // @gate enableOffscreen
478 it('revealing a hidden tree at high priority does not cause tearing', async () => {
479 // When revealing an offscreen tree, we need to include updates that were
480 // previously deferred because the tree was hidden, even if they are lower
@@ -593,8 +593,7 @@ describe('ReactOffscreen', () => {
593 );
594 });
595
596 - // TODO: Create TestFlag alias for Offscreen
597 - // @gate experimental || www
596 + // @gate enableOffscreen
597 it('regression: Offscreen instance is sometimes null during setState', async () => {
598 let setState;
599 function Child() {
packages/react-reconciler/src/__tests__/ReactOffscreenSuspense-test.js
+1 -1
@@ -86,7 +86,7 @@ describe('ReactOffscreen', () => {
86 return text;
87 }
88
89 - // @gate experimental || www
89 + // @gate enableOffscreen
90 test('detect updates to a hidden tree during a concurrent event', async () => {
91 // This is a pretty complex test case. It relates to how we detect if an
92 // update is made to a hidden tree: when scheduling the update, we walk up
scripts/jest/TestFlags.js
+2
@@ -87,6 +87,8 @@ function getTestFlags() {
87 // This isn't a flag, just a useful alias for tests.
88 enableUseSyncExternalStoreShim: !__VARIANT__,
89 enableSuspenseList: releaseChannel === 'experimental' || www,
90 + enableOffscreen: releaseChannel === 'experimental' || www,
91 + enableLegacyHidden: www,
92
93 // If there's a naming conflict between scheduler and React feature flags, the
94 // React ones take precedence.