-
Notifications
You must be signed in to change notification settings - Fork 86
chore: standardise ODB terminology #1641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2546f2c
chore: make odb terminology consistent
orinokai 941a34e
test: update tests with new odb headers
orinokai 777e76a
chore: add note about minimum ODB TTL
orinokai 6fe8e0f
fix: revert revalidate to 1 for test purposes
orinokai d09f656
test: updates tests with new header key
orinokai 841c46a
Merge branch 'main' into rs/odb-terminology
orinokai 4b3ce7f
test: fix dynamic route tests to use debug headers
orinokai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,127 +1,149 @@ | ||
/* eslint-disable max-lines-per-function */ | ||
describe('Static Routing', () => { | ||
it('renders correct page via SSR on a static route', () => { | ||
cy.request('/getServerSideProps/static/').then((res) => { | ||
cy.request({ url: '/getServerSideProps/static/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'ssr') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'ssr') | ||
expect(res.body).to.contain('Sleepy Hollow') | ||
}) | ||
}) | ||
it('serves correct static file on a static route', () => { | ||
cy.request('/getStaticProps/static/').then((res) => { | ||
cy.request({ url: '/getStaticProps/static/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.headers).to.not.have.property('x-nf-render-mode') | ||
expect(res.body).to.contain('Dancing with the Stars') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a static route', () => { | ||
cy.request('/getStaticProps/with-revalidate/').then((res) => { | ||
cy.request({ url: '/getStaticProps/with-revalidate/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb ttl=1') | ||
expect(res.body).to.contain('Dancing with the Stars') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Dynamic Routing', () => { | ||
it('renders correct page via SSR on a dynamic route', () => { | ||
cy.request('/getServerSideProps/1/').then((res) => { | ||
cy.request({ url: '/getServerSideProps/1/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'ssr') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'ssr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders correct page via SSR on a dynamic catch-all route', () => { | ||
cy.request('/getServerSideProps/all/1/').then((res) => { | ||
cy.request({ url: '/getServerSideProps/all/1/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'ssr') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'ssr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('serves correct static file on a prerendered dynamic route with fallback: false', () => { | ||
cy.request('/getStaticProps/1/').then((res) => { | ||
cy.request({ url: '/getStaticProps/1/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.headers).to.not.have.property('x-nf-render-mode') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders custom 404 on a non-prerendered dynamic route with fallback: false', () => { | ||
cy.request({ url: '/getStaticProps/3/', failOnStatusCode: false }).then((res) => { | ||
expect(res.status).to.eq(404) | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
expect(res.body).to.contain('Custom 404') | ||
}) | ||
cy.request({ url: '/getStaticProps/3/', headers: { 'x-nf-debug-logging': '1' }, failOnStatusCode: false }).then( | ||
(res) => { | ||
expect(res.status).to.eq(404) | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb') | ||
expect(res.body).to.contain('Custom 404') | ||
}, | ||
) | ||
}) | ||
it('serves correct static file on a prerendered dynamic route with fallback: true', () => { | ||
cy.request('/getStaticProps/withFallback/1/').then((res) => { | ||
cy.request({ url: '/getStaticProps/withFallback/1/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.headers).to.not.have.property('x-nf-render-mode') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders fallback page via ODB on a non-prerendered dynamic route with fallback: true', () => { | ||
cy.request('/getStaticProps/withFallback/3/').then((res) => { | ||
cy.request({ url: '/getStaticProps/withFallback/3/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
// expect 'odb' until https://github.com/netlify/pillar-runtime/issues/438 is fixed | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb') | ||
// expect 'Bitten' until the above is fixed and we can test for fallback 'Loading...' message | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
}) | ||
it('serves correct static file on a prerendered dynamic route with fallback: blocking', () => { | ||
cy.request('/getStaticProps/withFallbackBlocking/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
cy.request({ url: '/getStaticProps/withFallbackBlocking/1/', headers: { 'x-nf-debug-logging': '1' } }).then( | ||
(res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-nf-render-mode') | ||
expect(res.body).to.contain('Under the Dome') | ||
}, | ||
) | ||
}) | ||
it('renders correct page via ODB on a non-prerendered dynamic route with fallback: blocking', () => { | ||
cy.request('/getStaticProps/withFallbackBlocking/3/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
cy.request({ url: '/getStaticProps/withFallbackBlocking/3/', headers: { 'x-nf-debug-logging': '1' } }).then( | ||
(res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb') | ||
expect(res.body).to.contain('Bitten') | ||
}, | ||
) | ||
}) | ||
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: false', () => { | ||
cy.request('/getStaticProps/withRevalidate/1/').then((res) => { | ||
cy.request({ url: '/getStaticProps/withRevalidate/1/', headers: { 'x-nf-debug-logging': '1' } }).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb ttl=60') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders custom 404 on a non-prerendered dynamic route with revalidate and fallback: false', () => { | ||
cy.request({ url: '/getStaticProps/withRevalidate/3/', failOnStatusCode: false }).then((res) => { | ||
cy.request({ | ||
url: '/getStaticProps/withRevalidate/3/', | ||
headers: { 'x-nf-debug-logging': '1' }, | ||
failOnStatusCode: false, | ||
}).then((res) => { | ||
expect(res.status).to.eq(404) | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb') | ||
expect(res.body).to.contain('Custom 404') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: true', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallback/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
cy.request({ url: '/getStaticProps/withRevalidate/withFallback/1/', headers: { 'x-nf-debug-logging': '1' } }).then( | ||
(res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb ttl=60') | ||
expect(res.body).to.contain('Under the Dome') | ||
}, | ||
) | ||
}) | ||
it('renders fallback page via ODB on a non-prerendered dynamic route with revalidate and fallback: true', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallback/3/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
// expect 'Bitten' until https://github.com/netlify/pillar-runtime/issues/438 is fixed | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
cy.request({ url: '/getStaticProps/withRevalidate/withFallback/3/', headers: { 'x-nf-debug-logging': '1' } }).then( | ||
(res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb ttl=60') | ||
// expect 'Bitten' until https://github.com/netlify/pillar-runtime/issues/438 is fixed | ||
expect(res.body).to.contain('Bitten') | ||
}, | ||
) | ||
}) | ||
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: blocking', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallbackBlocking/1/').then((res) => { | ||
cy.request({ | ||
url: '/getStaticProps/withRevalidate/withFallbackBlocking/1/', | ||
headers: { 'x-nf-debug-logging': '1' }, | ||
}).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb ttl=60') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a non-prerendered dynamic route with revalidate and fallback: blocking', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallbackBlocking/3/').then((res) => { | ||
cy.request({ | ||
url: '/getStaticProps/withRevalidate/withFallbackBlocking/3/', | ||
headers: { 'x-nf-debug-logging': '1' }, | ||
}).then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.headers).to.have.property('x-nf-render-mode', 'odb ttl=60') | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
}) | ||
}) | ||
/* eslint-enable max-lines-per-function */ |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this console.log added for debugging purposes and accidentally added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks but nope - this is by design so that the ODB request is logged in the function logs