Skip to content

Gallery block: Add wide align unit tests#2577

Merged
mukeshpanchal27 merged 5 commits into
fix/2449-equal-columnfrom
add/wide-align-unit-tests
Jul 18, 2026
Merged

Gallery block: Add wide align unit tests#2577
mukeshpanchal27 merged 5 commits into
fix/2449-equal-columnfrom
add/wide-align-unit-tests

Conversation

@mukeshpanchal27

Copy link
Copy Markdown
Member

Summary

Part of #2449

This PR add unit test for wide alignment for gallery block.

Use of AI Tools

N/A

@mukeshpanchal27 mukeshpanchal27 self-assigned this Jul 11, 2026
@mukeshpanchal27 mukeshpanchal27 added [Type] Enhancement A suggestion for improvement of an existing feature no milestone PRs that do not have a defined milestone for release [Plugin] Enhanced Responsive Images Issues for the Enhanced Responsive Images plugin (formerly Auto Sizes) labels Jul 11, 2026
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.50%. Comparing base (c5ac72f) to head (2af7005).

Additional details and impacted files
@@                    Coverage Diff                    @@
##           fix/2449-equal-column    #2577      +/-   ##
=========================================================
+ Coverage                  70.48%   70.50%   +0.01%     
=========================================================
  Files                         91       91              
  Lines                       7877     7882       +5     
=========================================================
+ Hits                        5552     5557       +5     
  Misses                      2325     2325              
Flag Coverage Δ
multisite 70.50% <100.00%> (+0.01%) ⬆️
single 35.85% <100.00%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

Comment on lines +127 to +134
/*
* When the wide alignment for the gallery, the child image blocks should also use the
* wide alignment if chile image block didn't set the alignment.
*/
$is_parent_gallery = $block->context['is_parent_aligned'] ?? false;
if ( $is_parent_gallery && '' === $alignment ) {
$alignment = $max_alignment;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Gallery wide alignment should use the Gallery block's alignment rather than the individual child image alignment when the Gallery block is set to wide.

This change fixes that issue.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the auto-sizes plugin’s Gallery handling by ensuring Gallery-wide alignment (specifically wide) is reflected in the sizes calculation for child core/image blocks, and it adds PHPUnit coverage to lock in the expected sizes output for wide-aligned galleries.

Changes:

  • Add a new render-context flag intended to let Gallery alignment influence child Image blocks’ alignment during sizes calculation.
  • Extend Gallery-related test data providers with wide alignment scenarios (automatic columns + explicit columns).
  • Update core/image block context usage to include the new context key.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
plugins/auto-sizes/includes/improve-calculate-sizes.php Adds context-based logic to inherit Gallery alignment for child Image blocks and registers a new context key for core/image.
plugins/auto-sizes/tests/test-improve-calculate-sizes.php Adds unit test cases validating sizes output for wide-aligned Gallery block layouts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/auto-sizes/includes/improve-calculate-sizes.php
Comment on lines +388 to +389
// If the gallery is aligned, we can assume that the child images are also aligned.
$context['is_parent_aligned'] = true;
Comment thread plugins/auto-sizes/tests/test-improve-calculate-sizes.php Outdated
Comment thread plugins/auto-sizes/tests/test-improve-calculate-sizes.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread plugins/auto-sizes/includes/improve-calculate-sizes.php
@mukeshpanchal27
mukeshpanchal27 marked this pull request as ready for review July 13, 2026 05:33
@github-actions

Copy link
Copy Markdown

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>

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

@mukeshpanchal27
mukeshpanchal27 merged commit a4f79e2 into fix/2449-equal-column Jul 18, 2026
25 checks passed
@mukeshpanchal27
mukeshpanchal27 deleted the add/wide-align-unit-tests branch July 18, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no milestone PRs that do not have a defined milestone for release [Plugin] Enhanced Responsive Images Issues for the Enhanced Responsive Images plugin (formerly Auto Sizes) [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants