test: add comprehensive widget tests to achieve 80% coverage (ISMS compliance)#665
Conversation
….71% Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull Request Overview
This PR adds 29 test cases to improve widget test coverage for ISMS compliance requirements (§4.1), achieving 81.54% statement coverage and 73.77% branch coverage. The tests target the CostEstimationWidget and BusinessImpactAnalysisWidget components.
Key Changes:
- Added 21 tests for CostEstimationWidget covering branch coverage, expertise requirements, FTE calculations, and edge cases
- Added 8 tests for BusinessImpactAnalysisWidget covering security level variations and content validation
- Tests organized into logical describe blocks by functionality (Branch Coverage, Expertise Required, FTE Requirements, etc.)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/components/widgets/businessvalue/CostEstimationWidget.test.tsx | Added 21 new test cases covering CAPEX/OPEX ratios, complexity percentages, expertise requirements, FTE calculations, component breakdowns, accessibility, and edge cases |
| src/components/widgets/assessmentcenter/BusinessImpactAnalysisWidget.test.tsx | Added 8 new test cases covering Very High/None/Low security levels, asymmetric combinations, className prop handling, and CIA component content validation |
Note: While the tests improve coverage metrics, many assertions are overly generic (e.g., checking for word presence rather than validating specific calculated values). The tests verify that components render without crashing but don't always validate the correctness of the business logic being tested. Consider strengthening assertions to verify actual computed values (percentages, ratios, FTE numbers) match expected results for more robust test coverage.
Pull Request Description
Enhanced widget test coverage to meet ISMS Secure Development Policy requirements (§4.1) for v1.0 release. Added 29 focused test cases targeting branch coverage gaps and edge cases across critical widgets.
Coverage achieved:
Type of Change
Component(s) Modified
CIA Impact Area
Security Level Impact
Test Coverage Impact
Testing Performed
CostEstimationWidget (+21 tests, 43 total)
BusinessImpactAnalysisWidget (+8 tests, 18 total)
Test patterns:
Screenshots/Examples
N/A - Test coverage improvements only
Related Issues
Closes #298
Checklist
Additional Notes
Test suite health:
vitest.config.ts(lines 115-120)ISMS compliance verified:
Original prompt
This section details on the original issue you should resolve
<issue_title>🧪 Add comprehensive widget component tests to reach 80% coverage</issue_title>
<issue_description>## 🤖 Recommended Agent: @typescript-react-agent
🎯 Objective
Add comprehensive unit tests for all widget components to reach and maintain 80% test coverage target as required by ISMS Secure Development Policy for v1.0 release.
📋 Background
The ISMS Secure Development Policy (§4.1) requires minimum 80% line coverage and 70% branch coverage for all projects. Current test coverage: 75.06% statements / 64.9% branches. Widget components are critical user-facing elements that require thorough testing to ensure reliability and prevent regressions.
📊 Current State (Measured Metrics)
Current Coverage:
Widget Test Status:
Testing Gaps:
Low Coverage Widget Files (Priority):
CostEstimationWidget.tsx: ~65% coverage - missing edge case tests✅ Acceptance Criteria
🛠️ Implementation Guidance for @typescript-react-agent
Agent-Specific Instructions:
✅ Use Vitest + React Testing Library for all widget tests
✅ Follow existing test patterns from well-tested widgets
✅ Use test IDs from
src/constants/testIds.tsfor element selection✅ Mock services from
src/services/appropriately✅ Test TypeScript types are correct for props and state
Testing Pattern Template: