Skip to content

fix(ci): [FECHADO/OBSOLETO] resolve regressões de typecheck pós #154–#176#180

Closed
adm01-debug wants to merge 4 commits into
mainfrom
fix/ci-typecheck-regressions
Closed

fix(ci): [FECHADO/OBSOLETO] resolve regressões de typecheck pós #154–#176#180
adm01-debug wants to merge 4 commits into
mainfrom
fix/ci-typecheck-regressions

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

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

Objetivo

Deixar o gate de typecheck verde. A sequência de commits Lovable (test-drift, RLS, vários harden lint #166#171, #174 e #176) introduziu pares file:rule de erros TS acima do baseline. Este PR aplica 10 correções cirúrgicas, todas validadas localmente contra o baseline atual.

Resultado do gate (local, Node 20.20.2):
TS baseline gate — atual: 1041 erros · baseline: 1060 erros · ✅ Nenhuma regressão · drift positivo +19

Os testes de runtime dos arquivos afetados continuam passando (esbuild remove tipos; nenhuma mudança de comportamento).

Correções por área

connections / sidebar

  • RestrictedRouteNotice.tsxButton size="xs" (variante inexistente) → size="sm" (3×); a altura já é controlada via className.
  • SecretsManagerHealthPanel.tsx — narrowing de boot.requestId (string | undefined) antes de copyToClipboard.
  • __tests__/ConnectionUI.test.tsx e __tests__/ConnectionsOverviewTable.test.tsx — mocks alinhados ao tipo dos hooks (testingisTesting, casts as unknown as ReturnType<typeof vi.fn>).

quotes

personalization (#165)

  • lib/personalization/selectors.ts — hoist dos valores narrowed de criteria.* para fora dos closures de filter/sort (resolve 7× TS18048).

inventory / bi (#166#171)

  • inventory/SupplierRiskPanel.tsx — remove prop productSku não suportada por ProductRiskDetail (props: productId + productName?).
  • pages/bi/CommercialIntelligencePage.tsx — remove prop productId não suportada por SalesOverviewChart (props: days?).
  • hooks/products/useStockAlerts.integration.test.tsx — coalesce callArgs.select (?? '') antes do .split.

types — causa-raiz do #174

  • src/types/jest-dom.d.ts (novo) — restaura os tipos dos matchers do @testing-library/jest-dom para o escopo src/.
    O refactor(tsc): elimina top-5 do baseline TSC (Etapas 9-13) — -235 erros #174 deletou src/test/setup.ts (que continha import "@testing-library/jest-dom"). O setup de runtime (tests/setup.ts) ainda importa os matchers, mas tests/ fica fora do include do tsconfig.app.json, então 27 arquivos .test.tsx passaram a regredir com TS2339 (toBeInTheDocument, toHaveTextContent, toBeDisabled, toHaveAttribute). Este .d.ts (import '@testing-library/jest-dom/vitest') reintroduz esses tipos no escopo src/sem efeito em runtime.

Notas

  • Nenhuma alteração de comportamento — apenas tipos e props inválidas.
  • Branch isolada; não toca main diretamente (evita redeploy Lovable indevido).
  • 10 arquivos no total; diff contra main = exatamente esses 10.

Summary by cubic

Resolve regressões de TypeScript e deixa o gate de typecheck verde sem alterar comportamento. 10 correções pequenas em componentes, testes e declarações de tipo.

  • Bug Fixes
    • Tipos de @testing-library/jest-dom restaurados no escopo src via src/types/jest-dom.d.ts (import '@testing-library/jest-dom/vitest'), corrigindo TS2339 após remoção do antigo setup (refactor(tsc): elimina top-5 do baseline TSC (Etapas 9-13) — -235 erros #174).
    • Connections/Sidebar: narrowing de requestId em SecretsManagerHealthPanel; ajuste de Button para size="sm" e classes em RestrictedRouteNotice; testes (ConnectionUI/ConnectionsOverviewTable) com mocks alinhados (testingisTesting e casts tipados).
    • Quotes: QuoteViewPage remove cast desnecessário no update() e usa quote.id ?? '' ao montar QuoteHistoryPanel.
    • Personalization: selectors.ts faz hoist de valores estreitados fora dos closures para evitar TS18048.
    • Inventory/BI: SupplierRiskPanel remove prop não suportada em ProductRiskDetail e pequenos ajustes de UI; CommercialIntelligencePage não passa productId para SalesOverviewChart; useStockAlerts.integration.test coalesce select antes do split.

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

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

vercel Bot commented May 23, 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 23, 2026 9:46pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Warning

Review limit reached

@adm01-debug, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 2 reviews/hour. Refill in 1 minute and 48 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 17c7de46-f0f0-4beb-9a63-2ac558ef76b4

📥 Commits

Reviewing files that changed from the base of the PR and between 4268c46 and b305c3a.

📒 Files selected for processing (10)
  • src/components/admin/connections/SecretsManagerHealthPanel.tsx
  • src/components/admin/connections/__tests__/ConnectionUI.test.tsx
  • src/components/admin/connections/__tests__/ConnectionsOverviewTable.test.tsx
  • src/components/inventory/SupplierRiskPanel.tsx
  • src/components/layout/sidebar/RestrictedRouteNotice.tsx
  • src/hooks/products/useStockAlerts.integration.test.tsx
  • src/lib/personalization/selectors.ts
  • src/pages/bi/CommercialIntelligencePage.tsx
  • src/pages/quotes/QuoteViewPage.tsx
  • src/types/jest-dom.d.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-typecheck-regressions

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

@supabase
Copy link
Copy Markdown

supabase Bot commented May 23, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

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

Este PR tem como objetivo eliminar regressões de TypeScript no gate de typecheck (pós #154#176) com ajustes pontuais de tipagem/props inválidas, mantendo o comportamento de runtime inalterado.

Changes:

  • Restaura tipos dos matchers do @testing-library/jest-dom no escopo src/ via novo src/types/jest-dom.d.ts.
  • Corrige usos incompatíveis de props/assinaturas (ex.: SalesOverviewChart, ProductRiskDetail, copyToClipboard, mocks de hooks e isTesting).
  • Ajusta pontos de narrowing/TS strictness em seletores e testes de integração.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/types/jest-dom.d.ts Reintroduz tipos do jest-dom para testes dentro de src/** sem depender do setup em tests/.
src/pages/quotes/QuoteViewPage.tsx Remove cast no .update() e ajusta quoteId do histórico para satisfazer TS.
src/pages/bi/CommercialIntelligencePage.tsx Remove prop não suportada e aplica refactor/formatting para alinhar com tipos atuais.
src/lib/personalization/selectors.ts Hoist de valores de criteria para evitar erros de narrowing em closures (filter/sort).
src/hooks/products/useStockAlerts.integration.test.tsx Evita .split em select possivelmente undefined via coalesce.
src/components/layout/sidebar/RestrictedRouteNotice.tsx Troca Button size="xs" (inexistente) por size="sm" e ajustes de formatação.
src/components/inventory/SupplierRiskPanel.tsx Remove prop não suportada em ProductRiskDetail e ajustes de formatação.
src/components/admin/connections/SecretsManagerHealthPanel.tsx Narrowing adicional para boot.requestId antes de copyToClipboard.
src/components/admin/connections/tests/ConnectionUI.test.tsx Ajusta mocks para isTesting e altera tipagem dos mocks para destravar TS.
src/components/admin/connections/tests/ConnectionsOverviewTable.test.tsx Ajusta mocks para isTesting e altera tipagem dos mocks para destravar TS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 208 to 214
await supabase
// rls-allow: lookup por id; RLS valida ownership
.from('quotes')
.update({ status: 'pending' } as Record<string, unknown>)
.update({ status: 'pending' })
.eq('id', quote.id);
await logQuoteHistory(
quote.id,
</SheetHeader>
<div className="mt-6">
<QuoteHistoryPanel quoteId={quote.id} />
<QuoteHistoryPanel quoteId={quote.id ?? ''} />
Comment on lines +45 to +51
const useAuthMock = vi.mocked(useAuth) as unknown as ReturnType<typeof vi.fn>;
const useConnectionsOverviewMock = vi.mocked(useConnectionsOverview) as unknown as ReturnType<
typeof vi.fn
>;
const useConnectionTesterMock = vi.mocked(useConnectionTester) as unknown as ReturnType<
typeof vi.fn
>;
Comment on lines +40 to +50
const useAuthMock = vi.mocked(useAuth) as unknown as ReturnType<typeof vi.fn>;
const useConnectionsOverviewMock = vi.mocked(useConnectionsOverview) as unknown as ReturnType<
typeof vi.fn
>;
const useConnectionTesterMock = vi.mocked(useConnectionTester) as unknown as ReturnType<
typeof vi.fn
>;
const useConsecutiveFailuresMock = vi.mocked(useConsecutiveFailures) as unknown as ReturnType<
typeof vi.fn
>;
const useSecretsManagerMock = vi.mocked(useSecretsManager) as unknown as ReturnType<typeof vi.fn>;
@adm01-debug adm01-debug changed the title fix(ci): resolve regressões de typecheck pós #154–#176 (10 correções cirúrgicas) fix(ci): [FECHADO/OBSOLETO] resolve regressões de typecheck pós #154–#176 May 24, 2026
@adm01-debug adm01-debug deleted the fix/ci-typecheck-regressions branch May 24, 2026 14:29
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.

2 participants