Skip to content

Commit f2b3bb5

Browse files
committed
Merge branch 'main' into delete-e2e-deploys
2 parents 2cc7301 + 4185df0 commit f2b3bb5

36 files changed

+2115
-568
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
schedule:
88
- cron: '0 0 * * *'
99

10+
concurrency:
11+
group: ${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
build:
1216
name: Unit tests

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"packages/runtime": "4.32.2",
2+
"packages/runtime": "4.33.0",
33
"packages/next": "1.4.4"
44
}

cypress/integration/default/appdir.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ describe('appDir', () => {
2929
})
3030
})
3131

32+
it('returns a vary header for RSC data requests to ISR pages', () => {
33+
cy.request({
34+
url: '/blog/erica/',
35+
followRedirect: false,
36+
headers: {
37+
RSC: '1',
38+
},
39+
}).then((response) => {
40+
expect(response.headers).to.have.property('vary').contains('RSC')
41+
})
42+
})
43+
44+
it('returns a vary header for non-RSC data requests to ISR pages', () => {
45+
cy.request({
46+
url: '/blog/erica/',
47+
followRedirect: false,
48+
}).then((response) => {
49+
expect(response.headers).to.have.property('vary').contains('RSC')
50+
})
51+
})
52+
3253
it('returns RSC data for RSC requests to static pages', () => {
3354
cy.request({
3455
url: '/blog/erica/first-post/',
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
describe('On-demand revalidation', () => {
2+
it('revalidates static ISR route with default locale', () => {
3+
cy.request({ url: '/api/revalidate/?select=0' }).then((res) => {
4+
expect(res.status).to.eq(200)
5+
expect(res.body).to.have.property('message', 'success')
6+
})
7+
})
8+
it('revalidates static ISR route with non-default locale', () => {
9+
cy.request({ url: '/api/revalidate/?select=1' }).then((res) => {
10+
expect(res.status).to.eq(200)
11+
expect(res.body).to.have.property('message', 'success')
12+
})
13+
})
14+
it('revalidates root static ISR route with default locale', () => {
15+
cy.request({ url: '/api/revalidate/?select=2' }).then((res) => {
16+
expect(res.status).to.eq(200)
17+
expect(res.body).to.have.property('message', 'success')
18+
})
19+
})
20+
it('revalidates root static ISR route with non-default locale', () => {
21+
cy.request({ url: '/api/revalidate/?select=3' }).then((res) => {
22+
expect(res.status).to.eq(200)
23+
expect(res.body).to.have.property('message', 'success')
24+
})
25+
})
26+
it('revalidates dynamic prerendered ISR route with default locale', () => {
27+
cy.request({ url: '/api/revalidate/?select=4' }).then((res) => {
28+
expect(res.status).to.eq(200)
29+
expect(res.body).to.have.property('message', 'success')
30+
})
31+
})
32+
it('fails to revalidate dynamic non-prerendered ISR route with fallback false', () => {
33+
cy.request({ url: '/api/revalidate/?select=5', failOnStatusCode: false }).then((res) => {
34+
expect(res.status).to.eq(500)
35+
expect(res.body).to.have.property('message')
36+
expect(res.body.message).to.include('Invalid response 404')
37+
})
38+
})
39+
it('revalidates dynamic non-prerendered ISR route with fallback blocking', () => {
40+
cy.request({ url: '/api/revalidate/?select=6' }).then((res) => {
41+
expect(res.status).to.eq(200)
42+
expect(res.body).to.have.property('message', 'success')
43+
})
44+
})
45+
it('revalidates dynamic non-prerendered ISR route with fallback blocking and non-default locale', () => {
46+
cy.request({ url: '/api/revalidate/?select=7' }).then((res) => {
47+
expect(res.status).to.eq(200)
48+
expect(res.body).to.have.property('message', 'success')
49+
})
50+
})
51+
it('revalidates dynamic prerendered appDir route', () => {
52+
cy.request({ url: '/api/revalidate/?select=8' }).then((res) => {
53+
expect(res.status).to.eq(200)
54+
expect(res.body).to.have.property('message', 'success')
55+
})
56+
})
57+
it('fails to revalidate dynamic non-prerendered appDir route', () => {
58+
cy.request({ url: '/api/revalidate/?select=9' }).then((res) => {
59+
expect(res.status).to.eq(200)
60+
expect(res.body).to.have.property('message', 'success')
61+
})
62+
})
63+
it('revalidates dynamic prerendered appDir route with catch-all params', () => {
64+
cy.request({ url: '/api/revalidate/?select=10' }).then((res) => {
65+
expect(res.status).to.eq(200)
66+
expect(res.body).to.have.property('message', 'success')
67+
})
68+
})
69+
})

cypress/integration/middleware/enhanced.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('Enhanced middleware', () => {
22
it('rewrites the response body', () => {
33
cy.visit('/static')
4-
cy.get('#message').contains('This was static but has been transformed in')
4+
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
55
cy.contains("This is an ad that isn't shown by default")
66
})
77

@@ -10,7 +10,7 @@ describe('Enhanced middleware', () => {
1010
expect(response.body).to.have.nested.property('pageProps.showAd', true)
1111
expect(response.body)
1212
.to.have.nested.property('pageProps.message')
13-
.that.includes('This was static but has been transformed in')
13+
.that.includes('This was static (& escaping test &) but has been transformed in')
1414
})
1515
})
1616

@@ -27,13 +27,13 @@ describe('Enhanced middleware', () => {
2727

2828
it('handles uppercase i18n redirects properly ', () => {
2929
cy.visit('/de-DE/static')
30-
cy.get('#message').contains('This was static but has been transformed in')
30+
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
3131
cy.contains("This is an ad that isn't shown by default")
3232
})
3333

3434
it('handles lowercase i18n redirects properly ', () => {
3535
cy.visit('/de-de/static')
36-
cy.get('#message').contains('This was static but has been transformed in')
36+
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
3737
cy.contains("This is an ad that isn't shown by default")
3838
})
3939
})

demos/canary/package-lock.json

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/default/pages/api/revalidate.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export default async function handler(req, res) {
2+
const query = req.query
3+
const select = Number(query.select) || 0
4+
5+
// these paths are used for e2e testing res.revalidate()
6+
const paths = [
7+
'/getStaticProps/with-revalidate/', // valid path
8+
'/fr/getStaticProps/with-revalidate/', // valid path (with locale)
9+
'/', // valid path (index)
10+
'/fr/', // valid path (index with locale)
11+
'/getStaticProps/withRevalidate/2/', // valid path (with dynamic route)
12+
'/getStaticProps/withRevalidate/3/', // invalid path (fallback false with dynamic route)
13+
'/getStaticProps/withRevalidate/withFallbackBlocking/3/', // valid path (fallback blocking with dynamic route)
14+
'/fr/getStaticProps/withRevalidate/withFallbackBlocking/3/', // valid path (fallback blocking with dynamic route and locale)
15+
'/blog/nick/', // valid path (with prerendered appDir dynamic route)
16+
'/blog/greg/', // invalid path (with non-prerendered appDir dynamic route)
17+
'/blog/rob/hello/', // valid path (with appDir dynamic route catch-all)
18+
]
19+
20+
try {
21+
await res.revalidate(paths[select])
22+
return res.json({ code: 200, message: 'success' })
23+
} catch (err) {
24+
return res.status(500).send({ code: 500, message: err.message })
25+
}
26+
}

demos/default/pages/getStaticProps/with-revalidate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Link from 'next/link'
22

3-
const Show = ({ show }) => (
3+
const Show = ({ show, time }) => (
44
<div>
5-
<p>This page uses getStaticProps() to pre-fetch a TV show.</p>
5+
<p>This page uses getStaticProps() to pre-fetch a TV show at {time}</p>
66

77
<hr />
88

@@ -22,6 +22,7 @@ export async function getStaticProps(context) {
2222
return {
2323
props: {
2424
show: data,
25+
time: new Date().toISOString(),
2526
},
2627
// ODB handler will use the minimum TTL=60s
2728
revalidate: 1,

demos/middleware/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function middleware(req: NextRequest) {
2424
if (pathname.startsWith('/static')) {
2525
// Unlike NextResponse.next(), this actually sends the request to the origin
2626
const res = await request.next()
27-
const message = `This was static but has been transformed in ${req.geo?.city}`
27+
const message = `This was static (& escaping test &amp;) but has been transformed in ${req.geo?.city}`
2828

2929
// Transform the response HTML and props
3030
res.replaceText('p[id=message]', message)

0 commit comments

Comments
 (0)