-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathappdir.cy.ts
98 lines (88 loc) · 3.14 KB
/
appdir.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
describe('appDir', () => {
it('renders ISR appdir pages as HTML by default', () => {
cy.request({ url: '/blog/erica/', followRedirect: false }).then((response) => {
expect(response.headers['content-type']).to.match(/^text\/html/)
})
})
it('renders static appdir pages as HTML by default', () => {
cy.request({ url: '/blog/erica/first-post/', followRedirect: false }).then((response) => {
expect(response.headers['content-type']).to.match(/^text\/html/)
})
})
it('renders dynamic appdir pages as HTML by default', () => {
cy.request({ url: '/blog/erica/random-post/', followRedirect: false }).then((response) => {
expect(response.headers['content-type']).to.match(/^text\/html/)
})
})
it('returns RSC data for RSC requests to ISR pages', () => {
cy.request({
url: '/blog/erica/',
headers: {
RSC: '1',
},
followRedirect: false,
}).then((response) => {
expect(response.headers).to.have.property('content-type', 'text/x-component')
})
})
it.skip('returns a vary header for RSC data requests to ISR pages', () => {
cy.request({
url: '/blog/erica/',
followRedirect: false,
headers: {
RSC: '1',
},
}).then((response) => {
expect(response.headers).to.have.property('vary').contains('RSC')
})
})
it.skip('returns a vary header for non-RSC data requests to ISR pages', () => {
cy.request({
url: '/blog/erica/',
followRedirect: false,
}).then((response) => {
expect(response.headers).to.have.property('vary').contains('RSC')
})
})
it('returns RSC data for RSC requests to static pages', () => {
cy.request({
url: '/blog/erica/first-post/',
headers: {
RSC: '1',
},
followRedirect: false,
}).then((response) => {
expect(response.headers).to.have.property('content-type', 'text/x-component')
})
})
it('returns RSC data for RSC requests to dynamic pages', () => {
cy.request({
url: '/blog/erica/random-post/',
headers: {
RSC: '1',
},
followRedirect: false,
}).then((response) => {
expect(response.headers).to.have.property('content-type', 'text/x-component')
})
})
it('correctly redirects HTML requests for ISR pages', () => {
cy.request({ url: '/blog/erica', followRedirect: false }).then((response) => {
expect(response.status).to.equal(308)
expect(response.headers).to.have.property('location', '/blog/erica/')
})
})
// This needs trailing slash handling to be fixed
it.skip('correctly redirects HTML requests for static pages', () => {
cy.request({ url: '/blog/erica/first-post', followRedirect: false }).then((response) => {
expect(response.status).to.equal(308)
expect(response.headers).to.have.property('location', '/blog/erica/first-post/')
})
})
it('correctly redirects HTML requests for dynamic pages', () => {
cy.request({ url: '/blog/erica/random-post', followRedirect: false }).then((response) => {
expect(response.status).to.equal(308)
expect(response.headers).to.have.property('location', '/blog/erica/random-post/')
})
})
})