test(button): adiciona testes e2e com cypress nos samples#2763
test(button): adiciona testes e2e com cypress nos samples#2763alinelariguet wants to merge 2 commits intomasterfrom
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Configura Cypress no projeto e cria testes e2e para os três samples do componente po-button: basic, labs e social-network. Importa os samples originais no app via caminho relativo e adiciona path mapping no tsconfig.app.json para resolver @po-ui/ng-components. Testes cobrem (39 no total): - basic (5): renderização, clique/alert, kind, disabled, classe CSS - labs (25): estado inicial, label, disabled, loading, danger, ícones, kind, type, size, interação Danger/Tertiary, click/dialog, restore - social-network (9): widget, dados, botões, fluxos completos, avatar Co-Authored-By: aline.lariguet <alinecbgmoreira@gmail.com>
c7d8c28 to
1390e8c
Compare
Co-Authored-By: aline.lariguet <alinecbgmoreira@gmail.com>
| Cypress.on('uncaught:exception', () => { | ||
| // Previne falhas de teste por exceções não tratadas da aplicação | ||
| return false; |
There was a problem hiding this comment.
🟡 Blanket suppression of all uncaught exceptions silently masks real application errors in E2E tests
The Cypress.on('uncaught:exception', () => { return false; }) handler at cypress/support/e2e.ts:4-6 unconditionally swallows every uncaught exception thrown by the application under test. This means if the Angular app throws a real runtime error (e.g., null reference, failed service call, broken binding), the Cypress tests will still pass. This defeats a key purpose of E2E testing — catching runtime failures — and can mask real regressions. The handler should either be scoped to known/expected exceptions (e.g., filtering by err.message) or removed entirely so that genuine application errors cause test failures.
| Cypress.on('uncaught:exception', () => { | |
| // Previne falhas de teste por exceções não tratadas da aplicação | |
| return false; | |
| Cypress.on('uncaught:exception', (err) => { | |
| // Ignore known third-party or framework errors that are not actionable | |
| if (err.message.includes('ResizeObserver loop') || err.message.includes('Script error')) { | |
| return false; | |
| } | |
| // Let all other exceptions fail the test | |
| return true; | |
| }); |
Was this helpful? React with 👍 or 👎 to provide feedback.
test(button): adiciona testes e2e com cypress nos samples
Resumo
Configura o Cypress no monorepo e adiciona testes E2E para os 3 samples existentes do componente
po-button: basic, labs e social-network.Os samples originais (em
projects/ui/) são importados diretamente noapp.module.tsvia caminho relativo e servidos em rotas (/button/basic,/button/labs,/button/social-network). Um path mapping notsconfig.app.jsonresolve@po-ui/ng-componentspara os fontes locais, permitindo que os samples funcionem sem build prévio da lib.39 testes no total:
po-button-basic.cy.ts— 5 testes (renderização, click/alert, kind padrão, disabled, classe CSS)po-button-labs.cy.ts— 25 testes (estado inicial, label, disabled, loading, danger, 4 ícones, kind, type, size, interação Danger↔Tertiary, click/dialog, restore completo)po-button-social-network.cy.ts— 9 testes (widget, dados dos amigos, botões de ação, fluxos Confirm/Ignore/Block, mensagem final, avatar)Demonstração
Vídeo da execução dos samples e testes disponível na sessão Devin.
Atualizações desde última revisão
po-button-labs.cy.ts,po-button-social-network.cy.ts,app.module.ts)PoPopoverComponent(focus/tab trapping) — são testes pré-existentes, sem relação com as mudanças desta PRChecklist de Revisão
cypress/support/e2e.tssuprime todas as exceções — O handlerCypress.on('uncaught:exception', () => false)impede que erros reais da aplicação falhem os testes. Avaliar se é aceitável ou se deveria ser mais seletivo.po-icon i.an-newspaper,span.po-checkbox,.po-button-loading-icon. Se a estrutura interna dos componentes mudar, os testes quebrarão. Avaliar sedata-testidseria preferível.tsconfig.app.json—"@po-ui/ng-components": ["projects/ui/src/public-api"]sobrescreve o mapeamento dotsconfig.jsonraiz (./dist/ng-components). Verificar se isso não impacta outros usos do projetoappou builds de CI.app.module.tseapp.component.html— O projetoappantes era vazio. Confirmar que adicionar declarations, rotas e<router-outlet>não quebra nenhum uso existente.Plano de Testes
npm installnpx ng serve app --port 4200npx cypress run --spec "cypress/e2e/po-button/**/*.cy.ts" --browser chromenpx cypress open) e rodar os testes interativamente para visualizar o comportamentoNotes