-
Notifications
You must be signed in to change notification settings - Fork 15
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
base: main
Are you sure you want to change the base?
Changes from all commits
8985e99
09dc498
9adb68d
c502d4b
97f9384
d018fbe
dd84610
55a5b77
b2e73cc
71d3608
cb296d9
27ba9d4
37f546f
a7ba04e
e293670
7d38b70
62eacb5
3e521a1
bfec7a9
fab1a00
5a560de
324d88c
f3ee193
90fda63
1ae5985
bedbdeb
4de4752
a0d9f88
fee41b8
286fb7b
8e26d34
ffca1ec
c8596c8
be9755f
86760ca
15aea71
d64f358
7b6eeff
4a1000a
ccf3c6d
0eef4be
0457553
3bae055
74efd8b
5b2ec4e
915ac8b
ed42a48
9da80f7
691ffe2
32e27a3
53d9f33
ff08296
29e774e
1394459
97dff11
1a95dc8
4925d88
a1a818d
44dd92b
465f1c2
eeeb75c
2a83a7d
741a654
a7d4f60
69642f3
5426c7f
9817d4d
cad1b0f
19d9aca
9a557ad
bdb364d
00fbbc8
c51ca1a
ff4f7ed
dfe2715
645e16d
1cf0867
b031a27
86a1136
3636f16
cd52917
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
run: | | ||
npm install | ||
npm test | ||
continue-on-error: true # Action should continue in failure situations | ||
|
||
- name: Upload Cypress screenshots | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
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' | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,135 @@ | ||||||||
describe('Validate the API requests', () => { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 A propósito, recomendo pensar num melhor nome para o arquivo também. Eu nomeria simplemente |
||||||||
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); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Que tal verificar também o que é retornado no |
||||||||
}); | ||||||||
}); | ||||||||
|
||||||||
it('Get the second page', () => { | ||||||||
cy.request({ | ||||||||
method: 'GET', | ||||||||
url: `${CUSTOMERS_API_URL}?page=2`, | ||||||||
}).then(({ status }) => { | ||||||||
expect(status).to.equal(200); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||
}); | ||||||||
}); | ||||||||
|
||||||||
it('Change the limits of customers per page', () => { | ||||||||
cy.request({ | ||||||||
method: 'GET', | ||||||||
url: `${CUSTOMERS_API_URL}?page=1&limit=20`, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Se o teste é da query string |
||||||||
}).then(({ status, body }) => { | ||||||||
expect(status).to.equal(200); | ||||||||
expect(body.pageInfo.totalPages).to.equal(3); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||
}); | ||||||||
}); | ||||||||
}); | ||||||||
context('Filters', () => { | ||||||||
const sizes = ['Small', 'Medium', 'Enterprise', 'Large Enterprise', 'Very Large Enterprise']; | ||||||||
const industries = ['Logistics', 'Retail', 'Technology', 'HR', 'Finance']; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
É 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 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', () => { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Visto que a mensagem de erro é Perceba que a mensagem diz: Both must be positive numbers. O mesmo para para |
||||||||
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, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Se o teste é da propriedade |
||||||||
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.'); | ||||||||
}); | ||||||||
}); | ||||||||
}); | ||||||||
}); | ||||||||
}); |
There was a problem hiding this comment.
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.