@@ -6,21 +6,22 @@ function countSubstring(str: string, substr: string): number {
6
6
}
7
7
8
8
describe ( 'ppr-metadata-streaming' , ( ) => {
9
- const { next } = nextTestSetup ( {
9
+ const { next, isNextDev } = nextTestSetup ( {
10
10
files : __dirname ,
11
11
} )
12
12
13
13
// No dynamic APIs used in metadata
14
14
describe ( 'static metadata' , ( ) => {
15
15
it ( 'should generate metadata in head when page is fully static' , async ( ) => {
16
+ const rootSelector = isNextDev ? 'body' : 'head'
16
17
const $ = await next . render$ ( '/fully-static' )
17
- expect ( $ ( `head title` ) . text ( ) ) . toBe ( 'fully static' )
18
+ expect ( $ ( `${ rootSelector } title` ) . text ( ) ) . toBe ( 'fully static' )
18
19
expect ( countSubstring ( $ . html ( ) , '<title>' ) ) . toBe ( 1 )
19
20
20
21
const browser = await next . browser ( '/fully-static' )
21
- expect ( await browser . waitForElementByCss ( 'head title' ) . text ( ) ) . toBe (
22
- 'fully static'
23
- )
22
+ expect (
23
+ await browser . waitForElementByCss ( ` ${ rootSelector } title` ) . text ( )
24
+ ) . toBe ( 'fully static' )
24
25
await assertNoConsoleErrors ( browser )
25
26
} )
26
27
@@ -39,7 +40,7 @@ describe('ppr-metadata-streaming', () => {
39
40
40
41
// Dynamic APIs used in metadata, metadata should be suspended and inserted into body
41
42
describe ( 'dynamic metadata' , ( ) => {
42
- it ( 'should generate metadata in head when page is fully dynamic' , async ( ) => {
43
+ it ( 'should generate metadata in body when page is fully dynamic' , async ( ) => {
43
44
const $ = await next . render$ ( '/fully-dynamic' )
44
45
expect ( $ ( 'body title' ) . text ( ) ) . toBe ( 'fully dynamic' )
45
46
expect ( countSubstring ( $ . html ( ) , '<title>' ) ) . toBe ( 1 )
@@ -51,7 +52,7 @@ describe('ppr-metadata-streaming', () => {
51
52
await assertNoConsoleErrors ( browser )
52
53
} )
53
54
54
- it ( 'should generate metadata in head when page content is static' , async ( ) => {
55
+ it ( 'should generate metadata in body when page content is static' , async ( ) => {
55
56
const $ = await next . render$ ( '/dynamic-metadata' )
56
57
expect ( $ ( 'body title' ) . text ( ) ) . toBe ( 'dynamic metadata' )
57
58
expect ( countSubstring ( $ . html ( ) , '<title>' ) ) . toBe ( 1 )
@@ -78,14 +79,15 @@ describe('ppr-metadata-streaming', () => {
78
79
} )
79
80
80
81
it ( 'should insert metadata into head with dynamic metadata and dynamic page wrapped under layout Suspense boundary' , async ( ) => {
82
+ const rootSelector = isNextDev ? 'body' : 'head'
81
83
const $ = await next . render$ ( '/dynamic-page/partial' )
82
- expect ( $ ( 'head title' ) . text ( ) ) . toBe ( 'dynamic-page - partial' )
84
+ expect ( $ ( ` ${ rootSelector } title` ) . text ( ) ) . toBe ( 'dynamic-page - partial' )
83
85
expect ( countSubstring ( $ . html ( ) , '<title>' ) ) . toBe ( 1 )
84
86
85
87
const browser = await next . browser ( '/dynamic-page/partial' )
86
- expect ( await browser . waitForElementByCss ( 'head title' ) . text ( ) ) . toBe (
87
- 'dynamic-page - partial'
88
- )
88
+ expect (
89
+ await browser . waitForElementByCss ( ` ${ rootSelector } title` ) . text ( )
90
+ ) . toBe ( 'dynamic-page - partial' )
89
91
await assertNoConsoleErrors ( browser )
90
92
} )
91
93
} )
0 commit comments