-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#35] Extract data to constant for cypress
- Loading branch information
Showing
3 changed files
with
296 additions
and
393 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { api } from '../../support/constants'; | ||
|
||
const signInScreenTestIds = { | ||
nimbleLogo: 'sign-in__nimble-logo', | ||
signInForm: 'sign-in-form', | ||
|
@@ -12,23 +14,25 @@ const signInScreenTestIds = { | |
}; | ||
|
||
describe('SignIn screen', () => { | ||
context('given the valid form submission', () => { | ||
context('given a valid form submission', () => { | ||
beforeEach(() => { | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys*', 200, { | ||
statusCode: 200, | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys*', api.delay.short, { | ||
statusCode: api.status.success, | ||
fixture: 'Survey/List/valid.json', | ||
}); | ||
cy.interceptWithDelay('GET', '**/api/v1/me', 200, { | ||
statusCode: 200, | ||
|
||
cy.interceptWithDelay('GET', '**/api/v1/me', api.delay.short, { | ||
statusCode: api.status.success, | ||
fixture: 'User/valid.json', | ||
}); | ||
}); | ||
|
||
it('shows the loading dialog and navigates to Dashboard screen', () => { | ||
cy.interceptWithDelay('POST', '**/api/v1/oauth/token', 200, { | ||
statusCode: 200, | ||
cy.interceptWithDelay('POST', '**/api/v1/oauth/token', api.delay.short, { | ||
statusCode: api.status.success, | ||
fixture: 'Authentication/SignIn/valid.json', | ||
}); | ||
|
||
cy.visit('/'); | ||
cy.location().should((location) => { | ||
expect(location.pathname).to.equal('/sign-in'); | ||
|
@@ -48,10 +52,11 @@ describe('SignIn screen', () => { | |
|
||
context('given the invalid form submission', () => { | ||
it('shows the error dialog', () => { | ||
cy.interceptWithDelay('POST', '**/api/v1/oauth/token', 200, { | ||
statusCode: 400, | ||
cy.interceptWithDelay('POST', '**/api/v1/oauth/token', api.delay.short, { | ||
statusCode: api.status.badRequest, | ||
fixture: 'Authentication/SignIn/invalid.json', | ||
}); | ||
|
||
cy.visit('/'); | ||
cy.findByTestId(signInScreenTestIds.emailField).type('[email protected]'); | ||
cy.findByTestId(signInScreenTestIds.passwordField).type('12345678'); | ||
|
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,6 @@ | ||
export const api = { | ||
status: { success: 200, badRequest: 400 }, | ||
delay: { | ||
short: 200, | ||
}, | ||
}; |
Oops, something went wrong.