Add Cypress tests for UI interactions and form validations#2
Add Cypress tests for UI interactions and form validations#2brunonf15 wants to merge 10 commits intowlsf82:mainfrom
Conversation
wlsf82
left a comment
There was a problem hiding this comment.
Bom trabalho @brunonf15! 🎉
No entanto, deixei uma série de comentários ao longo do seu código, os quais creio que lhe ajudarão a melhorar o design do mesmo.
Obs.: Só faça novas alterações depois do encontro de hoje da Test Design Masterclass.
wlsf82
left a comment
There was a problem hiding this comment.
Bom trabalho @brunonf15! 👏🏻 👏🏻
No entanto, deixei novos comentários, os quais creio que lhe ajudarão a melhorar ainda mais o design dos testes.
Lembre-se de aplicar as mudanças sugeridas somente após o terceiro encontro da Test Design Masterclass da TAT.
Adding new scripts to run API and gui tests Adding new scripts to run Cypress tests Rename api and gui tests Updating the readme
Renaming the tests cases acording to the list Adding some extra spactes to improve the readbility of the tests
Using a command Adding more spaces to improve the readability of the code
wlsf82
left a comment
There was a problem hiding this comment.
Bom demais @brunonf15! Com ajustes de pequenos detalhes essa suíte de testes ficará 🔝
👏🏻 👏🏻 👏🏻
| ### Installing Cypress | ||
|
|
||
| 1. Install Cypress as a development dependency by running: | ||
| ```bash |
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Uma linha em branco já é o suficiente.
|
|
||
| - **API Tests**: Located in `cypress/e2e/api/engageSphere.cy.js`. | ||
| - **GUI Tests**: Located in `cypress/e2e/gui/engageSphere.cy.js`. | ||
|
|
| ```bash | ||
| npm test | ||
| ``` | ||
|
|
| ```bash | ||
| npm run test:api | ||
| ``` | ||
|
|
| cy.getByClassThatStartsWith('Messenger_success') | ||
| .should('be.visible') | ||
| .and('contain', 'Your message has been sent.'); | ||
| cy.tick(3000); |
There was a problem hiding this comment.
| cy.tick(3000); | |
| cy.tick(3000); | |
Deixando uma linha pra separar o assert.
| }); | ||
|
|
||
| it('Limpa todos os campos do formulário do messenger ao preenchê-los, fechar o messenger e abri-lo novamente', () => { | ||
| cy.getByClassThatStartsWith('Messenger_openCloseButton').click(); |
There was a problem hiding this comment.
| cy.getByClassThatStartsWith('Messenger_openCloseButton').click(); | |
| // Arrange | |
| cy.getByClassThatStartsWith('Messenger_openCloseButton').click(); | |
| // Act |
| cy.getByClassThatStartsWith('Messenger_openCloseButton').click(); | ||
| cy.getByClassThatStartsWith('Messenger_openCloseButton').click(); | ||
|
|
||
| cy.get('#messenger-name').should('have.value', ''); |
There was a problem hiding this comment.
E então:
| cy.get('#messenger-name').should('have.value', ''); | |
| // Assert | |
| cy.get('#messenger-name').should('have.value', ''); |
| cy.contains('th', 'Size').should('not.be.visible'); | ||
| }); | ||
|
|
||
| it('Bug - Edit name bloquado apos filtro não retornar dados', () => { |
There was a problem hiding this comment.
A descrição do caso de teste deve ser do comportamento sendo testado, não a descrição do bug.
Algo como:
| it('Bug - Edit name bloquado apos filtro não retornar dados', () => { | |
| it('Reativa o campo de entrada ao retornar de um filtro de estado vazio para um não vazio', () => { |
| @@ -0,0 +1,3 @@ | |||
| Cypress.Commands.add('getByClassThatStartsWith', classPart => { | |||
| cy.get(`[class^="${classPart}"]`) | |||
| }) No newline at end of file | |||
| }); | ||
| }); | ||
|
|
||
| it('Trata requisições inválidas (por exemplo, página negativa)', () => { |
There was a problem hiding this comment.
Que tal criar também casos de testes para os cenários onde page e limit são iguais a 0?
| } | ||
| }).then((response) => { | ||
| const totalCustomers = response.body.pageInfo.totalCustomers; | ||
| const expectedTotalPages = Math.ceil(totalCustomers / limit); |
There was a problem hiding this comment.
Explicarei com detalhes esse teste no encontro de amanhã.
| module.exports = defineConfig({ | ||
| e2e: { | ||
| baseUrl: "http://localhost:3000", | ||
| supportFile: false, |
There was a problem hiding this comment.
Visto que você criou o comando customizado, remova esta configuração, crie o arquivo cypress/support/e2e.js e dentro dele importe o arquivo cypress/support/commands.js.
✅ Updated Pull Request Description:
Summary:
This PR enhances and refines Cypress tests to validate key UI functionalities, including form validations, messenger interactions, footer verification, and responsive table behavior.
Changes include:
data-testid.How to Test:
npm run cypress:openornpx cypress run.Why?
data-testid.Reviewer Notes:
data-testid, using: