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.
Merge pull request #4 from graasp/3/inputValidatin
Input Validation
- Loading branch information
Showing
18 changed files
with
283 additions
and
14,987 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,25 @@ | ||
export const MEMBERS = { | ||
GRAASP: { | ||
id: 'graasp-id', | ||
name: 'graasp', | ||
email: 'graasp@graasp.org', | ||
nameValid: true, | ||
emailValid: true, | ||
}, | ||
WRONG_NAME: { | ||
id: 'id1', | ||
name: 'w', | ||
email: 'graasp@graasp.org', | ||
nameValid: false, | ||
emailValid: true, | ||
}, | ||
WRONG_EMAIL: { | ||
id: 'id2', | ||
name: 'graasp', | ||
email: 'wrong', | ||
nameValid: true, | ||
emailValid: false, | ||
}, | ||
}; | ||
|
||
export default MEMBERS; |
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 @@ | ||
import { SIGN_IN_PATH } from '../../src/config/paths'; | ||
import { MEMBERS } from '../fixtures/members'; | ||
|
||
describe('Name and Email Validation', () => { | ||
it('Sign In', () => { | ||
const { GRAASP, WRONG_EMAIL } = MEMBERS; | ||
cy.visit(SIGN_IN_PATH); | ||
// Signing in with a wrong email format | ||
cy.signInAndCheck(WRONG_EMAIL); | ||
// Siging in with a valid email | ||
cy.signInAndCheck(GRAASP); | ||
}); | ||
}); |
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 { SIGN_UP_PATH } from '../../src/config/paths'; | ||
import { MEMBERS } from '../fixtures/members'; | ||
|
||
describe('Name and Email Validation', () => { | ||
it('Sign Up', () => { | ||
const { GRAASP, WRONG_NAME, WRONG_EMAIL } = MEMBERS; | ||
cy.visit(SIGN_UP_PATH); | ||
// Signing up with a wrong name and right email | ||
cy.signUpAndCheck(WRONG_NAME); | ||
// Signing up with a wrong email and right name | ||
cy.signUpAndCheck(WRONG_EMAIL); | ||
// Signing up with right email and name | ||
cy.signUpAndCheck(GRAASP); | ||
}); | ||
}); |
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,24 @@ | ||
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(); | ||
}; |
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` 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,42 @@ | ||
// *********************************************** | ||
// 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 -- | ||
import { | ||
EMAIL_SIGN_UP_FIELD_ID, | ||
NAME_SIGN_UP_FIELD_ID, | ||
} from '../../src/config/selectors'; | ||
|
||
const { | ||
submitSignIn, | ||
fillSignUpLayout, | ||
fillSignInLayout, | ||
submitSignUp, | ||
} = require('../integration/util'); | ||
|
||
Cypress.Commands.add('checkErrorTextField', (id, flag) => { | ||
const existence = flag ? 'not.exist' : 'exist'; | ||
cy.get(`#${id}-helper-text`).should(existence); | ||
}); | ||
|
||
Cypress.Commands.add('signUpAndCheck', (user) => { | ||
fillSignUpLayout(user); | ||
submitSignUp(); | ||
|
||
cy.checkErrorTextField(NAME_SIGN_UP_FIELD_ID, user.nameValid); | ||
cy.checkErrorTextField(EMAIL_SIGN_UP_FIELD_ID, user.emailValid); | ||
}); | ||
|
||
Cypress.Commands.add('signInAndCheck', (user) => { | ||
fillSignInLayout(user); | ||
submitSignIn(); | ||
cy.checkErrorTextField(EMAIL_SIGN_UP_FIELD_ID, user.email); | ||
}); |
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
Oops, something went wrong.