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

[Transition Tracing][Code Cleanup] Delete Marker Name Change Tests #24908

Merged
merged 1 commit into from
Jul 12, 2022
Merged
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
190 changes: 0 additions & 190 deletions packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1338,194 +1338,4 @@ describe('ReactInteractionTracing', () => {
]);
});
});

// @gate enableTransitionTracing
it.skip('marker interaction cancelled when name changes', async () => {
const transitionCallbacks = {
onTransitionStart: (name, startTime) => {
Scheduler.unstable_yieldValue(
`onTransitionStart(${name}, ${startTime})`,
);
},
onTransitionComplete: (name, startTime, endTime) => {
Scheduler.unstable_yieldValue(
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
);
},
onMarkerProgress: (
transitioName,
markerName,
startTime,
currentTime,
pending,
) => {
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
Scheduler.unstable_yieldValue(
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
);
},
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
Scheduler.unstable_yieldValue(
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
);
},
};

let navigateToPageTwo;
let setMarkerNameFn;
function App() {
const [navigate, setNavigate] = useState(false);
navigateToPageTwo = () => {
setNavigate(true);
};

const [markerName, setMarkerName] = useState('old marker');
setMarkerNameFn = () => setMarkerName('new marker');

return (
<div>
{navigate ? (
<React.unstable_TracingMarker name={markerName}>
<Suspense fallback={<Text text="Loading..." />}>
<AsyncText text="Page Two" />
</Suspense>
</React.unstable_TracingMarker>
) : (
<Text text="Page One" />
)}
</div>
);
}

const root = ReactNoop.createRoot({transitionCallbacks});
await act(async () => {
root.render(<App />);
ReactNoop.expire(1000);
await advanceTimers(1000);

expect(Scheduler).toFlushAndYield(['Page One']);

startTransition(() => navigateToPageTwo(), {name: 'page transition'});
expect(Scheduler).toFlushAndYield([
'Suspend [Page Two]',
'Loading...',
'onTransitionStart(page transition, 1000)',
'onMarkerProgress(page transition, old marker, 1000, 1000, [<null>])',
]);

ReactNoop.expire(1000);
await advanceTimers(1000);
setMarkerNameFn();

expect(Scheduler).toFlushAndYield(['Suspend [Page Two]', 'Loading...']);
ReactNoop.expire(1000);
await advanceTimers(1000);
resolveText('Page Two');

// Marker complete is not called because the marker name changed
expect(Scheduler).toFlushAndYield([
'Page Two',
'onTransitionComplete(page transition, 1000, 3000)',
]);
});
});

// @gate enableTransitionTracing
it.skip('marker changes to new interaction when name changes', async () => {
const transitionCallbacks = {
onTransitionStart: (name, startTime) => {
Scheduler.unstable_yieldValue(
`onTransitionStart(${name}, ${startTime})`,
);
},
onTransitionComplete: (name, startTime, endTime) => {
Scheduler.unstable_yieldValue(
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
);
},
onMarkerProgress: (
transitioName,
markerName,
startTime,
currentTime,
pending,
) => {
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
Scheduler.unstable_yieldValue(
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
);
},
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
Scheduler.unstable_yieldValue(
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
);
},
};

let navigateToPageTwo;
let setMarkerNameFn;
function App() {
const [navigate, setNavigate] = useState(false);
navigateToPageTwo = () => {
setNavigate(true);
};

const [markerName, setMarkerName] = useState('old marker');
setMarkerNameFn = () => setMarkerName('new marker');

return (
<div>
{navigate ? (
<React.unstable_TracingMarker name={markerName}>
<Suspense fallback={<Text text="Loading..." />}>
<AsyncText text="Page Two" />
</Suspense>
</React.unstable_TracingMarker>
) : (
<Text text="Page One" />
)}
</div>
);
}

const root = ReactNoop.createRoot({transitionCallbacks});
await act(async () => {
root.render(<App />);
ReactNoop.expire(1000);
await advanceTimers(1000);

expect(Scheduler).toFlushAndYield(['Page One']);

startTransition(() => navigateToPageTwo(), {name: 'page transition'});
expect(Scheduler).toFlushAndYield([
'Suspend [Page Two]',
'Loading...',
'onTransitionStart(page transition, 1000)',
'onMarkerProgress(page transition, old marker, 1000, 2000, [<null>])',
]);

ReactNoop.expire(1000);
await advanceTimers(1000);
startTransition(() => setMarkerNameFn(), {name: 'marker transition'});

expect(Scheduler).toFlushAndYield([
'Suspend [Page Two]',
'Loading...',
'onTransitionStart(marker transition, 2000)',
'onMarkerProgress(marker transition, new marker, 2000, 3000, [])',
'onMarkerComplete(marker transition, new marker, 2000, 3000)',
'onTransitionComplete(marker transition, 2000, 3000)',
]);
ReactNoop.expire(1000);
await advanceTimers(1000);
resolveText('Page Two');

// Marker complete is not called because the marker name changed
expect(Scheduler).toFlushAndYield([
'Page Two',
'onMarkerComplete(new marker, 2000, 3000)',
'onTransitionComplete(page transition, 1000, 3000)',
]);
});
});
});