Skip to content

Commit cb55925

Browse files
committed
Merge branch 'main' into block-editor-preview-refactor
2 parents 6ce9181 + 3014706 commit cb55925

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

includes/blocks/class-convertkit-block-form.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ public function get_attributes() {
187187
),
188188

189189
// get_supports() style, color and typography attributes.
190+
'align' => array(
191+
'type' => 'string',
192+
),
190193
'style' => array(
191194
'type' => 'object',
192195
),
@@ -213,6 +216,7 @@ public function get_attributes() {
213216
public function get_supports() {
214217

215218
return array(
219+
'align' => true,
216220
'className' => true,
217221
'color' => array(
218222
'link' => false,

includes/blocks/form/block.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
}
2424
},
2525
"supports": {
26+
"align": true,
2627
"className": true,
2728
"color": {
2829
"link": false,

resources/backend/js/gutenberg-block-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function convertKitGutenbergFormBlockRenderPreview( block, props ) {
6767
html: html,
6868
title: block.name,
6969
styles: [
70-
'body{font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; text-align:center;}',
70+
'body{font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; text-align:center;} form{margin: 0 auto;}',
7171
],
7272
}
7373
)

tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormCest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,56 @@ public function testFormBlockWithMarginAndPaddingParameters(EndToEndTester $I)
13181318
$I->seeInSource('<div class="convertkit-form wp-block-convertkit-form" style="padding-top:var(--wp--preset--spacing--30);margin-top:var(--wp--preset--spacing--30)"');
13191319
}
13201320

1321+
/**
1322+
* Test the Form block's alignment parameter works.
1323+
*
1324+
* @since 2.8.8
1325+
*
1326+
* @param EndToEndTester $I Tester.
1327+
*/
1328+
public function testFormBlockWithAlignmentParameter(EndToEndTester $I)
1329+
{
1330+
// Setup Plugin and enable debug log.
1331+
$I->setupKitPlugin($I);
1332+
$I->setupKitPluginResources($I);
1333+
1334+
// It's tricky to interact with Gutenberg's margin and padding pickers, so we programmatically create the Page
1335+
// instead to then confirm the settings apply on the output.
1336+
// We don't need to test the margin and padding pickers themselves, as they are Gutenberg supplied components, and our
1337+
// other End To End tests confirm that the block can be added in Gutenberg etc.
1338+
$pageID = $I->havePostInDatabase(
1339+
[
1340+
'post_type' => 'page',
1341+
'post_name' => 'kit-page-form-block-alignment-param',
1342+
'post_content' => '<!-- wp:convertkit/form {"form":"' . $_ENV['CONVERTKIT_API_FORM_ID'] . '","align":"right"} /-->',
1343+
'meta_input' => [
1344+
// Configure Kit Plugin to not display a default Form.
1345+
'_wp_convertkit_post_meta' => [
1346+
'form' => '0',
1347+
'landing_page' => '',
1348+
'tag' => '',
1349+
],
1350+
],
1351+
]
1352+
);
1353+
1354+
// Load the Page on the frontend site.
1355+
$I->amOnPage('?p=' . $pageID);
1356+
1357+
// Wait for frontend web site to load.
1358+
$I->waitForElementVisible('body.page-template-default');
1359+
1360+
// Check that no PHP warnings or notices were output.
1361+
$I->checkNoWarningsAndNoticesOnScreen($I);
1362+
1363+
// Confirm that one Kit Form is output in the DOM.
1364+
// This confirms that there is only one script on the page for this form, which renders the form.
1365+
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID']);
1366+
1367+
// Confirm that the chosen alignment is applied as a CSS class.
1368+
$I->seeInSource('<div class="convertkit-form alignright wp-block-convertkit-form"');
1369+
}
1370+
13211371
/**
13221372
* Deactivate and reset Plugin(s) after each test, if the test passes.
13231373
* We don't use _after, as this would provide a screenshot of the Plugin

0 commit comments

Comments
 (0)