-
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.
add form validations on test e2e correctly
- Loading branch information
Showing
3 changed files
with
71 additions
and
15 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,5 +1,5 @@ | ||
describe('Sign in', () => { | ||
it('should navigate to the about page', () => { | ||
describe('Validate Form', () => { | ||
it('should show form validations', () => { | ||
// Start from the index page | ||
cy.visit('http://localhost:3000/sign-in') | ||
|
||
|
@@ -8,29 +8,53 @@ describe('Sign in', () => { | |
|
||
// The new page should contain an input field with the name "email" | ||
cy.get('input[name="email"]').should('be.visible') | ||
|
||
// The new page should contain an input field with the name "password" | ||
cy.get('input[name="password"]').should('be.visible') | ||
// The new page should contain a button with the value "Sign in" | ||
|
||
// The new page should contain a button with the value "Sign In" | ||
// On button pressed without dirty fields | ||
cy.get('button').contains('Sign in').should('be.visible').click() | ||
|
||
// The email input will be focused waiting to type a email | ||
cy.get('input[name="email"]').should('be.focused') | ||
cy.get('input[name="email"]').should('be.focus') | ||
|
||
// div tag element will be visible whit error validation below of email input | ||
cy.get('div').contains('Email is required').should('be.visible') | ||
|
||
// div tag element will be visible whit error validation below of password input | ||
cy.get('div').contains('Password is required').should('be.visible') | ||
|
||
cy.get('input[name=password]').focus().type('hire_me') | ||
|
||
cy.get('span').click() | ||
|
||
cy.get('input[type="text"]').should('be.visible') | ||
|
||
cy.get('span').click() | ||
|
||
cy.get('input[type="password"]').should('be.visible') | ||
}) | ||
}) | ||
describe('Sign in', () => { | ||
it('should sign in the app correctly', () => { | ||
// Start from the index page | ||
cy.visit('http://localhost:3000/sign-in') | ||
|
||
// The new url should include "/sign-in" | ||
cy.url().should('include', '/sign-in') | ||
|
||
// The new page should contain an input field with the name "email" | ||
cy.get('input[name="email"]').should('be.visible').focus().type('[email protected]') | ||
|
||
// The new page should contain an input field with the name "password" | ||
cy.get('input[name="password"]').should('be.visible').focus().type('12345678') | ||
|
||
// The new page should contain a button with the value "Sign in" | ||
// On button pressed without dirty fields | ||
cy.get('button').contains('Sign in').should('be.visible').click() | ||
|
||
// The new url should include "/dashboard" | ||
cy.url().should('include', '/dashboard') | ||
}) | ||
}) |
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,5 +1,5 @@ | ||
describe('Navigation', () => { | ||
it('should navigate to the about page', () => { | ||
describe('Validate Form', () => { | ||
it('should show form validations', () => { | ||
// Start from the index page | ||
cy.visit('http://localhost:3000/sign-up') | ||
|
||
|
@@ -18,9 +18,9 @@ describe('Navigation', () => { | |
// The new page should contain a button with the value "Sign Up" | ||
// On button pressed without dirty fields | ||
cy.get('button').contains('Sign Up').should('be.visible').click() | ||
|
||
// The email input will be focused waiting to type a email | ||
cy.get('input[name="fullName"]').should('be.focused') | ||
cy.get('input[name="fullName"]').should('be.focus') | ||
|
||
// div tag element will be visible whit error validation below of fullName input | ||
cy.get('div').contains('Full name is required').should('be.visible') | ||
|
@@ -31,6 +31,8 @@ describe('Navigation', () => { | |
// div tag element will be visible whit error validation below of password input | ||
cy.get('div').contains('Password is required').should('be.visible') | ||
|
||
cy.get('input[name=password]').focus().type('hire_me') | ||
|
||
cy.get('span').click() | ||
|
||
cy.get('input[type="text"]').should('be.visible') | ||
|
@@ -40,3 +42,31 @@ describe('Navigation', () => { | |
cy.get('input[type="password"]').should('be.visible') | ||
}) | ||
}) | ||
describe('Sign up exist user', () => { | ||
it('should try sign up whit exist user', () => { | ||
// Start from the index page | ||
cy.visit('http://localhost:3000/sign-up') | ||
|
||
// The new url should include "/sign-up" | ||
cy.url().should('include', '/sign-up') | ||
|
||
// The new page should contain an input field with the name "full name" | ||
cy.get('input[name="fullName"]').should('be.visible').focus().type('3FE 3LE') | ||
|
||
// The new page should contain an input field with the name "email" | ||
cy.get('input[name="email"]').should('be.visible').focus().type('[email protected]') | ||
|
||
// The new page should contain an input field with the name "password" | ||
cy.get('input[name="password"]').should('be.visible').focus().type('12345678') | ||
|
||
// The new page should contain a button with the value "Sign Up" | ||
cy.get('button').contains('Sign Up').should('be.visible').click() | ||
|
||
// div tag element will be visible whit error validation below of fullName input | ||
cy.get('div').contains('Email already exist').should('be.visible') | ||
|
||
// The new url should include "/sign-up" | ||
cy.url().should('include', '/sign-up') | ||
|
||
}) | ||
}) |
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