generated from nimblehq/git-template
-
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.
- Loading branch information
1 parent
ba6f301
commit 8d9c7e7
Showing
7 changed files
with
93 additions
and
14 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,4 +1,4 @@ | ||
REACT_APP_DEFAULT_LANGUAGE=en | ||
REACT_APP_API_ENDPOINT= | ||
REACT_APP_API_CLIENT_ID= | ||
REACT_APP_API_CLIENT_SECRET= | ||
REACT_APP_API_CLIENT_SECRET= |
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 @@ | ||
{ "errors": [{ "detail": "Your email or password is incorrect. Please try again.", "code": "invalid_email_or_password" }] } |
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,13 @@ | ||
{ | ||
"data": { | ||
"id": "18422", | ||
"type": "token", | ||
"attributes": { | ||
"access_token": "3XwBqiXrM-xhHCc-0QCKsOuE0Xp9AYdYTiZwTSqo4M4", | ||
"token_type": "Bearer", | ||
"expires_in": 7200, | ||
"refresh_token": "QOiwCsTV7Wn4mO56Kz-4rj8nGCWfVMcIwSbKo4yicEk", | ||
"created_at": 1677124678 | ||
} | ||
} | ||
} |
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,68 @@ | ||
describe('User Authentication', () => { | ||
context('upon navigation to /login', () => { | ||
it('displays login page', () => { | ||
cy.visit('/login'); | ||
|
||
cy.findByTestId('login-header').should('be.visible'); | ||
}); | ||
}); | ||
|
||
context('given valid credentials', () => { | ||
it('redirects to the home page', () => { | ||
cy.intercept('POST', '/oauth/token/', { | ||
statusCode: 200, | ||
fixture: 'Authentication/valid-credentials.json', | ||
}); | ||
|
||
cy.visit('/login'); | ||
|
||
cy.get('input[name=email]').type('[email protected]'); | ||
cy.get('input[name=password]').type('12345678'); | ||
cy.get('button[type="submit"]').click(); | ||
|
||
cy.location().should((location) => { | ||
expect(location.pathname).to.eq('/'); | ||
}); | ||
}); | ||
}); | ||
|
||
context('given NO credentials entered', () => { | ||
it('shows field validation errors', () => { | ||
cy.visit('/login'); | ||
|
||
cy.get('button[type="submit"]').click(); | ||
|
||
cy.get('.errors').should('be.visible'); | ||
|
||
cy.get('.errors').within(() => { | ||
cy.contains('Email has invalid format'); | ||
cy.contains('Password should be at least'); | ||
}); | ||
}); | ||
}); | ||
|
||
context('given INVALID credentials', () => { | ||
it('shows login error', () => { | ||
cy.intercept('POST', '/oauth/token/', { | ||
statusCode: 400, | ||
fixture: 'Authentication/invalid-credentials.json', | ||
}); | ||
|
||
cy.visit('/login'); | ||
|
||
cy.get('input[name=email]').type('[email protected]'); | ||
cy.get('input[name=password]').type('password123'); | ||
cy.get('button[type="submit"]').click(); | ||
|
||
cy.location().should((location) => { | ||
expect(location.pathname).to.eq('/login'); | ||
}); | ||
|
||
cy.get('.errors').should('be.visible'); | ||
|
||
cy.get('.errors').within(() => { | ||
cy.findByText('Your email or password is incorrect. Please try again.').should('exist'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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