@samitouri / QOS-React-1 / commits / 454fc41fc7

[test] Add tests for cyclic arrays in Flight and Flight Reply (#35347)

We already had tests for cyclic objects, but not for cyclic arrays.

Hendrik Liebau committed Dec 17, 2025 at 18:08 UTC 454fc41fc7d50f8abbcfb9595b01e8ea8bfcc265
2 files changed +30
packages/react-client/src/__tests__/ReactFlight-test.js
+19
@@ -724,6 +724,25 @@ describe('ReactFlight', () => {
724 });
725 });
726
727 + it('can transport cyclic arrays', async () => {
728 + function ComponentClient({prop, obj}) {
729 + expect(prop[1]).toBe(prop);
730 + expect(prop[0]).toBe(obj);
731 + }
732 + const Component = clientReference(ComponentClient);
733 +
734 + const obj = {};
735 + const cyclic = [obj];
736 + cyclic[1] = cyclic;
737 + const model = <Component prop={cyclic} obj={obj} />;
738 +
739 + const transport = ReactNoopFlightServer.render(model);
740 +
741 + await act(async () => {
742 + ReactNoop.render(await ReactNoopFlightClient.read(transport));
743 + });
744 + });
745 +
746 it('can render a lazy component as a shared component on the server', async () => {
747 function SharedComponent({text}) {
748 return (
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReply-test.js
+11
@@ -650,6 +650,17 @@ describe('ReactFlightDOMReply', () => {
650 expect(root.prop.obj).toBe(root.prop);
651 });
652
653 + it('can transport cyclic arrays', async () => {
654 + const obj = {};
655 + const cyclic = [obj];
656 + cyclic[1] = cyclic;
657 +
658 + const body = await ReactServerDOMClient.encodeReply({prop: cyclic, obj});
659 + const root = await ReactServerDOMServer.decodeReply(body, webpackServerMap);
660 + expect(root.prop[1]).toBe(root.prop);
661 + expect(root.prop[0]).toBe(root.obj);
662 + });
663 +
664 it('can abort an unresolved model and get the partial result', async () => {
665 const promise = new Promise(r => {});
666 const controller = new AbortController();