Skip to content

Query block enhanced pagination: Simplify test setup#55805

Merged
DAreRodz merged 1 commit intotrunkfrom
update/query-block-enhanced-pagination-tests
Nov 2, 2023
Merged

Query block enhanced pagination: Simplify test setup#55805
DAreRodz merged 1 commit intotrunkfrom
update/query-block-enhanced-pagination-tests

Conversation

@DAreRodz
Copy link
Copy Markdown
Contributor

@DAreRodz DAreRodz commented Nov 2, 2023

What?

Follow-up of #55714.

This PR improves how the Query block tests for the enhanced pagination are initialized.

Why?

To make tests a little bit more performant and straightforward.

How?

Using wpSetUpBeforeClass() and $factory->post->create_many() as suggested in this discussion.

Testing Instructions

N/A

@DAreRodz DAreRodz added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Block] Query Loop Affects the Query Loop Block labels Nov 2, 2023
@DAreRodz DAreRodz self-assigned this Nov 2, 2023
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 2, 2023

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ phpunit/blocks/render-query-test.php

@gziolo
Copy link
Copy Markdown
Member

gziolo commented Nov 2, 2023

I wasn't aware that you could use wpSetUpBeforeClass and wpTearDownAfterClass. It's covered in the docs at https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#slow-fixtures.

It is an abstraction integrated with set_up_before_class and tear_down_after_class which I usually see used instead.

Thank you for working on this enhancement!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 2, 2023

Flaky tests detected in 48732cb.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6732737583
📝 Reported issues:

@DAreRodz DAreRodz merged commit 6266974 into trunk Nov 2, 2023
@DAreRodz DAreRodz deleted the update/query-block-enhanced-pagination-tests branch November 2, 2023 13:49
@github-actions github-actions bot added this to the Gutenberg 17.1 milestone Nov 2, 2023
@getdave
Copy link
Copy Markdown
Contributor

getdave commented Jan 25, 2024

Reviewing this one it appears the test files are within phpunit/blocks which don't require backporting to WP Core.

✅ I updated the PHP Sync Tracking Issue for WP 6.5 to note this PR does not require a backport for WP 6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Query Loop Affects the Query Loop Block [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants