Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test gate alias for Offscreen #24749

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions packages/react-reconciler/src/__tests__/ReactOffscreen-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('ReactOffscreen', () => {
return <span prop={props.text} />;
}

// @gate www
// @gate enableLegacyHidden
it('unstable-defer-without-hiding should never toggle the visibility of its children', async () => {
function App({mode}) {
return (
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('ReactOffscreen', () => {
);
});

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

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

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

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

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

// @gate experimental || www
// @gate enableOffscreen
it('hides new insertions into an already hidden tree', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand Down Expand Up @@ -428,7 +428,7 @@ describe('ReactOffscreen', () => {
);
});

// @gate experimental || www
// @gate enableOffscreen
it('hides updated nodes inside an already hidden tree', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand Down Expand Up @@ -474,7 +474,7 @@ describe('ReactOffscreen', () => {
expect(root).toMatchRenderedOutput(<span>Hi</span>);
});

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

// TODO: Create TestFlag alias for Offscreen
// @gate experimental || www
// @gate enableOffscreen
it('regression: Offscreen instance is sometimes null during setState', async () => {
let setState;
function Child() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('ReactOffscreen', () => {
return text;
}

// @gate experimental || www
// @gate enableOffscreen
test('detect updates to a hidden tree during a concurrent event', async () => {
// This is a pretty complex test case. It relates to how we detect if an
// update is made to a hidden tree: when scheduling the update, we walk up
Expand Down
2 changes: 2 additions & 0 deletions scripts/jest/TestFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function getTestFlags() {
// This isn't a flag, just a useful alias for tests.
enableUseSyncExternalStoreShim: !__VARIANT__,
enableSuspenseList: releaseChannel === 'experimental' || www,
enableOffscreen: releaseChannel === 'experimental' || www,
enableLegacyHidden: www,

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