Giter VIP home page Giter VIP logo

cypress-api's Introduction

[email protected] + Mark85 - Gerenciador de Tarefas

Repositório do projeto de testes End-to-end (E2E) feitos com Cypress 💚 para o web app de demonstração: Mark85 - Gerenciador de Tarefas.

IDE utilizada nesse projeto

VS Code versão 1.89.1

Pré-requisitos

Você vai precisar dos seguintes sistemas instalados em seu computador:

Note

Durante a instalação do Node.js o NPM é automaticamente instalado.

Important

Para a instalação do Git garantir que as opções "Git Bash Here" e "(NEW!) Add a Git Bash Profile to Windows Terminal" estejam marcadas ✅.

Instalação

Após clonar o repositório, instalar as dependências da web app que estão na pasta /apps/mark85/

  1. Pasta api - API do gerenciador de tarefas, execute o comando
npm i
  1. Colocar API em execução
npm run dev
  1. Pasta web - Interface gráfica do gerenciador de tarefas, execute o comando
npm i
  1. Colocar Interface gráfica em execução
npm run dev
  1. Pasta mail - Serviço de envio de e-mails, execute o comando
npm i
  1. Colocar serviço de envio de e-mails em execução
npm run dev

Important

Necessário criar conta no CloudAMQP (RabbitMQ) para configurar fila de mensageria, MongoDB para utilização do banco de dados, onde ambos serão configurados no arquivo 'dotenv' do projeto. É utilizado o Ethereal para serviço SMTP.

Métodos HTTP

Requisições para a API REST

🟡 POST /Register a new user
curl --request POST \
  --url http://localhost:3333/users \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.1' \
  --data '{
	"name": "Steve Jobs",
	"email": "[email protected]",
	"password": "pwd123"
}'
🟡 POST /User session
curl --request POST \
  --url http://localhost:3333/sessions \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.1' \
  --data '{
	"email": "[email protected]",
	"password": "pwd123"
}'
🟡 POST /New task
curl --request POST \
  --url http://localhost:3333/tasks/ \
  --header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1ZjllMmI5YmUwOGFhMGQxMjlkYjg2ZiIsInVzZXIiOnsiX2lkIjoiNjVmOWUyYjliZTA4YWEwZDEyOWRiODZmIiwibmFtZSI6IlN0ZXZlIEpvYnMiLCJlbWFpbCI6ImpvYnNAbmV4dC5jb20iLCJwYXNzd29yZCI6IiQyYiQwOCRyaVZJNk8xcUlJVm40eDk2WlFpLktlcVZ2aTdTMWNWNmcuT2lRbHhMVDcwTTRiZUlFMmppeSJ9LCJpYXQiOjE3MTA5NTEwMzgsImV4cCI6MTcxMTgxNTAzOH0._fCQKSPTD1yl6rzsJr9ZVIIclRc6RcS2CCPpCTl_biM' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.1' \
  --data '{
	"name": "Definição técnica de arquitetura",
	"tags": [
		"x86",
		"unix"
	]
}'
🟢 GET /Get my tasks
curl --request GET \
  --url http://localhost:3333/tasks/ \
  --header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1ZjllMmI5YmUwOGFhMGQxMjlkYjg2ZiIsInVzZXIiOnsiX2lkIjoiNjVmOWUyYjliZTA4YWEwZDEyOWRiODZmIiwibmFtZSI6IlN0ZXZlIEpvYnMiLCJlbWFpbCI6ImpvYnNAbmV4dC5jb20iLCJwYXNzd29yZCI6IiQyYiQwOCRyaVZJNk8xcUlJVm40eDk2WlFpLktlcVZ2aTdTMWNWNmcuT2lRbHhMVDcwTTRiZUlFMmppeSJ9LCJpYXQiOjE3MTA5NTEwMzgsImV4cCI6MTcxMTgxNTAzOH0._fCQKSPTD1yl6rzsJr9ZVIIclRc6RcS2CCPpCTl_biM' \
  --header 'User-Agent: insomnia/8.6.1'
🟢 GET /Get unique task
curl --request GET \
  --url http://localhost:3333/tasks/65fb0bfe0b19f522d29bd234 \
  --header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1ZjllMmI5YmUwOGFhMGQxMjlkYjg2ZiIsInVzZXIiOnsiX2lkIjoiNjVmOWUyYjliZTA4YWEwZDEyOWRiODZmIiwibmFtZSI6IlN0ZXZlIEpvYnMiLCJlbWFpbCI6ImpvYnNAbmV4dC5jb20iLCJwYXNzd29yZCI6IiQyYiQwOCRyaVZJNk8xcUlJVm40eDk2WlFpLktlcVZ2aTdTMWNWNmcuT2lRbHhMVDcwTTRiZUlFMmppeSJ9LCJpYXQiOjE3MTA5NTEwMzgsImV4cCI6MTcxMTgxNTAzOH0._fCQKSPTD1yl6rzsJr9ZVIIclRc6RcS2CCPpCTl_biM' \
  --header 'User-Agent: insomnia/8.6.1'
🔴 DELETE /Remove task
curl --request DELETE \
  --url http://localhost:3333/tasks/65fb0bfe0b19f522d29bd234 \
  --header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1ZjllMmI5YmUwOGFhMGQxMjlkYjg2ZiIsInVzZXIiOnsiX2lkIjoiNjVmOWUyYjliZTA4YWEwZDEyOWRiODZmIiwibmFtZSI6IlN0ZXZlIEpvYnMiLCJlbWFpbCI6ImpvYnNAbmV4dC5jb20iLCJwYXNzd29yZCI6IiQyYiQwOCRyaVZJNk8xcUlJVm40eDk2WlFpLktlcVZ2aTdTMWNWNmcuT2lRbHhMVDcwTTRiZUlFMmppeSJ9LCJpYXQiOjE3MTA5NTEwMzgsImV4cCI6MTcxMTgxNTAzOH0._fCQKSPTD1yl6rzsJr9ZVIIclRc6RcS2CCPpCTl_biM' \
  --header 'User-Agent: insomnia/8.6.1'
🔵 PUT /Finish task
curl --request PUT \
  --url http://localhost:3333/tasks/65fb0bfe0b19f522d29bd234/done \
  --header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1ZjllMmI5YmUwOGFhMGQxMjlkYjg2ZiIsInVzZXIiOnsiX2lkIjoiNjVmOWUyYjliZTA4YWEwZDEyOWRiODZmIiwibmFtZSI6IlN0ZXZlIEpvYnMiLCJlbWFpbCI6ImpvYnNAbmV4dC5jb20iLCJwYXNzd29yZCI6IiQyYiQwOCRyaVZJNk8xcUlJVm40eDk2WlFpLktlcVZ2aTdTMWNWNmcuT2lRbHhMVDcwTTRiZUlFMmppeSJ9LCJpYXQiOjE3MTA5NTEwMzgsImV4cCI6MTcxMTgxNTAzOH0._fCQKSPTD1yl6rzsJr9ZVIIclRc6RcS2CCPpCTl_biM' \
  --header 'User-Agent: insomnia/8.6.1'
🔴 DELETE /Purge messages - RabbitMQ
curl --request DELETE \
  --url https://porpoise.rmq.cloudamqp.com/api/queues/fsbjfytv/tasks/contents \
  --header 'Authorization: Basic ZnNiamZ5dHY6dHk2QTJublluMW1KeUZNWjJMMzBNNzZ1NWhFWFRnS2E=' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.1' \
  --data '{
	"vhost": "fsbjfytv",
	"name": "tasks",
	"mode": "purge"
}'
🟡 POST /Get message - RabbitMQ
curl --request POST \
  --url https://porpoise.rmq.cloudamqp.com/api/queues/fsbjfytv/tasks/get \
  --header 'Authorization: Basic ZnNiamZ5dHY6dHk2QTJublluMW1KeUZNWjJMMzBNNzZ1NWhFWFRnS2E=' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.1' \
  --data '{
	"vhost": "fsbjfytv",
	"name": "tasks",
	"truncate": "50000",
	"ackmode": "ack_requeue_true",
	"encoding": "auto",
	"count": "1"
}'

Como executar

Testes

Você pode executá-los tanto em modo interativo, como em modo headless.

  1. Instalar as dependências do Cypress que estão na pasta raiz /, execute o comando
npm i
  1. Para rodar todos os testes em modo headless, execute o comando
npx cypress run --env allure=true
  1. O relatório de execução dos testes pode ser visualizado com Allure Report, execute o comando
npx allure serve

Warning

É necessário o Java 8 para executar o binário do Allure Reports.

Tip

Execute os testes através do Lauchpad, modo interativo do Cypress, com o comando npx cypress open.

Funcionalidades Testadas

Cypress.io

tasks > delete

  • remove a task
  • task not found

tasks > get

  • get my tasks
  • get unique task
  • task not found

tasks > post > context > register a new task

  • post task

tasks > post

  • duplicate task

tasks > put

  • update task to done
  • task not found

sessions

  • user session
  • invalid password
  • email not found

users

  • register a new user
  • duplicate email

users > context > required fields

  • name is required
  • email is required
  • password is required

cypress-api's People

Contributors

eudanilobarbosa avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.