Some checks are pending
Go Benchmark / Performance Regression Check (push) Waiting to run
Cerberus Integration / Cerberus Security Stack Integration (push) Waiting to run
Upload Coverage to Codecov / Backend Codecov Upload (push) Waiting to run
Upload Coverage to Codecov / Frontend Codecov Upload (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (go) (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (javascript-typescript) (push) Waiting to run
CrowdSec Integration / CrowdSec Bouncer Integration (push) Waiting to run
Docker Build, Publish & Test / build-and-push (push) Waiting to run
Docker Build, Publish & Test / Security Scan PR Image (push) Blocked by required conditions
Quality Checks / Auth Route Protection Contract (push) Waiting to run
Quality Checks / Codecov Trigger/Comment Parity Guard (push) Waiting to run
Quality Checks / Backend (Go) (push) Waiting to run
Quality Checks / Frontend (React) (push) Waiting to run
Rate Limit integration / Rate Limiting Integration (push) Waiting to run
Security Scan (PR) / Trivy Binary Scan (push) Waiting to run
Supply Chain Verification (PR) / Verify Supply Chain (push) Waiting to run
WAF integration / Coraza WAF Integration (push) Waiting to run
2.7 KiB
Executable File
2.7 KiB
Executable File
Frontend Test Hang Fix
Problem
Frontend tests took 1972 seconds (33 minutes) instead of the expected 2-3 minutes.
Root Cause
- Missing
frontend/src/setupTests.tsfile that was referenced in vite.config.ts - No test timeout configuration in Vitest
- Outdated backend tests referencing non-existent functions
Solutions Applied
1. Created Missing Setup File
File: frontend/src/setupTests.ts
import '@testing-library/jest-dom'
// Setup for vitest testing environment
2. Added Test Timeouts
File: frontend/vite.config.ts
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/setupTests.ts',
testTimeout: 10000, // 10 seconds max per test
hookTimeout: 10000, // 10 seconds for beforeEach/afterEach
coverage: { /* ... */ }
}
3. Fixed Backend Test Issues
-
Fixed:
backend/internal/api/handlers/dns_provider_handler_test.go- Updated
MockDNSProviderService.GetProviderCredentialFieldssignature to match interface - Changed from
(required, optional []dnsprovider.CredentialFieldSpec, err error)to([]dnsprovider.CredentialFieldSpec, error)
- Updated
-
Removed: Outdated test files and functions:
backend/internal/services/plugin_loader_test.go(referenced non-existentNewPluginLoader)TestValidateCredentials_AllRequiredFields(referenced non-existentProviderCredentialFields)TestValidateCredentials_MissingEachField(referenced non-existent constants)TestSupportedProviderTypes(referenced non-existentSupportedProviderTypes)
Results
Before Fix
- Frontend tests: 1972 seconds (33 minutes)
- Status: Hanging, eventually passing
After Fix
- Frontend tests: 88 seconds (1.5 minutes) ✅
- Speed improvement: 22x faster
- Status: Passing reliably
QA Suite Status
All QA checks now passing:
- ✅ Backend coverage: 85.1% (threshold: 85%)
- ✅ Frontend coverage: 85.31% (threshold: 85%)
- ✅ TypeScript check: Passed
- ✅ Pre-commit hooks: Passed
- ✅ Go vet: Passed
- ✅ CodeQL scans (Go + JS): Completed
Prevention
To prevent similar issues in the future:
- Always create setup files referenced in config before running tests
- Set reasonable test timeouts to catch hanging tests early
- Keep tests in sync with code - remove/update tests when refactoring
- Run
go vetlocally before committing to catch type mismatches
Files Modified
/frontend/src/setupTests.ts(created)/frontend/vite.config.ts(added timeouts)/backend/internal/api/handlers/dns_provider_handler_test.go(fixed mock signature)/backend/internal/services/plugin_loader_test.go(deleted)/backend/internal/services/dns_provider_service_test.go(removed outdated tests)