-
Notifications
You must be signed in to change notification settings - Fork 797
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
Button block: Add tests #19002
Button block: Add tests #19002
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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 🤖 Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
9beeb31
to
4a57880
Compare
} ); | ||
|
||
test( 'applies gradient color class and style to the button', () => { | ||
__experimentalUseGradient.mockReturnValueOnce = gradientProps; |
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.
As per the Slack thread, try
__experimentalUseGradient.mockImplementation( () => gradientProps );
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.
Works for me, nice!
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.
This seems to generate block validation errors when editing posts with Subscriptions blocks:
Click to expand!
Block validation: Block validation failed for `jetpack/subscriptions` (
{
"name": "jetpack/subscriptions",
"icon": {
"src": {
"key": null,
"ref": null,
"props": {
"width": "24",
"height": "24",
"viewBox": "0 0 24 24",
"fill": "none",
"xmlns": "http://www.w3.org/2000/svg",
"children": [
{
"key": null,
"ref": null,
"props": {
"x": "4.75",
"y": "6.75",
"width": "14.5",
"height": "10.5",
"rx": "1.25",
"stroke": "#069e08",
"strokeWidth": "1.5",
"fill": "none"
},
"_owner": null
},
{
"key": null,
"ref": null,
"props": {
"d": "M19 7L13.3609 12.2363C12.5935 12.9489 11.4065 12.9489 10.6391 12.2363L5 7",
"stroke": "#069e08",
"strokeWidth": "1.5",
"strokeLinejoin": "bevel",
"fill": "none"
},
"_owner": null
}
]
},
"_owner": null
},
"foreground": "#069e08"
},
"keywords": [
"subscribe",
"join",
"follow"
],
"providesContext": {},
"usesContext": [],
"styles": [],
"title": "Subscription Form",
"description": {
"type": "p",
"key": null,
"ref": null,
"props": {
"children": "A form enabling readers to get notifications when new posts are published from this site."
},
"_owner": null
},
"category": "grow",
"example": {
"attributes": {}
},
"deprecated": [
{
"attributes": {
"subscribeButton": {
"type": "string",
"default": "Subscribe"
},
"showSubscribersTotal": {
"type": "boolean",
"default": false
},
"className": {
"type": "string"
}
}
},
{
"attributes": {
"subscribePlaceholder": {
"type": "string",
"default": "Email Address"
},
"subscribeButton": {
"type": "string",
"default": "Subscribe"
},
"showSubscribersTotal": {
"type": "boolean",
"default": false
},
"submitButtonText": {
"type": "string",
"default": "Subscribe"
},
"backgroundButtonColor": {
"type": "string"
},
"textButtonColor": {
"type": "string"
},
"customBackgroundButtonColor": {
"type": "string"
},
"customTextButtonColor": {
"type": "string"
},
"submitButtonClasses": {
"type": "string"
},
"className": {
"type": "string"
}
}
},
{
"attributes": {
"subscribePlaceholder": {
"type": "string",
"default": "Enter your email address"
},
"showSubscribersTotal": {
"type": "boolean",
"default": false
},
"buttonOnNewLine": {
"type": "boolean",
"default": false
},
"submitButtonText": {
"type": "string",
"default": "Sign Up"
},
"emailFieldBackgroundColor": {
"type": "string"
},
"customEmailFieldBackgroundColor": {
"type": "string"
},
"emailFieldGradient": {
"type": "string"
},
"customEmailFieldGradient": {
"type": "string"
},
"buttonBackgroundColor": {
"type": "string"
},
"customButtonBackgroundColor": {
"type": "string"
},
"buttonGradient": {
"type": "string"
},
"customButtonGradient": {
"type": "string"
},
"textColor": {
"type": "string"
},
"customTextColor": {
"type": "string"
},
"fontSize": {
"type": "number"
},
"customFontSize": {
"type": "number"
},
"borderRadius": {
"type": "number"
},
"borderWeight": {
"type": "number"
},
"borderColor": {
"type": "string"
},
"customBorderColor": {
"type": "string"
},
"padding": {
"type": "number"
},
"spacing": {
"type": "number"
},
"className": {
"type": "string"
}
}
},
{
"attributes": {
"subscribePlaceholder": {
"type": "string",
"default": "Enter your email address"
},
"showSubscribersTotal": {
"type": "boolean",
"default": false
},
"buttonOnNewLine": {
"type": "boolean",
"default": false
},
"submitButtonText": {
"type": "string",
"default": "Sign Up"
},
"emailFieldBackgroundColor": {
"type": "string"
},
"customEmailFieldBackgroundColor": {
"type": "string"
},
"emailFieldGradient": {
"type": "string"
},
"customEmailFieldGradient": {
"type": "string"
},
"buttonBackgroundColor": {
"type": "string"
},
"customButtonBackgroundColor": {
"type": "string"
},
"buttonGradient": {
"type": "string"
},
"customButtonGradient": {
"type": "string"
},
"textColor": {
"type": "string"
},
"customTextColor": {
"type": "string"
},
"fontSize": {
"type": "number"
},
"customFontSize": {
"type": "number"
},
"borderRadius": {
"type": "number"
},
"borderWeight": {
"type": "number"
},
"borderColor": {
"type": "string"
},
"customBorderColor": {
"type": "string"
},
"padding": {
"type": "number"
},
"spacing": {
"type": "number"
},
"className": {
"type": "string"
}
}
}
],
"attributes": {
"subscribePlaceholder": {
"type": "string",
"default": "Enter your email address"
},
"showSubscribersTotal": {
"type": "boolean",
"default": false
},
"buttonOnNewLine": {
"type": "boolean",
"default": false
},
"submitButtonText": {
"type": "string",
"default": "Sign Up"
},
"emailFieldBackgroundColor": {
"type": "string"
},
"customEmailFieldBackgroundColor": {
"type": "string"
},
"emailFieldGradient": {
"type": "string"
},
"customEmailFieldGradient": {
"type": "string"
},
"buttonBackgroundColor": {
"type": "string"
},
"customButtonBackgroundColor": {
"type": "string"
},
"buttonGradient": {
"type": "string"
},
"customButtonGradient": {
"type": "string"
},
"textColor": {
"type": "string"
},
"customTextColor": {
"type": "string"
},
"fontSize": {
"type": "number"
},
"customFontSize": {
"type": "number"
},
"borderRadius": {
"type": "number"
},
"borderWeight": {
"type": "number"
},
"borderColor": {
"type": "string"
},
"customBorderColor": {
"type": "string"
},
"padding": {
"type": "number"
},
"spacing": {
"type": "number"
},
"className": {
"type": "string"
}
}
}
Content generated by `save` function:
<div class="wp-block-jetpack-subscriptions wp-block-jetpack-subscriptions__supports-newline wp-block-jetpack-subscriptions__use-newline">
[jetpack_subscription_form
subscribe_placeholder="Enter your email address"
show_subscribers_total="false"
button_on_newline="true"
submit_button_text="<strong>Sign up</strong> to receive emails of all my future posts"
custom_background_emailfield_color="undefined"
custom_background_button_color="undefined"
custom_text_button_color="undefined"
custom_font_size="16"
custom_border_radius="0"
custom_border_weight="3"
custom_border_color="#e22658"
custom_padding="15"
custom_spacing="10"
submit_button_classes="has-e-22658-border-color has-text-color has-accent-color has-background has-subtle-background-background-color"
email_field_classes="has-e-22658-border-color"
show_only_email_and_button="true"
]</div>
Content retrieved from post body:
<div class="wp-block-jetpack-subscriptions wp-block-jetpack-subscriptions__supports-newline wp-block-jetpack-subscriptions__use-newline">[jetpack_subscription_form subscribe_placeholder="Enter your email address" show_subscribers_total="false" button_on_newline="true" submit_button_text="<strong>Sign up</strong> to receive emails of all my future posts" custom_font_size="49px" custom_border_radius="0" custom_border_weight="3" custom_border_color="#e22658" custom_padding="15" custom_spacing="10" submit_button_classes="has-49-px-font-size has-e-22658-border-color has-text-color has-accent-color has-background has-subtle-background-background-color" email_field_classes="has-49-px-font-size has-e-22658-border-color" show_only_email_and_button="true"]</div>
845b143
to
f152055
Compare
@jeherve Good catch! This is really odd -- I'm not sure what the root cause was, but it looks to have disappeared after rebasing. |
Needs a changelogger change file. In |
f5645ac
to
da806ac
Compare
Rebased after merging in the button width options (#18809) |
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.
The tests seem to fail now:
https://github.com/Automattic/jetpack/pull/19002/checks?check_run_id=2098887487
@stacimc looks like the test failure is because the dependency tree that the jest test runner is using in the jetpack repo is older that the one that is used to compile the frontend client, and The Jetpack crew have been working to get the dependencies updated, in the mean time you will probably either need to comment out the tests that are mounting this part of the component, or you might be able to mock
|
My apologies -- there were a couple of PRs affected by this and I missed updating the status/comment on this one. Yes, this is being held up by the dependency update :( I like the suggestion of mocking it for now. I'll work on that and create a follow up to include removing the mock and adding additional tests for the width. |
I've temporarily mocked out the width controls for now, follow up issue to fix at: 253-gh-Automattic/view-design |
Great news! One last step: head over to your WordPress.com diff, D58003-code, and commit it. Thank you! |
Holding off on deploying this one, as it relies on #18809 (which needs to be deployed along with the release for the sake of Atomic sites). |
r223840-wpcom |
Adds tests for the Button block.
Changes proposed in this Pull Request:
Controls
component for simplification/separate testingJetpack product discussion
p1HpG7-b3G-p2
Does this pull request change what data or activity we track or use?
Testing instructions:
projects/plugins/jetpack
folder with:Proposed changelog entry for your changes: