Skip to content

Commit 00af602

Browse files
committed
[Flight] Add failing test for dedupe resolution on blocked models
Triggered by vercel/next.js#66033 I was suspecting that the bug was introduced with #28996, but I could not make the test succeed on a commit before that PR, so maybe this assumption is wrong.
1 parent 5cc9f69 commit 00af602

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,55 @@ describe('ReactFlightDOMBrowser', () => {
247247
expect(container.innerHTML).toBe('<span>Hello, World!</span>');
248248
});
249249

250+
it('should resolve deduped objects within the same model root when it is blocked', async () => {
251+
let resolveClientComponentChunk;
252+
253+
const ClientOuter = clientExports(function ClientOuter({Component, value}) {
254+
return <Component value={value} />;
255+
});
256+
257+
const ClientInner = clientExports(
258+
function ClientInner({value}) {
259+
return <pre>{JSON.stringify(value)}</pre>;
260+
},
261+
'42',
262+
'/test.js',
263+
new Promise(resolve => (resolveClientComponentChunk = resolve)),
264+
);
265+
266+
function Server({value}) {
267+
return <ClientOuter Component={ClientInner} value={value} />;
268+
}
269+
270+
const shared = [1, 2, 3];
271+
const value = [shared, shared];
272+
273+
const stream = ReactServerDOMServer.renderToReadableStream(
274+
<Server value={value} />,
275+
webpackMap,
276+
);
277+
278+
function ClientRoot({response}) {
279+
return use(response);
280+
}
281+
282+
const response = ReactServerDOMClient.createFromReadableStream(stream);
283+
const container = document.createElement('div');
284+
const root = ReactDOMClient.createRoot(container);
285+
286+
await act(() => {
287+
root.render(<ClientRoot response={response} />);
288+
});
289+
290+
expect(container.innerHTML).toBe('');
291+
292+
await act(() => {
293+
resolveClientComponentChunk();
294+
});
295+
296+
expect(container.innerHTML).toBe('<pre>[[1,2,3],[1,2,3]]</pre>');
297+
});
298+
250299
it('should progressively reveal server components', async () => {
251300
let reportedErrors = [];
252301

0 commit comments

Comments
 (0)