Skip to content

Commit

Permalink
[Transition Tracing][Code Cleanup] Delete Marker Name Change Tests (#…
Browse files Browse the repository at this point in the history
…24908)

We decided that changing the Tracing Marker name wasn't allowed and we would error, so this PR deletes all the tests that tested name change behavior
  • Loading branch information
lunaruan authored Jul 12, 2022
1 parent fa20b31 commit f5916d1
Showing 1 changed file with 0 additions and 190 deletions.
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)',
]);
});
});
});

0 comments on commit f5916d1

Please sign in to comment.