Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

videos/
screenshots/
10 changes: 10 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: 'https://qastage.buildbox.one/18/cadastro/'
},
});
137 changes: 137 additions & 0 deletions cypress/e2e/cadastro.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/// <reference types="cypress"/>
import { generate } from 'gerador-validador-cpf'

describe('Validação da função de cadastro', () => {

beforeEach(()=>{
cy.visit('/')
cy.get('[data-cy="button-btn-enroll"]').click()
})

it('Deve realizar o cadastro com sucesso', () => {
//let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
//cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'teste')
//cy.cadastroEndereco()
cy.cadastroCompleto()
cy.get('.text-lime-500').should('contain', 'Thank you for')
})

it('Deve mostrar mensagem de erro ao tentar cadastrar com email inválido', () => {
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000','email', 'senha')
cy.get(':nth-child(1) > .form-container > .input-error').should('contain', 'Email inválido')
})

it('Deve mostrar mensagem de erro ao tentar cadastrar com email já cadastrado', () => {
cy.cadastroCompleto().then(()=>{
cy.wait(3000)
let email = Cypress.env('generatedEmail')
cy.visit('/')
cy.get('[data-cy="button-btn-enroll"]').click()
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha')
cy.get('.input-error').should('contain', 'Este email já está em uso')
})
})

it('Deve mostrar mensagem de erro se o email no campo de confirmação estiver diferente', () => {
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
cy.get('[data-cy="input-signup-personal-data-email"]').type(email)
cy.get('[data-cy="input-signup-personal-data-email-confirm"]').type('email')
cy.get('.input-error').should('contain', 'Os e-mails não são iguais')
})

it('Deve mostrar mensagem de erro se a senha no campo de confirmação estiver diferente', () => {
cy.get('[data-cy="input-signup-personal-data-password"]').type('senha123')
cy.get('[data-cy="input-signup-personal-data-password-confirm"]').type('senha')
cy.get('.input-error').should('contain', 'As senhas não são iguais')
})

it('Deve mostrar mensagem de erro ao tentar cadastrar com CPF inválido', ()=>{
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha', '12345678910')
cy.get('.input-error').should('contain', 'CPF inválido')
})

it('Deve mostrar mensagem de erro ao tentar cadastrar com CPF já cadastrado', () => {
cy.cadastroCompleto().then(()=>{
cy.wait(3000)
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
let cpf = Cypress.env('generatedCPF')
cy.visit('/')
cy.get('[data-cy="button-btn-enroll"]').click()
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha', cpf)
cy.get('.input-error').should('contain', 'Este CPF já está em uso')
})
})

it('Deve mostrar mensagem de erro ao tentar cadastrar com CEP inválido', () => {
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha')
cy.cadastroEndereco('12345678', '23')
cy.get('.toasts-list').should('contain', 'CEP não encontrado')
})

it('Deve validar se o campo Nome é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-firstName"]').should('have.attr', 'required')
})

it('Deve validar se o campo Sobrenome é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-lastName"]').should('have.attr', 'required')
})

it('Deve validar se o campo Data de nascimento é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-birthDate"]').should('have.attr', 'required')
})

it('Deve validar se o campo CPF é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-cpf"]').should('have.attr', 'required')
})

it('Deve validar se o campo Email é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-email"]').should('have.attr', 'required')
})

it('Deve validar se o campo Confirme seu email é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-email-confirm"]').should('have.attr', 'required')
})

it('Deve validar se o campo Senha é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-password"]').should('have.attr', 'required')
})

it('Deve validar se o campo Confirme sua senha é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-password-confirm"]').should('have.attr', 'required')
})

it('Deve validar se o campo nivel de proficiência é obrigatório', () => {
cy.get('.lg\\:w-7\\/12 > .form-container > div.relative > .opatcity-0').should('have.attr', 'required')
})

it('Deve validar se o campo de Termos de Uso é obrigatório', () => {
cy.get('[data-cy="input-signup-personal-data-lgpd"]').should('have.attr', 'required')
})

it('Deve validar se o campo CEP é obrigatório', () => {
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha')
cy.get('[data-cy="input-signup-address-cep"]').should('have.attr', 'required')
})

it('Deve validar se o campo Número residencial é obrigatório', () => {
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha')
cy.get('[data-cy="input-signup-address-number"]').should('have.attr', 'required')
})

it('Deve validar se o campo Bairro é obrigatório', () => {
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha')
cy.get('[data-cy="input-signup-address-neighborhood"]').should('have.attr', 'required')
})

it('Deve validar se o campo Endereço é obrigatório', () => {
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha')
cy.get('[data-cy="input-signup-address-street"]').should('have.attr', 'required')
})

})
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
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"
}
33 changes: 33 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { generate } from 'gerador-validador-cpf'

Cypress.Commands.add('cadastroDadosPessoais', (nome, sobrenome, dataNascimento, email, senha, cpf)=>{
cpf = cpf || generate();
cy.get('[data-cy="input-signup-personal-data-firstName"]').type(nome)
cy.get('[data-cy="input-signup-personal-data-lastName"]').type(sobrenome)
cy.get('[data-cy="input-signup-personal-data-birthDate"]').type(dataNascimento)
cy.get('[data-cy="input-signup-personal-data-cpf"]').type(cpf)
cy.get('[data-cy="input-signup-personal-data-email"]').type(email)
cy.get('[data-cy="input-signup-personal-data-email-confirm"]').type(email)
cy.get('[data-cy="input-signup-personal-data-password"]').type(senha)
cy.get('[data-cy="input-signup-personal-data-password-confirm"]').type(senha)
cy.get('.lg\\:w-7\\/12 > .form-container > div.relative > .justify-between').click()
cy.get('#dropdown-button-1 > .overflow-y-scroll > :nth-child(3)').click()
cy.get('[data-cy="input-signup-personal-data-lgpd"]').click()
cy.get('[data-cy="button-signup_submit_button_1"]').click()
})

Cypress.Commands.add('cadastroEndereco', (cep, numero)=>{
cy.get('[data-cy="input-signup-address-cep"]').type(cep)
cy.get('[data-cy="input-signup-address-number"]').type(numero)
cy.wait(1000)
cy.get('[data-cy="button-signup_submit_button_3"]').click()
})

Cypress.Commands.add('cadastroCompleto', ()=>{
let email = `email${Math.floor(Math.random() * 100000000)}@mail.com`
Cypress.env('generatedEmail', email)
let cpf = generate()
Cypress.env('generatedCPF', cpf)
cy.cadastroDadosPessoais('nome', 'sobrenome', '23042000', email, 'senha', cpf)
cy.cadastroEndereco('13064759', '23')
})
20 changes: 20 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')
Loading