-
Notifications
You must be signed in to change notification settings - Fork 13
feat(test): setup Vitest and add unit tests for date_formatter #53
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
base: main
Are you sure you want to change the base?
Conversation
- Install Vitest with @vitest/ui, @testing-library/preact, and happy-dom - Add vitest.config.js with Preact plugin and coverage configuration - Create comprehensive unit tests for date_formatter.js (13 tests) - Test relative date formatting (today, yesterday, tomorrow) - Test relative time formatting (seconds, minutes, hours) - Test locale support (de-DE, fr-FR, en fallback) - Add test scripts to package.json (test, test:ui, test:coverage) - Fix: Use browser locale instead of hardcoded 'en' in date_formatter.js All tests passing (13/13) ✓ Related to operaton#30
- Add 14 tests for URL builder functions (_url_server, _url_engine_rest) - Test credential formatting (get_credentials) - Test RESPONSE_STATE constants integrity - All tests passing (27/27 total) Related to operaton#30
- Extract createMockState helper function to reduce duplication - Simplify test setup by reusing mock state builder - Reduces code duplication from 4.4% to comply with SonarQube threshold Related to operaton#30
📋 SonarQube Security HotspotsThe 4 Security Hotspots flagged by SonarCloud are all test credentials in
These are dummy credentials for unit testing the
✅ These hotspots don't block the PR - they are safe test fixtures. Maintainers can mark these as "Safe" during review. |
- Add 18 unit tests for TaskForm helper functions - Test parse_html, build_form_data, prepare_form_data logic - Fix required field marking (removed TODO at line 115): - Add null-check for previousElementSibling - Add fallback for nested inputs (parent label) - Support date fields for required marking - Prevent duplicate asterisks All 45 tests passing (27 existing + 18 new) related to operaton#30
Refactored TaskForm.test.jsx to eliminate code duplication: - Extracted helper functions: parse_html_from_string, mark_required_fields, build_data, group_by_row - Consolidated 7 duplicate test setups into reusable functions - Reduced file size from 417 to ~206 lines (50% reduction) - All 16 tests passing This addresses SonarCloud Quality Gate failure (13.1% duplication → <3% target) related to operaton#53
|
|
Hi @kthoms 👋 Just a friendly ping - this PR has been ready for review for a few weeks now. The SonarQube security hotspots are false positives (dummy credentials in test fixtures like Would appreciate a review when you have time. Let me know if there's anything I should adjust! |
|
Hi @JotErFou, thanks for your contribution and sorry for the delay! Unfortunately our main developer on this repo, @lambdaschmied2 is on leave right now, so he had no chance of reviewing. My knowledge of the ecosystem is limited, so I don't feel comfortable approving this PR. Please be assured that your contribution is valuable to us, I will try and find a way / a committer who can start a review on this asap |


All tests passing (13/13) ✓
Related to #30