Skip to content

Commit

Permalink
improvements on e2e testing
Browse files Browse the repository at this point in the history
  • Loading branch information
3FE3LE committed Sep 16, 2023
1 parent 7b83081 commit 5c80111
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 41 deletions.
13 changes: 0 additions & 13 deletions cypress/e2e/home.spec.cy.ts

This file was deleted.

32 changes: 32 additions & 0 deletions cypress/e2e/public-navigation.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe('Public navigation', () => {
it('should navigate to the about page', () => {
// Start from the index page
cy.visit('http://localhost:3000/')

cy.get('nav').should('be.visible')

// The new page should contain an h1 with "Welcome! to PKMdex"
cy.get('h1').contains('Welcome! to PKMdex')

// Find a link with an href attribute containing "sign-in" and click it
cy.get('a[href*="sign-in"]').click()

// The new url should include "/sign-in"
cy.url().should('include', '/sign-in')

// The new page should contain an h1 with "Sign in"
cy.get('h1').contains('Sign in')

// Find a link with an href attribute containing "sign-up" and click it
cy.get('a[href*="sign-up"]').click()

// The new url should include "/sign-up"
cy.url().should('include', '/sign-up')

// The new page should contain an h1 with "Sign up"
cy.get('h1').contains('Sign Up')



})
})
25 changes: 10 additions & 15 deletions cypress/e2e/sign-in.spec.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
describe('Navigation', () => {
describe('Sign in', () => {
it('should navigate to the about page', () => {
// Start from the index page
cy.visit('http://localhost:3000/')

// Find a link with an href attribute containing "sign-in" and click it
cy.get('a[href*="sign-in"]').click()
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 h1 with "Sign in"
cy.get('h1').contains('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"
cy.get('button').contains('Sign in').should('be.visible')

// On button pressed without dirty fields
cy.get('button').click()
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')

// div tag element will be visible whit error validation below of email input
cy.get('div[class="Form__FormError-sc-2ql3du-2"]').contains('Email is required').should('be.visible')
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[class="Form__FormError-sc-2ql3du-2"]').last().contains('Password is required').should('be.visible')
cy.get('div').contains('Password is required').should('be.visible')

cy.get('span').click()

Expand Down
24 changes: 11 additions & 13 deletions cypress/e2e/sign-up.spec.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
describe('Navigation', () => {
it('should navigate to the about page', () => {
// Start from the index page
cy.visit('http://localhost:3000/')

// Find a link with an href attribute containing "sign-up" and click it
cy.get('a[href*="sign-up"]').click()
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 h1 with "Sign up"
cy.get('h1').contains('Sign Up')

// The new page should contain an input field with the name "email"
cy.get('input[name="fullName"]').should('be.visible')

Expand All @@ -22,21 +16,25 @@ describe('Navigation', () => {
cy.get('input[name="password"]').should('be.visible')

// The new page should contain a button with the value "Sign Up"
cy.get('button').contains('Sign Up').should('be.visible')

// On button pressed without dirty fields
cy.get('button').click()
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')

// div tag element will be visible whit error validation below of fullName input
cy.get('div').contains('Full name is required').should('be.visible')

// div tag element will be visible whit error validation below of email input
cy.get('div[class="Form__FormError-sc-2ql3du-2"]').contains('Email is required').should('be.visible')
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[class="Form__FormError-sc-2ql3du-2"]').last().contains('Password is required').should('be.visible')
cy.get('div').contains('Password is required').should('be.visible')

cy.get('span').click()

cy.get('input[type="text"]').should('be.visible')

cy.get('span').click()

cy.get('input[type="password"]').should('be.visible')
Expand Down

0 comments on commit 5c80111

Please sign in to comment.