-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refresh-endpoint): Add e2e integration tests
- Loading branch information
Daniel Aparicio
committed
Jun 9, 2020
1 parent
f812e49
commit bb4370c
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
e2e-tests/development-runtime/cypress/integration/functionality/refresh-endpoint.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
describe(`When the refresh endpoint is hit`, () => { | ||
afterEach(() => { | ||
waitUntilRefreshFinishes() | ||
}) | ||
|
||
describe(`and accessing any page while refreshing`, () => { | ||
it(`the page shown should be restarting page for 404 page`, () => { | ||
cy.request(`/non-existing`).then(response => { | ||
expect(response.body).not.to.include(`<title>Restarting...</title>`) | ||
}) | ||
cy.request(`POST`, `/__refresh`) | ||
cy.request(`/non-existing`).then(response => { | ||
expect(response.body).to.include(`<title>Restarting...</title>`) | ||
}) | ||
}) | ||
|
||
it(`the page shown should be restarting page for existing pages`, () => { | ||
cy.request(`/page-2/`).then(response => { | ||
expect(response.body).not.to.include(`<title>Restarting...</title>`) | ||
}) | ||
cy.request(`POST`, `/__refresh`) | ||
cy.request(`/page-2/`).then(response => { | ||
expect(response.body).to.include(`<title>Restarting...</title>`) | ||
}) | ||
}) | ||
}) | ||
|
||
describe(`and it was not already refreshing`, () => { | ||
it(`should return empty body`, () => { | ||
cy.request(`POST`, `/__refresh`).then(response => { | ||
expect(response.body).to.be.equal(``) | ||
}) | ||
}) | ||
}) | ||
describe(`and it was already refreshing`, () => { | ||
it(`should put new requests with unique body in a queue`, () => { | ||
cy.request(`POST`, `/__refresh`).then(response => { | ||
expect(response.body).to.be.equal(``) | ||
}) | ||
cy.request(`POST`, `/__refresh`).then(response => { | ||
expect(response.body).to.include(`queued`) | ||
}) | ||
cy.request(`POST`, `/__refresh`).then(response => { | ||
expect(response.body).to.include(`already queued`) | ||
}) | ||
cy.request(`POST`, `/__refresh`, `otherBody`).then(response => { | ||
expect(response.body).to.include(`queued`) | ||
}) | ||
cy.request(`POST`, `/__refresh`, `otherBody`).then(response => { | ||
expect(response.body).to.include(`already queued`) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
function waitUntilRefreshFinishes() { | ||
cy.waitUntil( | ||
() => | ||
cy | ||
.request(`/`) | ||
.then( | ||
response => !response.body.includes(`<title>Restarting...</title>`) | ||
), | ||
{ | ||
timeout: 60000, | ||
interval: 2000, | ||
} | ||
) | ||
|
||
cy.request(`/`).then(response => { | ||
expect(response.body).not.to.include(`<title>Restarting...</title>`) | ||
}) | ||
} |
This file contains 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 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