fix tests for when float is off (#25839)
Some tests fail when float is off but when singletons are on. This PR makes some adjustments 1. 2 singleton tests assert float semantics so will fail. 2. the float dispatcher was being set on the server even when float was off. while the float calls didn't do anything warnings were still generated. Instead we provide an empty object for the dispatcher if float is off. Longer term the dispatcher should move to formatconfig and just reference the float methods if the flag is on 3. some external fizz runtime tests did not gate against float but should have
Josh Story committed
Dec 7, 2022 at 12:51 UTC
5dfc485f6957bf941fcd9565e0271aea019d7c9e
4 files changed
+9
-5
packages/react-dom-bindings/src/server/ReactDOMFloatServer.js
+1
-1
@@ -202,7 +202,7 @@ export function setCurrentlyRenderingBoundaryResourcesTarget(
202
resources.boundaryResources = boundaryResources;
203
}
204
205
-export const ReactDOMServerDispatcher = {
205
+export const ReactDOMServerFloatDispatcher = {
206
preload,
207
preinit,
208
};
packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js
+5
-1
@@ -69,7 +69,7 @@ import {
69
resourcesFromElement,
70
resourcesFromLink,
71
resourcesFromScript,
72
- ReactDOMServerDispatcher,
72
+ ReactDOMServerFloatDispatcher,
73
} from './ReactDOMFloatServer';
74
export {
75
createResources,
@@ -89,6 +89,10 @@ import {
89
import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
90
const ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
91
92
+const ReactDOMServerDispatcher = enableFloat
93
+ ? ReactDOMServerFloatDispatcher
94
+ : {};
95
+
96
export function prepareToRender(resources: Resources): mixed {
97
prepareToRenderResources(resources);
98
packages/react-dom/src/__tests__/ReactDOMFloat-test.js
+1
-1
@@ -608,6 +608,7 @@ describe('ReactDOMFloat', () => {
608
]);
609
});
610
611
+ // @gate enableFloat
612
it('dedupes if the external runtime is explicitly loaded using preinit', async () => {
613
const unstable_externalRuntimeSrc = 'src-of-external-runtime';
614
function App() {
@@ -5681,7 +5682,6 @@ describe('ReactDOMFloat', () => {
5682
);
5683
});
5684
5684
- // @gate enableFloat
5685
it('should not treat title descendants of svg into resources', async () => {
5686
await actIntoEmptyDocument(() => {
5687
const {pipe} = renderToPipeableStream(
packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js
+2
-2
@@ -116,7 +116,7 @@ describe('ReactDOM HostSingleton', () => {
116
: children;
117
}
118
119
- // @gate enableHostSingletons
119
+ // @gate enableHostSingletons && enableFloat
120
it('warns if you render the same singleton twice at the same time', async () => {
121
const root = ReactDOMClient.createRoot(document);
122
root.render(
@@ -201,7 +201,7 @@ describe('ReactDOM HostSingleton', () => {
201
);
202
});
203
204
- // @gate enableHostSingletons
204
+ // @gate enableHostSingletons && enableFloat
205
it('renders into html, head, and body persistently so the node identities never change and extraneous styles are retained', async () => {
206
gate(flags => {
207
if (flags.enableHostSingletons !== true) {