Skip to content

Conversation

@im3dabasia
Copy link
Contributor

@im3dabasia im3dabasia commented Feb 20, 2025

What?

This PR introduces unit tests for the DuotonePicker Component

Related comment: #48353 (comment)
Related issues: #48347, #48346

Why?

Adding these tests ensures that the components render correctly and behave as expected when interacting with the duotone color options. This improves confidence in the component functionality and helps catch regressions.

How?

  • Added tests for DuotonePicker to check:
    - Rendering of duotone options.
    - Proper handling of onChange when selecting and clearing duotone values.

Testing Instruction

Confirm tests pass.

npm run test:unit packages/components/src/duotone-picker/test/duotone-picker.tsx 

Screenshots

image

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Package] Components /packages/components labels Feb 20, 2025
@im3dabasia im3dabasia marked this pull request as ready for review February 21, 2025 16:10
@github-actions
Copy link

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: im3dabasia <im3dabasia1@git.wordpress.org>

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

@im3dabasia im3dabasia marked this pull request as draft February 21, 2025 16:27
@im3dabasia im3dabasia closed this Jun 3, 2025
@im3dabasia im3dabasia deleted the fix/add-tests-for-duotone-picker branch June 3, 2025 08:59
@im3dabasia im3dabasia restored the fix/add-tests-for-duotone-picker branch June 3, 2025 09:01
@im3dabasia im3dabasia reopened this Jun 3, 2025
@im3dabasia im3dabasia marked this pull request as ready for review June 3, 2025 10:38
@im3dabasia
Copy link
Contributor Author

Hi @t-hamano ,

When you have a moment, Please review my work in this PR.

Looking forward to your feedback

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Adding unit tests would be great, but here are some suggestions.

  • We might also need unit tests for the DuotoneSwatch component.
  • This component is based on the CircularOptionPicker component, but it would be nice to have some tests specific to the DuotonePicker component. For example:
    • should not render the unset option when the `unsetable` prop is false
    • should not render the custom duotone bar when the `disableCustomDuotone` prop or `disableCustomColors` prop is true


await user.click( unsetOption );

expect( handleChange ).toHaveBeenCalledWith( 'unset' );
Copy link
Contributor

Choose a reason for hiding this comment

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

This contradicts the test title. Because the test title mentions that onChange should be called with undefined.

@t-hamano t-hamano requested a review from a team June 9, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants