Skip to content

Commit 3555786

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 6b6cf83 commit 3555786

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

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

Lines changed: 10 additions & 11 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 () => {
@@ -474,7 +474,7 @@ describe('ReactOffscreen', () => {
474474
expect(root).toMatchRenderedOutput(<span>Hi</span>);
475475
});
476476

477-
// @gate experimental || www
477+
// @gate enableOffscreen
478478
it('revealing a hidden tree at high priority does not cause tearing', async () => {
479479
// When revealing an offscreen tree, we need to include updates that were
480480
// previously deferred because the tree was hidden, even if they are lower
@@ -593,8 +593,7 @@ describe('ReactOffscreen', () => {
593593
);
594594
});
595595

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('ReactOffscreen', () => {
8686
return text;
8787
}
8888

89-
// @gate experimental || www
89+
// @gate enableOffscreen
9090
test('detect updates to a hidden tree during a concurrent event', async () => {
9191
// This is a pretty complex test case. It relates to how we detect if an
9292
// 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)