Skip to content

t465: test(form-manager): improve Form_Manager test coverage to ≥60%#566

Merged
superdav42 merged 3 commits into
mainfrom
feature/t465-form-manager-coverage
Mar 27, 2026
Merged

t465: test(form-manager): improve Form_Manager test coverage to ≥60%#566
superdav42 merged 3 commits into
mainfrom
feature/t465-form-manager-coverage

Conversation

@superdav42

Copy link
Copy Markdown
Collaborator

Summary

  • Add 3 new tests covering previously untested code paths in Form_Manager
  • test_security_checks_dies_for_non_ajax_request: covers the wp_die(0) path in security_checks() when HTTP_X_REQUESTED_WITH is absent
  • test_security_checks_passes_for_valid_ajax_request: covers the pass-through path in security_checks() with valid AJAX context, registered form, and capable user
  • test_default_bulk_action_handler_sends_error_when_process_fails: covers the wp_send_json_error() path in default_bulk_action_handler() when process_bulk_action() returns WP_Error (nonexistent model)

Coverage Results

Metric Before After Target
Methods 56.25% (9/16) 62.50% (10/16) ≥60% ✓
Lines 79.06% (219/277) 81.23% (225/277) ≥60% ✓
Tests 40 43
Assertions 89 94

Note on remaining uncovered methods

display_form_unavailable(), display_form(), and handle_form() all terminate with bare die/exit (not wp_die()), making them untestable without process isolation. These are documented in the test file comments.

Runtime Testing

  • Testing level: unit-tested
  • Risk classification: Low (test files only, no production code modified)
  • Dev environment: local WordPress test suite
  • All 43 Form_Manager tests pass: OK (43 tests, 94 assertions)

Closes #559

- Add test_security_checks_dies_for_non_ajax_request: covers the
  wp_die(0) path in security_checks() when HTTP_X_REQUESTED_WITH
  is absent (non-AJAX request). Uses wp_die_handler filter to
  intercept WPDieException instead of process termination.
- Add test_security_checks_passes_for_valid_ajax_request: covers
  the pass-through path when AJAX context + valid form + capable user.
- Add test_default_bulk_action_handler_sends_error_when_process_fails:
  covers the wp_send_json_error() path in default_bulk_action_handler()
  when process_bulk_action() returns WP_Error (nonexistent model).

Coverage: 56.25% → 62.50% methods, 79.06% → 81.23% lines (≥60% target met)
Tests: 40 → 43, Assertions: 89 → 94

Closes #559
@coderabbitai

coderabbitai Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 6 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 22 minutes and 6 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 786d7f8c-f74b-4096-abe8-f6e00640b753

📥 Commits

Reviewing files that changed from the base of the PR and between 29296ac and ab6ef74.

📒 Files selected for processing (2)
  • TODO.md
  • tests/WP_Ultimo/Managers/Form_Manager_Test.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/t465-form-manager-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions

Copy link
Copy Markdown

Performance Test Results

Performance test results for 49ab9df are in 🛎️!

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 57 36.39 MB 306.00 ms 109.00 ms 415.50 ms 513.55 ms 429.90 ms 82.65 ms
1 57 36.39 MB 300.00 ms 105.00 ms 405.00 ms 500.30 ms 418.35 ms 82.20 ms

@superdav42 superdav42 merged commit d8aaac6 into main Mar 27, 2026
12 checks passed
@superdav42 superdav42 deleted the feature/t465-form-manager-coverage branch March 27, 2026 19:25
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.

test(form-manager): improve Form_Manager test coverage

1 participant