This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cypress testing for validation
- Loading branch information
Showing
14 changed files
with
173 additions
and
15,026 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 |
---|---|---|
|
@@ -31,3 +31,6 @@ cypress/videos | |
|
||
# jetbrains | ||
.idea | ||
|
||
#yarn lock | ||
yarn.lock |
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,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:3001" | ||
} |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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,15 @@ | ||
import { EMAIL_SIGN_IN_FIELD_ID } from '../../src/config/selectors'; | ||
import { SIGN_IN_PATH } from '../../src/config/paths'; | ||
import { checkErrorTextField, fillSignInLayout, submitSignIn } from './util'; | ||
|
||
describe('Name and Email Validation', () => { | ||
it('Sign In', () => { | ||
cy.visit(SIGN_IN_PATH); | ||
fillSignInLayout('ekfekfekf'); | ||
submitSignIn(); | ||
checkErrorTextField(EMAIL_SIGN_IN_FIELD_ID, true); | ||
fillSignInLayout('[email protected]'); | ||
checkErrorTextField(EMAIL_SIGN_IN_FIELD_ID, false); | ||
submitSignIn(); | ||
}); | ||
}); |
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,26 @@ | ||
import { | ||
EMAIL_SIGN_IN_FIELD_ID, | ||
EMAIL_SIGN_UP_FIELD_ID, | ||
NAME_SIGN_UP_FIELD_ID, | ||
} from '../../src/config/selectors'; | ||
import { SIGN_UP_PATH } from '../../src/config/paths'; | ||
import { | ||
checkErrorTextField, | ||
fillSignInLayout, | ||
fillSignUpLayout, | ||
submitSignIn, | ||
submitSignUp, | ||
} from './util'; | ||
|
||
describe('Name and Email Validation', () => { | ||
it('Sign In', () => { | ||
cy.visit(SIGN_UP_PATH); | ||
fillSignUpLayout({ name: 'e', email: 'jasjasjd' }); | ||
submitSignUp(); | ||
checkErrorTextField(EMAIL_SIGN_UP_FIELD_ID, true); | ||
checkErrorTextField(NAME_SIGN_UP_FIELD_ID, true); | ||
fillSignUpLayout({ name: 'graasp', email: '[email protected]' }); | ||
checkErrorTextField(EMAIL_SIGN_UP_FIELD_ID, false); | ||
checkErrorTextField(NAME_SIGN_UP_FIELD_ID, false); | ||
}); | ||
}); |
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,28 @@ | ||
import { | ||
EMAIL_SIGN_IN_FIELD_ID, | ||
EMAIL_SIGN_UP_FIELD_ID, | ||
NAME_SIGN_UP_FIELD_ID, | ||
SIGN_IN_BUTTON_ID, | ||
SIGN_UP_BUTTON_ID, | ||
} from '../../src/config/selectors'; | ||
|
||
export const fillSignUpLayout = ({ name, email }) => { | ||
cy.get(`#${NAME_SIGN_UP_FIELD_ID}`).clear().type(name); | ||
cy.get(`#${EMAIL_SIGN_UP_FIELD_ID}`).clear().type(email); | ||
}; | ||
|
||
export const fillSignInLayout = (email) => { | ||
cy.get(`#${EMAIL_SIGN_IN_FIELD_ID}`).clear().type(email); | ||
}; | ||
|
||
export const submitSignIn = () => { | ||
cy.get(`#${SIGN_IN_BUTTON_ID}`).click(); | ||
}; | ||
|
||
export const submitSignUp = () => { | ||
cy.get(`#${SIGN_UP_BUTTON_ID}`).click(); | ||
}; | ||
export const checkErrorTextField = (id, flag) => { | ||
const existence = flag ? 'exist' : 'not.exist'; | ||
cy.get(`#${id}-helper-text`).should(existence); | ||
}; |
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,21 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
}; |
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,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
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,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands'; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const NAME_SIGN_UP_FIELD_ID = 'nameSignUpFieldId'; | ||
export const EMAIL_SIGN_UP_FIELD_ID = 'emailSignUpFieldId'; | ||
export const EMAIL_SIGN_IN_FIELD_ID = 'emailSignInFieldId'; | ||
export const SIGN_IN_BUTTON_ID = 'signInButtonId'; | ||
export const SIGN_UP_BUTTON_ID = 'signUpButtonId'; |
Oops, something went wrong.