Skip to content
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

Slideshow: Add unit tests and fixtures to validate block content parsing #18967

Merged
merged 8 commits into from
Mar 9, 2021

Conversation

glendaviesnz
Copy link
Contributor

@glendaviesnz glendaviesnz commented Mar 2, 2021

Changes proposed in this Pull Request:

  • Adds basic unit tests and block fixture parsing tests to the Slideshow block which currently has no test coverage.

Jetpack product discussion

See p1HpG7-b3G-p2

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  • Check out the PR and check that insertion of Slideshow block still works as expected along with all setting of config via toolbar and side panel
  • Run yarn jest extensions/blocks/slideshow/test/controls.js & yarn jest extensions/blocks/slideshow/test/edit.js & yarn jest extensions/blocks/slideshow/test/validate.js in jetpack dir and make sure they all pass

Proposed changelog entry for your changes:

  • No changelog entry needed

@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello glendaviesnz! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D57874-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Mar 2, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2021

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Include a changelog entry for any meaningful change.
  • ✅ Specify whether this PR includes any changes to data or privacy.

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


If you are an automattician, once your PR is ready for review add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.undefined


jetpack plugin:

  • Next scheduled release: April 6, 2021.
  • Scheduled code freeze: March 29, 2021

@glendaviesnz glendaviesnz marked this pull request as ready for review March 2, 2021 22:35
stacimc
stacimc previously approved these changes Mar 3, 2021
Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

I ran the tests locally and all passed, and also manually tested the Slideshow block on a sandbox and a local Jetpack install.

I did notice an Each child in a list should have a unique "key" prop. error in the console in my local env for the Slideshow, but that was not caused by this PR. From a quick glance I'm not sure why it's complaining - maybe worth following up later?

LGTM

@glendaviesnz
Copy link
Contributor Author

I did notice an Each child in a list should have a unique "key" prop. error in the console in my local env for the Slideshow

I just added a quick fix for this - was happening when files were uploaded so didn't yet have an id, so now uses the blob url as a key in these cases.

stacimc
stacimc previously approved these changes Mar 3, 2021
Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

Even better -- re-tested with the fix and it looks good to me, no more console errors. Thanks!

@glendaviesnz glendaviesnz added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Team Review labels Mar 3, 2021
@jeherve jeherve added this to the 9.6 milestone Mar 4, 2021
<BlockControls>
{ !! images.length && (
<ToolbarGroup>
<ToolbarItem>
Copy link
Member

Choose a reason for hiding this comment

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

I see you've removed ToolbarItem. I added it in #18860 to address these changes:
https://make.wordpress.org/core/2020/11/18/changes-to-toolbar-components-in-wordpress-5-6/

Do you think we should get rid of it, or can we keep it here?

Copy link
Contributor Author

@glendaviesnz glendaviesnz Mar 4, 2021

Choose a reason for hiding this comment

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

My mistake here. When running through Jest ToolbarItem was erroring as undefined and I read some out-of-date docs which seemed to indicate it isn't needed. You are correct though that it should be there.

I have added it back and the reason it shows as undefined in jest tests is because the @wordpress/components dependency in the jetpack project is 9.2.6 which still as ToolbarItem as __experimentalToolbarItem.

I assume that the build process is pulling in a newer dependency somehow via the webpack '@automattic/calypso-build/webpack.config.js'. I tried forcing a newer version of @wordpress/components in package.json but this made things more broken. @brbrr, do you have any ideas on how to get jest using the same dependency tree for the @wordpress dependencies as the webpack builds? If you run yarn jest extensions/blocks/slideshow/test/controls.js on this PR you will get the error about ToolbarItem being undefined which doesn't happen on the webpack build.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, I ran into the same issue in #18860, but had forgotten about it :/

I had tried to update our dependencies, but was running into other issues; I ended up reverting:
b91bb2a

We'll need to merge #16763 before we can do anything. Until then, maybe we can remove ToolbarItem like you had done, with a note like the one I left in b91bb2a ?

Unless @brbrr has a better idea :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point I have just removed the single test for the toolbar, which was only doing a very basic 'did it render' sort of test, so not critical, and have added a comment in the spec file to indicate why there is no test for this component.

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Mar 4, 2021
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Mar 8, 2021
@glendaviesnz glendaviesnz merged commit 10e29c5 into master Mar 9, 2021
@glendaviesnz glendaviesnz deleted the add/slideshow-tests branch March 9, 2021 01:33
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Mar 9, 2021
@glendaviesnz
Copy link
Contributor Author

block build job currently broken on wpcom so will merge diff next week

@glendaviesnz
Copy link
Contributor Author

diff deployed rWP222707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Slideshow [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants