Skip to content

Conversation

@priethor
Copy link
Contributor

@priethor priethor commented Dec 30, 2025

What

Part of #315.

Expands JavaScript unit test coverage for the block bindings module (assets/src/js/bindings/).

Why

Block bindings enable connecting SCF fields to WordPress block attributes. These utilities handle field processing, metadata caching, editor context detection, and binding source registration. Tests ensure the binding system works correctly across post and site editors.

How

Adding 70 tests covering:

New test files:

  • block-editor.test.js - HOC filter registration and module setup
  • constants.test.js - BLOCK_BINDINGS_CONFIG structure and field type mappings

Expanded test files:

  • field-processing.test.js - All field types with parameterized tests, full branch coverage
  • hooks.test.js - Cleanup/cancellation, null handling, template edge cases
  • sources.test.js - canUserEditValue, registration validation, edge cases

Note: block-editor.js has low coverage because the HOC requires a full React rendering environment with WordPress data stores.

Testing Instructions

Run the test suite: npm run test:unit -- --testPathPattern="tests/js/bindings"

@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props priethor.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@priethor priethor mentioned this pull request Dec 30, 2025
22 tasks
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.20%. Comparing base (402b2cc) to head (63020ae).
⚠️ Report is 1 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #330      +/-   ##
============================================
+ Coverage     21.19%   21.20%   +0.01%     
  Complexity     4410     4410              
============================================
  Files           291      291              
  Lines         36940    36940              
============================================
+ Hits           7828     7832       +4     
+ Misses        29112    29108       -4     
Flag Coverage Δ
e2e 28.87% <ø> (ø)
javascript 2.57% <ø> (+0.06%) ⬆️
phpunit 21.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@priethor priethor force-pushed the c3bd-phase-3-pr-17-fi branch 3 times, most recently from 668c891 to ae6d928 Compare December 30, 2025 13:13
Add comprehensive test coverage for the block bindings module:

- Create block-editor.test.js with 19 tests for HOC filter registration
- Create constants.test.js with 43 tests for BLOCK_BINDINGS_CONFIG
- Expand field-processing.test.js with edge cases for all field types
- Expand hooks.test.js with cleanup, cancellation, and null handling
- Expand sources.test.js with canUserEditValue and registration tests

Total bindings tests: 224 (up from 111)
Coverage: 82.42% statements, 79.87% branches
@priethor priethor force-pushed the c3bd-phase-3-pr-17-fi branch from ae6d928 to 63020ae Compare December 30, 2025 13:17
@priethor priethor self-assigned this Dec 30, 2025
@priethor priethor added this to the 6.9.0 milestone Dec 30, 2025
@priethor priethor merged commit e77257e into trunk Dec 30, 2025
9 checks passed
@priethor priethor deleted the c3bd-phase-3-pr-17-fi branch December 30, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants