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

[Flight] Add failing test for dedupe resolution on blocked models #29200

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,55 @@ describe('ReactFlightDOMBrowser', () => {
expect(container.innerHTML).toBe('<span>Hello, World!</span>');
});

it('should resolve deduped objects within the same model root when it is blocked', async () => {
Copy link
Contributor

@lubieowoce lubieowoce May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe do

Suggested change
it('should resolve deduped objects within the same model root when it is blocked', async () => {
it.failing('should resolve deduped objects within the same model root when it is blocked', async () => {

so that it passes CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that already in #29129, but the Jest setup in the React repo does not seem to support this.

let resolveClientComponentChunk;

const ClientOuter = clientExports(function ClientOuter({Component, value}) {
return <Component value={value} />;
});

const ClientInner = clientExports(
function ClientInner({value}) {
return <pre>{JSON.stringify(value)}</pre>;
},
'42',
'/test.js',
new Promise(resolve => (resolveClientComponentChunk = resolve)),
);

function Server({value}) {
return <ClientOuter Component={ClientInner} value={value} />;
}

const shared = [1, 2, 3];
const value = [shared, shared];

const stream = ReactServerDOMServer.renderToReadableStream(
<Server value={value} />,
webpackMap,
);

function ClientRoot({response}) {
return use(response);
}

const response = ReactServerDOMClient.createFromReadableStream(stream);
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);

await act(() => {
root.render(<ClientRoot response={response} />);
});

expect(container.innerHTML).toBe('');

await act(() => {
resolveClientComponentChunk();
});

expect(container.innerHTML).toBe('<pre>[[1,2,3],[1,2,3]]</pre>');
});

it('should progressively reveal server components', async () => {
let reportedErrors = [];

Expand Down