-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Improve the performance of the marketplace tests #14935
Conversation
Nice, I'll take it for a spin on Monday before approving.
Awesome! good thinking. Do you think we need the snapshots for plugins and providers? Maybe we could just remove them and take one snapshot in the index.test.js edit: don't think it makes a difference for performance, but it's a bit redundant isn't it? |
Codecov ReportBase: 59.79% // Head: 59.79% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## market-pagination/pages #14935 +/- ##
========================================================
Coverage 59.79% 59.79%
========================================================
Files 1340 1340
Lines 32689 32689
Branches 6196 6196
========================================================
Hits 19546 19546
Misses 11296 11296
Partials 1847 1847
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I agree with you about the snapshots @markkaylor, I added a commit to only keep the one from |
edit: just realized this PR isn't targeting main |
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 am a little late to review this, but this is very great PR 😮, I also learned some things and so tried to suggest some changes.
packages/core/admin/admin/src/pages/MarketplacePage/tests/plugins.test.js
Show resolved
Hide resolved
await user.click(filtersButton); | ||
|
||
const categoriesButton = screen.getByTestId('Categories-button'); | ||
await user.click(categoriesButton); | ||
|
||
const option = screen.getByRole('option', { name: `Custom fields (4)` }); | ||
await user.click(option); | ||
|
||
await waitForReload(); | ||
|
||
const optionTag = screen.getByRole('button', { name: 'Custom fields' }); |
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.
const optionTag = screen.getByText('Custom fields');
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.
Unfortunately that's not precise enough because of the made by strapi icons on the plugin cards
What does it do?
Improve the performance of the marketplace tests:
Render the provider tab directly
For provider tests, before every test, the app would render on the default plugins tab, wait for it to load, find the providers tab, click on it and wait to load again. I added a query param so that it renders the right tab directly and only loads once. It saved 10 seconds.
Remove the artificial msw delay
It turns out that even without a delay, the 1st render will still be a loading screen if the request is not cached by react-query. So I removed these
Speed up
waitForReload
Mark identified that getByRole was slow, so I removed it there, since that function is called many times in the tests
Use
findBy
queriesWhen we want to check something on screen after the application reloads, I found that it was slightly faster to use
findBy
rather than the combination ofwaitForReload
andgetBy
. I assume it's because the latter requires selecting the page header in addition to what we actually want.The exception I found was
byRole
queries. Since usingfindBy
, the queries get re-ran until they find something, having a slow query in there makes things much worse. So I never usedfindByRole
but instead a combination ofwaitForReload
andgetByRole
, so thatbyRole
only runs once.Only keep one snapshot test
We had snapshots in
index.test.js
,plugins.test.ts
andproviders.test.js
. As suggested by Mark I only kept the index one as the others seem redundantUse
within
to scope queriesI don't know if this actually makes a difference in terms of perf. But
within
seems to be the preferred way to query things inside a particular element. Also it avoids having to import all the selectors at the top of the files.What this doesn't do
At first I wanted to also stop clearing the react-query cache between each test, but it's actually recommended by the library author.
I had also found comments saying that passing
{ hidden: false }
would makebyRole
faster. In my testing it was actually slower.