Skip to content

Commit 0fddb4e

Browse files
committed
Fix gates
1 parent e8d5dea commit 0fddb4e

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,8 +2347,10 @@ describe('ReactFlight', () => {
23472347
},
23482348
);
23492349

2350-
// Wait for the iterator to finish
2351-
await iteratorPromise;
2350+
if (gate(flag => flag.enableFlightReadableStream)) {
2351+
// Wait for the iterator to finish
2352+
await iteratorPromise;
2353+
}
23522354
await 0; // One more tick for the return value / closing.
23532355

23542356
const transport = ReactNoopFlightServer.render(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ describe('ReactFlightDOMEdge', () => {
454454
expect(result.get('value')).toBe('hello');
455455
});
456456

457+
// @gate enableFlightReadableStream
457458
it('can pass an async import to a ReadableStream while enqueuing in order', async () => {
458459
let resolve;
459460
const promise = new Promise(r => (resolve = r));
@@ -496,6 +497,7 @@ describe('ReactFlightDOMEdge', () => {
496497
expect(await reader.read()).toEqual({value: undefined, done: true});
497498
});
498499

500+
// @gate enableFlightReadableStream
499501
it('can pass an async import a AsyncIterable while allowing peaking at future values', async () => {
500502
let resolve;
501503
const promise = new Promise(r => (resolve = r));

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

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,35 @@ describe('ReactFlightDOMReplyEdge', () => {
109109
expect(await result.arrayBuffer()).toEqual(await blob.arrayBuffer());
110110
});
111111

112-
it('can transport FormData (blobs)', async () => {
113-
const bytes = new Uint8Array([
114-
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
115-
]);
116-
const blob = new Blob([bytes, bytes], {
117-
type: 'application/x-test',
112+
if (typeof FormData !== 'undefined' && typeof File !== 'undefined') {
113+
it('can transport FormData (blobs)', async () => {
114+
const bytes = new Uint8Array([
115+
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
116+
]);
117+
const blob = new Blob([bytes, bytes], {
118+
type: 'application/x-test',
119+
});
120+
121+
const formData = new FormData();
122+
formData.append('hi', 'world');
123+
formData.append('file', blob, 'filename.test');
124+
125+
expect(formData.get('file') instanceof File).toBe(true);
126+
expect(formData.get('file').name).toBe('filename.test');
127+
128+
const body = await ReactServerDOMClient.encodeReply(formData);
129+
const result = await ReactServerDOMServer.decodeReply(
130+
body,
131+
webpackServerMap,
132+
);
133+
134+
expect(result instanceof FormData).toBe(true);
135+
expect(result.get('hi')).toBe('world');
136+
const resultBlob = result.get('file');
137+
expect(resultBlob instanceof Blob).toBe(true);
138+
expect(resultBlob.name).toBe('filename.test'); // In this direction we allow file name to pass through but not other direction.
139+
expect(resultBlob.size).toBe(bytes.length * 2);
140+
expect(await resultBlob.arrayBuffer()).toEqual(await blob.arrayBuffer());
118141
});
119-
120-
const formData = new FormData();
121-
formData.append('hi', 'world');
122-
formData.append('file', blob, 'filename.test');
123-
124-
expect(formData.get('file') instanceof File).toBe(true);
125-
expect(formData.get('file').name).toBe('filename.test');
126-
127-
const body = await ReactServerDOMClient.encodeReply(formData);
128-
const result = await ReactServerDOMServer.decodeReply(
129-
body,
130-
webpackServerMap,
131-
);
132-
133-
expect(result instanceof FormData).toBe(true);
134-
expect(result.get('hi')).toBe('world');
135-
const resultBlob = result.get('file');
136-
expect(resultBlob instanceof Blob).toBe(true);
137-
expect(resultBlob.name).toBe('filename.test'); // In this direction we allow file name to pass through but not other direction.
138-
expect(resultBlob.size).toBe(bytes.length * 2);
139-
expect(await resultBlob.arrayBuffer()).toEqual(await blob.arrayBuffer());
140-
});
142+
}
141143
});

0 commit comments

Comments
 (0)