fix: rename JSX discount test file to .tsx#32
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughArquivo de testes de desconto migrado de ChangesTestes de Desconto QuoteBuilder
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/quotes/__tests__/QuoteBuilderDiscount.test.tsx (1)
31-49:⚠️ Potential issue | 🟠 Major | ⚡ Quick winTeste está passando sem validar comportamento (falso positivo).
Entre as Lines 31-49, o teste não faz nenhuma
expect(...)nem valida chamada de callback após a interação. Do jeito atual, ele sempre passa mesmo se a conversão quebrar.💡 Sugestão objetiva de correção
it('converts percent to amount correctly with round2', () => { const setDiscountValue = vi.fn(); const setDiscountType = vi.fn(); render( <QuoteBuilderSummaryColumn {...defaultProps} discountValue={10.589} // 10.59% setDiscountValue={setDiscountValue} setDiscountType={setDiscountType} />, ); - // Switch to amount const select = screen.getByLabelText('Tipo de desconto'); fireEvent.click(select); - // Find R$ option and click it - // In shadcn select, this might need more specific queries if it's open, but let's assume direct onValueChange works for now if we invoke it + const amountOption = screen.getByText('R$'); + fireEvent.click(amountOption); + + expect(setDiscountType).toHaveBeenCalledWith('amount'); + expect(setDiscountValue).toHaveBeenCalled(); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/quotes/__tests__/QuoteBuilderDiscount.test.tsx` around lines 31 - 49, The test currently interacts with the select but contains no assertions so it yields a false positive; update the test to assert that after switching the discount type the component calls setDiscountType('amount') and calls setDiscountValue with the correctly converted rounded amount (compute expected = round2(defaultProps.total * 10.589 / 100) using the same rounding logic as the component) — locate the interaction around QuoteBuilderSummaryColumn and the mocks setDiscountValue and setDiscountType, trigger the select change (either by firing the option click or invoking the underlying onChange/onValueChange used by the shadcn Select) and then add expects that setDiscountType was called with 'amount' and setDiscountValue was called with the expected numeric amount.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/components/quotes/__tests__/QuoteBuilderDiscount.test.tsx`:
- Around line 31-49: The test currently interacts with the select but contains
no assertions so it yields a false positive; update the test to assert that
after switching the discount type the component calls setDiscountType('amount')
and calls setDiscountValue with the correctly converted rounded amount (compute
expected = round2(defaultProps.total * 10.589 / 100) using the same rounding
logic as the component) — locate the interaction around
QuoteBuilderSummaryColumn and the mocks setDiscountValue and setDiscountType,
trigger the select change (either by firing the option click or invoking the
underlying onChange/onValueChange used by the shadcn Select) and then add
expects that setDiscountType was called with 'amount' and setDiscountValue was
called with the expected numeric amount.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c7cbd4c7-5fec-4d9c-ae13-cbca2cf7ba9c
📒 Files selected for processing (2)
src/components/quotes/__tests__/QuoteBuilderDiscount.test.tssrc/components/quotes/__tests__/QuoteBuilderDiscount.test.tsx
💤 Files with no reviewable changes (1)
- src/components/quotes/tests/QuoteBuilderDiscount.test.ts
There was a problem hiding this comment.
Pull request overview
This PR removes the duplicate .test.ts version of the QuoteBuilder discount tests and consolidates the suite under the .test.tsx file so JSX is handled correctly by the TypeScript/Vitest toolchain.
Changes:
- Deleted
QuoteBuilderDiscount.test.ts(the JSX-bearing.tstest file). - Updated
QuoteBuilderDiscount.test.tsxwith small formatting adjustments and an added React import.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/components/quotes/tests/QuoteBuilderDiscount.test.tsx | Keeps the discount tests in TSX and applies minor formatting/import changes. |
| src/components/quotes/tests/QuoteBuilderDiscount.test.ts | Removes the duplicate TS test file to avoid JSX-in-TS issues and duplicate test execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1,5 +1,6 @@ | |||
| import { describe, it, expect, vi } from 'vitest'; | |||
| import { render, screen, fireEvent } from '@testing-library/react'; | |||
| import React from 'react'; | |||
Agent-Logs-Url: https://github.com/adm01-debug/we-dream-big/sessions/8385ee63-cdec-46db-9541-d54279763683
📋 Descrição
🎯 Tipo de mudança
🔗 Issues relacionadas
Closes #
Refs #
🌐 Sistemas afetados
🧪 Como testar
✅ Checklist pré-merge
Qualidade
npx tsc --noEmitpassa sem errosnpm run test)Segurança
console.logcom payloads sensíveis (usarlogger.*)Documentação
mem://) se a mudança afetar arquitetura/regras_backup_*_YYYYMMDDse destrutivasUI
📸 Screenshots (se UI)
🔄 Plano de rollback
Summary by cubic
Renamed the discount test to
.tsxso JSX compiles and the test runs correctly. Cleaned up imports and formatting; no behavior changes.src/components/quotes/__tests__/QuoteBuilderDiscount.test.ts.QuoteBuilderDiscount.test.tsxwith an explicitReactimport and minor formatting to satisfyvitest/@testing-library/react.Written for commit 9cf45b7. Summary will update on new commits. Review in cubic
Summary by CodeRabbit