Skip to content

Conversation

@tomerqodo
Copy link

Benchmark PR langgenius#29881

Type: Clean (correct implementation)

Original PR Title: perf: improve Jest caching and configuration in web tests
Original PR Description: # Performance: CI Test Improvements & Test Reliability Enhancements

Overview

This PR significantly improves web frontend test performance and reliability while maintaining comprehensive test coverage. The changes focus on CI optimization, test stability improvements, and enhanced error handling.

Key Changes

🚀 CI Performance Improvements

  • Jest Caching: Added persistent Jest cache layer (web/.cache/jest) to speed up test execution
  • Parallel Testing: Replaced --runInBand with --maxWorkers=100% to utilize all available CPU cores
  • Cache Strategy: Configured proper cache keying based on OS and dependency lock file
  • Expected Impact: ~60-80% reduction in CI test execution time

🧪 Test Reliability Enhancements

  • Headless UI Mocks: Added targeted mocks for @headlessui/react in concurrent test environments
  • Race Condition Fix: Synchronized rendering for Popover/Menu/Dialog components to prevent timing issues
  • Targeted Approach: Mocks applied only to affected test files, preserving integration test integrity
  • Preserved Logic: Mock implementations maintain conditional rendering and accessibility attributes

📝 Test Suite Improvements

  • Enhanced Error Testing: Improved error handling coverage in EditAnnotationModal tests
  • Toast Notifications: Added proper error toast verification for API failure scenarios
  • User Experience: Tested error message display and user feedback mechanisms
  • API Contract Testing: Verified proper error propagation and fallback behavior

🔧 Component Refinements

  • EditAnnotationModal: Enhanced error handling with proper try-catch blocks and user feedback
  • Internationalization: Added missing success/error message translations across 21 languages
  • Type Safety: Improved type definitions for annotation-related components

Technical Details

Mock Implementation Strategy

// Applied locally to prevent CI race conditions
// Preserves conditional rendering: if (!context?.open) return null
// Maintains accessibility: role="dialog", aria-expanded
// Avoids global __mocks__/ directory to keep real component tests

Files Modified

  • CI/CD: .github/workflows/web-tests.yml, web/jest.config.ts
  • Test Files: Enhanced 4 test suites with better coverage and reliability
  • Components: Improved error handling in annotation editing workflow
  • i18n: Added missing translations for error/success messages

Testing Strategy

  • ✅ All existing tests continue to pass
  • ✅ New tests cover edge cases and error scenarios
  • ✅ Performance optimizations maintain test quality
  • ✅ Mocks are minimal and targeted

Impact

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