Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First delivery #3

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
8985e99
First commit
Cicero-Henrique Oct 8, 2024
09dc498
Add spaces
Cicero-Henrique Oct 8, 2024
9adb68d
Improve tests
Cicero-Henrique Oct 8, 2024
c502d4b
Add comments
Cicero-Henrique Oct 9, 2024
97f9384
Add a backend validation
Cicero-Henrique Oct 9, 2024
d018fbe
Update readme
Cicero-Henrique Oct 9, 2024
dd84610
Merge pull request #1 from Cicero-Henrique/tests
Cicero-Henrique Oct 9, 2024
55a5b77
Reverting all packages and package-locks committed by mistake.
Cicero-Henrique Oct 13, 2024
b2e73cc
Moving the tests to root of the project and adding scripts
Cicero-Henrique Oct 13, 2024
71d3608
Update the readme
Cicero-Henrique Oct 13, 2024
cb296d9
Add end line
Cicero-Henrique Oct 13, 2024
27ba9d4
Change urls to enviroment variables
Cicero-Henrique Oct 13, 2024
37f546f
Improve the command name
Cicero-Henrique Oct 14, 2024
a7ba04e
Insert the cookies in the browser
Cicero-Henrique Oct 14, 2024
e293670
Fix the select filter test case
Cicero-Henrique Oct 14, 2024
7d38b70
Improve the test that returns to the clients list
Cicero-Henrique Oct 15, 2024
62eacb5
Improve the test that checks the footer
Cicero-Henrique Oct 15, 2024
3e521a1
Separating the assertions
Cicero-Henrique Oct 15, 2024
bfec7a9
Remove dynamic parts from cy.get
Cicero-Henrique Oct 15, 2024
fab1a00
Reduce the code to check the header
Cicero-Henrique Oct 15, 2024
5a560de
Reduce the code to open and close the messenger
Cicero-Henrique Oct 15, 2024
324d88c
Remove the custom command, reduce the tick time and reduce a line to …
Cicero-Henrique Oct 15, 2024
f3ee193
Reduce a line to click on the element
Cicero-Henrique Oct 15, 2024
90fda63
Remove the getCustomers custom command
Cicero-Henrique Oct 15, 2024
1ae5985
Fix the first test, removing unnecessary API validation
Cicero-Henrique Oct 15, 2024
bedbdeb
Add pagination validation
Cicero-Henrique Oct 15, 2024
4de4752
Validating the limits of items per page
Cicero-Henrique Oct 15, 2024
a0d9f88
Validate the filter by company size
Cicero-Henrique Oct 15, 2024
fee41b8
Validate the industry filter
Cicero-Henrique Oct 15, 2024
286fb7b
Validate a negative page scenario
Cicero-Henrique Oct 15, 2024
8e26d34
Add a second assertion on negative page scenario and a validation of …
Cicero-Henrique Oct 15, 2024
ffca1ec
Validate to use a text in the page field
Cicero-Henrique Oct 15, 2024
c8596c8
Validate a bool limit
Cicero-Henrique Oct 15, 2024
be9755f
Validate a invalid company size scenario
Cicero-Henrique Oct 15, 2024
86760ca
Validate an invalid company industry scenario
Cicero-Henrique Oct 15, 2024
15aea71
Add tests to contexts
Cicero-Henrique Oct 15, 2024
d64f358
Add github action
Cicero-Henrique Oct 15, 2024
7b6eeff
Fix github action
Cicero-Henrique Oct 23, 2024
4a1000a
Use baseUrl
Cicero-Henrique Oct 23, 2024
ccf3c6d
Set cookies quickly and remove support folder
Cicero-Henrique Oct 23, 2024
0eef4be
Improve the contexts
Cicero-Henrique Oct 24, 2024
0457553
Destructuring the responses on api tests
Cicero-Henrique Oct 24, 2024
3bae055
Remove unecessary url parameters
Cicero-Henrique Oct 24, 2024
74efd8b
Improve requests urls
Cicero-Henrique Oct 24, 2024
5b2ec4e
Remove blank lines
Cicero-Henrique Oct 24, 2024
915ac8b
Remove unecessary lines and comments
Cicero-Henrique Oct 24, 2024
ed42a48
Change from get to contains
Cicero-Henrique Oct 24, 2024
9da80f7
Fixed tests that were performing two validations
Cicero-Henrique Oct 24, 2024
691ffe2
Use fixture to improve the tests
Cicero-Henrique Oct 24, 2024
32e27a3
Improve the filters
Cicero-Henrique Oct 25, 2024
53d9f33
Add localstorage validation
Cicero-Henrique Oct 25, 2024
ff08296
Add no customers scenarios
Cicero-Henrique Oct 25, 2024
29e774e
Add the input disable validation
Cicero-Henrique Oct 25, 2024
1394459
Add test to validate the loading element
Cicero-Henrique Oct 25, 2024
97dff11
Add tests to validate the cookies
Cicero-Henrique Oct 25, 2024
1a95dc8
Add test to check the customer address
Cicero-Henrique Oct 25, 2024
4925d88
Change customer fixture and fix the tests
Cicero-Henrique Oct 26, 2024
a1a818d
Add missing info tests
Cicero-Henrique Oct 26, 2024
44dd92b
Add test to hide address
Cicero-Henrique Oct 26, 2024
465f1c2
Change from many describes to only one
Cicero-Henrique Oct 26, 2024
eeeb75c
Add theme tests
Cicero-Henrique Oct 26, 2024
2a83a7d
Add the first pagination test
Cicero-Henrique Oct 26, 2024
741a654
Add first test for two page scenarios
Cicero-Henrique Oct 26, 2024
a7d4f60
Add second test for two pages validation
Cicero-Henrique Oct 26, 2024
69642f3
Add one page test
Cicero-Henrique Oct 26, 2024
5426c7f
Add test to check if the pagination element is rendered with 50 custo…
Cicero-Henrique Oct 26, 2024
9817d4d
Add test to sort ascendant
Cicero-Henrique Oct 26, 2024
cad1b0f
Add test to sort descendant
Cicero-Henrique Oct 26, 2024
19d9aca
Increase the width
Cicero-Henrique Oct 26, 2024
9a557ad
Add test to sort by number of employees descendant
Cicero-Henrique Oct 26, 2024
bdb364d
Add test to validate the sort by number of employees ascendant
Cicero-Henrique Oct 26, 2024
00fbbc8
Add test to download csv
Cicero-Henrique Oct 26, 2024
c51ca1a
Fix csv test
Cicero-Henrique Oct 26, 2024
ff4f7ed
Add eslint
Cicero-Henrique Oct 27, 2024
dfe2715
Fix the delay scenario
Cicero-Henrique Oct 27, 2024
645e16d
Remove blank lines
Cicero-Henrique Oct 27, 2024
1cf0867
Add first acessibility test
Cicero-Henrique Oct 29, 2024
b031a27
Add test to check accessibility on customers list dark mode
Cicero-Henrique Oct 29, 2024
86a1136
Add test to check accessibility on customers details light mode
Cicero-Henrique Oct 29, 2024
3636f16
check accessibility on dark mode in details page
Cicero-Henrique Oct 29, 2024
cd52917
Add test of messenget button
Cicero-Henrique Oct 29, 2024
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
44 changes: 44 additions & 0 deletions .github/workflows/actionTests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: EngageSphere tests 🧪

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install and run backend
run: |
cd backend
npm install
npm start &
env:
CI: true

- name: Install and run frontend
run: |
cd frontend
npm install
npm start &
env:
CI: true

- name: Install and run tests
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Que tal criar uma estratégia para execução de diferentes testes em paralelo uns aos outros.

Exemplo, enquanto roda os testes de API em uma máquina, os teste de GUI poderiam estar rodando em outro, fornecendo feedback mais rápido.

run: |
npm install
npm test
continue-on-error: true # Action should continue in failure situations

- name: Upload Cypress screenshots
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

if: failure()
uses: actions/upload-artifact@v3
with:
name: cypress-screenshots
path: cypress/screenshots
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,68 @@ Read the following [doc](./docs/TestEnvironment.md) to install and start the bac

Read the following [doc](./docs/TestCases.md) to get a list of test cases.

To execute the tests on the first time you need install the dev dependencies:

```bash
npm install
```

When the installation was completed you can execute the tests using the following commands:

```bash
npm run test
```

### Custom Commands

This repository includes custom commands to facilitate running tests in different scenarios:

### Open Cypress Launchpad Command

To open Cypress Launchpad with the default configuration:

``` bash
npm run cy:open
```

### Open Cypress Launchpad in Mobile Size

To simulate a mobile environment when opening Cypress Launchpad:

``` bash
npm run cy:open:mobile
```

### Run Tests in Specific Browsers

To run tests in specific browsers, use the commands below. Ensure that the desired browser is installed on your machine.

**Chrome**:

``` bash
npm run test:chrome
```

**Electron**:

``` bash
npm run test:electron
```

**Firefox**:

``` bash
npm run test:firefox
```

### Run Tests Simulating Mobile Screens

To run tests simulating a mobile environment:

``` bash
npm run test:mobile
```

___

Made with ❤️ by [Walmyr](https://walmyr.dev).
11 changes: 11 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { defineConfig } = require('cypress');

module.exports = defineConfig({
env: {
API_URL: 'http://localhost:3001'
},
e2e: {
viewportWidth: 1100,
baseUrl: 'http://localhost:3000'
}
});
135 changes: 135 additions & 0 deletions cypress/e2e/api/testsApi.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
describe('Validate the API requests', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Que tal uma descrição melhor para a suíte de testes?

Algo como EngageShere - GET customers endpoint.

A propósito, recomendo pensar num melhor nome para o arquivo também.

Eu nomeria simplemente EngageSphere.cy.js, e visto que ele já está na pasta cypress/e2e/api/, é óbvio que são testes de API, e portanto, isso pode ser omitido do nome do arquivo.

const CUSTOMERS_API_URL = `${Cypress.env('API_URL')}/customers`;

context('Pagination and limits', () => {
it('Get customers successfully', () => {
cy.request({
method: 'GET',
url: CUSTOMERS_API_URL,
}).then(({ status }) => {
expect(status).to.equal(200);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Que tal verificar também o que é retornado no body da resposta?

});
});

it('Get the second page', () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?page=2`,
}).then(({ status }) => {
expect(status).to.equal(200);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essa verificação só garante o sucesso da requisição, no entanto, não garante que os customers da página 2 foram retornados.

});
});

it('Change the limits of customers per page', () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?page=1&limit=20`,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se o teste é da query string limit, a page pode ser omitida.

}).then(({ status, body }) => {
expect(status).to.equal(200);
expect(body.pageInfo.totalPages).to.equal(3);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O que garante que sempre haverão 3 páginas quando o limite for 20?

Aqui, quem sabe você deveria verificar que body.customers.length é menor ou igual ao limit.

});
});
});
context('Filters', () => {
const sizes = ['Small', 'Medium', 'Enterprise', 'Large Enterprise', 'Very Large Enterprise'];
const industries = ['Logistics', 'Retail', 'Technology', 'HR', 'Finance'];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const industries = ['Logistics', 'Retail', 'Technology', 'HR', 'Finance'];
const industries = ['Logistics', 'Retail', 'Technology', 'HR', 'Finance'];

É uma boa prática e convenção separar a definição de variáveis de outras expressões por uma linha em branco.

Isso ajuda na legibilidade do código.

Cypress._.each(sizes, (size) => {
it(`Filter company by the size ${size}`, () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?size=${size}`,
}).then(({ status, body }) => {
expect(status).to.equal(200);
// Check if all returned companies have less than 100 employees
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tem certeza desse comentário?

const allCompaniesHaveSameSize = body.customers.every(customer => customer.size == `${size}`);
expect(allCompaniesHaveSameSize).to.be.true;
});
});
});

Cypress._.each(industries, (industry) => {
it(`Filter company by the industry ${industry}`, () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?industry=${industry}`,
}).then(({ status, body }) => {
expect(status).to.equal(200);
// Check if all returned companies have less than 100 employees
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mesma coisa aqui.

const allCompaniesHaveSameIndustry = body.customers.every(customer => customer.industry == industry);
expect(allCompaniesHaveSameIndustry).to.be.true;
});
});
});
});

context('Negative scenarios', () => {
context('Pagination and limits', () => {
it('Request a negative page', () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?page=-1`,
failOnStatusCode: false
}).then(({ status, body }) => {
expect(status).to.equal(400);
expect(body).to.have.property('error', 'Invalid page or limit. Both must be positive numbers.');
});
});

it('Request a negative limit', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visto que a mensagem de erro é Invalid page or limit. Both must be positive numbers., que tal testar também com limit=0?

Perceba que a mensagem diz: Both must be positive numbers.

O mesmo para para page.

cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?limit=-10`,
failOnStatusCode: false
}).then(({ status, body }) => {
expect(status).to.equal(400);
expect(body).to.have.property('error', 'Invalid page or limit. Both must be positive numbers.');
});
});

it('Request text page', () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?page=cicero&limit=-10`,
failOnStatusCode: false
}).then(({ status, body }) => {
expect(status).to.equal(400);
expect(body).to.have.property('error', 'Invalid page or limit. Both must be positive numbers.');
});
});

it('Request bool limit', () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?page=cicero&limit=` + true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se o teste é da propriedade limit, você não deveria passar page.

failOnStatusCode: false
}).then(({ status, body }) => {
expect(status).to.equal(400);
expect(body).to.have.property('error', 'Invalid page or limit. Both must be positive numbers.');
});
});
});
context('Filters', () => {
it('Request an invalid company size', () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?size=Cicero`,
failOnStatusCode: false
}).then(({ status, body }) => {
expect(status).to.equal(400);
expect(body).to.have.property('error', 'Unsupported size value. Supported values are All, Small, Medium, Enterprise, Large Enterprise, and Very Large Enterprise.');
});
});

it('Request an invalid company industry', () => {
cy.request({
method: 'GET',
url: `${CUSTOMERS_API_URL}?industry=Cicero`,
failOnStatusCode: false
}).then(({ status, body }) => {
expect(status).to.equal(400);
expect(body).to.have.property('error', 'Unsupported industry value. Supported values are All, Logistics, Retail, Technology, HR, and Finance.');
});
});
});
});
});
Loading