Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into fix/revalidate-stuff
- Loading branch information
Showing
28 changed files
with
297 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import path from 'path' | ||
import cheerio from 'cheerio' | ||
import { createNext, FileRef } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import { renderViaHTTP } from 'next-test-utils' | ||
|
||
describe('app dir head', () => { | ||
if ((global as any).isNextDeploy) { | ||
it('should skip next deploy for now', () => {}) | ||
return | ||
} | ||
|
||
if (process.env.NEXT_TEST_REACT_VERSION === '^17') { | ||
it('should skip for react v17', () => {}) | ||
return | ||
} | ||
let next: NextInstance | ||
|
||
function runTests() { | ||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: new FileRef(path.join(__dirname, 'head')), | ||
dependencies: { | ||
react: 'experimental', | ||
'react-dom': 'experimental', | ||
}, | ||
skipStart: true, | ||
}) | ||
|
||
await next.start() | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should use head from index page', async () => { | ||
const html = await renderViaHTTP(next.url, '/') | ||
const $ = cheerio.load(html) | ||
const headTags = $('head').children().toArray() | ||
|
||
expect(headTags.find((el) => el.attribs.src === '/hello.js')).toBeTruthy() | ||
expect( | ||
headTags.find((el) => el.attribs.src === '/another.js') | ||
).toBeTruthy() | ||
}) | ||
|
||
it('should use correct head for /blog', async () => { | ||
const html = await renderViaHTTP(next.url, '/blog') | ||
const $ = cheerio.load(html) | ||
const headTags = $('head').children().toArray() | ||
|
||
expect(headTags.find((el) => el.attribs.src === '/hello3.js')).toBeFalsy() | ||
expect( | ||
headTags.find((el) => el.attribs.src === '/hello1.js') | ||
).toBeTruthy() | ||
expect( | ||
headTags.find((el) => el.attribs.src === '/hello2.js') | ||
).toBeTruthy() | ||
expect( | ||
headTags.find((el) => el.attribs.src === '/another.js') | ||
).toBeTruthy() | ||
}) | ||
|
||
it('should use head from layout when not on page', async () => { | ||
const html = await renderViaHTTP(next.url, '/blog/about') | ||
const $ = cheerio.load(html) | ||
const headTags = $('head').children().toArray() | ||
|
||
expect( | ||
headTags.find((el) => el.attribs.src === '/hello1.js') | ||
).toBeTruthy() | ||
expect( | ||
headTags.find((el) => el.attribs.src === '/hello2.js') | ||
).toBeTruthy() | ||
expect( | ||
headTags.find((el) => el.attribs.src === '/another.js') | ||
).toBeTruthy() | ||
}) | ||
|
||
it('should pass params to head for dynamic path', async () => { | ||
const html = await renderViaHTTP(next.url, '/blog/post-1') | ||
const $ = cheerio.load(html) | ||
const headTags = $('head').children().toArray() | ||
|
||
expect( | ||
headTags.find( | ||
(el) => | ||
el.attribs.src === '/hello3.js' && | ||
el.attribs['data-slug'] === 'post-1' | ||
) | ||
).toBeTruthy() | ||
expect( | ||
headTags.find((el) => el.attribs.src === '/another.js') | ||
).toBeTruthy() | ||
}) | ||
} | ||
|
||
runTests() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default async function Head({ params }) { | ||
return ( | ||
<> | ||
<script async src="/hello3.js" data-slug={params.slug} /> | ||
<title>{`hello from dynamic blog page ${params.slug}`}</title> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<p id="page">dynamic blog page</p> | ||
<Link href="/" id="to-index"> | ||
to / | ||
</Link> | ||
<br /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<p id="page">blog about page</p> | ||
<Link href="/" id="to-index"> | ||
to / | ||
</Link> | ||
<br /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default async function Head() { | ||
return ( | ||
<> | ||
<script async src="/hello1.js" /> | ||
<script async src="/hello2.js" /> | ||
<title>hello from blog layout</title> | ||
<meta name="description" content="a neat blog" /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<> | ||
<p id="layout">blog layout</p> | ||
{children} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<p id="page">blog page</p> | ||
<Link href="/" id="to-index"> | ||
to / | ||
</Link> | ||
<br /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default async function Head() { | ||
return ( | ||
<> | ||
<script async src="/hello.js" /> | ||
<title>hello from index</title> | ||
<meta name="description" content="an index page" /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default function Root({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<script async src="/another.js" /> | ||
</head> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
Oops, something went wrong.