Skip to content

Conversation

@tomerqodo
Copy link

Benchmark PR langgenius#29881

Type: Corrupted (contains bugs)

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

lyzno1 and others added 15 commits December 18, 2025 18:43
… tests

- Updated test descriptions for clarity on error handling scenarios.
- Enhanced tests to verify error toast notifications when API calls fail.
- Refactored test logic for better readability and maintainability.
- Ensured success notifications are correctly asserted after save operations.
- Added a step to restore Jest cache in the GitHub Actions workflow.
- Updated Jest's cache directory to a more appropriate location for better management.
- Adjusted Jest execution parameters to optimize performance during tests.
- Introduced a new type `AnnotationCreateResponse` for better API response handling.
- Updated `addAnnotation` and related components to handle optional account names more gracefully.
- Enhanced tests for `EditAnnotationModal` to cover fallback error messages when API calls fail.
- Improved user interaction tests in `ParamsConfig` to ensure correct behavior during modal operations.
…etup

- Merged the `AnnotationCreateResponse` type with `AnnotationItem` for better structure.
- Updated test setup in `HeaderOptions` to use real timers for more accurate timing in tests.
…ssertions

- Removed unnecessary spies from the test setup for `ParamsConfig`.
- Enhanced user interaction tests to use `userEvent` for better simulation of user actions.
- Updated assertions to verify the correct behavior of modal operations, including saving and canceling changes.
…nfig tests

- Introduced mock implementations for Headless UI components to simplify testing in `ParamsConfig`.
- Enhanced test setup to improve the simulation of user interactions with modal dialogs and switches.
…tions tests

- Introduced mock implementations for Headless UI components to facilitate testing in `HeaderOptions`.
- Enhanced the test setup to better simulate user interactions with popovers and menus.
- Reduced the maximum number of workers for Jest to improve test stability.
- Updated the coverage table output to use HTML formatting for better readability.
- Added HTML escaping for coverage data to prevent rendering issues in the output.
- Increased the maximum number of workers for Jest to utilize available resources more effectively during test execution.
- Added assertions to verify that the edit mode remains open after save failures in the EditAnnotationModal tests.
- Updated the EditItem component to maintain edit mode when save operations encounter errors, ensuring a better user experience.
- Implemented tests to verify that the EditItem component remains in edit mode when save or delete actions fail.
- Updated the component to handle errors gracefully without throwing exceptions, improving user experience during error scenarios.
- Updated the EditItem component to ensure that the UI state remains unchanged when a delete action fails, allowing users to retry.
- Added assertions in the corresponding test to verify that the delete button and modified content are still visible after a failed delete operation.
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