-
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.
Merge pull request #163 from Geoportail-Luxembourg/GSLUX-748-auth-plu…
…g-api GSLUX-748: Auth plug api
- Loading branch information
Showing
17 changed files
with
3,865 additions
and
2,296 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,13 @@ describe('Authentification', () => { | |
}) | ||
|
||
describe('When user arrives on the page', () => { | ||
it('the authentification icon is located in the header', () => { | ||
it('the authentication icon is located in the header', () => { | ||
cy.get('header [data-cy="authFormIcon"]').should('exist') | ||
}) | ||
}) | ||
|
||
describe('When user clicks on the auth icon in the header', () => { | ||
it('displays the authentification form correctly', () => { | ||
it('displays the authentication form correctly', () => { | ||
cy.get('header [data-cy="authFormIcon"]').click() | ||
cy.get('header [data-cy="authForm"]').should('exist') | ||
cy.get('header [data-cy="authForm"] form input[name="userName"]').should( | ||
|
@@ -28,12 +28,107 @@ describe('Authentification', () => { | |
}) | ||
|
||
describe('When user clicks again', () => { | ||
it('hides the authentification form', () => { | ||
it('hides the authentication form', () => { | ||
cy.get('header [data-cy="authFormIcon"]').click() | ||
cy.get('header [data-cy="authForm"]').should('exist') | ||
cy.get('header [data-cy="authFormIcon"]').click() | ||
cy.get('header [data-cy="authForm"]').should('not.be.visible') | ||
}) | ||
}) | ||
|
||
describe('When user is authenticating with success', () => { | ||
beforeEach(() => { | ||
cy.intercept('POST', '/login', { | ||
statusCode: 200, | ||
body: { | ||
login: 'MyLogin', | ||
mail: '[email protected]', | ||
}, | ||
}) | ||
cy.get('header [data-cy="authFormIcon"]').click() | ||
cy.get('[data-cy="authForm"] input[name="userName"]').type('MyLogin') | ||
cy.get('[data-cy="authForm"] input[name="userPassword"]').type( | ||
'Rand87321mdp' | ||
) | ||
cy.get('[data-cy="authForm"] input[type="submit"]').click() | ||
}) | ||
|
||
it('authenticates the user, hides the form and display the success notification msg', () => { | ||
cy.get('[data-cy="authForm"]').should('not.be.visible') | ||
cy.get('[data-cy="notification"]').should( | ||
'have.text', | ||
'Vous êtes maintenant correctement connecté.' | ||
) | ||
}) | ||
|
||
it('displays the user login and mail', () => { | ||
cy.get('header [data-cy="authFormIcon"]').click() | ||
cy.get('[data-cy="authForm"]').should('contain.text', 'MyLogin') | ||
cy.get('[data-cy="authForm"]').should( | ||
'contain.text', | ||
'[email protected]' | ||
) | ||
}) | ||
}) | ||
|
||
describe('When user is logging out', () => { | ||
beforeEach(() => { | ||
cy.intercept('POST', '/login', { | ||
statusCode: 200, | ||
body: { | ||
login: 'MyLogin', | ||
mail: '[email protected]', | ||
}, | ||
}) | ||
cy.intercept('GET', '/logout', { | ||
statusCode: 200, | ||
body: {}, | ||
}) | ||
cy.get('[data-cy="authFormIcon"]').click() | ||
cy.get('[data-cy="authForm"] input[name="userName"]').type('MyLogin') | ||
cy.get('[data-cy="authForm"] input[name="userPassword"]').type( | ||
'Rand87321mdp' | ||
) | ||
cy.get('[data-cy="authForm"] input[type="submit"]').click() | ||
}) | ||
|
||
it('logs out the user and display back the login form', () => { | ||
cy.get('[data-cy="authFormIcon"]').click() | ||
cy.get('[data-cy="authForm"] button').click() | ||
cy.get('[data-cy="authForm"]').should('be.visible') | ||
cy.get('[data-cy="authForm"] input[name="userName"]').should( | ||
'be.visible' | ||
) | ||
cy.get('[data-cy="authForm"] input[name="userPassword"]').should( | ||
'be.visible' | ||
) | ||
}) | ||
}) | ||
|
||
describe('When user tries to authenticate with failure', () => { | ||
beforeEach(() => { | ||
cy.intercept('POST', '/login', { | ||
statusCode: 401, | ||
body: {}, | ||
}) | ||
cy.get('header [data-cy="authFormIcon"]').click() | ||
cy.get('[data-cy="authForm"] input[name="userName"]').type( | ||
'incorrectLogin' | ||
) | ||
cy.get('[data-cy="authForm"] input[name="userPassword"]').type( | ||
'Rand87321mdp' | ||
) | ||
cy.get('[data-cy="authForm"] input[type="submit"]').click() | ||
}) | ||
|
||
it('does not close the form and displays a warning msg', () => { | ||
cy.get('[data-cy="notification"]').should('be.visible') | ||
cy.get('[data-cy="notification"]').should( | ||
'contain.text', | ||
'utilisateur ou mot de passe non valides' | ||
) | ||
cy.get('[data-cy="authForm"]').should('be.visible') | ||
}) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.