Skip to content

fix: rename JSX discount test file to .tsx#32

Merged
adm01-debug merged 1 commit into
mainfrom
copilot/fix-all-code-bugs
May 21, 2026
Merged

fix: rename JSX discount test file to .tsx#32
adm01-debug merged 1 commit into
mainfrom
copilot/fix-all-code-bugs

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 21, 2026

Agent-Logs-Url: https://github.com/adm01-debug/we-dream-big/sessions/8385ee63-cdec-46db-9541-d54279763683

📋 Descrição

🎯 Tipo de mudança

  • 🚀 feat — nova funcionalidade
  • 🐛 fix — correção de bug
  • ♻️ refactor — refatoração (sem mudança de comportamento)
  • 🔧 chore — manutenção, deps, config
  • 📚 docs — documentação
  • ⚡ perf — performance
  • 🔒 security — segurança
  • 🚨 hotfix — correção urgente em produção
  • 💥 breaking change — quebra compatibilidade

🔗 Issues relacionadas

Closes #
Refs #

🌐 Sistemas afetados

  • Bitrix24 (CRM, SPAs, BizProc)
  • Supabase (DB, Edge Functions, RLS, migrations)
  • n8n (workflows)
  • Evolution API / WhatsApp
  • Bling (NFe, OAuth)
  • Cloudflare (Workers, Images, Tunnels)
  • Frontend (UI, dashboards)
  • CI / GitHub Actions
  • Outro: ____

🧪 Como testar

✅ Checklist pré-merge

Qualidade

  • Código segue style guide (ESLint passa)
  • npx tsc --noEmit passa sem erros
  • Testes passam (npm run test)
  • Adicionei testes para novas funcionalidades quando aplicável
  • CodeRabbit revisou o PR (ou justificativa para skip)

Segurança

  • Sem secrets, tokens ou credenciais hardcoded
  • Variáveis de ambiente novas documentadas
  • Sem console.log com payloads sensíveis (usar logger.*)
  • RLS revisado se houve mudança em tabelas
  • Edge functions: input validado com Zod

Documentação

  • Atualizei docs (README / CHANGELOG / docs/) se necessário
  • Memória atualizada (mem://) se a mudança afetar arquitetura/regras
  • Migrations com backup em _backup_*_YYYYMMDD se destrutivas

UI

  • Componentes usam tokens semânticos (sem cores hardcoded)
  • Screenshots / vídeo anexados (se mudança visual)

📸 Screenshots (se UI)

🔄 Plano de rollback

⚠️ Notas para o reviewer


Summary by cubic

Renamed the discount test to .tsx so JSX compiles and the test runs correctly. Cleaned up imports and formatting; no behavior changes.

  • Bug Fixes
    • Removed src/components/quotes/__tests__/QuoteBuilderDiscount.test.ts.
    • Updated QuoteBuilderDiscount.test.tsx with an explicit React import and minor formatting to satisfy vitest/@testing-library/react.

Written for commit 9cf45b7. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Tests
    • Atualização e reorganização dos testes do componente de desconto para melhorar a cobertura de cenários de conversão entre percentual e valor em reais.

Review Change Stack

Copilot AI review requested due to automatic review settings May 21, 2026 14:55
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
we-dream-big Ready Ready Preview, Comment May 21, 2026 2:55pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Walkthrough

Arquivo de testes de desconto migrado de .test.ts para .test.tsx. React adicionado como import, JSX do componente reformatado, e testes de conversão percentual-valor reescritos com expressões multi-linhas e cálculos intermediários. Asserções e valores esperados mantidos.

Changes

Testes de Desconto QuoteBuilder

Layer / File(s) Summary
Setup e importações do teste
src/components/quotes/__tests__/QuoteBuilderDiscount.test.tsx
import React adicionado, JSX de renderização do QuoteBuilderSummaryColumn reformatado para múltiplas linhas com props mantidos.
Testes de lógica de conversão de desconto
src/components/quotes/__tests__/QuoteBuilderDiscount.test.tsx
Testes de conversão %R$ reescritos com expressões round2 multi-linhas e variáveis intermediárias. Casos de zero subtotal e descontos altos (capping em 1000 e 100%) reformatados, asserções preservadas (116.44, 10.59).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning O título descreve apenas renomear um arquivo (.ts → .tsx), mas o changeset contém refatoração significativa de testes, remoção de arquivo antigo e reescritas de lógica de conversão. Atualize o título para refletir a mudança real, ex: 'refactor: rewrite discount conversion tests with improved formatting' ou detalhe as alterações de lógica no corpo da PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch copilot/fix-all-code-bugs

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 win

Teste 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

📥 Commits

Reviewing files that changed from the base of the PR and between cf8309a and 9cf45b7.

📒 Files selected for processing (2)
  • src/components/quotes/__tests__/QuoteBuilderDiscount.test.ts
  • src/components/quotes/__tests__/QuoteBuilderDiscount.test.tsx
💤 Files with no reviewable changes (1)
  • src/components/quotes/tests/QuoteBuilderDiscount.test.ts

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 .ts test file).
  • Updated QuoteBuilderDiscount.test.tsx with 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';
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants