import { fireEvent, render, screen } from '@testing-library/react' import * as React from 'react' // Simple Mock Components that reproduce the exact UI issues const MockNavLink = ({ name, mode }: { name: string, mode: string }) => { return ( {/* Icon with inconsistent margin - reproduces issue #2 */} {/* Text that appears/disappears abruptly - reproduces issue #2 */} {mode === 'expand' && {name}} ) } const MockSidebarToggleButton = ({ expand, onToggle }: { expand: boolean, onToggle: () => void }) => { return (
{/* Top section with variable padding - reproduces issue #1 */}
App Info Area
{/* Navigation section - reproduces issue #2 */} {/* Toggle button section with consistent padding - issue #1 FIXED */}
) } const MockAppInfo = ({ expand }: { expand: boolean }) => { return (
) } describe('Sidebar Animation Issues Reproduction', () => { beforeEach(() => { // Mock getBoundingClientRect for position testing Element.prototype.getBoundingClientRect = vi.fn(() => ({ width: 200, height: 40, x: 10, y: 10, left: 10, right: 210, top: 10, bottom: 50, toJSON: vi.fn(), })) }) describe('Issue #1: Toggle Button Position Movement - FIXED', () => { it('should verify consistent padding prevents button position shift', () => { let expanded = false const handleToggle = () => { expanded = !expanded } const { rerender } = render() // Check collapsed state padding const toggleSection = screen.getByTestId('toggle-section') expect(toggleSection).toHaveClass('px-4') // Consistent padding expect(toggleSection).not.toHaveClass('px-5') expect(toggleSection).not.toHaveClass('px-6') // Switch to expanded state rerender() // Check expanded state padding - should be the same expect(toggleSection).toHaveClass('px-4') // Same consistent padding expect(toggleSection).not.toHaveClass('px-5') expect(toggleSection).not.toHaveClass('px-6') }) it('should verify sidebar width animation is working correctly', () => { const handleToggle = vi.fn() const { rerender } = render() const container = screen.getByTestId('sidebar-container') // Collapsed state expect(container).toHaveClass('w-14') expect(container).toHaveClass('transition-all') // Expanded state rerender() expect(container).toHaveClass('w-[216px]') }) }) describe('Issue #2: Navigation Text Squeeze Animation', () => { it('should reproduce text squeeze effect from padding and margin changes', () => { const { rerender } = render() const link = screen.getByTestId('nav-link-Orchestrate') const icon = screen.getByTestId('nav-icon-Orchestrate') // Collapsed state checks expect(link).toHaveClass('px-2.5') // 10px padding expect(icon).toHaveClass('mr-0') // No margin expect(screen.queryByTestId('nav-text-Orchestrate')).not.toBeInTheDocument() // Switch to expanded state rerender() // Expanded state checks expect(link).toHaveClass('px-3') // 12px padding (+2px) expect(icon).toHaveClass('mr-2') // 8px margin (+8px) expect(screen.getByTestId('nav-text-Orchestrate')).toBeInTheDocument() }) it('should document the abrupt text rendering issue', () => { const { rerender } = render() // Text completely absent expect(screen.queryByTestId('nav-text-API Access')).not.toBeInTheDocument() rerender() // Text suddenly appears - no transition expect(screen.getByTestId('nav-text-API Access')).toBeInTheDocument() }) }) describe('Issue #3: App Icon Bounce Animation', () => { it('should reproduce icon bounce from layout mode switching', () => { const { rerender } = render() const iconContainer = screen.getByTestId('icon-container') const appIcon = screen.getByTestId('app-icon') // Expanded state layout expect(iconContainer).toHaveClass('justify-between') expect(iconContainer).not.toHaveClass('flex-col') expect(appIcon).toHaveAttribute('data-size', 'large') // Switch to collapsed state rerender() // Collapsed state layout - completely different layout mode expect(iconContainer).toHaveClass('flex-col') expect(iconContainer).toHaveClass('gap-1') expect(iconContainer).not.toHaveClass('justify-between') expect(appIcon).toHaveAttribute('data-size', 'small') }) it('should identify the problematic transition-all property', () => { render() const appIcon = screen.getByTestId('app-icon') const computedStyle = window.getComputedStyle(appIcon) // The problematic broad transition expect(computedStyle.transition).toContain('all') }) }) describe('Interactive Toggle Test', () => { it('should demonstrate all issues in a single interactive test', () => { let expanded = false const handleToggle = () => { expanded = !expanded } const { rerender } = render(
, ) const toggleButton = screen.getByTestId('toggle-button') // Initial state verification expect(expanded).toBe(false) // Simulate toggle click fireEvent.click(toggleButton) expanded = true rerender(
, ) }) }) })