Skip to content

test(button): adiciona testes e2e com cypress nos samples#2763

Open
alinelariguet wants to merge 2 commits intomasterfrom
po-button/e2e-cypress
Open

test(button): adiciona testes e2e com cypress nos samples#2763
alinelariguet wants to merge 2 commits intomasterfrom
po-button/e2e-cypress

Conversation

@alinelariguet
Copy link
Copy Markdown
Member

@alinelariguet alinelariguet commented Mar 11, 2026

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 no app.module.ts via caminho relativo e servidos em rotas (/button/basic, /button/labs, /button/social-network). Um path mapping no tsconfig.app.json resolve @po-ui/ng-components para 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

  • Corrigida formatação Prettier em 3 arquivos (po-button-labs.cy.ts, po-button-social-network.cy.ts, app.module.ts)
  • Nota CI: o job "Test ui" apresenta 4 falhas em PoPopoverComponent (focus/tab trapping) — são testes pré-existentes, sem relação com as mudanças desta PR

Checklist de Revisão

  • cypress/support/e2e.ts suprime todas as exceções — O handler Cypress.on('uncaught:exception', () => false) impede que erros reais da aplicação falhem os testes. Avaliar se é aceitável ou se deveria ser mais seletivo.
  • Seletores acoplados ao DOM interno — Testes usam seletores como po-icon i.an-newspaper, span.po-checkbox, .po-button-loading-icon. Se a estrutura interna dos componentes mudar, os testes quebrarão. Avaliar se data-testid seria preferível.
  • Path mapping no tsconfig.app.json"@po-ui/ng-components": ["projects/ui/src/public-api"] sobrescreve o mapeamento do tsconfig.json raiz (./dist/ng-components). Verificar se isso não impacta outros usos do projeto app ou builds de CI.
  • Modificação do app.module.ts e app.component.html — O projeto app antes era vazio. Confirmar que adicionar declarations, rotas e <router-outlet> não quebra nenhum uso existente.
  • Executar os testes localmente — validar os 39 testes conforme o plano abaixo.

Plano de Testes

  1. Clonar a branch e rodar npm install
  2. Iniciar o dev server: npx ng serve app --port 4200
  3. Em outro terminal, executar os testes: npx cypress run --spec "cypress/e2e/po-button/**/*.cy.ts" --browser chrome
  4. Validar que todos os 39 testes passam
  5. (Opcional) Abrir a interface do Cypress (npx cypress open) e rodar os testes interativamente para visualizar o comportamento

Notes


Open with Devin

@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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>
@devin-ai-integration devin-ai-integration bot force-pushed the po-button/e2e-cypress branch from c7d8c28 to 1390e8c Compare March 11, 2026 01:58
@devin-ai-integration devin-ai-integration bot changed the title test(button): adiciona testes e2e com cypress para os samples do po-button test(button): adiciona testes e2e com cypress nos samples Mar 11, 2026
Co-Authored-By: aline.lariguet <alinecbgmoreira@gmail.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +4 to +6
Cypress.on('uncaught:exception', () => {
// Previne falhas de teste por exceções não tratadas da aplicação
return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.

Suggested change
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;
});
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@alinelariguet alinelariguet added the Teste IA PR geradas por IA label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Teste IA PR geradas por IA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant