diff --git a/.tsc-baseline.json b/.tsc-baseline.json index a8e7a156e..06c3bfcce 100644 --- a/.tsc-baseline.json +++ b/.tsc-baseline.json @@ -1,6 +1,6 @@ { - "generatedAt": "2026-05-31T13:23:04.590Z", - "totalErrors": 62, + "generatedAt": "2026-05-31T21:30:44.376Z", + "totalErrors": 96, "counts": { "src/components/mockup/approval/OffscreenLayoutCapture.tsx": { "TS2345": 1 @@ -8,6 +8,12 @@ "src/components/search/AdvancedSearch.tsx": { "TS2345": 1 }, + "src/hooks/admin/useAllowedIPs.ts": { + "TS2322": 5, + "TS2345": 3, + "TS2352": 1, + "TS2769": 4 + }, "src/hooks/admin/useDeviceDetection.ts": { "TS2353": 1 }, @@ -20,6 +26,12 @@ "src/hooks/auth/useAccessSecurity.ts": { "TS2345": 1 }, + "src/hooks/intelligence/useSalesGoals.ts": { + "TS2322": 10, + "TS2345": 5, + "TS2353": 1, + "TS2769": 6 + }, "src/hooks/mockup/mockupGenerationService.ts": { "TS2322": 1 }, @@ -41,6 +53,10 @@ "TS2589": 4, "TS2769": 5 }, + "src/hooks/simulation/useSimulation.ts": { + "TS2345": 1, + "TS2769": 3 + }, "src/hooks/simulation/useTechniquePricing.ts": { "TS2339": 16, "TS2345": 1, @@ -60,9 +76,6 @@ "TS2322": 1, "TS2339": 1 }, - "src/lib/theme-presets.ts": { - "TS2322": 5 - }, "src/pages/products/FavoritesPage.tsx": { "TS2322": 2 }, diff --git a/src/components/novelties/NoveltyProductGrid.tsx b/src/components/novelties/NoveltyProductGrid.tsx index 9276da540..40bd4df45 100644 --- a/src/components/novelties/NoveltyProductGrid.tsx +++ b/src/components/novelties/NoveltyProductGrid.tsx @@ -613,14 +613,26 @@ export function NoveltyProductGrid() { setCurrentPage((p) => Math.max(1, p - 1))} - className={cn(currentPage === 1 && 'pointer-events-none opacity-50', 'cursor-pointer')} + className={cn( + currentPage === 1 && 'pointer-events-none opacity-50', + 'cursor-pointer', + )} /> {Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => { - if (totalPages > 7 && page !== 1 && page !== totalPages && Math.abs(page - currentPage) > 1) { + if ( + totalPages > 7 && + page !== 1 && + page !== totalPages && + Math.abs(page - currentPage) > 1 + ) { if (page === currentPage - 2 || page === currentPage + 2) { - return ; + return ( + + + + ); } return null; } @@ -640,7 +652,10 @@ export function NoveltyProductGrid() { setCurrentPage((p) => Math.min(totalPages, p + 1))} - className={cn(currentPage === totalPages && 'pointer-events-none opacity-50', 'cursor-pointer')} + className={cn( + currentPage === totalPages && 'pointer-events-none opacity-50', + 'cursor-pointer', + )} /> diff --git a/src/components/products/__tests__/ColorVariationsStyle.test.tsx b/src/components/products/__tests__/ColorVariationsStyle.test.tsx index de747ade9..a74ddde9c 100644 --- a/src/components/products/__tests__/ColorVariationsStyle.test.tsx +++ b/src/components/products/__tests__/ColorVariationsStyle.test.tsx @@ -6,14 +6,20 @@ import { TooltipProvider } from '@/components/ui/tooltip'; // Mock color data const mockColors = [ - { id: '1', name: 'Vermelho', hex: '#FF0000', variationName: 'Vermelho', groupName: 'Cores Quentes' }, + { + id: '1', + name: 'Vermelho', + hex: '#FF0000', + variationName: 'Vermelho', + groupName: 'Cores Quentes', + }, { id: '2', name: 'Azul', hex: '#0000FF', variationName: 'Azul', groupName: 'Cores Frias' }, ]; describe('Color Variation Layout Consistency', () => { it('ColorTooltipContent renders with correct structure and styles', () => { const { getByTestId, getByText } = render( - + , ); const swatch = getByTestId('color-tooltip-swatch'); @@ -33,7 +39,7 @@ describe('Color Variation Layout Consistency', () => { render( - + , ); const swatches = screen.getAllByRole('button'); @@ -43,11 +49,14 @@ describe('Color Variation Layout Consistency', () => { fireEvent.mouseEnter(firstSwatch); // Wait for the tooltip to appear in the DOM (searching globally since it might be in a portal) - await waitFor(() => { - // Check for the text inside the tooltip - const tooltipText = document.body.textContent || ''; - expect(tooltipText).toContain('Vermelho'); - }, { timeout: 2000 }); + await waitFor( + () => { + // Check for the text inside the tooltip + const tooltipText = document.body.textContent || ''; + expect(tooltipText).toContain('Vermelho'); + }, + { timeout: 2000 }, + ); // Verify it's not a native title expect(firstSwatch.getAttribute('title')).toBeNull(); @@ -59,23 +68,26 @@ describe('No Native Title Attributes', () => { render( - + , ); const swatches = screen.getAllByRole('button'); - swatches.forEach(s => expect(s.getAttribute('title')).toBeNull()); + expect(swatches).not.toHaveLength(0); + for (const s of swatches) { + expect(s.getAttribute('title')).toBeNull(); + } }); it('CompactColorDots elements have no title attribute', () => { const { container } = render( - + , ); const dots = container.querySelectorAll('span'); - dots.forEach(d => { - if (d.style.backgroundColor) { - expect(d.getAttribute('title')).toBeNull(); - } - }); + for (const d of Array.from(dots)) { + if (d.style.backgroundColor) { + expect(d.getAttribute('title')).toBeNull(); + } + } }); }); diff --git a/src/components/products/__tests__/GalleryTitleAudit.test.tsx b/src/components/products/__tests__/GalleryTitleAudit.test.tsx index fc59719a8..30642bfa8 100644 --- a/src/components/products/__tests__/GalleryTitleAudit.test.tsx +++ b/src/components/products/__tests__/GalleryTitleAudit.test.tsx @@ -1,75 +1,89 @@ import { describe, it, expect } from 'vitest'; -import { render, screen } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { ProductGallery } from '../ProductGallery'; import { QuickViewGallery } from '../quick-view/QuickViewGallery'; import { ZoomableGallery } from '../ZoomableGallery'; import { TooltipProvider } from '@/components/ui/tooltip'; +import type { ProductImageMeta } from '@/utils/image-utils'; describe('Gallery Components - Tooltip Regression Audit', () => { const mockImages = ['https://example.com/image1.jpg', 'https://example.com/image2.jpg']; const productName = 'Produto Teste'; const renderWithProviders = (ui: React.ReactElement) => { - return render( - - {ui} - - ); + return render({ui}); }; const auditNoTooltip = (container: HTMLElement) => { // 1. Check native title attribute on all images const allImages = container.querySelectorAll('img'); - allImages.forEach(img => { + expect(allImages.length).toBeGreaterThan(0); + for (const img of Array.from(allImages)) { expect(img.getAttribute('title')).toBeFalsy(); - }); + } // 2. Check for Radix Tooltip wrappers (TooltipTrigger/TooltipContent) // TooltipTrigger usually adds data-state or aria-describedby const tooltipTriggers = container.querySelectorAll('[data-state], [aria-describedby]'); - tooltipTriggers.forEach(trigger => { + for (const trigger of Array.from(tooltipTriggers)) { // If it's a trigger, it shouldn't be the image itself or wrap the image directly for title purposes const isImageRelated = trigger.tagName === 'IMG' || trigger.querySelector('img'); if (isImageRelated) { // We allow some triggers (like color variations), but not on the main gallery images - const isMainImageContainer = trigger.classList.contains('aspect-[4/3]') || - trigger.classList.contains('aspect-square') || - trigger.tagName === 'IMG'; + const isMainImageContainer = + trigger.classList.contains('aspect-[4/3]') || + trigger.classList.contains('aspect-square') || + trigger.tagName === 'IMG'; if (isMainImageContainer) { - // Radix tooltips for non-interactive elements are usually discouraged anyway - // But here we specifically want to ensure the main images are clean - expect(trigger.getAttribute('data-state')).not.toBe('closed'); - expect(trigger.getAttribute('data-state')).not.toBe('delayed-open'); + // Radix tooltips for non-interactive elements are usually discouraged anyway + // But here we specifically want to ensure the main images are clean + expect(trigger.getAttribute('data-state')).not.toBe('closed'); + expect(trigger.getAttribute('data-state')).not.toBe('delayed-open'); } } - }); + } }; it('ProductGallery should be free of tooltips on main images', () => { - const { container } = renderWithProviders(); + const { container } = renderWithProviders( + , + ); auditNoTooltip(container); }); it('QuickViewGallery should be free of tooltips on main images', () => { - const displayImages = [ - { url_cdn: mockImages[0], alt_text: 'Alt 1' }, - { url_cdn: mockImages[1], alt_text: 'Alt 2' } + const displayImages: ProductImageMeta[] = [ + { + url_cdn: mockImages[0], + alt_text: 'Alt 1', + image_type: 'main', + is_primary: true, + display_order: 0, + }, + { + url_cdn: mockImages[1], + alt_text: 'Alt 2', + image_type: 'main', + is_primary: false, + display_order: 1, + }, ]; const { container } = renderWithProviders( - {}} - /> + />, ); auditNoTooltip(container); }); it('ZoomableGallery should be free of tooltips on main images', () => { - const { container } = renderWithProviders(); + const { container } = renderWithProviders( + , + ); auditNoTooltip(container); }); }); - diff --git a/src/components/products/__tests__/ProductColorSelector.test.tsx b/src/components/products/__tests__/ProductColorSelector.test.tsx index a69ef1b09..0fa38e236 100644 --- a/src/components/products/__tests__/ProductColorSelector.test.tsx +++ b/src/components/products/__tests__/ProductColorSelector.test.tsx @@ -5,7 +5,13 @@ import { TooltipProvider } from '@/components/ui/tooltip'; // Mock color data const mockColors = [ - { id: '1', name: 'Vermelho', hex: '#FF0000', variationName: 'Vermelho', groupName: 'Cores Quentes' }, + { + id: '1', + name: 'Vermelho', + hex: '#FF0000', + variationName: 'Vermelho', + groupName: 'Cores Quentes', + }, { id: '2', name: 'Azul', hex: '#0000FF', variationName: 'Azul', groupName: 'Cores Frias' }, ]; @@ -14,29 +20,30 @@ describe('ProductColorSelector Tooltip Requirements', () => { const { getAllByRole } = render( - + , ); const swatches = getAllByRole('button'); - swatches.forEach(swatch => { + expect(swatches).not.toHaveLength(0); + for (const swatch of swatches) { expect(swatch.getAttribute('title')).toBeNull(); - }); + } }); it('does not have a native title attribute on dots in CompactColorDots', () => { const { container } = render( - + , ); // CompactColorDots renders spans that act as triggers const dots = container.querySelectorAll('span'); - dots.forEach(dot => { + for (const dot of Array.from(dots)) { // Check if it's one of our color dots (they have a background color set) if (dot.style.backgroundColor) { expect(dot.getAttribute('title')).toBeNull(); } - }); + } }); }); diff --git a/src/components/products/__tests__/ProductQuickActions.test.tsx b/src/components/products/__tests__/ProductQuickActions.test.tsx index a22fa84f6..46f1efce9 100644 --- a/src/components/products/__tests__/ProductQuickActions.test.tsx +++ b/src/components/products/__tests__/ProductQuickActions.test.tsx @@ -2,6 +2,7 @@ import { describe, it, expect, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; import { ProductQuickActions } from '../ProductQuickActions'; import { TooltipProvider } from '@/components/ui/tooltip'; +import type { Product } from '@/hooks/products'; // Mock Lucide icons vi.mock('lucide-react', async () => { @@ -25,33 +26,34 @@ describe('ProductQuickActions Tooltips and Titles', () => { minQuantity: 10, tags: { 'Público-Alvo': ['Empresas'] }, niches: ['Tecnologia'], - product: { - id: '123', - name: 'Test', + product: { + id: '123', + name: 'Test', images: [], category_id: 'cat1', brand: 'Brand', description: 'Desc', sku: 'SKU', colors: [], - sizes: [] - } as any, + sizes: [], + } as unknown as Product, }; const renderComponent = (props = defaultProps) => { return render( - + , ); }; it('should not have native title attributes on any button', () => { renderComponent(); const buttons = screen.getAllByRole('button'); - buttons.forEach(button => { + expect(buttons).not.toHaveLength(0); + for (const button of buttons) { expect(button.getAttribute('title')).toBeNull(); - }); + } }); it('should have correct action labels on buttons', () => { @@ -61,4 +63,4 @@ describe('ProductQuickActions Tooltips and Titles', () => { expect(screen.getByText('Indicação')).toBeInTheDocument(); expect(screen.getByText('Nicho')).toBeInTheDocument(); }); -}); \ No newline at end of file +}); diff --git a/src/components/ui/__tests__/TruncatedTooltip.test.tsx b/src/components/ui/__tests__/TruncatedTooltip.test.tsx index 05f2f925c..0421da2ee 100644 --- a/src/components/ui/__tests__/TruncatedTooltip.test.tsx +++ b/src/components/ui/__tests__/TruncatedTooltip.test.tsx @@ -1,8 +1,7 @@ import { describe, it, expect } from 'vitest'; -import { render, screen, act } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { TruncatedTooltip } from '../truncated-tooltip'; -import { TOOLTIP_DELAY, TooltipProvider } from '../tooltip'; -import { vi } from 'vitest'; +import { TOOLTIP_DELAY } from '../tooltip'; describe('TruncatedTooltip Delay', () => { it('should use the centralized TOOLTIP_DELAY by default', () => { @@ -17,7 +16,7 @@ describe('TruncatedTooltip Delay', () => { const { container } = render( This is a very long text that will surely truncate in a small container - + , ); // Since it's a component test, we're mainly checking it doesn't crash and respects the prop expect(container).toBeDefined(); diff --git a/src/pages/products/NoveltiesPage.tsx b/src/pages/products/NoveltiesPage.tsx index 9101d6d92..be3de893f 100644 --- a/src/pages/products/NoveltiesPage.tsx +++ b/src/pages/products/NoveltiesPage.tsx @@ -12,25 +12,27 @@ export default function NoveltiesPage() { description="Confira os produtos mais recentes adicionados ao catálogo de brindes promocionais." path="/novidades" /> - + {/* Cabeçalho da página */} - - - - - - - Novidades - - - Produtos recém-chegados ao catálogo nos últimos 30 dias - + + + + + + + + Novidades + + + Produtos recém-chegados ao catálogo nos últimos 30 dias + +
- Produtos recém-chegados ao catálogo nos últimos 30 dias -
+ Produtos recém-chegados ao catálogo nos últimos 30 dias +