Skip to content

Commit c45789c

Browse files
committed
Add test gate alias for Offscreen
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.
1 parent 229c86a commit c45789c

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

packages/react-reconciler/src/__tests__/ReactOffscreen-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('ReactOffscreen', () => {
3030
return <span prop={props.text} />;
3131
}
3232

33-
// @gate www
33+
// @gate enableLegacyHidden
3434
it('unstable-defer-without-hiding should never toggle the visibility of its children', async () => {
3535
function App({mode}) {
3636
return (
@@ -180,7 +180,7 @@ describe('ReactOffscreen', () => {
180180
);
181181
});
182182

183-
// @gate experimental || www
183+
// @gate enableOffscreen
184184
it('mounts without layout effects when hidden', async () => {
185185
function Child({text}) {
186186
useLayoutEffect(() => {
@@ -218,7 +218,7 @@ describe('ReactOffscreen', () => {
218218
expect(root).toMatchRenderedOutput(<span prop="Child" />);
219219
});
220220

221-
// @gate experimental || www
221+
// @gate enableOffscreen
222222
it('mounts/unmounts layout effects when visibility changes (starting visible)', async () => {
223223
function Child({text}) {
224224
useLayoutEffect(() => {
@@ -264,7 +264,7 @@ describe('ReactOffscreen', () => {
264264
expect(root).toMatchRenderedOutput(<span prop="Child" />);
265265
});
266266

267-
// @gate experimental || www
267+
// @gate enableOffscreen
268268
it('mounts/unmounts layout effects when visibility changes (starting hidden)', async () => {
269269
function Child({text}) {
270270
useLayoutEffect(() => {
@@ -311,7 +311,7 @@ describe('ReactOffscreen', () => {
311311
expect(root).toMatchRenderedOutput(<span hidden={true} prop="Child" />);
312312
});
313313

314-
// @gate experimental || www
314+
// @gate enableOffscreen
315315
it('hides children of offscreen after layout effects are destroyed', async () => {
316316
const root = ReactNoop.createRoot();
317317
function Child({text}) {
@@ -350,7 +350,7 @@ describe('ReactOffscreen', () => {
350350
expect(root).toMatchRenderedOutput(<span hidden={true} prop="Child" />);
351351
});
352352

353-
// @gate www
353+
// @gate enableLegacyHidden
354354
it('does not toggle effects for LegacyHidden component', async () => {
355355
// LegacyHidden is meant to be the same as offscreen except it doesn't
356356
// do anything to effects. Only used by www, as a temporary migration step.
@@ -398,7 +398,7 @@ describe('ReactOffscreen', () => {
398398
expect(Scheduler).toHaveYielded(['Unmount layout']);
399399
});
400400

401-
// @gate experimental || www
401+
// @gate enableOffscreen
402402
it('hides new insertions into an already hidden tree', async () => {
403403
const root = ReactNoop.createRoot();
404404
await act(async () => {
@@ -428,7 +428,7 @@ describe('ReactOffscreen', () => {
428428
);
429429
});
430430

431-
// @gate experimental || www
431+
// @gate enableOffscreen
432432
it('hides updated nodes inside an already hidden tree', async () => {
433433
const root = ReactNoop.createRoot();
434434
await act(async () => {
@@ -476,6 +476,7 @@ describe('ReactOffscreen', () => {
476476

477477
// Only works in new reconciler
478478
// @gate variant
479+
// @gate enableOffscreen
479480
it('revealing a hidden tree at high priority does not cause tearing', async () => {
480481
// When revealing an offscreen tree, we need to include updates that were
481482
// previously deferred because the tree was hidden, even if they are lower
@@ -594,8 +595,7 @@ describe('ReactOffscreen', () => {
594595
);
595596
});
596597

597-
// TODO: Create TestFlag alias for Offscreen
598-
// @gate experimental || www
598+
// @gate enableOffscreen
599599
it('regression: Offscreen instance is sometimes null during setState', async () => {
600600
let setState;
601601
function Child() {

packages/react-reconciler/src/__tests__/ReactOffscreenSuspense-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ describe('ReactOffscreen', () => {
8888

8989
// Only works in new reconciler
9090
// @gate variant
91+
// @gate enableOffscreen
9192
test('detect updates to a hidden tree during a concurrent event', async () => {
9293
// This is a pretty complex test case. It relates to how we detect if an
9394
// update is made to a hidden tree: when scheduling the update, we walk up

scripts/jest/TestFlags.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ function getTestFlags() {
8787
// This isn't a flag, just a useful alias for tests.
8888
enableUseSyncExternalStoreShim: !__VARIANT__,
8989
enableSuspenseList: releaseChannel === 'experimental' || www,
90+
enableOffscreen: releaseChannel === 'experimental' || www,
91+
enableLegacyHidden: www,
9092

9193
// If there's a naming conflict between scheduler and React feature flags, the
9294
// React ones take precedence.

0 commit comments

Comments
 (0)