Skip to content

Commit 613d43f

Browse files
committed
Update tests
Update snapshots
1 parent 8845bea commit 613d43f

11 files changed

+49
-29
lines changed

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3580,7 +3580,8 @@ describe('ReactDOMFizzServer', () => {
35803580
expect(document.head.innerHTML).toBe(
35813581
'<script type="importmap">' +
35823582
JSON.stringify(importMap) +
3583-
'</script><script async="" src="foo"></script>',
3583+
'</script><script async="" src="foo"></script>' +
3584+
'<link rel="expect" href="#«R»" blocking="render">',
35843585
);
35853586
});
35863587

@@ -4189,7 +4190,7 @@ describe('ReactDOMFizzServer', () => {
41894190
renderOptions.unstable_externalRuntimeSrc,
41904191
).map(n => n.outerHTML),
41914192
).toEqual([
4192-
'<script src="foo" async=""></script>',
4193+
'<script src="foo" id="«R»" async=""></script>',
41934194
'<script src="bar" async=""></script>',
41944195
'<script src="baz" integrity="qux" async=""></script>',
41954196
'<script type="module" src="quux" async=""></script>',
@@ -4276,7 +4277,7 @@ describe('ReactDOMFizzServer', () => {
42764277
renderOptions.unstable_externalRuntimeSrc,
42774278
).map(n => n.outerHTML),
42784279
).toEqual([
4279-
'<script src="foo" async=""></script>',
4280+
'<script src="foo" id="«R»" async=""></script>',
42804281
'<script src="bar" async=""></script>',
42814282
'<script src="baz" crossorigin="" async=""></script>',
42824283
'<script src="qux" crossorigin="" async=""></script>',
@@ -4512,7 +4513,7 @@ describe('ReactDOMFizzServer', () => {
45124513

45134514
// the html should be as-is
45144515
expect(document.documentElement.innerHTML).toEqual(
4515-
'<head></head><body><p>hello world!</p></body>',
4516+
'<head><link rel="expect" href="#«R»" blocking="render"></head><body><p>hello world!</p><template id="«R»"></template></body>',
45164517
);
45174518
});
45184519

@@ -6492,7 +6493,7 @@ describe('ReactDOMFizzServer', () => {
64926493
});
64936494

64946495
expect(document.documentElement.outerHTML).toEqual(
6495-
'<html><head></head><body><script>try { foo() } catch (e) {} ;</script></body></html>',
6496+
'<html><head><link rel="expect" href="#«R»" blocking="render"></head><body><script>try { foo() } catch (e) {} ;</script><template id="«R»"></template></body></html>',
64966497
);
64976498
});
64986499

packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('ReactDOMFizzServerBrowser', () => {
8585
);
8686
const result = await readResult(stream);
8787
expect(result).toMatchInlineSnapshot(
88-
`"<!DOCTYPE html><html><head></head><body>hello world</body></html>"`,
88+
`"<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head><body>hello world<template id="«R»"></template></body></html>"`,
8989
);
9090
});
9191

@@ -99,7 +99,7 @@ describe('ReactDOMFizzServerBrowser', () => {
9999
);
100100
const result = await readResult(stream);
101101
expect(result).toMatchInlineSnapshot(
102-
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script>INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
102+
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script id="«R»">INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
103103
);
104104
});
105105

@@ -529,7 +529,7 @@ describe('ReactDOMFizzServerBrowser', () => {
529529

530530
const result = await readResult(stream);
531531
expect(result).toEqual(
532-
'<!DOCTYPE html><html><head><title>foo</title></head><body>bar</body></html>',
532+
'<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/><title>foo</title></head><body>bar<template id="«R»"></template></body></html>',
533533
);
534534
});
535535

@@ -547,7 +547,7 @@ describe('ReactDOMFizzServerBrowser', () => {
547547
expect(result).toMatchInlineSnapshot(
548548
// TODO: remove interpolation because it prevents snapshot updates.
549549
// eslint-disable-next-line jest/no-interpolation-in-snapshots
550-
`"<link rel="preload" as="script" fetchPriority="low" nonce="R4nd0m" href="init.js"/><link rel="modulepreload" fetchPriority="low" nonce="R4nd0m" href="init.mjs"/><div>hello world</div><script nonce="${nonce}">INIT();</script><script src="init.js" nonce="${nonce}" async=""></script><script type="module" src="init.mjs" nonce="${nonce}" async=""></script>"`,
550+
`"<link rel="preload" as="script" fetchPriority="low" nonce="R4nd0m" href="init.js"/><link rel="modulepreload" fetchPriority="low" nonce="R4nd0m" href="init.mjs"/><div>hello world</div><script nonce="${nonce}" id="«R»">INIT();</script><script src="init.js" nonce="${nonce}" async=""></script><script type="module" src="init.mjs" nonce="${nonce}" async=""></script>"`,
551551
);
552552
});
553553

packages/react-dom/src/__tests__/ReactDOMFizzServerEdge-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('ReactDOMFizzServerEdge', () => {
7272
});
7373

7474
expect(result).toMatchInlineSnapshot(
75-
`"<!DOCTYPE html><html><head></head><body><main>hello</main></body></html>"`,
75+
`"<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head><body><main>hello</main><template id="«R»"></template></body></html>"`,
7676
);
7777
});
7878
});

packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('ReactDOMFizzServerNode', () => {
7979
});
8080
// with Float, we emit empty heads if they are elided when rendering <html>
8181
expect(output.result).toMatchInlineSnapshot(
82-
`"<!DOCTYPE html><html><head></head><body>hello world</body></html>"`,
82+
`"<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head><body>hello world<template id="«R»"></template></body></html>"`,
8383
);
8484
});
8585

@@ -97,7 +97,7 @@ describe('ReactDOMFizzServerNode', () => {
9797
pipe(writable);
9898
});
9999
expect(output.result).toMatchInlineSnapshot(
100-
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script>INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
100+
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script id="«R»">INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
101101
);
102102
});
103103

packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ describe('ReactDOMFizzStatic', () => {
106106
node.tagName !== 'TEMPLATE' &&
107107
node.tagName !== 'template' &&
108108
!node.hasAttribute('hidden') &&
109-
!node.hasAttribute('aria-hidden')
109+
!node.hasAttribute('aria-hidden') &&
110+
// Ignore the render blocking expect
111+
(node.getAttribute('rel') !== 'expect' ||
112+
node.getAttribute('blocking') !== 'render')
110113
) {
111114
const props = {};
112115
const attributes = node.attributes;

packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
187187
);
188188
const prelude = await readContent(result.prelude);
189189
expect(prelude).toMatchInlineSnapshot(
190-
`"<!DOCTYPE html><html><head></head><body>hello world</body></html>"`,
190+
`"<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head><body>hello world<template id="«R»"></template></body></html>"`,
191191
);
192192
});
193193

@@ -201,7 +201,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
201201
);
202202
const prelude = await readContent(result.prelude);
203203
expect(prelude).toMatchInlineSnapshot(
204-
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script>INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
204+
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script id="«R»">INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
205205
);
206206
});
207207

@@ -1428,7 +1428,8 @@ describe('ReactDOMFizzStaticBrowser', () => {
14281428
expect(await readContent(content)).toBe(
14291429
'<!DOCTYPE html><html lang="en"><head>' +
14301430
'<link rel="stylesheet" href="my-style" data-precedence="high"/>' +
1431-
'</head><body>Hello</body></html>',
1431+
'<link rel="expect" href="#«R»" blocking="render"/></head>' +
1432+
'<body>Hello<template id="«R»"></template></body></html>',
14321433
);
14331434
});
14341435

@@ -1474,7 +1475,8 @@ describe('ReactDOMFizzStaticBrowser', () => {
14741475
expect(await readContent(content)).toBe(
14751476
'<!DOCTYPE html><html lang="en"><head>' +
14761477
'<link rel="stylesheet" href="my-style" data-precedence="high"/>' +
1477-
'</head><body>Hello</body></html>',
1478+
'<link rel="expect" href="#«R»" blocking="render"/></head>' +
1479+
'<body>Hello<template id="«R»"></template></body></html>',
14781480
);
14791481
});
14801482

@@ -1525,7 +1527,8 @@ describe('ReactDOMFizzStaticBrowser', () => {
15251527
expect(await readContent(content)).toBe(
15261528
'<!DOCTYPE html><html><head>' +
15271529
'<link rel="stylesheet" href="my-style" data-precedence="high"/>' +
1528-
'</head><body><div>Hello</div></body></html>',
1530+
'<link rel="expect" href="#«R»" blocking="render"/></head>' +
1531+
'<body><div>Hello</div><template id="«R»"></template></body></html>',
15291532
);
15301533
});
15311534

@@ -1607,7 +1610,8 @@ describe('ReactDOMFizzStaticBrowser', () => {
16071610
let result = decoder.decode(value, {stream: true});
16081611

16091612
expect(result).toBe(
1610-
'<!DOCTYPE html><html><head></head><body>hello<!--$?--><template id="B:1"></template><!--/$-->',
1613+
'<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head>' +
1614+
'<body>hello<!--$?--><template id="B:1"></template><!--/$--><template id="«R»"></template>',
16111615
);
16121616

16131617
await 1;
@@ -1631,7 +1635,9 @@ describe('ReactDOMFizzStaticBrowser', () => {
16311635
const slice = result.slice(0, instructionIndex + '$RC'.length);
16321636

16331637
expect(slice).toBe(
1634-
'<!DOCTYPE html><html><head></head><body>hello<!--$?--><template id="B:1"></template><!--/$--><div hidden id="S:1">world<!-- --></div><script>$RC',
1638+
'<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head>' +
1639+
'<body>hello<!--$?--><template id="B:1"></template><!--/$--><template id="«R»"></template>' +
1640+
'<div hidden id="S:1">world<!-- --></div><script>$RC',
16351641
);
16361642
});
16371643

packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('ReactDOMFizzStaticNode', () => {
6464
);
6565
const prelude = await readContent(result.prelude);
6666
expect(prelude).toMatchInlineSnapshot(
67-
`"<!DOCTYPE html><html><head></head><body>hello world</body></html>"`,
67+
`"<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head><body>hello world<template id="«R»"></template></body></html>"`,
6868
);
6969
});
7070

@@ -80,7 +80,7 @@ describe('ReactDOMFizzStaticNode', () => {
8080
);
8181
const prelude = await readContent(result.prelude);
8282
expect(prelude).toMatchInlineSnapshot(
83-
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script>INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
83+
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script id="«R»">INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
8484
);
8585
});
8686

packages/react-dom/src/test-utils/FizzTestUtils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ function getVisibleChildren(element: Element): React$Node {
150150
node.tagName !== 'TEMPLATE' &&
151151
node.tagName !== 'template' &&
152152
!node.hasAttribute('hidden') &&
153-
!node.hasAttribute('aria-hidden')
153+
!node.hasAttribute('aria-hidden') &&
154+
// Ignore the render blocking expect
155+
(node.getAttribute('rel') !== 'expect' ||
156+
node.getAttribute('blocking') !== 'render')
154157
) {
155158
const props: any = {};
156159
const attributes = node.attributes;

packages/react-server-dom-fb/src/__tests__/ReactDOMServerFB-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('ReactDOMServerFB', () => {
5959
});
6060
const result = readResult(stream);
6161
expect(result).toMatchInlineSnapshot(
62-
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script>INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
62+
`"<link rel="preload" as="script" fetchPriority="low" href="init.js"/><link rel="modulepreload" fetchPriority="low" href="init.mjs"/><div>hello world</div><script id="«R»">INIT();</script><script src="init.js" async=""></script><script type="module" src="init.mjs" async=""></script>"`,
6363
);
6464
});
6565

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ describe('ReactFlightDOM', () => {
193193
node.tagName !== 'TEMPLATE' &&
194194
node.tagName !== 'template' &&
195195
!node.hasAttribute('hidden') &&
196-
!node.hasAttribute('aria-hidden'))
196+
!node.hasAttribute('aria-hidden') &&
197+
// Ignore the render blocking expect
198+
(node.getAttribute('rel') !== 'expect' ||
199+
node.getAttribute('blocking') !== 'render'))
197200
) {
198201
const props = {};
199202
const attributes = node.attributes;
@@ -1917,11 +1920,15 @@ describe('ReactFlightDOM', () => {
19171920

19181921
expect(content1).toEqual(
19191922
'<!DOCTYPE html><html><head><link rel="preload" href="before1" as="style"/>' +
1920-
'<link rel="preload" href="after1" as="style"/></head><body><p>hello world</p></body></html>',
1923+
'<link rel="preload" href="after1" as="style"/>' +
1924+
'<link rel="expect" href="#«R»" blocking="render"/></head>' +
1925+
'<body><p>hello world</p><template id="«R»"></template></body></html>',
19211926
);
19221927
expect(content2).toEqual(
19231928
'<!DOCTYPE html><html><head><link rel="preload" href="before2" as="style"/>' +
1924-
'<link rel="preload" href="after2" as="style"/></head><body><p>hello world</p></body></html>',
1929+
'<link rel="preload" href="after2" as="style"/>' +
1930+
'<link rel="expect" href="#«R»" blocking="render"/></head>' +
1931+
'<body><p>hello world</p><template id="«R»"></template></body></html>',
19251932
);
19261933
});
19271934

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,8 +1899,8 @@ describe('ReactFlightDOMBrowser', () => {
18991899
}
19001900

19011901
expect(content).toEqual(
1902-
'<!DOCTYPE html><html><head>' +
1903-
'</head><body><p>hello world</p></body></html>',
1902+
'<!DOCTYPE html><html><head><link rel="expect" href="#«R»" blocking="render"/></head>' +
1903+
'<body><p>hello world</p><template id="«R»"></template></body></html>',
19041904
);
19051905
});
19061906

0 commit comments

Comments
 (0)