Skip to content

Commit 85667e0

Browse files
committed
test: update dev test
1 parent 873b8d5 commit 85667e0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Diff for: test/e2e/app-dir/ppr-metadata-streaming/ppr-metadata-streaming.test.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@ function countSubstring(str: string, substr: string): number {
66
}
77

88
describe('ppr-metadata-streaming', () => {
9-
const { next } = nextTestSetup({
9+
const { next, isNextDev } = nextTestSetup({
1010
files: __dirname,
1111
})
1212

1313
// No dynamic APIs used in metadata
1414
describe('static metadata', () => {
1515
it('should generate metadata in head when page is fully static', async () => {
16+
const rootSelector = isNextDev ? 'body' : 'head'
1617
const $ = await next.render$('/fully-static')
17-
expect($(`head title`).text()).toBe('fully static')
18+
expect($(`${rootSelector} title`).text()).toBe('fully static')
1819
expect(countSubstring($.html(), '<title>')).toBe(1)
1920

2021
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')
2425
await assertNoConsoleErrors(browser)
2526
})
2627

@@ -39,7 +40,7 @@ describe('ppr-metadata-streaming', () => {
3940

4041
// Dynamic APIs used in metadata, metadata should be suspended and inserted into body
4142
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 () => {
4344
const $ = await next.render$('/fully-dynamic')
4445
expect($('body title').text()).toBe('fully dynamic')
4546
expect(countSubstring($.html(), '<title>')).toBe(1)
@@ -51,7 +52,7 @@ describe('ppr-metadata-streaming', () => {
5152
await assertNoConsoleErrors(browser)
5253
})
5354

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 () => {
5556
const $ = await next.render$('/dynamic-metadata')
5657
expect($('body title').text()).toBe('dynamic metadata')
5758
expect(countSubstring($.html(), '<title>')).toBe(1)
@@ -78,14 +79,15 @@ describe('ppr-metadata-streaming', () => {
7879
})
7980

8081
it('should insert metadata into head with dynamic metadata and dynamic page wrapped under layout Suspense boundary', async () => {
82+
const rootSelector = isNextDev ? 'body' : 'head'
8183
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')
8385
expect(countSubstring($.html(), '<title>')).toBe(1)
8486

8587
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')
8991
await assertNoConsoleErrors(browser)
9092
})
9193
})

0 commit comments

Comments
 (0)