-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a block fixtures framework to allow automated checking of block v…
…alidation (#18643) Co-authored-by: Glen Davies <glen.davies@a8c.com>
- Loading branch information
1 parent
3fa52d0
commit 1ee629e
Showing
13 changed files
with
563 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...ensions/blocks/send-a-message/whatsapp-button/test/fixtures/jetpack__whatsapp-button.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- wp:jetpack/send-a-message --> | ||
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} --> | ||
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&text=My%20Message" style="background-color:#25D366;color:#fff" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div> | ||
<!-- /wp:jetpack/whatsapp-button --></div> | ||
<!-- /wp:jetpack/send-a-message --> |
29 changes: 29 additions & 0 deletions
29
...ensions/blocks/send-a-message/whatsapp-button/test/fixtures/jetpack__whatsapp-button.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "jetpack/send-a-message", | ||
"isValid": true, | ||
"attributes": {}, | ||
"innerBlocks": [ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "jetpack/whatsapp-button", | ||
"isValid": true, | ||
"attributes": { | ||
"countryCode": "61CX", | ||
"phoneNumber": "267 8888", | ||
"firstMessage": "My Message", | ||
"buttonText": [ | ||
"Chat on WhatsApp" | ||
], | ||
"backgroundColor": "#25D366", | ||
"colorClass": "dark", | ||
"openInNewTab": false | ||
}, | ||
"innerBlocks": [], | ||
"originalContent": "<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&text=My%20Message\" style=\"background-color:#25D366;color:#fff\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>" | ||
} | ||
], | ||
"originalContent": "<div class=\"wp-block-jetpack-send-a-message\"></div>" | ||
} | ||
] |
36 changes: 36 additions & 0 deletions
36
.../blocks/send-a-message/whatsapp-button/test/fixtures/jetpack__whatsapp-button.parsed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[ | ||
{ | ||
"blockName": "jetpack/send-a-message", | ||
"attrs": {}, | ||
"innerBlocks": [ | ||
{ | ||
"blockName": "jetpack/whatsapp-button", | ||
"attrs": { | ||
"countryCode": "61CX", | ||
"phoneNumber": "267 8888", | ||
"firstMessage": "My Message" | ||
}, | ||
"innerBlocks": [], | ||
"innerHTML": "\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&text=My%20Message\" style=\"background-color:#25D366;color:#fff\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t", | ||
"innerContent": [ | ||
"\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&text=My%20Message\" style=\"background-color:#25D366;color:#fff\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t" | ||
] | ||
} | ||
], | ||
"innerHTML": "\n<div class=\"wp-block-jetpack-send-a-message\"></div>\n\t", | ||
"innerContent": [ | ||
"\n<div class=\"wp-block-jetpack-send-a-message\">", | ||
null, | ||
"</div>\n\t" | ||
] | ||
}, | ||
{ | ||
"blockName": null, | ||
"attrs": {}, | ||
"innerBlocks": [], | ||
"innerHTML": "\n", | ||
"innerContent": [ | ||
"\n" | ||
] | ||
} | ||
] |
5 changes: 5 additions & 0 deletions
5
...cks/send-a-message/whatsapp-button/test/fixtures/jetpack__whatsapp-button.serialized.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- wp:jetpack/send-a-message --> | ||
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} --> | ||
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&text=My%20Message" style="background-color:#25D366;color:#fff" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div> | ||
<!-- /wp:jetpack/whatsapp-button --></div> | ||
<!-- /wp:jetpack/send-a-message --> |
5 changes: 5 additions & 0 deletions
5
.../send-a-message/whatsapp-button/test/fixtures/jetpack__whatsapp-button__deprecated-1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- wp:jetpack/send-a-message --> | ||
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} --> | ||
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&text=My%20Message" style="background-color:#25D366;" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div> | ||
<!-- /wp:jetpack/whatsapp-button --></div> | ||
<!-- /wp:jetpack/send-a-message --> |
29 changes: 29 additions & 0 deletions
29
.../send-a-message/whatsapp-button/test/fixtures/jetpack__whatsapp-button__deprecated-1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "jetpack/send-a-message", | ||
"isValid": true, | ||
"attributes": {}, | ||
"innerBlocks": [ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "jetpack/whatsapp-button", | ||
"isValid": true, | ||
"attributes": { | ||
"countryCode": "61CX", | ||
"phoneNumber": "267 8888", | ||
"firstMessage": "My Message", | ||
"buttonText": [ | ||
"Chat on WhatsApp" | ||
], | ||
"backgroundColor": "#25D366", | ||
"colorClass": "dark", | ||
"openInNewTab": false | ||
}, | ||
"innerBlocks": [], | ||
"originalContent": "<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&text=My%20Message\" style=\"background-color:#25D366;\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>" | ||
} | ||
], | ||
"originalContent": "<div class=\"wp-block-jetpack-send-a-message\"></div>" | ||
} | ||
] |
36 changes: 36 additions & 0 deletions
36
...-message/whatsapp-button/test/fixtures/jetpack__whatsapp-button__deprecated-1.parsed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[ | ||
{ | ||
"blockName": "jetpack/send-a-message", | ||
"attrs": {}, | ||
"innerBlocks": [ | ||
{ | ||
"blockName": "jetpack/whatsapp-button", | ||
"attrs": { | ||
"countryCode": "61CX", | ||
"phoneNumber": "267 8888", | ||
"firstMessage": "My Message" | ||
}, | ||
"innerBlocks": [], | ||
"innerHTML": "\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&text=My%20Message\" style=\"background-color:#25D366;\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t", | ||
"innerContent": [ | ||
"\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&text=My%20Message\" style=\"background-color:#25D366;\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t" | ||
] | ||
} | ||
], | ||
"innerHTML": "\n<div class=\"wp-block-jetpack-send-a-message\"></div>\n\t", | ||
"innerContent": [ | ||
"\n<div class=\"wp-block-jetpack-send-a-message\">", | ||
null, | ||
"</div>\n\t" | ||
] | ||
}, | ||
{ | ||
"blockName": null, | ||
"attrs": {}, | ||
"innerBlocks": [], | ||
"innerHTML": "\n", | ||
"innerContent": [ | ||
"\n" | ||
] | ||
} | ||
] |
5 changes: 5 additions & 0 deletions
5
...sage/whatsapp-button/test/fixtures/jetpack__whatsapp-button__deprecated-1.serialized.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- wp:jetpack/send-a-message --> | ||
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} --> | ||
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&text=My%20Message" style="background-color:#25D366;color:#fff" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div> | ||
<!-- /wp:jetpack/whatsapp-button --></div> | ||
<!-- /wp:jetpack/send-a-message --> |
15 changes: 15 additions & 0 deletions
15
projects/plugins/jetpack/extensions/blocks/send-a-message/whatsapp-button/test/validate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { settings } from '../'; | ||
import { settings as parentSettings } from '../../'; | ||
import runBlockFixtureTests from '../../../../shared/test/block-fixtures'; | ||
|
||
// Need to include all the blocks involved in rendering this block. | ||
// The main block should be the first in the array. | ||
const blocks = [ | ||
{ name: 'jetpack/whatsapp-button', settings }, | ||
{ name: 'jetpack/send-a-message', settings: parentSettings }, | ||
]; | ||
|
||
runBlockFixtureTests( 'jetpack/whatsapp-button', blocks, __dirname ); |
Oops, something went wrong.