-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathenhanced.spec.ts
39 lines (35 loc) · 1.69 KB
/
enhanced.spec.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
describe('Enhanced middleware', () => {
it('rewrites the response body', () => {
cy.visit('/static')
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
cy.contains("This is an ad that isn't shown by default")
})
it('modifies the page props', () => {
cy.request('/_next/data/build-id/en/static.json').then((response) => {
expect(response.body).to.have.nested.property('pageProps.showAd', true)
expect(response.body)
.to.have.nested.property('pageProps.message')
.that.includes('This was static (& escaping test &) but has been transformed in')
})
})
it('adds geo data', () => {
cy.request('/api/geo').then((response) => {
expect(response.body).to.have.nested.property('headers.x-geo-country')
expect(response.body).to.have.nested.property('headers.x-geo-region')
expect(response.body).to.have.nested.property('headers.x-geo-city')
expect(response.body).to.have.nested.property('headers.x-geo-longitude')
expect(response.body).to.have.nested.property('headers.x-geo-latitude')
expect(response.body).to.have.nested.property('headers.x-geo-timezone')
})
})
it('handles uppercase i18n redirects properly ', () => {
cy.visit('/de-DE/static')
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
cy.contains("This is an ad that isn't shown by default")
})
it('handles lowercase i18n redirects properly ', () => {
cy.visit('/de-de/static')
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
cy.contains("This is an ad that isn't shown by default")
})
})