Skip to content

Commit cc1cc9a

Browse files
committed
test: add more cypress tests
1 parent 0f81eab commit cc1cc9a

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed
+58-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
describe('appDir', () => {
2-
it('renders appdir pages as HTML by default', () => {
2+
it('renders ISR appdir pages as HTML by default', () => {
3+
cy.request('/blog/erica/').then((response) => {
4+
expect(response.headers['content-type']).to.match(/^text\/html/)
5+
})
6+
})
7+
8+
it('renders static appdir pages as HTML by default', () => {
39
cy.request('/blog/erica/first-post/').then((response) => {
410
expect(response.headers['content-type']).to.match(/^text\/html/)
511
})
612
})
713

8-
it('returns RSC data for RSC requests', () => {
14+
it('renders dynamic appdir pages as HTML by default', () => {
15+
cy.request('/blog/erica/random-post/').then((response) => {
16+
expect(response.headers['content-type']).to.match(/^text\/html/)
17+
})
18+
})
19+
20+
it('returns RSC data for RSC requests to ISR pages', () => {
21+
cy.request({
22+
url: '/blog/erica/',
23+
headers: {
24+
RSC: '1',
25+
},
26+
}).then((response) => {
27+
expect(response.headers).to.have.property('content-type', 'application/octet-stream')
28+
})
29+
})
30+
31+
it('returns RSC data for RSC requests to static pages', () => {
932
cy.request({
1033
url: '/blog/erica/first-post/',
1134
headers: {
@@ -15,4 +38,37 @@ describe('appDir', () => {
1538
expect(response.headers).to.have.property('content-type', 'application/octet-stream')
1639
})
1740
})
41+
42+
it('returns RSC data for RSC requests to dynamic pages', () => {
43+
cy.request({
44+
url: '/blog/erica/random-post/',
45+
headers: {
46+
RSC: '1',
47+
},
48+
}).then((response) => {
49+
expect(response.headers).to.have.property('content-type', 'application/octet-stream')
50+
})
51+
})
52+
53+
it('correctly redirects HTML requests for ISR pages', () => {
54+
cy.request('/blog/erica').then((response) => {
55+
expect(response.status).to.be('308')
56+
expect(response.headers).to.have.property('location', '/blog/erica/')
57+
})
58+
})
59+
60+
// This needs trailing slash handling to be fixed
61+
it.skip('correctly redirects HTML requests for static pages', () => {
62+
cy.request('/blog/erica/first-post').then((response) => {
63+
expect(response.status).to.be('308')
64+
expect(response.headers).to.have.property('location', '/blog/erica/first-post/')
65+
})
66+
})
67+
68+
it('correctly redirects HTML requests for dynamic pages', () => {
69+
cy.request('/blog/erica/random-post').then((response) => {
70+
expect(response.status).to.be('308')
71+
expect(response.headers).to.have.property('location', '/blog/erica/random-post/')
72+
})
73+
})
1874
})

0 commit comments

Comments
 (0)