-
Notifications
You must be signed in to change notification settings - Fork 480
fix: resolve Frontend Unit Tests CI timeout and cancellations #34196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resolve Frontend Unit Tests CI timeout and cancellations #34196
Conversation
…ction Minimal changes to identify root cause of 20min timeout: 1. Fix TypeScript compilation errors: - router.currentNavigation() -> getCurrentNavigation() - Prevents test compilation failures 2. Add leak detection: - Only --detectOpenHandles flag (no forceExit, no config changes) - Will show which tests are leaking resources This minimal approach lets us see the actual leak source without changing test execution environment or Jest configuration. Related: #34166
The issue was command line parsing, not the TypeScript fixes. Problem: Single quotes and -- separator were breaking argument parsing: yarn nx affected -t test --base=origin/main --exclude='tag:skip:test' -- --detectOpenHandles This was being parsed by Yarn as: nx affected --detectOpenHandles (missing all the other args!) Solution: Remove quotes and -- separator: yarn nx affected -t test --base=origin/main --exclude=tag:skip:test --detectOpenHandles Note: TypeScript API fixes (currentNavigation -> getCurrentNavigation) are REQUIRED and should NOT be backed out - those are real compilation errors. Related: #34166
Problem: --detectOpenHandles makes Jest wait forever for handles to close Solution: Add --forceExit so Jest reports what it detected and exits Together these flags: - --detectOpenHandles = detect leaking resources - --forceExit = force exit and SHOW the detections Without --forceExit, Jest hangs indefinitely waiting for handles to close. Related: #34166
Update all test mocks to use getCurrentNavigation() instead of currentNavigation(): - core-web/libs/data-access/src/lib/dot-router/dot-router.service.spec.ts - core-web/apps/dotcms-ui/src/app/view/components/dot-navigation/services/dot-navigation.service.spec.ts - core-web/apps/dotcms-ui/src/app/api/services/guards/ema-app/edit-page.guard.spec.ts This fixes the test failures caused by updating the Angular Router API. Related: #34166
|
@dotCMS/frontend i'm not so sure about these and would love your feedback
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR resolves CI timeout issues in Frontend Unit Tests by fixing deprecated TypeScript Router API usage and enhancing Jest configuration to detect and handle resource leaks. The changes address TypeScript compilation errors and Jest worker processes hanging after test execution.
Key Changes
- Fixed deprecated
router.currentNavigation()calls to use the correctrouter.getCurrentNavigation()API across production and test code - Updated Jest configuration to add
--detectOpenHandlesand--forceExitflags for better resource leak detection and forced cleanup - Updated all associated test mocks to match the corrected API signatures
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
core-web/pom.xml |
Added Jest flags (--detectOpenHandles, --forceExit) to identify resource leaks and force test completion |
core-web/libs/data-access/src/lib/dot-router/dot-router.service.ts |
Replaced deprecated currentNavigation() with getCurrentNavigation() in queryParams getter |
core-web/libs/data-access/src/lib/dot-router/dot-router.service.spec.ts |
Updated RouterMock to implement getCurrentNavigation() and updated test spy calls |
core-web/apps/dotcms-ui/src/app/view/components/dot-navigation/services/dot-navigation.service.spec.ts |
Renamed mock method from currentNavigation() to getCurrentNavigation() |
core-web/apps/dotcms-ui/src/app/api/services/guards/ema-app/edit-page.guard.ts |
Fixed guard to use getCurrentNavigation() for accessing navigation state |
core-web/apps/dotcms-ui/src/app/api/services/guards/ema-app/edit-page.guard.spec.ts |
Updated test mock to use getCurrentNavigation() |
consistency Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Fixes the recurring ~20 minute timeout issue in GitHub Actions Frontend Unit Tests.
Root Causes Identified
TypeScript API errors preventing test compilation
router.currentNavigation()instead ofgetCurrentNavigation()Jest worker processes not exiting gracefully
Changes
TypeScript API Fixes
router.currentNavigation()→router.getCurrentNavigation()dot-router.service.ts,edit-page.guard.tsTest Mock Updates
dot-router.service.spec.ts,dot-navigation.service.spec.ts,edit-page.guard.spec.tsJest Configuration (pom.xml)
--detectOpenHandlesto identify resource leaks--forceExitto force cleanup even with leaksTest Results
Before
After
Impact
Closes #34194
This PR fixes: #34194