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

Issue #845: Script to create Gutenberg test page #1018

Merged
merged 10 commits into from Mar 14, 2018

Conversation

Projects
None yet
2 participants
@kienstra
Collaborator

kienstra commented Mar 13, 2018

Pull Request

This PR for Issue #845 uses the test fixtures in Gutenberg, but excludes the embeds. Those fixtures usually don't have actual URLs.

From the plugin root, run this command from inside an environment like VVV:

bash bin/create-gutenberg-test-post.sh

This clones Gutenberg if it's not present, or pulls the master branch. Then, it runs the wp-cli script to create the test page, based on the test fixtures.

This uses logic from create-embed-test-post.php and amphtml-update.sh

kienstra added some commits Mar 13, 2018

Begin script to create Gutenberg test page.
Use the test fixtures in Gutenberg,
but exclude the embeds.
These usually don't have actual embed URLs.
@todos include adding some permutations,
and testing this more.
This uses much of the logic in create-embed-test-post.php
and amphtml-update.sh.
Correct regex pattern, improve DocBlock.
The matching group needed to have a ?P.
Also, change some DocBlocks,
including removing use of imperative 'Create'
in favor of 'Creates.'
Allow running bash script from plugin root.
Copy a line from amphtml-update.sh.
This removes the need to run this from bin/.

@kienstra kienstra changed the title from Issue #845: Begin script to create Gutenberg test page. to [WIP] Issue #845: Begin script to create Gutenberg test page. Mar 13, 2018

@kienstra kienstra changed the title from [WIP] Issue #845: Begin script to create Gutenberg test page. to [WIP] Issue #845: Script to create Gutenberg test page Mar 13, 2018

Add documentation to contributing.md.
Add steps to create test post.
This mainly copies the other sections.

@kienstra kienstra referenced this pull request Mar 13, 2018

Merged

Add AMP validation checking for Gutenberg blocks #1019

3 of 3 tasks complete

kienstra added some commits Mar 13, 2018

Add permutations of Gutenberg blocks.
Variations include a gallery with 3 columns,
and some embeds and shortcodes.
Embeds and shortcodes are mainly tested in:
create-embed-test-post.php.
Make title correspond to path, add bash script echo statements.
The slug should match the title.
Also, add echo statments in the bash script.
The user will need to run 'npm install' and 'npm run build.'
Create a test reusable block, reduce heading size.
amp_create_reusable_block() inserts a new post for the block.
Also, reduce the size of the headings to <h2>.
Remove extra tab in content.
There was a tab in the 'columns' block,
possibly from copying it.
@kienstra

This comment has been minimized.

Collaborator

kienstra commented Mar 14, 2018

Request For Review

Hi @westonruter,
Could you please review this pull request for #845? Please ssh into VVV, cd to this plugin, and run:

bash bin/create-gutenberg-test-post.sh

This adds all of the blocks in gutenberg/tree/master/blocks/library/ to a test post. It also adds blocks with these permutations.

You might have to open the /wp-admin/post.php page for the test post, save it, and visit the front-end of the page.

@@ -0,0 +1,32 @@
#!/bin/bash

This comment has been minimized.

@kienstra

kienstra Mar 14, 2018

Collaborator

Do you think this script is needed? It clones Gutenberg if it's not present, then runs create-gutenberg-test-post.php.

This comment has been minimized.

@westonruter

westonruter Mar 14, 2018

Member

It doesn't hurt, but it probably isn't necessary. The amp_create_gutenberg_test_post() function could just throw an exception if Gutenberg isn't active (e.g. if ! function_exists( 'do_blocks' ))

),
array(
'title' => 'Columns, With 2 Columns',
'content' => '<!-- wp:columns {"columns":2} --><div class="wp-block-columns has-2-columns"><!-- wp:paragraph {"layout":"column-1"} --> <p class="layout-column-1">Column One, Paragraph One</p><!-- /wp:paragraph --><!-- wp:paragraph {"layout":"column-1"} --><p class="layout-column-1">Column One, Paragraph Two</p><!-- /wp:paragraph --><!-- wp:paragraph {"layout":"column-2"} --><p class="layout-column-2">Column Two, Paragraph One</p><!-- /wp:paragraph --></div><!-- /wp:columns -->',

This comment has been minimized.

@kienstra

kienstra Mar 14, 2018

Collaborator

This might need to be wp:core/columns instead of wp:columns, and likewise for the rest of the line.

This comment has been minimized.

@kienstra

kienstra Mar 14, 2018

Collaborator

Applied with 3e41cca.

This comment has been minimized.

@westonruter

@kienstra kienstra requested a review from westonruter Mar 14, 2018

@kienstra kienstra assigned kienstra and westonruter and unassigned kienstra Mar 14, 2018

@kienstra kienstra changed the title from [WIP] Issue #845: Script to create Gutenberg test page to Issue #845: Script to create Gutenberg test page Mar 14, 2018

Throw exception if no fixtures are found.
This can happen if the plugin is downloaded from
wordpress.org.
Also, add 'core' to the comments:
wp:core/columns
* @throws Exception If this is script is not run inside the plugin directory.
* @return string $content Post content with all Gutenberg blocks.
*/
function amp_get_blocks() {

This comment has been minimized.

@westonruter

westonruter Mar 14, 2018

Member

Since we're using PHP 5.3, let's just go ahead and use namespaces for this file. This will help prevent confusion with autocompletion. So then this could be renamed to just get_test_data_blocks().

@westonruter westonruter merged commit 66e12d7 into develop Mar 14, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@westonruter westonruter deleted the add/845-gutenberg-test-script branch Mar 14, 2018

@westonruter westonruter added this to the v0.7 milestone Mar 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment