CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Automated testing: Add taxonomy pagination tests #71584
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
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: 0 B Total Size: 1.94 MB βΉοΈ View Unchanged
|
Flaky tests detected in a5b2222. π Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17617673090
|
apiFetch.mockReset(); | ||
} ); | ||
|
||
it( 'should add supportsPagination: true to taxonomy entities', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a test for this. The supportsPagination
is a "static" value; as long as taxonomies load from the server, it will be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the value in this test is to make sure no one deletes the prop by accident! π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, the reason to test the configuration is that I spent a lot of time trying to understand why taxonomies didn't explicitly support pagination, whether it was an oversight or there was a specific reason. Testing it makes it explicit, but I don't feel too strongly, we have the original PR as history/context.
const resolveSelect = { | ||
getEntitiesConfig: jest | ||
.fn() | ||
.mockResolvedValue( loadedTaxonomyEntities ), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just mock the full return value here, instead of running loadEntities
in setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something like
const resolveSelect = {
getEntitiesConfig: jest.fn().mockResolvedValue( [
{
baseURL: '/wp/v2/categories',
baseURLParams: { context: 'edit' },
kind: 'taxonomy',
name: 'category',
supportsPagination: true,
},
] ),
};
Depends on what we're testing. If the "unit" is testing the getEntityRecord's resolver's pagination logic (&per_page=2&page=1
), then yeah that makes sense to me in terms of test isolation and clearer intent.
There's less integration coverage, by which I mean, we're not testing the full flow from entity loading to pagination, but is that the intent of the test?
If not, then entity loading could have its own separate tests later on. I see this PR has already started in entities.js.
Another reason to isolate is if the entity loading logic ever has bugs, it could affect these tests. Pretty edge case. No blocker though from me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're just testing getEntityRecord's pagination logic, and not entity loading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow; if we mock the entity config and set supportsPagination: true
, we will not be testing that taxonomies are indeed paginated after #71302. We would test that pagination works when setting supportsPagination
to true, but not verify that the settings are correct. π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test coverage!!
LGTM after feedback is resolved ππ»
I'm happy to adjust either part of the feedback, but I feel adjusting both (removing the static check of Would it make more sense to move this test out of the resolver test suite, and mark it as a specific integration test for taxonomies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comments aren't blocker. The tests look good, so let's merge them.
P.S. I plan to introduce integration tests for the core-data
package, and then it might be better to migrate the pagination-related tests there.
What?
Follow up to #71302, add tests for taxonomy pagination functionality.
Why?
To prevent future regressions.
How?
entities.js
: VerifiesloadTaxonomyEntities()
addssupportsPagination: true
to taxonomy entitiesesolvers.js
: Verifies pagination behavior by testing API calls useparse: false
and, most importantly, extract pagination metadata from headers, which were being discarded.Testing Instructions
The tests introduced in this PR can be run with:
supportsPagination: true
fromloadTaxonomyEntities
inpackages/core-data/src/entities.js
supportsPagination: true