From 1789255c500d1232231e2582f37570d8cd3d66ad Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 21 May 2025 15:09:48 +0800 Subject: [PATCH 01/16] Add named arguments to CPTFormCest --- .../EndToEnd/forms/post-types/CPTFormCest.php | 178 +++++++++++++----- tests/Support/Helper/KitForms.php | 10 +- 2 files changed, 135 insertions(+), 53 deletions(-) diff --git a/tests/EndToEnd/forms/post-types/CPTFormCest.php b/tests/EndToEnd/forms/post-types/CPTFormCest.php index 229d2a0d1..e3d2b4218 100644 --- a/tests/EndToEnd/forms/post-types/CPTFormCest.php +++ b/tests/EndToEnd/forms/post-types/CPTFormCest.php @@ -64,7 +64,11 @@ public function testAccessibility(EndToEndTester $I) public function testNoOptionsOrOutputOnPrivateCustomPostType(EndToEndTester $I) { // Add a Private CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'private', 'Kit: Private: Form: None'); + $I->addGutenbergPage( + $I, + postType: 'private', + title: 'Kit: Private: Form: None' + ); // Check that the metabox is not displayed. $I->dontSeeElementInDOM('#wp-convertkit-meta-box'); @@ -128,7 +132,11 @@ public function testAddNewCPTUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin( $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: None'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default: None' + ); // Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms. $I->checkSelectFormOptionOrder( @@ -143,8 +151,8 @@ public function testAddNewCPTUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin( // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -176,13 +184,17 @@ public function testAddNewCPTUsingDefaultForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -217,7 +229,11 @@ public function testAddNewCPTUsingDefaultFormBeforeContent(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: Before Content'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default: Before Content' + ); // Add paragraph to CPT. $I->addGutenbergParagraphBlock($I, 'CPT content'); @@ -225,8 +241,8 @@ public function testAddNewCPTUsingDefaultFormBeforeContent(EndToEndTester $I) // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -261,7 +277,11 @@ public function testAddNewCPTUsingDefaultFormBeforeAndAfterContent(EndToEndTeste $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: Before and After Content'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default: Before and After Content' + ); // Add paragraph to CPT. $I->addGutenbergParagraphBlock($I, 'CPT content'); @@ -269,8 +289,8 @@ public function testAddNewCPTUsingDefaultFormBeforeAndAfterContent(EndToEndTeste // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -279,7 +299,11 @@ public function testAddNewCPTUsingDefaultFormBeforeAndAfterContent(EndToEndTeste $I->publishAndViewGutenbergPage($I); // Confirm that two Kit Forms are output in the DOM before and after the CPT content. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'before_after_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'before_after_content' + ); } /** @@ -306,7 +330,11 @@ public function testAddNewCPTUsingDefaultFormAfterParagraphElement(EndToEndTeste $I->setupKitPluginResources($I); // Setup Article with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 3rd Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default: After 3rd Paragraph Element' + ); // View the CPT on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -315,7 +343,13 @@ public function testAddNewCPTUsingDefaultFormAfterParagraphElement(EndToEndTeste $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the third paragraph. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'p', + elementIndex: 3 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -348,7 +382,11 @@ public function testAddNewCPTUsingDefaultNonInlineFormAfterParagraphElement(EndT $I->setupKitPluginResources($I); // Setup CPT with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Non-Inline Form: Default: After 3rd Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'article', + title: 'Kit: CPT: Non-Inline Form: Default: After 3rd Paragraph Element' + ); // View the Page on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -391,7 +429,11 @@ public function testAddNewCPTUsingDefaultFormAfterHeadingElement(EndToEndTester $I->setupKitPluginResources($I); // Setup Article with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 2nd H2 Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default: After 2nd H2 Element' + ); // View the CPT on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -400,7 +442,13 @@ public function testAddNewCPTUsingDefaultFormAfterHeadingElement(EndToEndTester $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the second

element. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'h2', + elementIndex: 2 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -433,7 +481,11 @@ public function testAddNewCPTUsingDefaultFormAfterImageElement(EndToEndTester $I $I->setupKitPluginResources($I); // Setup Article with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 2nd Image Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default: After 2nd Image Element' + ); // View the CPT on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -442,7 +494,13 @@ public function testAddNewCPTUsingDefaultFormAfterImageElement(EndToEndTester $I $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the second element. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'img', + elementIndex: 2 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -475,7 +533,11 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(EndToEndTes $I->setupKitPluginResources($I); // Setup Article with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 9th Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Default: After 9th Paragraph Element' + ); // View the CPT on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -485,7 +547,11 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(EndToEndTes // Confirm that one Kit Form is output in the DOM after the content, as // the number of paragraphs is less than the position. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_content' + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -516,7 +582,11 @@ public function testAddNewCPTUsingDefaultLegacyForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Legacy: Default'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: Legacy: Default' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( @@ -554,13 +624,17 @@ public function testAddNewCPTUsingNoForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: None'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: None' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -592,13 +666,17 @@ public function testAddNewCPTUsingDefinedForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -633,13 +711,17 @@ public function testAddNewCPTUsingDefinedLegacyForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME']); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] ], ] ); @@ -735,9 +817,9 @@ public function testQuickEditUsingDefaultForm(EndToEndTester $I) // Quick Edit the CPT in the CPTs WP_List_Table. $I->quickEdit( $I, - 'article', - $postID, - [ + postType: 'article', + postID: $postID, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -783,9 +865,9 @@ public function testQuickEditUsingDefinedForm(EndToEndTester $I) // Quick Edit the CPT in the CPTs WP_List_Table. $I->quickEdit( $I, - 'article', - $postID, - [ + postType: 'article', + postID: $postID, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -839,9 +921,9 @@ public function testBulkEditUsingDefaultForm(EndToEndTester $I) // Bulk Edit the CPTs in the CPTs WP_List_Table. $I->bulkEdit( $I, - 'article', - $postIDs, - [ + postType: 'article', + postIDs: $postIDs, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -898,9 +980,9 @@ public function testBulkEditUsingDefinedForm(EndToEndTester $I) // Bulk Edit the CPTs in the CPTs WP_List_Table. $I->bulkEdit( $I, - 'article', - $postIDs, - [ + postType: 'article', + postIDs: $postIDs, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -971,9 +1053,9 @@ public function testBulkEditWithNoChanges(EndToEndTester $I) // Bulk Edit the CPTs in the CPTs WP_List_Table. $I->bulkEdit( $I, - 'article', - $postIDs, - [ + postType: 'article', + postIDs: $postIDs, + configuration: [ 'form' => [ 'select', '— No Change —' ], ] ); diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index ad5a072c4..09619157f 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -19,9 +19,9 @@ class KitForms extends \Codeception\Module * @param int $formID Form ID. * @param bool|string $position Position of the form in the DOM relative to the content. * @param bool|string $element Element the form should display after. - * @param bool|string $element_index Number of elements before the form should display. + * @param bool|string $elementIndex Number of elements before the form should display. */ - public function seeFormOutput($I, $formID, $position = false, $element = false, $element_index = 0) + public function seeFormOutput($I, $formID, $position = false, $element = false, $elementIndex = 0) { // Calculate how many times the Form should be in the DOM. $count = ( ( $position === 'before_after_content' ) ? 2 : 1 ); @@ -53,16 +53,16 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, // The block editor automatically adds CSS classes to some elements. switch ( $element ) { case 'p': - $I->seeInSource('<' . $element . '>Item #' . $element_index . '
seeInSource('<' . $element . '>Item #' . $elementIndex . 'seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $element_index . '">seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $elementIndex . '">seeInSource('<' . $element . ' class="wp-block-heading">Item #' . $element_index . 'seeInSource('<' . $element . ' class="wp-block-heading">Item #' . $elementIndex . ' Date: Wed, 21 May 2025 15:21:04 +0800 Subject: [PATCH 02/16] Tests: Added named arguments to PageFormCest --- .../forms/post-types/PageFormCest.php | 197 +++++++++++++----- 1 file changed, 142 insertions(+), 55 deletions(-) diff --git a/tests/EndToEnd/forms/post-types/PageFormCest.php b/tests/EndToEnd/forms/post-types/PageFormCest.php index c98a1fe0e..a20f1ed7e 100644 --- a/tests/EndToEnd/forms/post-types/PageFormCest.php +++ b/tests/EndToEnd/forms/post-types/PageFormCest.php @@ -62,13 +62,16 @@ public function testAddNewPageUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: Default: None'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: Default: None' + ); // Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms. $I->checkSelectFormOptionOrder( $I, - '#wp-convertkit-form', - [ + selectElement: '#wp-convertkit-form', + prependOptions: [ 'Default', 'None', ] @@ -77,8 +80,8 @@ public function testAddNewPageUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -105,13 +108,16 @@ public function testAddNewPageUsingDefaultForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: Default'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: Default' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -145,7 +151,10 @@ public function testAddNewPageUsingDefaultFormBeforeContent(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: Default: Before Content'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: Default: Before Content' + ); // Add paragraph to Page. $I->addGutenbergParagraphBlock($I, 'Page content'); @@ -153,8 +162,8 @@ public function testAddNewPageUsingDefaultFormBeforeContent(EndToEndTester $I) // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -164,7 +173,11 @@ public function testAddNewPageUsingDefaultFormBeforeContent(EndToEndTester $I) // Confirm that one Kit Form is output in the DOM after the Page content. // This confirms that there is only one script on the page for this form, which renders the form. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'before_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'before_content' + ); } /** @@ -188,7 +201,10 @@ public function testAddNewPageUsingDefaultFormBeforeAndAfterContent(EndToEndTest $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: Default: Before and After Content'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: Default: Before and After Content' + ); // Add paragraph to Page. $I->addGutenbergParagraphBlock($I, 'Page content'); @@ -196,8 +212,8 @@ public function testAddNewPageUsingDefaultFormBeforeAndAfterContent(EndToEndTest // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -206,7 +222,11 @@ public function testAddNewPageUsingDefaultFormBeforeAndAfterContent(EndToEndTest $I->publishAndViewGutenbergPage($I); // Confirm that two Kit Forms are output in the DOM before and after the Page content. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'before_after_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'before_after_content' + ); } /** @@ -233,7 +253,10 @@ public function testAddNewPageUsingDefaultFormAfterParagraphElement(EndToEndTest $I->setupKitPluginResources($I); // Setup Page with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'page', 'Kit: Page: Form: Default: After 3rd Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + title: 'Kit: Page: Form: Default: After 3rd Paragraph Element' + ); // View the Page on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -242,7 +265,13 @@ public function testAddNewPageUsingDefaultFormAfterParagraphElement(EndToEndTest $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the third paragraph. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'p', + elementIndex: 3 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -275,7 +304,10 @@ public function testAddNewPageUsingDefaultNonInlineFormAfterParagraphElement(End $I->setupKitPluginResources($I); // Setup Page with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'page', 'Kit: Page: Non-Inline Form: Default: After 3rd Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + title: 'Kit: Page: Non-Inline Form: Default: After 3rd Paragraph Element' + ); // View the Page on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -318,7 +350,10 @@ public function testAddNewPageUsingDefaultFormAfterHeadingElement(EndToEndTester $I->setupKitPluginResources($I); // Setup Page with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'page', 'Kit: Page: Form: Default: After 2nd H2 Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + title: 'Kit: Page: Form: Default: After 2nd H2 Element' + ); // View the Page on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -327,7 +362,13 @@ public function testAddNewPageUsingDefaultFormAfterHeadingElement(EndToEndTester $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the second

element. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'h2', + elementIndex: 2 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -360,7 +401,10 @@ public function testAddNewPageUsingDefaultFormAfterImageElement(EndToEndTester $ $I->setupKitPluginResources($I); // Setup Page with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'page', 'Kit: Page: Form: Default: After 2nd H2 Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + title: 'Kit: Page: Form: Default: After 2nd Image Element' + ); // View the Post on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -369,7 +413,13 @@ public function testAddNewPageUsingDefaultFormAfterImageElement(EndToEndTester $ $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the second element. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'img', + elementIndex: 2 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -405,7 +455,10 @@ public function testAddNewPageUsingDefaultFormAfterOutOfBoundsElement(EndToEndTe $I->setupKitPluginResources($I); // Setup Page with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'page', 'Kit: Page: Form: Default: After 9th Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + title: 'Kit: Page: Form: Default: After 9th Paragraph Element' + ); // View the Page on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -415,7 +468,11 @@ public function testAddNewPageUsingDefaultFormAfterOutOfBoundsElement(EndToEndTe // Confirm that one Kit Form is output in the DOM after the content, as // the number of paragraphs is less than the position. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_content' + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -446,13 +503,16 @@ public function testAddNewPageUsingDefaultLegacyForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: Legacy: Default'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: Legacy: Default' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -482,13 +542,16 @@ public function testAddNewPageUsingNoForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: None'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: None' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -515,13 +578,16 @@ public function testAddNewPageUsingDefinedForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -552,13 +618,16 @@ public function testAddNewPageUsingModalFormWithAutoptimizePlugin(EndToEndTester $I->activateThirdPartyPlugin($I, 'autoptimize'); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Autoptimize'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Autoptimize' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] ], ] ); @@ -598,13 +667,16 @@ public function testAddNewPageUsingModalFormWithJetpackBoostPlugin(EndToEndTeste $I->click('#inspector-toggle-control-1'); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Jetpack Boost'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Jetpack Boost' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] ], ] ); @@ -644,13 +716,16 @@ public function testAddNewPageUsingModalFormWithLiteSpeedCachePlugin(EndToEndTes $I->enableLiteSpeedCacheLoadJSDeferred($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': LiteSpeed Cache'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': LiteSpeed Cache' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] ], ] ); @@ -688,13 +763,16 @@ public function testAddNewPageUsingModalFormWithSitegroundSpeedOptimizerPlugin(E $I->haveOptionInDatabase('siteground_optimizer_combine_javascript', '1'); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Siteground Speed Optimizer'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Siteground Speed Optimizer' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] ], ] ); @@ -739,13 +817,16 @@ public function testAddNewPageUsingModalFormWithPerfmattersPlugin(EndToEndTester ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Perfmatters'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': Perfmatters' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] ], ] ); @@ -783,13 +864,16 @@ public function testAddNewPageUsingModalFormWithWPRocketPlugin(EndToEndTester $I $I->enableWPRocketDelayJS($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': WP Rocket'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] . ': WP Rocket' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] ], ] ); @@ -828,13 +912,16 @@ public function testAddNewPageUsingDefinedLegacyForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] ], ] ); From 5a0c198084e79563c8bd0179904b47bcf90be361 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 21 May 2025 15:30:05 +0800 Subject: [PATCH 03/16] Tests: Add named arguments to other and post-types form tests --- .../forms/post-types/PageFormCest.php | 30 +-- .../forms/post-types/PostFormCest.php | 186 +++++++++++++----- .../other/RefreshResourcesButtonCest.php | 146 ++++++++++---- .../general/other/ReviewRequestCest.php | 30 ++- 4 files changed, 275 insertions(+), 117 deletions(-) diff --git a/tests/EndToEnd/forms/post-types/PageFormCest.php b/tests/EndToEnd/forms/post-types/PageFormCest.php index a20f1ed7e..44d42b323 100644 --- a/tests/EndToEnd/forms/post-types/PageFormCest.php +++ b/tests/EndToEnd/forms/post-types/PageFormCest.php @@ -1010,9 +1010,9 @@ public function testQuickEditUsingDefaultForm(EndToEndTester $I) // Quick Edit the Page in the Pages WP_List_Table. $I->quickEdit( $I, - 'page', - $pageID, - [ + postType: 'page', + pageID: $pageID, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -1053,9 +1053,9 @@ public function testQuickEditUsingDefinedForm(EndToEndTester $I) // Quick Edit the Page in the Pages WP_List_Table. $I->quickEdit( $I, - 'page', - $pageID, - [ + postType: 'page', + pageID: $pageID, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -1104,9 +1104,9 @@ public function testBulkEditUsingDefaultForm(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + pageIDs: $pageIDs, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -1158,9 +1158,9 @@ public function testBulkEditUsingDefinedForm(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + pageIDs: $pageIDs, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -1226,9 +1226,9 @@ public function testBulkEditWithNoChanges(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + pageIDs: $pageIDs, + configuration: [ 'form' => [ 'select', '— No Change —' ], ] ); diff --git a/tests/EndToEnd/forms/post-types/PostFormCest.php b/tests/EndToEnd/forms/post-types/PostFormCest.php index 6b3b699e6..66b311116 100644 --- a/tests/EndToEnd/forms/post-types/PostFormCest.php +++ b/tests/EndToEnd/forms/post-types/PostFormCest.php @@ -61,13 +61,17 @@ public function testAddNewPostUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: Default: None'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default: None' + ); // Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms. $I->checkSelectFormOptionOrder( $I, - '#wp-convertkit-form', - [ + selector: '#wp-convertkit-form', + prependOptions: [ 'Default', 'None', ] @@ -76,8 +80,8 @@ public function testAddNewPostUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -104,13 +108,17 @@ public function testAddNewPostUsingDefaultForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: Default'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -144,7 +152,11 @@ public function testAddNewPostUsingDefaultFormBeforeContent(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: Default: Before Content'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default: Before Content' + ); // Add paragraph to Post. $I->addGutenbergParagraphBlock($I, 'Post content'); @@ -152,8 +164,8 @@ public function testAddNewPostUsingDefaultFormBeforeContent(EndToEndTester $I) // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -163,7 +175,11 @@ public function testAddNewPostUsingDefaultFormBeforeContent(EndToEndTester $I) // Confirm that one Kit Form is output in the DOM after the Post content. // This confirms that there is only one script on the post for this form, which renders the form. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'before_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'before_content' + ); } /** @@ -187,7 +203,11 @@ public function testAddNewPostUsingDefaultFormBeforeAndAfterContent(EndToEndTest $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: Default: Before and After Content'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default: Before and After Content' + ); // Add paragraph to Post. $I->addGutenbergParagraphBlock($I, 'Post content'); @@ -195,8 +215,8 @@ public function testAddNewPostUsingDefaultFormBeforeAndAfterContent(EndToEndTest // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -205,7 +225,11 @@ public function testAddNewPostUsingDefaultFormBeforeAndAfterContent(EndToEndTest $I->publishAndViewGutenbergPage($I); // Confirm that two Kit Forms are output in the DOM before and after the Post content. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'before_after_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'before_after_content' + ); } /** @@ -232,7 +256,11 @@ public function testAddNewPostUsingDefaultFormAfterParagraphElement(EndToEndTest $I->setupKitPluginResources($I); // Setup Post with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'post', 'Kit: Post: Form: Default: After 3rd Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default: After 3rd Paragraph Element' + ); // View the Post on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -241,7 +269,13 @@ public function testAddNewPostUsingDefaultFormAfterParagraphElement(EndToEndTest $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the third paragraph. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'p', + elementIndex: 3 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -274,7 +308,11 @@ public function testAddNewPostUsingDefaultNonInlineFormAfterParagraphElement(End $I->setupKitPluginResources($I); // Setup Post with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'post', 'Kit: Post: Non-Inline Form: Default: After 3rd Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'post', + title: 'Kit: Post: Non-Inline Form: Default: After 3rd Paragraph Element' + ); // View the Page on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -317,7 +355,11 @@ public function testAddNewPostUsingDefaultFormAfterHeadingElement(EndToEndTester $I->setupKitPluginResources($I); // Setup Post with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'post', 'Kit: Post: Form: Default: After 2nd H2 Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default: After 2nd H2 Element' + ); // View the Post on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -326,7 +368,13 @@ public function testAddNewPostUsingDefaultFormAfterHeadingElement(EndToEndTester $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the second

element. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'h2', + elementIndex: 2 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -359,7 +407,11 @@ public function testAddNewPostUsingDefaultFormAfterImageElement(EndToEndTester $ $I->setupKitPluginResources($I); // Setup Post with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'post', 'Kit: Post: Form: Default: After 2nd Image Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default: After 2nd Image Element' + ); // View the Post on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -368,7 +420,13 @@ public function testAddNewPostUsingDefaultFormAfterImageElement(EndToEndTester $ $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that one Kit Form is output in the DOM after the second element. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_element', + element: 'img', + elementIndex: 2 + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -401,7 +459,11 @@ public function testAddNewPostUsingDefaultFormAfterOutOfBoundsElement(EndToEndTe $I->setupKitPluginResources($I); // Setup Post with placeholder content. - $pageID = $I->addGutenbergPageToDatabase($I, 'post', 'Kit: Post: Form: Default: After 9th Paragraph Element'); + $pageID = $I->addGutenbergPageToDatabase( + $I, + postType: 'post', + title: 'Kit: Post: Form: Default: After 9th Paragraph Element' + ); // View the Post on the frontend site. $I->amOnPage('?p=' . $pageID); @@ -411,7 +473,11 @@ public function testAddNewPostUsingDefaultFormAfterOutOfBoundsElement(EndToEndTe // Confirm that one Kit Form is output in the DOM after the content, as // the number of paragraphs is less than the position. - $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content'); + $I->seeFormOutput( + $I, + formID: $_ENV['CONVERTKIT_API_FORM_ID'], + position: 'after_content' + ); // Confirm character encoding is not broken due to using DOMDocument. $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); @@ -442,13 +508,17 @@ public function testAddNewPostUsingDefaultLegacyForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: Legacy: Default'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: Legacy: Default' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); @@ -475,13 +545,17 @@ public function testAddNewPostUsingNoForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: None'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: None' + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -508,13 +582,17 @@ public function testAddNewPostUsingDefinedForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -549,13 +627,17 @@ public function testAddNewPostUsingDefinedLegacyForm(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME']); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] + ); // Configure metabox's Form setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] ], ] ); @@ -641,9 +723,9 @@ public function testQuickEditUsingDefaultForm(EndToEndTester $I) // Quick Edit the Post in the Posts WP_List_Table. $I->quickEdit( $I, - 'post', - $postID, - [ + postType: 'post', + postID: $postID, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -684,9 +766,9 @@ public function testQuickEditUsingDefinedForm(EndToEndTester $I) // Quick Edit the Post in the Posts WP_List_Table. $I->quickEdit( $I, - 'post', - $postID, - [ + postType: 'post', + postID: $postID, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -735,9 +817,9 @@ public function testBulkEditUsingDefaultForm(EndToEndTester $I) // Bulk Edit the Posts in the Posts WP_List_Table. $I->bulkEdit( $I, - 'post', - $postIDs, - [ + postType: 'post', + postIDs: $postIDs, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -789,9 +871,9 @@ public function testBulkEditUsingDefinedForm(EndToEndTester $I) // Bulk Edit the Posts in the Posts WP_List_Table. $I->bulkEdit( $I, - 'post', - $postIDs, - [ + postType: 'post', + postIDs: $postIDs, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -857,9 +939,9 @@ public function testBulkEditWithNoChanges(EndToEndTester $I) // Bulk Edit the Posts in the Posts WP_List_Table. $I->bulkEdit( $I, - 'post', - $postIDs, - [ + postType: 'post', + postIDs: $postIDs, + configuration: [ 'form' => [ 'select', '— No Change —' ], ] ); diff --git a/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php b/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php index 60c4c9dff..c5df28dbb 100644 --- a/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php +++ b/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php @@ -51,8 +51,8 @@ public function testRefreshResourcesOnPage(EndToEndTester $I) // Check the order of the Form resources are alphabetical, with Default and None options prepending the Forms. $I->checkSelectFormOptionOrder( $I, - '#wp-convertkit-form', - [ + selectElement: '#wp-convertkit-form', + prependOptions: [ 'Default', 'None', ] @@ -60,7 +60,11 @@ public function testRefreshResourcesOnPage(EndToEndTester $I) // Change resource to value specified in the .env file, which should now be available. // If the expected dropdown value does not exist in the Select2 field, this will fail the test. - $I->fillSelect2Field($I, '#select2-wp-convertkit-form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Click the Landing Pages refresh button. $I->click('button.wp-convertkit-refresh-resources[data-resource="landing_pages"]'); @@ -71,15 +75,19 @@ public function testRefreshResourcesOnPage(EndToEndTester $I) // Check the order of the Landing Page resources are alphabetical, with the None option prepending the Landing Pages. $I->checkSelectLandingPageOptionOrder( $I, - '#wp-convertkit-landing_page', - [ + selectElement: '#wp-convertkit-landing_page', + prependOptions: [ 'None', ] ); // Change resource to value specified in the .env file, which should now be available. // If the expected dropdown value does not exist in the Select2 field, this will fail the test. - $I->fillSelect2Field($I, '#select2-wp-convertkit-landing_page-container', $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-landing_page-container', + value: $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] + ); // Click the Tags refresh button. $I->click('button.wp-convertkit-refresh-resources[data-resource="tags"]'); @@ -90,15 +98,19 @@ public function testRefreshResourcesOnPage(EndToEndTester $I) // Check the order of the Tag resources are alphabetical, with the None option prepending the Tags. $I->checkSelectTagOptionOrder( $I, - '#wp-convertkit-tag', - [ + selectElement: '#wp-convertkit-tag', + prependOptions: [ 'None', ] ); // Change resource to value specified in the .env file, which should now be available. // If the expected dropdown value does not exist in the Select2 field, this will fail the test. - $I->fillSelect2Field($I, '#select2-wp-convertkit-tag-container', $_ENV['CONVERTKIT_API_TAG_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-tag-container', + value: $_ENV['CONVERTKIT_API_TAG_NAME'] + ); // Click the Restrict Content refresh button. $I->click('button.wp-convertkit-refresh-resources[data-resource="restrict_content"]'); @@ -108,11 +120,19 @@ public function testRefreshResourcesOnPage(EndToEndTester $I) // Confirm that the expected Tag is within the Tags option group and selectable. $I->seeElementInDOM('select#wp-convertkit-restrict_content optgroup[data-resource="tags"] option[value="tag_' . $_ENV['CONVERTKIT_API_TAG_ID'] . '"]'); - $I->fillSelect2Field($I, '#select2-wp-convertkit-restrict_content-container', $_ENV['CONVERTKIT_API_TAG_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-restrict_content-container', + value: $_ENV['CONVERTKIT_API_TAG_NAME'] + ); // Confirm that the expected Product is within the Products option group and selectable. $I->seeElementInDOM('select#wp-convertkit-restrict_content optgroup[data-resource="products"] option[value="product_' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '"]'); - $I->fillSelect2Field($I, '#select2-wp-convertkit-restrict_content-container', $_ENV['CONVERTKIT_API_PRODUCT_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-restrict_content-container', + value: $_ENV['CONVERTKIT_API_PRODUCT_NAME'] + ); } /** @@ -147,8 +167,8 @@ public function testRefreshResourcesOnQuickEdit(EndToEndTester $I) // Check the order of the Form resources are alphabetical, with Default and None options prepending the Forms. $I->checkSelectFormOptionOrder( $I, - '#wp-convertkit-quick-edit-form', - [ + selectElement: '#wp-convertkit-quick-edit-form', + prependOptions: [ 'Default', 'None', ] @@ -156,7 +176,11 @@ public function testRefreshResourcesOnQuickEdit(EndToEndTester $I) // Change resource to value specified in the .env file, which should now be available. // If the expected dropdown value does not exist, this will fail the test. - $I->selectOption('#wp-convertkit-quick-edit-form', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-quick-edit-form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Click the Tags refresh button. $I->click('button.wp-convertkit-refresh-resources[data-resource="tags"]'); @@ -167,8 +191,8 @@ public function testRefreshResourcesOnQuickEdit(EndToEndTester $I) // Check the order of the Tag resources are alphabetical, with the None option prepending the Tags. $I->checkSelectTagOptionOrder( $I, - '#wp-convertkit-quick-edit-tag', - [ + selectElement: '#wp-convertkit-quick-edit-tag', + prependOptions: [ 'None', ] ); @@ -232,8 +256,8 @@ public function testRefreshResourcesOnBulkEdit(EndToEndTester $I) // Check the order of the Form resources are alphabetical, with No Change, Default and None options prepending the Forms. $I->checkSelectFormOptionOrder( $I, - '#wp-convertkit-bulk-edit-form', - [ + selectElement: '#wp-convertkit-bulk-edit-form', + prependOptions: [ '— No Change —', 'Default', 'None', @@ -253,8 +277,8 @@ public function testRefreshResourcesOnBulkEdit(EndToEndTester $I) // Check the order of the Tag resources are alphabetical, with the No Chage and None options prepending the Tags. $I->checkSelectTagOptionOrder( $I, - '#wp-convertkit-bulk-edit-tag', - [ + selectElement: '#wp-convertkit-bulk-edit-tag', + prependOptions: [ '— No Change —', 'None', ] @@ -303,8 +327,8 @@ public function testRefreshResourcesOnAddCategory(EndToEndTester $I) // Check the order of the Form resources are alphabetical, with the Default option prepending the Forms. $I->checkSelectFormOptionOrder( $I, - '#wp-convertkit-form', - [ + selectElement: '#wp-convertkit-form', + prependOptions: [ 'Default', 'None', ] @@ -312,7 +336,11 @@ public function testRefreshResourcesOnAddCategory(EndToEndTester $I) // Change resource to value specified in the .env file, which should now be available. // If the expected dropdown value does not exist in the Select2 field, this will fail the test. - $I->fillSelect2Field($I, '#select2-wp-convertkit-form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); } /** @@ -343,8 +371,8 @@ public function testRefreshResourcesOnEditCategory(EndToEndTester $I) // Check the order of the Form resources are alphabetical, with the Default option prepending the Forms. $I->checkSelectFormOptionOrder( $I, - '#wp-convertkit-form', - [ + selectElement: '#wp-convertkit-form', + prependOptions: [ 'Default', 'None', ] @@ -352,7 +380,11 @@ public function testRefreshResourcesOnEditCategory(EndToEndTester $I) // Change resource to value specified in the .env file, which should now be available. // If the expected dropdown value does not exist in the Select2 field, this will fail the test. - $I->fillSelect2Field($I, '#select2-wp-convertkit-form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); } /** @@ -386,13 +418,16 @@ public function testRefreshResourcesOnFormBlock(EndToEndTester $I) ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Forms: Block: Refresh Button'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Forms: Block: Refresh Button' + ); // Add block to Page. $I->addGutenbergBlock( $I, - 'Kit Form', - 'convertkit-form' + blockName: 'Kit Form', + blockProgrammaticName: 'convertkit-form' ); // Click the refresh button. @@ -441,7 +476,10 @@ public function testRefreshResourcesOnFormShortcodeUsingTinyMCE(EndToEndTester $ ); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Form: Shortcode: Visual Editor: Refresh Button'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Form: Shortcode: Visual Editor: Refresh Button' + ); // Open Visual Editor shortcode modal. $I->openVisualEditorShortcodeModal($I, 'Kit Form'); @@ -501,7 +539,10 @@ public function testRefreshResourcesOnFormShortcodeUsingTextEditor(EndToEndTeste ); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Form: Shortcode: Text Editor: Refresh Button'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Form: Shortcode: Text Editor: Refresh Button' + ); // Open Text Editor shortcode modal. $I->openTextEditorShortcodeModal($I, 'convertkit-form'); @@ -560,13 +601,16 @@ public function testRefreshResourcesOnFormTriggerBlock(EndToEndTester $I) ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form Trigger: Block: Refresh Button'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form Trigger: Block: Refresh Button' + ); // Add block to Page. $I->addGutenbergBlock( $I, - 'Kit Form Trigger', - 'convertkit-formtrigger' + blockName: 'Kit Form Trigger', + blockProgrammaticName: 'convertkit-formtrigger' ); // Click the refresh button. @@ -615,7 +659,10 @@ public function testRefreshResourcesOnFormTriggerShortcodeUsingTinyMCE(EndToEndT ); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Form Trigger: Shortcode: Visual Editor: Refresh Button'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Form Trigger: Shortcode: Visual Editor: Refresh Button' + ); // Open Visual Editor shortcode modal. $I->openVisualEditorShortcodeModal($I, 'Kit Form Trigger'); @@ -675,7 +722,10 @@ public function testRefreshResourcesOnFormTriggerShortcodeUsingTextEditor(EndToE ); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Form Trigger: Shortcode: Text Editor: Refresh Button'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Form Trigger: Shortcode: Text Editor: Refresh Button' + ); // Open Text Editor shortcode modal. $I->openTextEditorShortcodeModal($I, 'convertkit-formtrigger'); @@ -729,13 +779,16 @@ public function testRefreshResourcesOnProductBlock(EndToEndTester $I) ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Block: Refresh Button'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Block: Refresh Button' + ); // Add block to Page. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product' + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product' ); // Click the refresh button. @@ -779,7 +832,10 @@ public function testRefreshResourcesOnProductShortcodeUsingTinyMCE(EndToEndTeste ); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Visual Editor: Refresh Button'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Visual Editor: Refresh Button' + ); // Open Visual Editor shortcode modal. $I->openVisualEditorShortcodeModal($I, 'Kit Product'); @@ -834,7 +890,10 @@ public function testRefreshResourcesOnProductShortcodeUsingTextEditor(EndToEndTe ); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Text Editor: Refresh Button'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Text Editor: Refresh Button' + ); // Open Text Editor shortcode modal. $I->openTextEditorShortcodeModal($I, 'convertkit-product'); @@ -908,7 +967,10 @@ public function testRefreshResourcesErrorNoticeOnPageClassicEditor(EndToEndTeste $I->setupKitPluginFakeAPIKey($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Refresh Resources: Classic Editor' ); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Refresh Resources: Classic Editor' + ); // Click the Forms refresh button. $I->click('button.wp-convertkit-refresh-resources[data-resource="forms"]'); diff --git a/tests/EndToEnd/general/other/ReviewRequestCest.php b/tests/EndToEnd/general/other/ReviewRequestCest.php index 3bcae7c9d..96e20cf1b 100644 --- a/tests/EndToEnd/general/other/ReviewRequestCest.php +++ b/tests/EndToEnd/general/other/ReviewRequestCest.php @@ -40,8 +40,16 @@ public function testReviewRequestOnSaveSettings(EndToEndTester $I) $I->loadKitSettingsGeneralScreen($I); // Select Default Form for Pages and Posts. - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_page_form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_post_form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-_wp_convertkit_settings_page_form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); + $I->fillSelect2Field( + $I, + container: '#select2-_wp_convertkit_settings_post_form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Click the Save Changes button. $I->click('Save Changes'); @@ -99,13 +107,16 @@ public function testReviewRequestOnSavePageWithFormSpecified(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Test Review Request on Save with Form Specified'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Test Review Request on Save with Form Specified' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -139,13 +150,16 @@ public function testReviewRequestOnSavePageWithLandingPageSpecified(EndToEndTest $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Test Review Request on Save with Form Specified'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Test Review Request on Save with Landing Page Specified' + ); // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] ], ] ); From dfaec29545d46f3f219e17f7a6838af72468f762 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 21 May 2025 15:40:07 +0800 Subject: [PATCH 04/16] Tests: Integrations --- .../PluginSettingsGeneralCest.php | 42 ++++++++++-- .../plugin-screens/PluginSetupWizardCest.php | 18 ++++- .../divi-builder/DiviPluginBroadcastsCest.php | 16 ++--- .../divi-builder/DiviPluginFormCest.php | 40 +++++------ .../DiviPluginFormTriggerCest.php | 32 ++++----- .../divi-builder/DiviPluginProductCest.php | 32 ++++----- .../divi-theme/DiviThemeBroadcastsCest.php | 16 ++--- .../divi-theme/DiviThemeFormCest.php | 40 +++++------ .../divi-theme/DiviThemeFormTriggerCest.php | 32 ++++----- .../divi-theme/DiviThemeProductCest.php | 32 ++++----- .../other/ContactForm7FormCest.php | 42 +++++++----- .../other/ElementorBroadcastsCest.php | 29 ++++---- .../integrations/other/ElementorFormCest.php | 23 +++++-- .../other/ElementorFormTriggerCest.php | 27 ++++++-- .../other/ElementorProductCest.php | 21 ++++-- .../integrations/other/ForminatorCest.php | 68 +++++++++++-------- 16 files changed, 305 insertions(+), 205 deletions(-) diff --git a/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php b/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php index 3b76dd0bf..7eaad9222 100644 --- a/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php +++ b/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php @@ -246,7 +246,11 @@ public function testChangeDefaultFormSettingAndPreviewFormLinks(EndToEndTester $ $I->loadKitSettingsGeneralScreen($I); // Select Default Form for Pages, and change the Position. - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_page_form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-_wp_convertkit_settings_page_form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); $I->selectOption('_wp_convertkit_settings[page_form_position]', 'Before Page content'); // Open preview. @@ -267,7 +271,11 @@ public function testChangeDefaultFormSettingAndPreviewFormLinks(EndToEndTester $ $I->closeTab(); // Select Default Form for Posts. - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_post_form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-_wp_convertkit_settings_post_form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Open preview. $I->click('a#convertkit-preview-form-post'); @@ -317,7 +325,11 @@ public function testChangeDefaultSiteWideFormsSettingAndPreviewFormLinks(EndToEn $I->loadKitSettingsGeneralScreen($I); // Select the Sticky Bar Form for the Site Wide option. - $I->fillSelect2MultipleField($I, '#select2-_wp_convertkit_settings_non_inline_form-container', $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME']); + $I->fillSelect2MultipleField( + $I, + container: '#select2-_wp_convertkit_settings_non_inline_form-container', + value: $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME'] + ); // Open preview. $I->click('a#convertkit-preview-non-inline-form'); @@ -337,7 +349,11 @@ public function testChangeDefaultSiteWideFormsSettingAndPreviewFormLinks(EndToEn $I->closeTab(); // Select a second Modal Form for the Site Wide option. - $I->fillSelect2MultipleField($I, '#select2-_wp_convertkit_settings_non_inline_form-container', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME']); + $I->fillSelect2MultipleField( + $I, + container: '#select2-_wp_convertkit_settings_non_inline_form-container', + value: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'] + ); // Open preview. $I->click('a#convertkit-preview-non-inline-form'); @@ -395,7 +411,11 @@ public function testChangeDefaultFormPositionAfterElementSetting(EndToEndTester $I->dontSeeElement('_wp_convertkit_settings[page_form_position_element]'); // Select Default Form for Pages, and change the Position. - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_page_form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-_wp_convertkit_settings_page_form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); $I->selectOption('_wp_convertkit_settings[page_form_position]', 'After element'); // Confirm the conditional fields display for Pages, now that 'After element' is selected. @@ -410,7 +430,11 @@ public function testChangeDefaultFormPositionAfterElementSetting(EndToEndTester $I->dontSeeElement('select[name="_wp_convertkit_settings[post_form_position_element]"]'); // Select Default Form for Posts, and change the Position. - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_post_form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-_wp_convertkit_settings_post_form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); $I->selectOption('_wp_convertkit_settings[post_form_position]', 'After element'); // Confirm the conditional fields display for Posts, now that 'After element' is selected. @@ -482,7 +506,11 @@ public function testPublicPrivateCustomPostTypeSettingsExist(EndToEndTester $I) $I->loadKitSettingsGeneralScreen($I); // Select Default Form for Articles. - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_article_form-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-_wp_convertkit_settings_article_form-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Confirm no Default Form option is displayed for the Private CPT. $I->dontSeeElementInDOM('#_wp_convertkit_settings_private_form'); diff --git a/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php b/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php index ac97f4045..b06dd8e61 100644 --- a/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php +++ b/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php @@ -239,7 +239,11 @@ public function testSetupWizardFormConfigurationScreen(EndToEndTester $I) $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); // Select a Post Form. - $I->fillSelect2Field($I, '#select2-wp-convertkit-form-posts-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-form-posts-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Open preview. $I->click('a#convertkit-preview-form-post'); @@ -259,7 +263,11 @@ public function testSetupWizardFormConfigurationScreen(EndToEndTester $I) $I->closeTab(); // Select a Page Form. - $I->fillSelect2Field($I, '#select2-wp-convertkit-form-pages-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-form-pages-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); // Open preview. $I->click('a#convertkit-preview-form-page'); @@ -331,7 +339,11 @@ public function testSetupWizardFormConfigurationScreenWhenNoFormsExist(EndToEndT $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); // Confirm we can select a Post Form. - $I->fillSelect2Field($I, '#select2-wp-convertkit-form-posts-container', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-wp-convertkit-form-posts-container', + value: $_ENV['CONVERTKIT_API_FORM_NAME'] + ); } /** diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php index 2669ae663..a3a2ade15 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php @@ -45,8 +45,8 @@ public function testBroadcastsModuleInBackendEditor(EndToEndTester $I) // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName:'convertkit_broadcasts' ); // Save Divi module and view the page on the frontend site. @@ -91,8 +91,8 @@ public function testBroadcastsModuleInFrontendEditor(EndToEndTester $I) // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName: 'convertkit_broadcasts' ); // Save Divi module and view the page on the frontend site. @@ -129,8 +129,8 @@ public function testBroadcastsModuleInFrontendEditorWhenNoCredentials(EndToEndTe // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName: 'convertkit_broadcasts' ); // Confirm the on screen message displays. @@ -158,8 +158,8 @@ public function testBroadcastsModuleInFrontendEditorWhenNoBroadcasts(EndToEndTes // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName: 'convertkit_broadcasts' ); // Confirm the on screen message displays. diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php index 768218d53..2de93876c 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php @@ -45,10 +45,10 @@ public function testFormModuleInBackendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form', - 'form', - $_ENV['CONVERTKIT_API_FORM_ID'] + name: 'Kit Form', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_ID'] ); // Save Divi module and view the page on the frontend site. @@ -82,10 +82,10 @@ public function testFormModuleInFrontendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form', - 'form', - $_ENV['CONVERTKIT_API_FORM_ID'] + name: 'Kit Form', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_ID'] ); // Save Divi module and view the page on the frontend site. @@ -111,8 +111,8 @@ public function testFormModuleInFrontendEditorWhenNoCredentials(EndToEndTester $ // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form' + name: 'Kit Form', + programmaticName: 'convertkit_form' ); // Confirm the on screen message displays. @@ -140,8 +140,8 @@ public function testFormModuleInFrontendEditorWhenNoForms(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form' + name: 'Kit Form', + programmaticName: 'convertkit_form' ); // Confirm the on screen message displays. @@ -174,10 +174,10 @@ public function testFormModuleWithValidLegacyFormParameter(EndToEndTester $I) // Create Page with Form module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Legacy Form: Divi Module: Valid Form Param', - 'convertkit_form', - 'form', - $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] + title: 'Kit: Legacy Form: Divi Module: Valid Form Param', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] ); // Load Page. @@ -206,10 +206,10 @@ public function testFormModuleWithNoFormParameter(EndToEndTester $I) // Create Page with Form module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Legacy Form: Divi Module: No Form Param', - 'convertkit_form', - 'form', - '' + title: 'Kit: Legacy Form: Divi Module: No Form Param', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: '' ); // Load Page. diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php index 211f12305..8c8d13b2e 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php @@ -45,10 +45,10 @@ public function testFormTriggerModuleInBackendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger', - 'form', - $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] ); // Save Divi module and view the page on the frontend site. @@ -85,10 +85,10 @@ public function testFormTriggerModuleInFrontendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger', - 'form', - $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] ); // Save Divi module and view the page on the frontend site. @@ -117,8 +117,8 @@ public function testFormTriggerModuleInFrontendEditorWhenNoCredentials(EndToEndT // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger' + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger' ); // Confirm the on screen message displays. @@ -146,8 +146,8 @@ public function testFormTriggerModuleInFrontendEditorWhenNoForms(EndToEndTester // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger' + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger' ); // Confirm the on screen message displays. @@ -171,10 +171,10 @@ public function testFormTriggerModuleWithNoFormParameter(EndToEndTester $I) // Create Page with Form module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Legacy Form Trigger: Divi Module: No Form Param', - 'convertkit_formtrigger', - 'form', - '' + title: 'Kit: Legacy Form Trigger: Divi Module: No Form Param', + programmaticName: 'convertkit_formtrigger', + fieldName: 'form', + fieldValue: '' ); // Load Page. diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php index df94ccd95..272eb1d05 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php @@ -45,10 +45,10 @@ public function testProductModuleInBackendEditor(EndToEndTester $I) // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product', - 'product', - $_ENV['CONVERTKIT_API_PRODUCT_ID'] + name: 'Kit Product', + programmaticName: 'convertkit_product', + fieldName: 'product', + fieldValue: $_ENV['CONVERTKIT_API_PRODUCT_ID'] ); // Save Divi module and view the page on the frontend site. @@ -81,10 +81,10 @@ public function testProductModuleInFrontendEditor(EndToEndTester $I) // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product', - 'product', - $_ENV['CONVERTKIT_API_PRODUCT_ID'] + name: 'Kit Product', + programmaticName: 'convertkit_product', + fieldName: 'product', + fieldValue: $_ENV['CONVERTKIT_API_PRODUCT_ID'] ); // Save Divi module and view the page on the frontend site. @@ -109,8 +109,8 @@ public function testProductModuleInFrontendEditorWhenNoCredentials(EndToEndTeste // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product' + name: 'Kit Product', + programmaticName: 'convertkit_product' ); // Confirm the on screen message displays. @@ -138,8 +138,8 @@ public function testProductModuleInFrontendEditorWhenNoProducts(EndToEndTester $ // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product' + name: 'Kit Product', + programmaticName: 'convertkit_product' ); // Confirm the on screen message displays. @@ -163,10 +163,10 @@ public function testProductModuleWithNoProductParameter(EndToEndTester $I) // Create Page with Product module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Product: Divi Module: No Product Param', - 'convertkit_product', - 'product', - '' + title: 'Kit: Product: Divi Module: No Product Param', + programmaticName: 'convertkit_product', + fieldName: 'product', + fieldValue: '' ); // Load Page. diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php index a6c230af0..90546a41e 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php @@ -47,8 +47,8 @@ public function testBroadcastsModuleInBackendEditor(EndToEndTester $I) // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName: 'convertkit_broadcasts' ); // Save Divi module and view the page on the frontend site. @@ -93,8 +93,8 @@ public function testBroadcastsModuleInFrontendEditor(EndToEndTester $I) // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName: 'convertkit_broadcasts' ); // Save Divi module and view the page on the frontend site. @@ -131,8 +131,8 @@ public function testBroadcastsModuleInFrontendEditorWhenNoCredentials(EndToEndTe // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName: 'convertkit_broadcasts' ); // Confirm the on screen message displays. @@ -160,8 +160,8 @@ public function testBroadcastsModuleInFrontendEditorWhenNoBroadcasts(EndToEndTes // Insert the Broadcasts module. $I->insertDiviRowWithModule( $I, - 'Kit Broadcasts', - 'convertkit_broadcasts' + name: 'Kit Broadcasts', + programmaticName: 'convertkit_broadcasts' ); // Confirm the on screen message displays. diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php index 657251a7f..ac9eb484b 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php @@ -45,10 +45,10 @@ public function testFormModuleInBackendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form', - 'form', - $_ENV['CONVERTKIT_API_FORM_ID'] + name: 'Kit Form', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_ID'] ); // Save Divi module and view the page on the frontend site. @@ -82,10 +82,10 @@ public function testFormModuleInFrontendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form', - 'form', - $_ENV['CONVERTKIT_API_FORM_ID'] + name: 'Kit Form', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_ID'] ); // Save Divi module and view the page on the frontend site. @@ -111,8 +111,8 @@ public function testFormModuleInFrontendEditorWhenNoCredentials(EndToEndTester $ // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form' + name: 'Kit Form', + programmaticName: 'convertkit_form' ); // Confirm the on screen message displays. @@ -140,8 +140,8 @@ public function testFormModuleInFrontendEditorWhenNoForms(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form', - 'convertkit_form' + name: 'Kit Form', + programmaticName: 'convertkit_form' ); // Confirm the on screen message displays. @@ -174,10 +174,10 @@ public function testFormModuleWithValidLegacyFormParameter(EndToEndTester $I) // Create Page with Form module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Legacy Form: Divi Module: Valid Form Param', - 'convertkit_form', - 'form', - $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] + title: 'Kit: Legacy Form: Divi Module: Valid Form Param', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] ); // Load Page. @@ -206,10 +206,10 @@ public function testFormModuleWithNoFormParameter(EndToEndTester $I) // Create Page with Form module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Legacy Form: Divi Module: No Form Param', - 'convertkit_form', - 'form', - '' + title: 'Kit: Legacy Form: Divi Module: No Form Param', + programmaticName: 'convertkit_form', + fieldName: 'form', + fieldValue: '' ); // Load Page. diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php index d4d44bf67..36ab10a6e 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php @@ -45,10 +45,10 @@ public function testFormTriggerModuleInBackendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger', - 'form', - $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] ); // Save Divi module and view the page on the frontend site. @@ -85,10 +85,10 @@ public function testFormTriggerModuleInFrontendEditor(EndToEndTester $I) // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger', - 'form', - $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger', + fieldName: 'form', + fieldValue: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] ); // Save Divi module and view the page on the frontend site. @@ -117,8 +117,8 @@ public function testFormTriggerModuleInFrontendEditorWhenNoCredentials(EndToEndT // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger' + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger' ); // Confirm the on screen message displays. @@ -146,8 +146,8 @@ public function testFormTriggerModuleInFrontendEditorWhenNoForms(EndToEndTester // Insert the Form module. $I->insertDiviRowWithModule( $I, - 'Kit Form Trigger', - 'convertkit_formtrigger' + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger' ); // Confirm the on screen message displays. @@ -171,10 +171,10 @@ public function testFormTriggerModuleWithNoFormParameter(EndToEndTester $I) // Create Page with Form module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Legacy Form Trigger: Divi Module: No Form Param', - 'convertkit_formtrigger', - 'form', - '' + title: 'Kit: Legacy Form Trigger: Divi Module: No Form Param', + programmaticName: 'convertkit_formtrigger', + fieldName: 'form', + fieldValue: '' ); // Load Page. diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php index 62546bffe..877f1c080 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php @@ -45,10 +45,10 @@ public function testProductModuleInBackendEditor(EndToEndTester $I) // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product', - 'product', - $_ENV['CONVERTKIT_API_PRODUCT_ID'] + name: 'Kit Product', + programmaticName: 'convertkit_product', + fieldName: 'product', + fieldValue: $_ENV['CONVERTKIT_API_PRODUCT_ID'] ); // Save Divi module and view the page on the frontend site. @@ -81,10 +81,10 @@ public function testProductModuleInFrontendEditor(EndToEndTester $I) // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product', - 'product', - $_ENV['CONVERTKIT_API_PRODUCT_ID'] + name: 'Kit Product', + programmaticName: 'convertkit_product', + fieldName: 'product', + fieldValue: $_ENV['CONVERTKIT_API_PRODUCT_ID'] ); // Save Divi module and view the page on the frontend site. @@ -109,8 +109,8 @@ public function testProductModuleInFrontendEditorWhenNoCredentials(EndToEndTeste // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product' + name: 'Kit Product', + programmaticName: 'convertkit_product' ); // Confirm the on screen message displays. @@ -138,8 +138,8 @@ public function testProductModuleInFrontendEditorWhenNoProducts(EndToEndTester $ // Insert the Product module. $I->insertDiviRowWithModule( $I, - 'Kit Product', - 'convertkit_product' + name: 'Kit Product', + programmaticName: 'convertkit_product' ); // Confirm the on screen message displays. @@ -163,10 +163,10 @@ public function testProductModuleWithNoProductParameter(EndToEndTester $I) // Create Page with Product module in Divi. $pageID = $I->createPageWithDiviModuleProgrammatically( $I, - 'Kit: Product: Divi Module: No Product Param', - 'convertkit_product', - 'product', - '' + title: 'Kit: Product: Divi Module: No Product Param', + programmaticName: 'convertkit_product', + fieldName: 'product', + fieldValue: '' ); // Load Page. diff --git a/tests/EndToEnd/integrations/other/ContactForm7FormCest.php b/tests/EndToEnd/integrations/other/ContactForm7FormCest.php index d471d26bc..762434f4d 100644 --- a/tests/EndToEnd/integrations/other/ContactForm7FormCest.php +++ b/tests/EndToEnd/integrations/other/ContactForm7FormCest.php @@ -62,8 +62,8 @@ public function testSettingsContactForm7ToKitFormMapping(EndToEndTester $I) // Complete and submit Contact Form 7 Form. $this->_contactForm7CompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. @@ -72,9 +72,9 @@ public function testSettingsContactForm7ToKitFormMapping(EndToEndTester $I) // Check that the subscriber has the expected form and referrer value set. $I->apiCheckSubscriberHasForm( $I, - $subscriberID, - $_ENV['CONVERTKIT_API_THIRD_PARTY_INTEGRATIONS_FORM_ID'], - $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl() + subscriberID: $subscriberID, + formID: $_ENV['CONVERTKIT_API_THIRD_PARTY_INTEGRATIONS_FORM_ID'], + referrer: $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl() ); } @@ -99,8 +99,8 @@ public function testSettingsContactForm7ToKitLegacyFormMapping(EndToEndTester $I // Complete and submit Contact Form 7 Form. $this->_contactForm7CompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. @@ -128,15 +128,19 @@ public function testSettingsContactForm7ToKitTagMapping(EndToEndTester $I) // Complete and submit Contact Form 7 Form. $this->_contactForm7CompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); // Check that the subscriber has been assigned to the tag. - $I->apiCheckSubscriberHasTag($I, $subscriberID, $_ENV['CONVERTKIT_API_TAG_ID']); + $I->apiCheckSubscriberHasTag( + $I, + subscriberID: $subscriberID, + tagID: $_ENV['CONVERTKIT_API_TAG_ID'] + ); } /** @@ -160,15 +164,19 @@ public function testSettingsContactForm7ToKitSequenceMapping(EndToEndTester $I) // Complete and submit Contact Form 7 Form. $this->_contactForm7CompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); // Check that the subscriber has been assigned to the sequence. - $I->apiCheckSubscriberHasSequence($I, $subscriberID, $_ENV['CONVERTKIT_API_SEQUENCE_ID']); + $I->apiCheckSubscriberHasSequence( + $I, + subscriberID: $subscriberID, + sequenceID: $_ENV['CONVERTKIT_API_SEQUENCE_ID'] + ); } /** @@ -192,8 +200,8 @@ public function testSettingsContactForm7DoNotSubscribeOption(EndToEndTester $I) // Complete and submit Contact Form 7 Form. $this->_contactForm7CompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was not added to Kit. @@ -221,8 +229,8 @@ public function testSettingsContactForm7SubscribeOption(EndToEndTester $I) // Complete and submit Contact Form 7 Form. $this->_contactForm7CompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. diff --git a/tests/EndToEnd/integrations/other/ElementorBroadcastsCest.php b/tests/EndToEnd/integrations/other/ElementorBroadcastsCest.php index 935751e01..38b0363c1 100644 --- a/tests/EndToEnd/integrations/other/ElementorBroadcastsCest.php +++ b/tests/EndToEnd/integrations/other/ElementorBroadcastsCest.php @@ -36,7 +36,10 @@ public function _before(EndToEndTester $I) public function testBroadcastsWidgetIsRegistered(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Broadcasts: Elementor: Registered'); + $I->addGutenbergPage( + I: $I, + title: 'Kit: Page: Broadcasts: Elementor: Registered' + ); // Click Edit with Elementor button. $I->click('#elementor-switch-mode-button'); @@ -65,8 +68,8 @@ public function testBroadcastsWidgetWithValidParameters(EndToEndTester $I) // Create Page with Broadcasts widget in Elementor. $pageID = $this->_createPageWithBroadcastsWidget( $I, - 'Kit: Page: Broadcasts: Elementor Widget: Valid Params', - [ + title: 'Kit: Page: Broadcasts: Elementor Widget: Valid Params', + settings: [ 'date_format' => 'F j, Y', 'limit' => 10, ] @@ -106,8 +109,8 @@ public function testBroadcastsWidgetWithDateFormatParameter(EndToEndTester $I) // Create Page with Broadcasts widget in Elementor. $pageID = $this->_createPageWithBroadcastsWidget( $I, - 'Kit: Page: Broadcasts: Elementor Widget: Date Format', - [ + title: 'Kit: Page: Broadcasts: Elementor Widget: Date Format', + settings: [ 'date_format' => 'Y-m-d', 'limit' => 10, ] @@ -147,8 +150,8 @@ public function testBroadcastsWidgetWithLimitParameter(EndToEndTester $I) // Create Page with Broadcasts widget in Elementor. $pageID = $this->_createPageWithBroadcastsWidget( $I, - 'Kit: Page: Broadcasts: Elementor Widget: Limit', - [ + title: 'Kit: Page: Broadcasts: Elementor Widget: Limit', + settings: [ 'date_format' => 'F j, Y', 'limit' => 2, ] @@ -185,8 +188,8 @@ public function testBroadcastsWidgetWithPaginationEnabled(EndToEndTester $I) // Create Page with Broadcasts widget in Elementor. $pageID = $this->_createPageWithBroadcastsWidget( $I, - 'Kit: Page: Broadcasts: Elementor Widget: Pagination', - [ + title: 'Kit: Page: Broadcasts: Elementor Widget: Pagination', + settings: [ 'date_format' => 'F j, Y', 'limit' => 2, 'paginate' => 1, @@ -215,8 +218,8 @@ public function testBroadcastsWidgetWithPaginationLabelParameters(EndToEndTester // Create Page with Broadcasts widget in Elementor. $pageID = $this->_createPageWithBroadcastsWidget( $I, - 'Kit: Page: Broadcasts: Elementor Widget: Valid Params', - [ + title: 'Kit: Page: Broadcasts: Elementor Widget: Valid Params', + settings: [ 'date_format' => 'F j, Y', 'limit' => 2, 'paginate' => 1, @@ -252,8 +255,8 @@ public function testBroadcastsWidgetWithHexColorParameters(EndToEndTester $I) // Create Page with Broadcasts widget in Elementor. $pageID = $this->_createPageWithBroadcastsWidget( $I, - 'Kit: Page: Broadcasts: Elementor Widget: Hex Colors', - [ + title: 'Kit: Page: Broadcasts: Elementor Widget: Hex Colors', + settings: [ 'date_format' => 'F j, Y', 'limit' => 2, 'paginate' => 1, diff --git a/tests/EndToEnd/integrations/other/ElementorFormCest.php b/tests/EndToEnd/integrations/other/ElementorFormCest.php index f5862e19c..8b71e5746 100644 --- a/tests/EndToEnd/integrations/other/ElementorFormCest.php +++ b/tests/EndToEnd/integrations/other/ElementorFormCest.php @@ -38,7 +38,10 @@ public function _before(EndToEndTester $I) public function testFormWidgetIsRegistered(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: Elementor: Valid Form Param'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form: Elementor: Valid Form Param' + ); // Click Edit with Elementor button. $I->click('#elementor-switch-mode-button'); @@ -65,7 +68,11 @@ public function testFormWidgetIsRegistered(EndToEndTester $I) public function testFormWidgetWithValidFormParameter(EndToEndTester $I) { // Create Page with Form widget in Elementor. - $pageID = $this->_createPageWithFormWidget($I, 'Kit: Page: Form: Elementor Widget: Valid Form Param', $_ENV['CONVERTKIT_API_FORM_ID']); + $pageID = $this->_createPageWithFormWidget( + $I, + title: 'Kit: Page: Form: Elementor Widget: Valid Form Param', + formID: $_ENV['CONVERTKIT_API_FORM_ID'] + ); // Load Page. $I->amOnPage('?p=' . $pageID); @@ -100,7 +107,11 @@ public function testFormWidgetWithValidLegacyFormParameter(EndToEndTester $I) ); // Create Page with Form widget in Elementor. - $pageID = $this->_createPageWithFormWidget($I, 'Kit: Legacy Form: Elementor Widget: Valid Form Param', $_ENV['CONVERTKIT_API_LEGACY_FORM_ID']); + $pageID = $this->_createPageWithFormWidget( + $I, + title: 'Kit: Legacy Form: Elementor Widget: Valid Form Param', + formID: $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] + ); // Load Page. $I->amOnPage('?p=' . $pageID); @@ -122,7 +133,11 @@ public function testFormWidgetWithValidLegacyFormParameter(EndToEndTester $I) public function testFormWidgetWithNoFormParameter(EndToEndTester $I) { // Create Page with Form widget in Elementor. - $pageID = $this->_createPageWithFormWidget($I, 'Kit: Page: Form: Elementor Widget: No Form Param', ''); + $pageID = $this->_createPageWithFormWidget( + $I, + title: 'Kit: Page: Form: Elementor Widget: No Form Param', + formID: '' + ); // Load Page. $I->amOnPage('?p=' . $pageID); diff --git a/tests/EndToEnd/integrations/other/ElementorFormTriggerCest.php b/tests/EndToEnd/integrations/other/ElementorFormTriggerCest.php index e7c08248c..754b3098f 100644 --- a/tests/EndToEnd/integrations/other/ElementorFormTriggerCest.php +++ b/tests/EndToEnd/integrations/other/ElementorFormTriggerCest.php @@ -36,7 +36,10 @@ public function _before(EndToEndTester $I) public function testFormTriggerWidgetIsRegistered(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Form Trigger: Elementor: Registered'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Form Trigger: Elementor: Registered' + ); // Click Edit with Elementor button. $I->click('#elementor-switch-mode-button'); @@ -65,8 +68,8 @@ public function testFormTriggerWidgetWithValidParameters(EndToEndTester $I) // Create Page with Form Trigger widget in Elementor. $pageID = $this->_createPageWithFormTriggerWidget( $I, - 'Kit: Page: Form Trigger: Elementor Widget: Valid Params', - [ + title: 'Kit: Page: Form Trigger: Elementor Widget: Valid Params', + settings: [ 'form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'], 'text' => 'Subscribe', ] @@ -79,7 +82,11 @@ public function testFormTriggerWidgetWithValidParameters(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that the form trigger button displays. - $I->seeFormTriggerOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_URL'], 'Subscribe'); + $I->seeFormTriggerOutput( + $I, + formURL: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_URL'], + text: 'Subscribe' + ); } /** @@ -98,8 +105,8 @@ public function testFormTriggerWidgetWithHexColorParameters(EndToEndTester $I) // Create Page with Form Trigger widget in Elementor. $pageID = $this->_createPageWithFormTriggerWidget( $I, - 'Kit: Page: Form Trigger: Elementor Widget: Hex Colors', - [ + title: 'Kit: Page: Form Trigger: Elementor Widget: Hex Colors', + settings: [ 'form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'], 'text' => 'Subscribe', 'background_color' => $backgroundColor, @@ -114,7 +121,13 @@ public function testFormTriggerWidgetWithHexColorParameters(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that the form trigger button displays. - $I->seeFormTriggerOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_URL'], 'Subscribe', $textColor, $backgroundColor); + $I->seeFormTriggerOutput( + $I, + formURL: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_URL'], + text: 'Subscribe', + textColor: $textColor, + backgroundColor: $backgroundColor + ); } /** diff --git a/tests/EndToEnd/integrations/other/ElementorProductCest.php b/tests/EndToEnd/integrations/other/ElementorProductCest.php index 893e3b1ef..96a4b0a35 100644 --- a/tests/EndToEnd/integrations/other/ElementorProductCest.php +++ b/tests/EndToEnd/integrations/other/ElementorProductCest.php @@ -36,7 +36,10 @@ public function _before(EndToEndTester $I) public function testProductWidgetIsRegistered(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Elementor: Registered'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Elementor: Registered' + ); // Click Edit with Elementor button. $I->click('#elementor-switch-mode-button'); @@ -65,8 +68,8 @@ public function testProductWidgetWithValidParameters(EndToEndTester $I) // Create Page with Product widget in Elementor. $pageID = $this->_createPageWithProductWidget( $I, - 'Kit: Page: Product: Elementor Widget: Valid Params', - [ + title: 'Kit: Page: Product: Elementor Widget: Valid Params', + settings: [ 'product' => $_ENV['CONVERTKIT_API_PRODUCT_ID'], 'text' => 'Buy my product', ] @@ -98,8 +101,8 @@ public function testProductWidgetWithHexColorParameters(EndToEndTester $I) // Create Page with Product widget in Elementor. $pageID = $this->_createPageWithProductWidget( $I, - 'Kit: Page: Product: Elementor Widget: Hex Colors', - [ + title: 'Kit: Page: Product: Elementor Widget: Hex Colors', + settings: [ 'product' => $_ENV['CONVERTKIT_API_PRODUCT_ID'], 'text' => 'Buy my product', 'background_color' => $backgroundColor, @@ -114,7 +117,13 @@ public function testProductWidgetWithHexColorParameters(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product', $textColor, $backgroundColor); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product', + textColor: $textColor, + backgroundColor: $backgroundColor + ); } /** diff --git a/tests/EndToEnd/integrations/other/ForminatorCest.php b/tests/EndToEnd/integrations/other/ForminatorCest.php index 865ce3f30..37245288b 100644 --- a/tests/EndToEnd/integrations/other/ForminatorCest.php +++ b/tests/EndToEnd/integrations/other/ForminatorCest.php @@ -62,8 +62,8 @@ public function testSettingsForminatorFormToKitFormMapping(EndToEndTester $I) // Complete and submit Forminator Form. $this->_forminatorCompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. @@ -72,9 +72,9 @@ public function testSettingsForminatorFormToKitFormMapping(EndToEndTester $I) // Check that the subscriber has the expected form and referrer value set. $I->apiCheckSubscriberHasForm( $I, - $subscriberID, - $_ENV['CONVERTKIT_API_THIRD_PARTY_INTEGRATIONS_FORM_ID'], - $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl() + subscriberID: $subscriberID, + formID: $_ENV['CONVERTKIT_API_THIRD_PARTY_INTEGRATIONS_FORM_ID'], + referrer: $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl() ); } @@ -99,8 +99,8 @@ public function testSettingsForminatorFormToKitLegacyFormMapping(EndToEndTester // Complete and submit Forminator Form. $this->_forminatorCompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. @@ -128,15 +128,19 @@ public function testSettingsForminatorFormToKitTagMapping(EndToEndTester $I) // Complete and submit Forminator Form. $this->_forminatorCompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); // Check that the subscriber has been assigned to the tag. - $I->apiCheckSubscriberHasTag($I, $subscriberID, $_ENV['CONVERTKIT_API_TAG_ID']); + $I->apiCheckSubscriberHasTag( + $I, + subscriberID: $subscriberID, + tagID: $_ENV['CONVERTKIT_API_TAG_ID'] + ); } /** @@ -160,8 +164,8 @@ public function testSettingsForminatorFormToKitSequenceMapping(EndToEndTester $I // Complete and submit Forminator Form. $this->_forminatorCompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. @@ -192,8 +196,8 @@ public function testSettingsForminatorFormDoNotSubscribeOption(EndToEndTester $I // Complete and submit Forminator Form. $this->_forminatorCompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was not added to Kit. @@ -221,8 +225,8 @@ public function testSettingsForminatorFormSubscribeOption(EndToEndTester $I) // Complete and submit Forminator Form. $this->_forminatorCompleteAndSubmitForm( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. @@ -250,8 +254,8 @@ public function testSettingsForminatorQuizToKitFormMapping(EndToEndTester $I) // Complete and submit Forminator Quiz. $this->_forminatorCompleteAndSubmitQuiz( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. @@ -279,15 +283,19 @@ public function testSettingsForminatorQuizToKitTagMapping(EndToEndTester $I) // Complete and submit Forminator Quiz. $this->_forminatorCompleteAndSubmitQuiz( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); // Check that the subscriber has been assigned to the tag. - $I->apiCheckSubscriberHasTag($I, $subscriberID, $_ENV['CONVERTKIT_API_TAG_ID']); + $I->apiCheckSubscriberHasTag( + $I, + subscriberID: $subscriberID, + tagID: $_ENV['CONVERTKIT_API_TAG_ID'] + ); } /** @@ -311,15 +319,19 @@ public function testSettingsForminatorQuizToKitSequenceMapping(EndToEndTester $I // Complete and submit Forminator Quiz. $this->_forminatorCompleteAndSubmitQuiz( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); // Check that the subscriber has been assigned to the sequence. - $I->apiCheckSubscriberHasSequence($I, $subscriberID, $_ENV['CONVERTKIT_API_SEQUENCE_ID']); + $I->apiCheckSubscriberHasSequence( + $I, + subscriberID: $subscriberID, + sequenceID: $_ENV['CONVERTKIT_API_SEQUENCE_ID'] + ); } /** @@ -343,8 +355,8 @@ public function testSettingsForminatorQuizDoNotSubscribeOption(EndToEndTester $I // Complete and submit Forminator Quiz. $this->_forminatorCompleteAndSubmitQuiz( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was not added to Kit. @@ -372,8 +384,8 @@ public function testSettingsForminatorQuizSubscribeOption(EndToEndTester $I) // Complete and submit Forminator Quiz. $this->_forminatorCompleteAndSubmitQuiz( $I, - $pageID, - $emailAddress + pageID: $pageID, + emailAddress: $emailAddress ); // Confirm that the email address was added to Kit. From 06276b9704b1c5fccf5e18500311ee4cd9135b7c Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 23 May 2025 18:51:08 +0800 Subject: [PATCH 05/16] Fix failing tests --- tests/EndToEnd/forms/post-types/PageFormCest.php | 4 ++-- .../woocommerce/WooCommerceProductFormCest.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/EndToEnd/forms/post-types/PageFormCest.php b/tests/EndToEnd/forms/post-types/PageFormCest.php index 44d42b323..5363eebb5 100644 --- a/tests/EndToEnd/forms/post-types/PageFormCest.php +++ b/tests/EndToEnd/forms/post-types/PageFormCest.php @@ -1011,7 +1011,7 @@ public function testQuickEditUsingDefaultForm(EndToEndTester $I) $I->quickEdit( $I, postType: 'page', - pageID: $pageID, + postID: $pageID, configuration: [ 'form' => [ 'select', 'Default' ], ] @@ -1054,7 +1054,7 @@ public function testQuickEditUsingDefinedForm(EndToEndTester $I) $I->quickEdit( $I, postType: 'page', - pageID: $pageID, + postID: $pageID, configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] diff --git a/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php b/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php index 87c34647e..515f9f0b1 100644 --- a/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php +++ b/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php @@ -262,9 +262,9 @@ public function testQuickEditUsingDefaultForm(EndToEndTester $I) // Quick Edit the Product in the Products WP_List_Table. $I->quickEdit( $I, - 'product', - $productID, - [ + postType: 'product', + postID: $productID, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -305,9 +305,9 @@ public function testQuickEditUsingDefinedForm(EndToEndTester $I) // Quick Edit the Product in the Products WP_List_Table. $I->quickEdit( $I, - 'product', - $productID, - [ + postType: 'product', + postID: $productID, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); From c909a137610982b37d77417cb62e570e3b91df8c Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 23 May 2025 19:53:36 +0800 Subject: [PATCH 06/16] Fix failing tests --- .../EndToEnd/forms/post-types/PageFormCest.php | 6 +++--- .../woocommerce/WooCommerceProductFormCest.php | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/EndToEnd/forms/post-types/PageFormCest.php b/tests/EndToEnd/forms/post-types/PageFormCest.php index 5363eebb5..66678d30f 100644 --- a/tests/EndToEnd/forms/post-types/PageFormCest.php +++ b/tests/EndToEnd/forms/post-types/PageFormCest.php @@ -1105,7 +1105,7 @@ public function testBulkEditUsingDefaultForm(EndToEndTester $I) $I->bulkEdit( $I, postType: 'page', - pageIDs: $pageIDs, + postIDs: $pageIDs, configuration: [ 'form' => [ 'select', 'Default' ], ] @@ -1159,7 +1159,7 @@ public function testBulkEditUsingDefinedForm(EndToEndTester $I) $I->bulkEdit( $I, postType: 'page', - pageIDs: $pageIDs, + postIDs: $pageIDs, configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] @@ -1227,7 +1227,7 @@ public function testBulkEditWithNoChanges(EndToEndTester $I) $I->bulkEdit( $I, postType: 'page', - pageIDs: $pageIDs, + postIDs: $pageIDs, configuration: [ 'form' => [ 'select', '— No Change —' ], ] diff --git a/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php b/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php index 515f9f0b1..4d7ab297d 100644 --- a/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php +++ b/tests/EndToEnd/integrations/woocommerce/WooCommerceProductFormCest.php @@ -356,9 +356,9 @@ public function testBulkEditUsingDefaultForm(EndToEndTester $I) // Bulk Edit the Products in the Products WP_List_Table. $I->bulkEdit( $I, - 'product', - $productIDs, - [ + postType: 'product', + postIDs: $productIDs, + configuration: [ 'form' => [ 'select', 'Default' ], ] ); @@ -410,9 +410,9 @@ public function testBulkEditUsingDefinedForm(EndToEndTester $I) // Bulk Edit the Products in the Products WP_List_Table. $I->bulkEdit( $I, - 'product', - $productIDs, - [ + postType: 'product', + postIDs: $productIDs, + configuration: [ 'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -478,9 +478,9 @@ public function testBulkEditWithNoChanges(EndToEndTester $I) // Bulk Edit the Products in the Products WP_List_Table. $I->bulkEdit( $I, - 'product', - $productIDs, - [ + postType: 'product', + postIDs: $productIDs, + configuration: [ 'form' => [ 'select', '— No Change —' ], ] ); From 1392bf62e1d7f29794eb43ca1bb9e39d04ac7f53 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 23 May 2025 20:04:18 +0800 Subject: [PATCH 07/16] Fix failing test --- tests/EndToEnd/forms/post-types/PostFormCest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/EndToEnd/forms/post-types/PostFormCest.php b/tests/EndToEnd/forms/post-types/PostFormCest.php index 66b311116..9d545a09e 100644 --- a/tests/EndToEnd/forms/post-types/PostFormCest.php +++ b/tests/EndToEnd/forms/post-types/PostFormCest.php @@ -70,7 +70,7 @@ public function testAddNewPostUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin // Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms. $I->checkSelectFormOptionOrder( $I, - selector: '#wp-convertkit-form', + selectElement: '#wp-convertkit-form', prependOptions: [ 'Default', 'None', From e85c08cc43e30d92453926319dc3b45d5660442d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 23 May 2025 20:24:45 +0800 Subject: [PATCH 08/16] Fix failing test --- .../EndToEnd/general/other/RefreshResourcesButtonCest.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php b/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php index c5df28dbb..07f48a633 100644 --- a/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php +++ b/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php @@ -176,11 +176,8 @@ public function testRefreshResourcesOnQuickEdit(EndToEndTester $I) // Change resource to value specified in the .env file, which should now be available. // If the expected dropdown value does not exist, this will fail the test. - $I->fillSelect2Field( - $I, - container: '#select2-wp-convertkit-quick-edit-form-container', - value: $_ENV['CONVERTKIT_API_FORM_NAME'] - ); + $I->selectOption('#wp-convertkit-quick-edit-form', $_ENV['CONVERTKIT_API_FORM_NAME']); + // Click the Tags refresh button. $I->click('button.wp-convertkit-refresh-resources[data-resource="tags"]'); From 92cd91281a69537355e4721035c471c57d771ca3 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 23 May 2025 20:38:38 +0800 Subject: [PATCH 09/16] Coding standards --- tests/EndToEnd/general/other/RefreshResourcesButtonCest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php b/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php index 07f48a633..6175901e1 100644 --- a/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php +++ b/tests/EndToEnd/general/other/RefreshResourcesButtonCest.php @@ -178,7 +178,6 @@ public function testRefreshResourcesOnQuickEdit(EndToEndTester $I) // If the expected dropdown value does not exist, this will fail the test. $I->selectOption('#wp-convertkit-quick-edit-form', $_ENV['CONVERTKIT_API_FORM_NAME']); - // Click the Tags refresh button. $I->click('button.wp-convertkit-refresh-resources[data-resource="tags"]'); From 6e9f1e36803c4540a43cf1afa5011113e015dc97 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 23 May 2025 21:54:34 +0800 Subject: [PATCH 10/16] Tests: Contact Form 7: Wait for API to update before checking subscriber exists --- .../integrations/other/ContactForm7FormCest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/EndToEnd/integrations/other/ContactForm7FormCest.php b/tests/EndToEnd/integrations/other/ContactForm7FormCest.php index 762434f4d..fd4934f30 100644 --- a/tests/EndToEnd/integrations/other/ContactForm7FormCest.php +++ b/tests/EndToEnd/integrations/other/ContactForm7FormCest.php @@ -66,6 +66,9 @@ public function testSettingsContactForm7ToKitFormMapping(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -103,6 +106,9 @@ public function testSettingsContactForm7ToKitLegacyFormMapping(EndToEndTester $I emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $I->apiCheckSubscriberExists($I, $emailAddress); } @@ -132,6 +138,9 @@ public function testSettingsContactForm7ToKitTagMapping(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -168,6 +177,9 @@ public function testSettingsContactForm7ToKitSequenceMapping(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -233,6 +245,9 @@ public function testSettingsContactForm7SubscribeOption(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $I->apiCheckSubscriberExists($I, $emailAddress); } From 21d8e89be4f65450c2766c392a6391a05438346d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 23 May 2025 22:34:56 +0800 Subject: [PATCH 11/16] Tests: Forminator: Wait for API to update before checking subscriber exists --- .../integrations/other/ForminatorCest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/EndToEnd/integrations/other/ForminatorCest.php b/tests/EndToEnd/integrations/other/ForminatorCest.php index 37245288b..60e8a9cb2 100644 --- a/tests/EndToEnd/integrations/other/ForminatorCest.php +++ b/tests/EndToEnd/integrations/other/ForminatorCest.php @@ -66,6 +66,9 @@ public function testSettingsForminatorFormToKitFormMapping(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -103,6 +106,9 @@ public function testSettingsForminatorFormToKitLegacyFormMapping(EndToEndTester emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $I->apiCheckSubscriberExists($I, $emailAddress); } @@ -132,6 +138,9 @@ public function testSettingsForminatorFormToKitTagMapping(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -168,6 +177,9 @@ public function testSettingsForminatorFormToKitSequenceMapping(EndToEndTester $I emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -258,6 +270,9 @@ public function testSettingsForminatorQuizToKitFormMapping(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $I->apiCheckSubscriberExists($I, $emailAddress); } @@ -287,6 +302,9 @@ public function testSettingsForminatorQuizToKitTagMapping(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -323,6 +341,9 @@ public function testSettingsForminatorQuizToKitSequenceMapping(EndToEndTester $I emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $subscriberID = $I->apiCheckSubscriberExists($I, $emailAddress); @@ -388,6 +409,9 @@ public function testSettingsForminatorQuizSubscribeOption(EndToEndTester $I) emailAddress: $emailAddress ); + // Wait for the API to update. + $I->wait(2); + // Confirm that the email address was added to Kit. $I->apiCheckSubscriberExists($I, $emailAddress); } From 4d9c1611525a8a654ea1163754f0339250567b33 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Sat, 24 May 2025 10:32:31 +0800 Subject: [PATCH 12/16] Tests: Use Named Arguments, Part 3 --- .../landing-pages/PageLandingPageCest.php | 76 ++++--- .../PageLandingPageSetupWizardCest.php | 12 +- .../landing-pages/PostLandingPageCest.php | 10 +- .../PageBlockFormatterProductLinkCest.php | 56 +++-- .../products/PageBlockProductCest.php | 204 +++++++++++++----- .../products/PageShortcodeProductCest.php | 158 ++++++++++---- 6 files changed, 359 insertions(+), 157 deletions(-) diff --git a/tests/EndToEnd/landing-pages/PageLandingPageCest.php b/tests/EndToEnd/landing-pages/PageLandingPageCest.php index 8ef1e8810..930c93b99 100644 --- a/tests/EndToEnd/landing-pages/PageLandingPageCest.php +++ b/tests/EndToEnd/landing-pages/PageLandingPageCest.php @@ -39,13 +39,16 @@ public function _before(EndToEndTester $I) public function testAddNewPageUsingNoLandingPage(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Landing Page: None'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Landing Page: None' + ); // Check the order of the Landing Page resources are alphabetical, with the None option prepending the Landing Pages. $I->checkSelectLandingPageOptionOrder( $I, - '#wp-convertkit-landing_page', - [ + selectElement: '#wp-convertkit-landing_page', + prependOptions:[ 'None', ] ); @@ -53,8 +56,8 @@ public function testAddNewPageUsingNoLandingPage(EndToEndTester $I) // Configure metabox's Landing Page setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', 'None' ], ] ); @@ -78,13 +81,16 @@ public function testAddNewPageUsingNoLandingPage(EndToEndTester $I) public function testAddNewPageUsingDefinedLandingPage(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Landing Page: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Landing Page: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] + ); // Configure metabox's Landing Page setting to value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] ], ] ); @@ -125,13 +131,16 @@ public function testLandingPageSiteIcon(EndToEndTester $I) $I->haveOptionInDatabase('site_icon', $imageID); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Landing Page: Site Icon: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Landing Page: Site Icon: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] + ); // Configure metabox's Landing Page setting to value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] ], ] ); @@ -167,13 +176,16 @@ public function testLandingPageSiteIcon(EndToEndTester $I) public function testLandingPageCharacterEncoding(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Landing Page: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Landing Page: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_NAME'] + ); // Configure metabox's Landing Page setting to value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_NAME'] ], ] ); @@ -202,13 +214,16 @@ public function testLandingPageCharacterEncoding(EndToEndTester $I) public function testAddNewPageUsingDefinedLegacyLandingPage(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Landing Page: ' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Landing Page: ' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME'] + ); // Configure metabox's Landing Page setting to value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME'] ], ] ); @@ -242,13 +257,16 @@ public function testLegacyLandingPageSiteIcon(EndToEndTester $I) $I->haveOptionInDatabase('site_icon', $imageID); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Legacy Landing Page: Site Icon: ' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Legacy Landing Page: Site Icon: ' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME'] + ); // Configure metabox's Landing Page setting to value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME'] ], ] ); @@ -347,13 +365,16 @@ public function testAddNewPageUsingDefinedLandingPageWithPerfmattersPlugin(EndTo ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Landing Page: Perfmatters: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Landing Page: Perfmatters: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] + ); // Configure metabox's Landing Page setting to value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] ], ] ); @@ -402,13 +423,16 @@ public function testAddNewPageUsingDefinedLandingPageWithWPRocket(EndToEndTester $I->enableWPRocketLazyLoad($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Landing Page: WP Rocket: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME']); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Landing Page: WP Rocket: ' . $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] + ); // Configure metabox's Landing Page setting to value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'landing_page' => [ 'select2', $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] ], ] ); diff --git a/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php b/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php index c9c3e1dbd..dd5270eb9 100644 --- a/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php +++ b/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php @@ -185,7 +185,11 @@ public function testAddNewMemberLandingPage(EndToEndTester $I) $this->_setupAndLoadAddNewLandingPageScreen($I); // Select a landing page and enter a slug. - $I->fillSelect2Field($I, '#select2-landing_page-container', $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-landing_page-container', + value: $_ENV['CONVERTKIT_API_LANDING_PAGE_NAME'] + ); $I->fillField('post_name', 'landing-page-setup-wizard'); // Click create button. @@ -226,7 +230,11 @@ public function testAddNewMemberLegacyLandingPage(EndToEndTester $I) $this->_setupAndLoadAddNewLandingPageScreen($I); // Select a landing page and enter a slug. - $I->fillSelect2Field($I, '#select2-landing_page-container', $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME']); + $I->fillSelect2Field( + $I, + container: '#select2-landing_page-container', + value: $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_NAME'] + ); $I->fillField('post_name', 'landing-page-setup-wizard'); // Click create button. diff --git a/tests/EndToEnd/landing-pages/PostLandingPageCest.php b/tests/EndToEnd/landing-pages/PostLandingPageCest.php index b5841af4e..ed99a7c2d 100644 --- a/tests/EndToEnd/landing-pages/PostLandingPageCest.php +++ b/tests/EndToEnd/landing-pages/PostLandingPageCest.php @@ -40,7 +40,11 @@ public function _before(EndToEndTester $I) public function testAddNewPostDoesNotDisplayLandingPageOption(EndToEndTester $I) { // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Landing Page'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Landing Page' + ); // Check that the metabox is displayed. $I->seeElementInDOM('#wp-convertkit-meta-box'); @@ -51,8 +55,8 @@ public function testAddNewPostDoesNotDisplayLandingPageOption(EndToEndTester $I) // Configure metabox's Form setting = Default. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'Default' ], ] ); diff --git a/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php b/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php index 326d30d4c..de86338d8 100644 --- a/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php +++ b/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php @@ -37,13 +37,16 @@ public function testProductLinkFormatter(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product Link Formatter'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product Link Formatter' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -57,9 +60,9 @@ public function testProductLinkFormatter(EndToEndTester $I) // Apply formatter to link the selected text. $I->applyGutenbergFormatter( $I, - 'Kit Product Trigger', - 'convertkit-product-link', - [ + formatterName: 'Kit Product Trigger', + formatterProgrammaticName:'convertkit-product-link', + formatterConfiguration:[ // Product. 'data-id' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -87,13 +90,16 @@ public function testProductLinkFormatterToggleProductSelection(EndToEndTester $I $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product Link Formatter: Product Toggle'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product Link Formatter: Product Toggle' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -107,9 +113,9 @@ public function testProductLinkFormatterToggleProductSelection(EndToEndTester $I // Apply formatter to link the selected text. $I->applyGutenbergFormatter( $I, - 'Kit Product Trigger', - 'convertkit-product-link', - [ + formatterName: 'Kit Product Trigger', + formatterProgrammaticName:'convertkit-product-link', + formatterConfiguration:[ // Product. 'data-id' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -118,9 +124,9 @@ public function testProductLinkFormatterToggleProductSelection(EndToEndTester $I // Apply the formatter again, this time selecting the 'None' option. $I->applyGutenbergFormatter( $I, - 'Kit Product Trigger', - 'convertkit-product-link', - [ + formatterName: 'Kit Product Trigger', + formatterProgrammaticName:'convertkit-product-link', + formatterConfiguration:[ // Form. 'data-id' => [ 'select', 'None' ], ] @@ -147,13 +153,16 @@ public function testProductLinkFormatterWithNoProduct(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product Link Formatter: No Product'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product Link Formatter: No Product' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -167,9 +176,9 @@ public function testProductLinkFormatterWithNoProduct(EndToEndTester $I) // Apply formatter to link the selected text. $I->applyGutenbergFormatter( $I, - 'Kit Product Trigger', - 'convertkit-product-link', - [ + formatterName: 'Kit Product Trigger', + formatterProgrammaticName:'convertkit-product-link', + formatterConfiguration:[ // Form. 'data-id' => [ 'select', 'None' ], ] @@ -192,7 +201,10 @@ public function testProductLinkFormatterWithNoProduct(EndToEndTester $I) public function testProductLinkFormatterNotRegisteredWhenNoProductsExist(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product Link Formatter: No Products Exist'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product Link Formatter: No Products Exist' + ); // Add paragraph to Page. $I->addGutenbergParagraphBlock($I, 'Subscribe'); diff --git a/tests/EndToEnd/products/PageBlockProductCest.php b/tests/EndToEnd/products/PageBlockProductCest.php index b2d96672c..a5925dcff 100644 --- a/tests/EndToEnd/products/PageBlockProductCest.php +++ b/tests/EndToEnd/products/PageBlockProductCest.php @@ -37,13 +37,16 @@ public function testProductBlockWithValidProductParameter(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Valid Product Param'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Valid Product Param' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -51,9 +54,9 @@ public function testProductBlockWithValidProductParameter(EndToEndTester $I) // Add block to Page, setting the Product setting to the value specified in the .env file. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product', - [ + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product', + blockConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] ); @@ -62,7 +65,11 @@ public function testProductBlockWithValidProductParameter(EndToEndTester $I) $I->publishAndViewGutenbergPage($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); } /** @@ -79,19 +86,26 @@ public function testProductBlockWithNoProductParameter(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: No Product Param'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: No Product Param' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); // Add block to Page. - $I->addGutenbergBlock($I, 'Kit Product', 'convertkit-product'); + $I->addGutenbergBlock( + $I, + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product' + ); // Confirm that the Product block displays instructions to the user on how to select a Product. $I->seeBlockHasNoContentMessage($I, 'Select a Product using the Product option in the Gutenberg sidebar.'); @@ -117,14 +131,17 @@ public function testProductBlockWithTextParameter(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Text Param'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Text Param' + ); // Add block to Page, setting the date format. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product', - [ + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product', + blockConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'text' => [ 'text', 'Buy Now' ], ] @@ -134,7 +151,11 @@ public function testProductBlockWithTextParameter(EndToEndTester $I) $I->publishAndViewGutenbergPage($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy Now'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy Now' + ); } /** @@ -151,14 +172,17 @@ public function testProductBlockWithBlankTextParameter(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Blank Text Param'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Blank Text Param' + ); // Add block to Page, setting the date format. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product', - [ + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product', + blockConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'text' => [ 'text', '' ], ] @@ -168,7 +192,11 @@ public function testProductBlockWithBlankTextParameter(EndToEndTester $I) $I->publishAndViewGutenbergPage($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); } /** @@ -185,13 +213,16 @@ public function testProductBlockWithValidDiscountCodeParameter(EndToEndTester $I $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Valid Discount Code Param'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Valid Discount Code Param' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -199,9 +230,9 @@ public function testProductBlockWithValidDiscountCodeParameter(EndToEndTester $I // Add block to Page, setting the Product setting to the value specified in the .env file. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product', - [ + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product', + blockConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'discount_code' => [ 'text', $_ENV['CONVERTKIT_API_PRODUCT_DISCOUNT_CODE'] ], ] @@ -211,7 +242,11 @@ public function testProductBlockWithValidDiscountCodeParameter(EndToEndTester $I $I->publishAndViewGutenbergPage($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); // Confirm the discount code has been applied. $I->switchToIFrame('iframe[data-active]'); @@ -233,13 +268,16 @@ public function testProductBlockWithInvalidDiscountCodeParameter(EndToEndTester $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Invalid Discount Code Param'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Invalid Discount Code Param' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -247,9 +285,9 @@ public function testProductBlockWithInvalidDiscountCodeParameter(EndToEndTester // Add block to Page, setting the Product setting to the value specified in the .env file. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product', - [ + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product', + blockConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'discount_code' => [ 'text', 'fake' ], ] @@ -259,7 +297,11 @@ public function testProductBlockWithInvalidDiscountCodeParameter(EndToEndTester $I->publishAndViewGutenbergPage($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); // Confirm the discount code is not valid, but the modal displays so the user can still purchase. $I->switchToIFrame('iframe[data-active]'); @@ -282,13 +324,16 @@ public function testProductBlockWithCheckoutParameterEnabled(EndToEndTester $I) $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Checkout Step'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Checkout Step' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -296,9 +341,9 @@ public function testProductBlockWithCheckoutParameterEnabled(EndToEndTester $I) // Add block to Page, setting the Product setting to the value specified in the .env file. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product', - [ + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product', + blockConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], '#inspector-toggle-control-0' => [ 'toggle', true ], ] @@ -308,7 +353,11 @@ public function testProductBlockWithCheckoutParameterEnabled(EndToEndTester $I) $I->publishAndViewGutenbergPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); // Confirm the checkout step is displayed. $I->switchToIFrame('iframe[data-active]'); @@ -331,13 +380,16 @@ public function testProductBlockWithDisableModalOnMobileParameterEnabled(EndToEn $I->setupKitPluginResources($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Disable Modal on Mobile'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Disable Modal on Mobile' + ); // Configure metabox's Form setting = None, ensuring we only test the block in Gutenberg. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], ] ); @@ -345,9 +397,9 @@ public function testProductBlockWithDisableModalOnMobileParameterEnabled(EndToEn // Add block to Page, setting the Product setting to the value specified in the .env file. $I->addGutenbergBlock( $I, - 'Kit Product', - 'convertkit-product', - [ + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product', + blockConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], '#inspector-toggle-control-1' => [ 'toggle', true ], ] @@ -412,7 +464,10 @@ public function testProductBlockWithThemeColorParameters(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL']); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'] + ); // Confirm that the chosen colors are applied as CSS styles. $I->seeInSource('class="wp-block-button__link convertkit-product has-text-color has-' . $textColor . '-color has-background has-' . $backgroundColor . '-background-color'); @@ -456,7 +511,13 @@ public function testProductBlockWithHexColorParameters(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that the block displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product', $textColor, $backgroundColor); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product', + textColor: $textColor, + backgroundColor: $backgroundColor + ); } /** @@ -470,16 +531,23 @@ public function testProductBlockWithHexColorParameters(EndToEndTester $I) public function testProductBlockWhenNoCredentials(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Block: No API Key'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Block: No API Key' + ); // Add block to Page. - $I->addGutenbergBlock($I, 'Kit Product', 'convertkit-product'); + $I->addGutenbergBlock( + $I, + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product' + ); // Test that the popup window works. $I->testBlockNoCredentialsPopupWindow( $I, - 'convertkit-product', - 'Select a Product using the Product option in the Gutenberg sidebar.' + blockName: 'convertkit-product', + expectedMessage:'Select a Product using the Product option in the Gutenberg sidebar.' ); // Save page to avoid alert box when _passed() runs to deactivate the Plugin. @@ -501,10 +569,17 @@ public function testProductBlockWhenNoProducts(EndToEndTester $I) $I->setupKitPluginResourcesNoData($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Block: No Products'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Block: No Products' + ); // Add block to Page. - $I->addGutenbergBlock($I, 'Kit Product', 'convertkit-product'); + $I->addGutenbergBlock( + $I, + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product' + ); // Confirm that the Product block displays instructions to the user on how to add a Product in Kit. $I->seeBlockHasNoContentMessage($I, 'No products exist in Kit.'); @@ -530,10 +605,17 @@ public function testProductBlockRefreshButton(EndToEndTester $I) $I->setupKitPluginResourcesNoData($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Product: Refresh Button'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Product: Refresh Button' + ); // Add block to Page. - $I->addGutenbergBlock($I, 'Kit Product', 'convertkit-product'); + $I->addGutenbergBlock( + $I, + blockName: 'Kit Product', + blockProgrammaticName: 'convertkit-product' + ); // Setup Plugin with a valid API Key and resources, as if the user performed the necessary steps to authenticate // and create a product. @@ -586,7 +668,11 @@ public function testProductBlockParameterEscaping(EndToEndTester $I) $I->dontSeeInSource('style="color:red" onmouseover="alert(1)""'); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); } /** diff --git a/tests/EndToEnd/products/PageShortcodeProductCest.php b/tests/EndToEnd/products/PageShortcodeProductCest.php index 93626452f..98150842f 100644 --- a/tests/EndToEnd/products/PageShortcodeProductCest.php +++ b/tests/EndToEnd/products/PageShortcodeProductCest.php @@ -38,23 +38,30 @@ public function testProductShortcodeInVisualEditorWithValidProductParameter(EndT $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Visual Editor'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Visual Editor' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Product', - [ + shortcodeName: 'Kit Product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="0" disable_modal_on_mobile="0"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="0" disable_modal_on_mobile="0"]' ); // Publish and view the Page on the frontend site. $I->publishAndViewClassicEditorPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); } /** @@ -72,23 +79,30 @@ public function testProductShortcodeInTextEditorWithValidProductParameter(EndToE $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Text Editor'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Text Editor' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addTextEditorShortcode( $I, - 'convertkit-product', - [ + shortcodeProgrammaticName: 'convertkit-product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="0" disable_modal_on_mobile="0"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="0" disable_modal_on_mobile="0"]' ); // Publish and view the Page on the frontend site. $I->publishAndViewClassicEditorPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); } /** @@ -136,24 +150,31 @@ public function testProductShortcodeInVisualEditorWithTextParameter(EndToEndTest $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Text Param'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Text Param' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Product', - [ + shortcodeName: 'Kit Product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'text' => [ 'input', 'Buy now' ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy now" checkout="0" disable_modal_on_mobile="0"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy now" checkout="0" disable_modal_on_mobile="0"]' ); // Publish and view the Page on the frontend site. $I->publishAndViewClassicEditorPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy now'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy now' + ); } /** @@ -170,24 +191,31 @@ public function testProductShortcodeInVisualEditorWithBlankTextParameter(EndToEn $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Blank Text Param'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Blank Text Param' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Product', - [ + shortcodeName: 'Kit Product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'text' => [ 'input', '' ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" checkout="0" disable_modal_on_mobile="0"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" checkout="0" disable_modal_on_mobile="0"]' ); // Publish and view the Page on the frontend site. $I->publishAndViewClassicEditorPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); } /** @@ -204,24 +232,31 @@ public function testProductShortcodeInVisualEditorWithValidDiscountCodeParameter $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Valid Discount Code Param'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Valid Discount Code Param' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Product', - [ + shortcodeName: 'Kit Product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'discount_code' => [ 'input', $_ENV['CONVERTKIT_API_PRODUCT_DISCOUNT_CODE'] ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" discount_code="' . $_ENV['CONVERTKIT_API_PRODUCT_DISCOUNT_CODE'] . '" checkout="0" disable_modal_on_mobile="0"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" discount_code="' . $_ENV['CONVERTKIT_API_PRODUCT_DISCOUNT_CODE'] . '" checkout="0" disable_modal_on_mobile="0"]' ); // Publish and view the Page on the frontend site. $I->publishAndViewClassicEditorPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); // Confirm the discount code has been applied. $I->switchToIFrame('iframe[data-active]'); @@ -243,24 +278,31 @@ public function testProductShortcodeInVisualEditorWithInvalidDiscountCodeParamet $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Valid Discount Code Param'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Valid Discount Code Param' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Product', - [ + shortcodeName: 'Kit Product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'discount_code' => [ 'input', 'fake' ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" discount_code="fake" checkout="0" disable_modal_on_mobile="0"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" discount_code="fake" checkout="0" disable_modal_on_mobile="0"]' ); // Publish and view the Page on the frontend site. $I->publishAndViewClassicEditorPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); // Confirm the discount code is not valid, but the modal displays so the user can still purchase. $I->switchToIFrame('iframe[data-active]'); @@ -283,24 +325,31 @@ public function testProductShortcodeWithCheckoutParameterEnabled(EndToEndTester $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Checkout Step'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Checkout Step' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Product', - [ + shortcodeName: 'Kit Product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'checkout' => [ 'toggle', 'Yes' ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="1" disable_modal_on_mobile="0"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="1" disable_modal_on_mobile="0"]' ); // Publish and view the Page on the frontend site. $I->publishAndViewClassicEditorPage($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); // Confirm the checkout step is displayed. $I->switchToIFrame('iframe[data-active]'); @@ -323,17 +372,20 @@ public function testProductShortcodeWithDisableModalOnMobileParameterEnabled(End $I->setupKitPluginResources($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: Disable Modal on Mobile'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: Disable Modal on Mobile' + ); // Add shortcode to Page, setting the Product setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Product', - [ + shortcodeName: 'Kit Product', + shortcodeConfiguration: [ 'product' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], 'disable_modal_on_mobile' => [ 'toggle', 'Yes' ], ], - '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="0" disable_modal_on_mobile="1"]' + expectedShortcodeOutput: '[convertkit_product product="' . $_ENV['CONVERTKIT_API_PRODUCT_ID'] . '" text="Buy my product" checkout="0" disable_modal_on_mobile="1"]' ); // Publish and view the Page on the frontend site. @@ -398,7 +450,13 @@ public function testProductShortcodeWithHexColorParameters(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product', $textColor, $backgroundColor); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product', + textColor: $textColor, + backgroundColor: $backgroundColor + ); } /** @@ -437,7 +495,11 @@ public function testProductShortcodeParameterEscaping(EndToEndTester $I) $I->dontSeeInSource('style="color:red" onmouseover="alert(1)""'); // Confirm that the Kit Product is displayed. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); + $I->seeProductOutput( + $I, + productURL: $_ENV['CONVERTKIT_API_PRODUCT_URL'], + text: 'Buy my product' + ); } /** @@ -451,12 +513,15 @@ public function testProductShortcodeParameterEscaping(EndToEndTester $I) public function testProductShortcodeWhenNoCredentials(EndToEndTester $I) { // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: No API Key'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: No API Key' + ); // Open Visual Editor modal for the shortcode. $I->openVisualEditorShortcodeModal( $I, - 'Kit Product' + shortcodeName:'Kit Product' ); // Confirm an error notice displays. @@ -509,12 +574,15 @@ public function testProductShortcodeWhenNoProducts(EndToEndTester $I) $I->setupKitPluginResourcesNoData($I); // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Product: Shortcode: No Products'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Product: Shortcode: No Products' + ); // Open Visual Editor modal for the shortcode. $I->openVisualEditorShortcodeModal( $I, - 'Kit Product' + shortcodeName: 'Kit Product' ); // Confirm an error notice displays. From b35c2f7cf17b9979101cdb684d74236d507be646 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Sat, 24 May 2025 10:44:30 +0800 Subject: [PATCH 13/16] Add named arguments to Tag and some Restrict Content tests --- .../general/RestrictContentCacheCest.php | 36 ++++- .../general/RestrictContentFormCest.php | 56 +++++-- .../general/RestrictContentSetupCest.php | 12 +- .../general/RestrictContentTagCest.php | 140 +++++++++++++----- .../tags/PageShortcodeCustomContentCest.php | 22 ++- tests/EndToEnd/tags/PageTagCest.php | 69 ++++++--- 6 files changed, 242 insertions(+), 93 deletions(-) diff --git a/tests/EndToEnd/restrict-content/general/RestrictContentCacheCest.php b/tests/EndToEnd/restrict-content/general/RestrictContentCacheCest.php index ed3d425cc..9495df5a0 100644 --- a/tests/EndToEnd/restrict-content/general/RestrictContentCacheCest.php +++ b/tests/EndToEnd/restrict-content/general/RestrictContentCacheCest.php @@ -85,7 +85,11 @@ public function testRestrictContentLiteSpeedCache(EndToEndTester $I) // Test that the restricted content displays when a valid signed subscriber ID is used, // to confirm caching does not show the incorrect content. - $I->setRestrictContentCookieAndReload($I, $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], $pageID); + $I->setRestrictContentCookieAndReload( + $I, + subscriberID: $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], + urlOrPageID: $pageID + ); $I->testRestrictContentDisplaysContent($I); // Deactivate Litespeed Cache Plugin. @@ -150,7 +154,11 @@ public function testRestrictContentW3TotalCache(EndToEndTester $I) // Test that the restricted content displays when a valid signed subscriber ID is used, // to confirm caching does not show the incorrect content. - $I->setRestrictContentCookieAndReload($I, $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], $pageID); + $I->setRestrictContentCookieAndReload( + $I, + subscriberID: $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], + urlOrPageID: $pageID + ); $I->testRestrictContentDisplaysContent($I); // Deactivate W3 Total Cache Plugin. @@ -224,7 +232,11 @@ public function testRestrictContentWPFastestCache(EndToEndTester $I) // Test that the restricted content displays when a valid signed subscriber ID is used, // to confirm caching does not show the incorrect content. - $I->setRestrictContentCookieAndReload($I, $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], $pageID); + $I->setRestrictContentCookieAndReload( + $I, + subscriberID: $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], + urlOrPageID: $pageID + ); $I->testRestrictContentDisplaysContent($I); // Deactivate WP Fastest Cache Plugin. @@ -289,7 +301,11 @@ public function testRestrictContentWPOptimize(EndToEndTester $I) // Test that the restricted content displays when a valid signed subscriber ID is used, // to confirm caching does not show the incorrect content. - $I->setRestrictContentCookieAndReload($I, $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], $pageID); + $I->setRestrictContentCookieAndReload( + $I, + subscriberID: $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], + urlOrPageID: $pageID + ); $I->testRestrictContentDisplaysContent($I); // Deactivate WP-Optimize Cache Plugin. @@ -354,7 +370,11 @@ public function testRestrictContentWPSuperCache(EndToEndTester $I) // Test that the restricted content displays when a valid signed subscriber ID is used, // to confirm caching does not show the incorrect content. - $I->setRestrictContentCookieAndReload($I, $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], $pageID); + $I->setRestrictContentCookieAndReload( + $I, + subscriberID: $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], + urlOrPageID: $pageID + ); $I->testRestrictContentDisplaysContent($I); // Deactivate WP Super Cache Plugin. @@ -410,7 +430,11 @@ public function testRestrictContentWPRocketCache(EndToEndTester $I) // Test that the restricted content displays when a valid signed subscriber ID is used, // to confirm caching does not show the incorrect content. - $I->setRestrictContentCookieAndReload($I, $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], $pageID); + $I->setRestrictContentCookieAndReload( + $I, + subscriberID: $_ENV['CONVERTKIT_API_SIGNED_SUBSCRIBER_ID'], + urlOrPageID: $pageID + ); $I->testRestrictContentDisplaysContent($I); // Deactivate WP Super Cache Plugin. diff --git a/tests/EndToEnd/restrict-content/general/RestrictContentFormCest.php b/tests/EndToEnd/restrict-content/general/RestrictContentFormCest.php index b8bd17f0a..9792aaa07 100644 --- a/tests/EndToEnd/restrict-content/general/RestrictContentFormCest.php +++ b/tests/EndToEnd/restrict-content/general/RestrictContentFormCest.php @@ -38,7 +38,10 @@ public function testRestrictContentByForm(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Form'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Form' + ); // Configure metabox's Restrict Content setting = Form name. $I->configureMetaboxSettings( @@ -52,14 +55,22 @@ public function testRestrictContentByForm(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. $url = $I->publishGutenbergPage($I); // Test Restrict Content functionality. - $I->testRestrictedContentByFormOnFrontend($I, $url, $_ENV['CONVERTKIT_API_FORM_ID']); + $I->testRestrictedContentByFormOnFrontend( + $I, + urlOrPageID: $url, + formID: $_ENV['CONVERTKIT_API_FORM_ID'] + ); } /** @@ -76,13 +87,16 @@ public function testRestrictContentByFormWithLoginModal(EndToEndTester $I) $I->setupKitPlugin($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Form'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Form' + ); // Configure metabox's Restrict Content setting = Form name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration:[ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] @@ -90,14 +104,22 @@ public function testRestrictContentByFormWithLoginModal(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. $url = $I->publishGutenbergPage($I); // Test Restrict Content functionality. - $I->testRestrictedContentByFormOnFrontendUsingLoginModal($I, $url, $_ENV['CONVERTKIT_API_FORM_ID']); + $I->testRestrictedContentByFormOnFrontendUsingLoginModal( + $I, + urlOrPageID: $url, + formID: $_ENV['CONVERTKIT_API_FORM_ID'] + ); } /** @@ -164,7 +186,11 @@ public function testRestrictContentByFormUsingQuickEdit(EndToEndTester $I) ); // Test Restrict Content functionality. - $I->testRestrictedContentByFormOnFrontend($I, $pageID, $_ENV['CONVERTKIT_API_FORM_ID']); + $I->testRestrictedContentByFormOnFrontend( + $I, + urlOrPageID: $pageID, + formID: $_ENV['CONVERTKIT_API_FORM_ID'] + ); } /** @@ -199,9 +225,9 @@ public function testRestrictContentByFormUsingBulkEdit(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + postIDs: $pageIDs, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ], ] ); @@ -209,7 +235,11 @@ public function testRestrictContentByFormUsingBulkEdit(EndToEndTester $I) // Iterate through Pages to run frontend tests. foreach ($pageIDs as $pageID) { // Test Restrict Content functionality. - $I->testRestrictedContentByFormOnFrontend($I, $pageID, $_ENV['CONVERTKIT_API_FORM_ID']); + $I->testRestrictedContentByFormOnFrontend( + $I, + urlOrPageID: $pageID, + formID: $_ENV['CONVERTKIT_API_FORM_ID'] + ); } } diff --git a/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php b/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php index 82e4028f5..196b24167 100644 --- a/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php +++ b/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php @@ -370,9 +370,9 @@ public function testAddNewMemberContentDownloadsByTag(EndToEndTester $I) // Test Restrict Content functionality. $I->testRestrictedContentByTagOnFrontend( $I, - $url, - $I->generateEmailAddress(), - [ + urlOrPageID: $url, + emailAddress: $I->generateEmailAddress(), + options: [ 'member_content' => 'The downloadable content (that is available when the visitor has paid for the Kit product) goes here.', ] ); @@ -439,9 +439,9 @@ public function testAddNewMemberContentCourseByTag(EndToEndTester $I) // Test Restrict Content functionality. $I->testRestrictedContentByTagOnFrontend( $I, - $url, - $I->generateEmailAddress(), - [ + urlOrPageID: $url, + emailAddress: $I->generateEmailAddress(), + options: [ 'visible_content' => 'Some introductory text about lesson 1', 'member_content' => 'Lesson 1 content (that is available when the visitor has paid for the Kit product) goes here.', ] diff --git a/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php b/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php index efeb94d52..dee67e9ec 100644 --- a/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php +++ b/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php @@ -38,13 +38,16 @@ public function testRestrictContentByTag(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Tag'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Tag' + ); // Configure metabox's Restrict Content setting = Tag name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] @@ -52,14 +55,22 @@ public function testRestrictContentByTag(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. $url = $I->publishGutenbergPage($I); // Test Restrict Content functionality. - $I->testRestrictedContentByTagOnFrontend($I, $url, $I->generateEmailAddress()); + $I->testRestrictedContentByTagOnFrontend( + $I, + urlOrPageID: $url, + emailAddress: $I->generateEmailAddress() + ); } /** @@ -87,13 +98,16 @@ public function testRestrictContentByTagWithRequireLoginEnabled(EndToEndTester $ ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Tag: Require Login'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Tag: Require Login' + ); // Configure metabox's Restrict Content setting = Tag name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] @@ -101,14 +115,22 @@ public function testRestrictContentByTagWithRequireLoginEnabled(EndToEndTester $ // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. $url = $I->publishGutenbergPage($I); // Test Restrict Content functionality. - $I->testRestrictedContentByTagOnFrontendWhenRequireLoginEnabled($I, $url, $I->generateEmailAddress()); + $I->testRestrictedContentByTagOnFrontendWhenRequireLoginEnabled( + $I, + urlOrPageID: $url, + emailAddress: $I->generateEmailAddress() + ); } /** @@ -142,13 +164,16 @@ public function testRestrictContentByTagWithRecaptchaAndRequireLoginEnabled(EndT $I->setupKitPluginRestrictContent($I, $options['settings']); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Tag: Recaptcha and Require Login'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Tag: Recaptcha and Require Login' + ); // Configure metabox's Restrict Content setting = Tag name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] @@ -156,14 +181,23 @@ public function testRestrictContentByTagWithRecaptchaAndRequireLoginEnabled(EndT // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. $url = $I->publishGutenbergPage($I); // Test Restrict Content functionality. - $I->testRestrictedContentByTagOnFrontendWhenRequireLoginEnabled($I, $url, $I->generateEmailAddress(), $options); + $I->testRestrictedContentByTagOnFrontendWhenRequireLoginEnabled( + $I, + urlOrPageID: $url, + emailAddress: $I->generateEmailAddress(), + options: $options + ); } /** @@ -194,13 +228,16 @@ public function testRestrictContentByTagUsingLoginModal(EndToEndTester $I) $I->setupKitPluginRestrictContent($I, $options['settings']); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Tag: Login Modal'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Tag: Login Modal' + ); // Configure metabox's Restrict Content setting = Tag name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] @@ -208,14 +245,22 @@ public function testRestrictContentByTagUsingLoginModal(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. $url = $I->publishGutenbergPage($I); // Test Restrict Content functionality. - $I->testRestrictedContentByTagOnFrontendUsingLoginModal($I, $url, $options); + $I->testRestrictedContentByTagOnFrontendUsingLoginModal( + $I, + urlOrPageID: $url, + options: $options + ); } /** @@ -276,13 +321,16 @@ public function testRestrictContentByTagWithRecaptchaEnabled(EndToEndTester $I) $I->setupKitPluginRestrictContent($I, $options); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Tag: reCAPTCHA'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Tag: reCAPTCHA' + ); // Configure metabox's Restrict Content setting = Tag name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] @@ -290,14 +338,23 @@ public function testRestrictContentByTagWithRecaptchaEnabled(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. $url = $I->publishGutenbergPage($I); // Test Restrict Content functionality. - $I->testRestrictedContentByTagOnFrontend($I, $url, $I->generateEmailAddress(), $options['settings']); + $I->testRestrictedContentByTagOnFrontend( + $I, + urlOrPageID: $url, + emailAddress: $I->generateEmailAddress(), + options: $options + ); } /** @@ -324,13 +381,16 @@ public function testRestrictContentByTagWithRecaptchaEnabledWithHighMinimumScore ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Tag: reCAPTCHA High Min Score'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Tag: reCAPTCHA High Min Score' + ); // Configure metabox's Restrict Content setting = Tag name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] @@ -338,7 +398,11 @@ public function testRestrictContentByTagWithRecaptchaEnabledWithHighMinimumScore // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. @@ -383,15 +447,19 @@ public function testRestrictContentByTagUsingQuickEdit(EndToEndTester $I) // Quick Edit the Page in the Pages WP_List_Table. $I->quickEdit( $I, - 'page', - $pageID, - [ + postType: 'page', + postID: $pageID, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] ); // Test Restrict Content functionality. - $I->testRestrictedContentByTagOnFrontend($I, $pageID, $I->generateEmailAddress()); + $I->testRestrictedContentByTagOnFrontend( + $I, + urlOrPageID: $pageID, + emailAddress: $I->generateEmailAddress() + ); } /** @@ -426,9 +494,9 @@ public function testRestrictContentByTagUsingBulkEdit(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + postIDs: $pageIDs, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] ); diff --git a/tests/EndToEnd/tags/PageShortcodeCustomContentCest.php b/tests/EndToEnd/tags/PageShortcodeCustomContentCest.php index da14a7856..837da3349 100644 --- a/tests/EndToEnd/tags/PageShortcodeCustomContentCest.php +++ b/tests/EndToEnd/tags/PageShortcodeCustomContentCest.php @@ -37,16 +37,19 @@ public function _before(EndToEndTester $I) public function testCustomContentShortcodeInVisualEditor(EndToEndTester $I) { // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Custom Content: Shortcode: Visual Editor'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Custom Content: Shortcode: Visual Editor' + ); // Add shortcode to Page, setting the Tag setting to the value specified in the .env file. $I->addVisualEditorShortcode( $I, - 'Kit Custom Content', - [ + shortcodeName: 'Kit Custom Content', + shortcodeConfiguration: [ 'tag' => [ 'select', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ], - '[convertkit_content tag="' . $_ENV['CONVERTKIT_API_TAG_ID'] . '"][/convertkit_content]' + expectedShortcodeOutput: '[convertkit_content tag="' . $_ENV['CONVERTKIT_API_TAG_ID'] . '"][/convertkit_content]' ); // Publish and view the Page on the frontend site. @@ -63,16 +66,19 @@ public function testCustomContentShortcodeInVisualEditor(EndToEndTester $I) public function testCustomContentShortcodeInTextEditor(EndToEndTester $I) { // Add a Page using the Classic Editor. - $I->addClassicEditorPage($I, 'page', 'Kit: Page: Custom Content: Shortcode: Text Editor'); + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Custom Content: Shortcode: Text Editor' + ); // Add shortcode to Page, setting the Tag setting to the value specified in the .env file. $I->addTextEditorShortcode( $I, - 'convertkit-content', - [ + shortcodeProgrammaticName: 'convertkit-content', + shortcodeConfiguration: [ 'tag' => [ 'select', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ], - '[convertkit_content tag="' . $_ENV['CONVERTKIT_API_TAG_ID'] . '"][/convertkit_content]' + expectedShortcodeOutput: '[convertkit_content tag="' . $_ENV['CONVERTKIT_API_TAG_ID'] . '"][/convertkit_content]' ); // Publish and view the Page on the frontend site. diff --git a/tests/EndToEnd/tags/PageTagCest.php b/tests/EndToEnd/tags/PageTagCest.php index 38aa60828..a696e4763 100644 --- a/tests/EndToEnd/tags/PageTagCest.php +++ b/tests/EndToEnd/tags/PageTagCest.php @@ -47,13 +47,16 @@ public function testAddNewPageUsingNoTag(EndToEndTester $I) $subscriberID = $I->apiSubscribe($emailAddress, $_ENV['CONVERTKIT_API_FORM_ID']); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Tag: None'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Tag: None' + ); // Check the order of the Tag resources are alphabetical, with the None option prepending the Tags. $I->checkSelectTagOptionOrder( $I, - '#wp-convertkit-tag', - [ + selectElement: '#wp-convertkit-tag', + prependOptions:[ 'None', ] ); @@ -61,8 +64,8 @@ public function testAddNewPageUsingNoTag(EndToEndTester $I) // Configure metabox's Tag setting = None. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'tag' => [ 'select2', 'None' ], ] ); @@ -77,7 +80,7 @@ public function testAddNewPageUsingNoTag(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Check that the subscriber has not been assigned to the tag. - $I->apiCheckSubscriberHasNoTags($I, $subscriberID, $_ENV['CONVERTKIT_API_TAG_ID']); + $I->apiCheckSubscriberHasNoTags($I, $subscriberID); } /** @@ -99,13 +102,16 @@ public function testAddNewPageUsingDefinedTag(EndToEndTester $I) $subscriberID = $I->apiSubscribe($emailAddress, $_ENV['CONVERTKIT_API_FORM_ID']); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Tag: ' . $_ENV['CONVERTKIT_API_TAG_NAME'] ); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Tag: ' . $_ENV['CONVERTKIT_API_TAG_NAME'] + ); // Configure metabox's Tag setting to the value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'tag' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] ); @@ -120,7 +126,11 @@ public function testAddNewPageUsingDefinedTag(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Check that the subscriber has been assigned to the tag. - $I->apiCheckSubscriberHasTag($I, $subscriberID, $_ENV['CONVERTKIT_API_TAG_ID']); + $I->apiCheckSubscriberHasTag( + $I, + subscriberID: $subscriberID, + tagID: $_ENV['CONVERTKIT_API_TAG_ID'] + ); } /** @@ -135,13 +145,16 @@ public function testAddNewPageUsingDefinedTag(EndToEndTester $I) public function testAddNewPageUsingDefinedTagWithInvalidSubscriberID(EndToEndTester $I) { // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Tag: ' . $_ENV['CONVERTKIT_API_TAG_NAME'] . ': Invalid Subscriber ID' ); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Tag: ' . $_ENV['CONVERTKIT_API_TAG_NAME'] . ': Invalid Subscriber ID' + ); // Configure metabox's Tag setting to the value specified in the .env file. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'tag' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] ); @@ -184,9 +197,9 @@ public function testQuickEditUsingDefinedTag(EndToEndTester $I) // Quick Edit the Page in the Pages WP_List_Table. $I->quickEdit( $I, - 'page', - $pageID, - [ + postType: 'page', + postID: $pageID, + configuration: [ 'tag' => [ 'select', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] ); @@ -198,7 +211,11 @@ public function testQuickEditUsingDefinedTag(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Check that the subscriber has been assigned to the tag. - $I->apiCheckSubscriberHasTag($I, $subscriberID, $_ENV['CONVERTKIT_API_TAG_ID']); + $I->apiCheckSubscriberHasTag( + $I, + subscriberID: $subscriberID, + tagID: $_ENV['CONVERTKIT_API_TAG_ID'] + ); } /** @@ -230,9 +247,9 @@ public function testBulkEditUsingDefinedTag(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + postIDs: $pageIDs, + configuration: [ 'tag' => [ 'select', $_ENV['CONVERTKIT_API_TAG_NAME'] ], ] ); @@ -300,9 +317,9 @@ public function testBulkEditWithNoChanges(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + postIDs: $pageIDs, + configuration: [ 'tag' => [ 'select', '— No Change —' ], ] ); @@ -323,7 +340,11 @@ public function testBulkEditWithNoChanges(EndToEndTester $I) $I->checkNoWarningsAndNoticesOnScreen($I); // Check that the subscriber has been assigned to the tag. - $I->apiCheckSubscriberHasTag($I, $subscriberID, $_ENV['CONVERTKIT_API_TAG_ID']); + $I->apiCheckSubscriberHasTag( + $I, + subscriberID: $subscriberID, + tagID: $_ENV['CONVERTKIT_API_TAG_ID'] + ); } } From 71015d7c95defecca8f9e97660d60ec842c548df Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Sat, 24 May 2025 10:58:54 +0800 Subject: [PATCH 14/16] Use named arguments on remaining Restrict Content tests --- .../RestrictContentProductCPTCest.php | 92 ++++++++++----- .../RestrictContentProductPageCest.php | 105 ++++++++++++------ .../RestrictContentProductPostCest.php | 96 +++++++++++----- ...roductThirdPartyThemeOrPageBuilderCest.php | 8 +- 4 files changed, 211 insertions(+), 90 deletions(-) diff --git a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductCPTCest.php b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductCPTCest.php index 0027d0858..9dbd09530 100644 --- a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductCPTCest.php +++ b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductCPTCest.php @@ -40,11 +40,19 @@ public function testRestrictContentWhenDisabled(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add the CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: Article: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: Article: Restrict Content: Product' + ); // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Article. @@ -70,7 +78,11 @@ public function testNoRestrictContentOnPrivateCPT(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add the CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'private', 'Kit: Private: Restrict Content'); + $I->addGutenbergPage( + $I, + postType: 'private', + title: 'Kit: Private: Restrict Content' + ); // Check that the metabox is not displayed. $I->dontSeeElementInDOM('#wp-convertkit-meta-box'); @@ -93,13 +105,17 @@ public function testRestrictContentByProduct(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add the CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: Article: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: Article: Restrict Content: Product' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -107,7 +123,11 @@ public function testRestrictContentByProduct(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Article. @@ -132,13 +152,17 @@ public function testRestrictContentByProductWithAddTag(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: Article: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: Article: Restrict Content: Product' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'tag' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], @@ -147,7 +171,11 @@ public function testRestrictContentByProductWithAddTag(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Article. @@ -176,13 +204,17 @@ public function testRestrictContentByProductWithGeneratedExcerpt(EndToEndTester $memberOnlyContent = 'Member-only content'; // Add the CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: Article: Restrict Content: Product: Generated Excerpt'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: Article: Restrict Content: Product: Generated Excerpt' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -198,8 +230,8 @@ public function testRestrictContentByProductWithGeneratedExcerpt(EndToEndTester // Test Restrict Content functionality. $I->testRestrictedContentByProductOnFrontend( $I, - $url, - [ + urlOrPageID: $url, + options: [ 'visible_content' => $visibleContent, 'member_content' => $memberOnlyContent, ] @@ -221,13 +253,17 @@ public function testRestrictContentModalByProduct(EndToEndTester $I) $I->setupKitPlugin($I); // Add the CPT using the Gutenberg editor. - $I->addGutenbergPage($I, 'article', 'Kit: Article: Restrict Content: Product: Modal'); + $I->addGutenbergPage( + $I, + postType: 'article', + title: 'Kit: Article: Restrict Content: Product: Modal' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -235,7 +271,11 @@ public function testRestrictContentModalByProduct(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Article. @@ -303,9 +343,9 @@ public function testRestrictContentByProductUsingQuickEdit(EndToEndTester $I) // Quick Edit the CPT in the CPTs WP_List_Table. $I->quickEdit( $I, - 'article', - $postID, - [ + postType: 'article', + postID: $postID, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] ); @@ -348,9 +388,9 @@ public function testRestrictContentByProductUsingBulkEdit(EndToEndTester $I) // Bulk Edit the CPTs in the CPTs WP_List_Table. $I->bulkEdit( $I, - 'article', - $postIDs, - [ + postType: 'article', + postIDs: $postIDs, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] ); diff --git a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPageCest.php b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPageCest.php index 178e27f21..dba4e306f 100644 --- a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPageCest.php +++ b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPageCest.php @@ -37,11 +37,18 @@ public function testRestrictContentWhenDisabled(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Product' + ); // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. @@ -67,13 +74,16 @@ public function testRestrictContentByProduct(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Product' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -81,7 +91,11 @@ public function testRestrictContentByProduct(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. @@ -106,13 +120,16 @@ public function testRestrictContentByProductWithAddTag(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Product' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'tag' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], @@ -121,7 +138,11 @@ public function testRestrictContentByProductWithAddTag(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. @@ -150,13 +171,16 @@ public function testRestrictContentByProductWithGeneratedExcerpt(EndToEndTester $memberOnlyContent = 'Member-only content'; // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Product: Generated Excerpt'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Product: Generated Excerpt' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -172,8 +196,8 @@ public function testRestrictContentByProductWithGeneratedExcerpt(EndToEndTester // Test Restrict Content functionality. $I->testRestrictedContentByProductOnFrontend( $I, - $url, - [ + urlOrPageID: $url, + options: [ 'visible_content' => $visibleContent, 'member_content' => $memberOnlyContent, ] @@ -195,13 +219,16 @@ public function testRestrictContentModalByProduct(EndToEndTester $I) $I->setupKitPlugin($I); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Product: Modal'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Product: Modal' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -209,7 +236,11 @@ public function testRestrictContentModalByProduct(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. @@ -276,13 +307,16 @@ public function testRestrictContentWhenEditingWithFrontendPageBuilder(EndToEndTe $I->activateThirdPartyPlugin($I, 'beaver-builder-lite-version'); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Beaver Builder'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Beaver Builder' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -338,13 +372,16 @@ public function testRestrictContentUsingCrawler(EndToEndTester $I) ); // Add a Page using the Gutenberg editor. - $I->addGutenbergPage($I, 'page', 'Kit: Page: Restrict Content: Product: Search Engines'); + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Restrict Content: Product: Search Engines' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -352,7 +389,11 @@ public function testRestrictContentUsingCrawler(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Page. @@ -389,9 +430,9 @@ public function testRestrictContentByProductUsingQuickEdit(EndToEndTester $I) // Quick Edit the Page in the Pages WP_List_Table. $I->quickEdit( $I, - 'page', - $pageID, - [ + postType: 'page', + postID: $pageID, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] ); @@ -432,9 +473,9 @@ public function testRestrictContentByProductUsingBulkEdit(EndToEndTester $I) // Bulk Edit the Pages in the Pages WP_List_Table. $I->bulkEdit( $I, - 'page', - $pageIDs, - [ + postType: 'page', + postIDs: $pageIDs, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] ); diff --git a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPostCest.php b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPostCest.php index fd2390b5e..36fc31568 100644 --- a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPostCest.php +++ b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductPostCest.php @@ -37,11 +37,19 @@ public function testRestrictContentWhenDisabled(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Restrict Content: Product' + ); // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Post. @@ -67,13 +75,17 @@ public function testRestrictContentByProduct(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Restrict Content: Product' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -81,7 +93,11 @@ public function testRestrictContentByProduct(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Post. @@ -106,13 +122,17 @@ public function testRestrictContentByProductWithAddTag(EndToEndTester $I) $I->setupKitPluginDisableJS($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Restrict Content: Product'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Restrict Content: Product' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'tag' => [ 'select2', $_ENV['CONVERTKIT_API_TAG_NAME'] ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], @@ -121,7 +141,11 @@ public function testRestrictContentByProductWithAddTag(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Post. @@ -150,13 +174,17 @@ public function testRestrictContentByProductWithGeneratedExcerpt(EndToEndTester $memberOnlyContent = 'Member-only content'; // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Restrict Content: Product: Generated Excerpt'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Restrict Content: Product: Generated Excerpt' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -172,8 +200,8 @@ public function testRestrictContentByProductWithGeneratedExcerpt(EndToEndTester // Test Restrict Content functionality. $I->testRestrictedContentByProductOnFrontend( $I, - $url, - [ + urlOrPageID: $url, + options: [ 'visible_content' => $visibleContent, 'member_content' => $memberOnlyContent, ] @@ -201,13 +229,17 @@ public function testRestrictContentByProductWithDefinedExcerpt(EndToEndTester $I ]; // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Restrict Content: Product: Defined Excerpt'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Restrict Content: Product: Defined Excerpt' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -258,13 +290,17 @@ public function testRestrictContentModalByProduct(EndToEndTester $I) $I->setupKitPlugin($I); // Add a Post using the Gutenberg editor. - $I->addGutenbergPage($I, 'post', 'Kit: Post: Restrict Content: Product: Modal'); + $I->addGutenbergPage( + $I, + postType: 'post', + title: 'Kit: Post: Restrict Content: Product: Modal' + ); // Configure metabox's Restrict Content setting = Product name. $I->configureMetaboxSettings( $I, - 'wp-convertkit-meta-box', - [ + metabox: 'wp-convertkit-meta-box', + configuration: [ 'form' => [ 'select2', 'None' ], 'restrict_content' => [ 'select2', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] @@ -272,7 +308,11 @@ public function testRestrictContentModalByProduct(EndToEndTester $I) // Add blocks. $I->addGutenbergParagraphBlock($I, 'Visible content.'); - $I->addGutenbergBlock($I, 'More', 'more'); + $I->addGutenbergBlock( + $I, + blockName: 'More', + blockProgrammaticName: 'more' + ); $I->addGutenbergParagraphBlock($I, 'Member-only content.'); // Publish Post. @@ -340,9 +380,9 @@ public function testRestrictContentByProductUsingQuickEdit(EndToEndTester $I) // Quick Edit the Post in the Posts WP_List_Table. $I->quickEdit( $I, - 'post', - $postID, - [ + postType: 'post', + postID: $postID, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] ); @@ -385,9 +425,9 @@ public function testRestrictContentByProductUsingBulkEdit(EndToEndTester $I) // Bulk Edit the Posts in the Posts WP_List_Table. $I->bulkEdit( $I, - 'post', - $postIDs, - [ + postType: 'post', + postIDs: $postIDs, + configuration: [ 'restrict_content' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], ] ); diff --git a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductThirdPartyThemeOrPageBuilderCest.php b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductThirdPartyThemeOrPageBuilderCest.php index 5c5708a50..82970aaa1 100644 --- a/tests/EndToEnd/restrict-content/post-types/RestrictContentProductThirdPartyThemeOrPageBuilderCest.php +++ b/tests/EndToEnd/restrict-content/post-types/RestrictContentProductThirdPartyThemeOrPageBuilderCest.php @@ -71,8 +71,8 @@ public function testRestrictContentByProductWithUncodeThemeAndVisualComposer(End // Test Restrict Content functionality. $I->testRestrictedContentByProductOnFrontend( $I, - $pageID, - [ + urlOrPageID: $pageID, + options: [ 'visible_content' => '', 'member_content' => 'Member-only content.', ] @@ -127,8 +127,8 @@ public function testRestrictContentByProductWithUncodeTheme(EndToEndTester $I) // Test Restrict Content functionality. $I->testRestrictedContentByProductOnFrontend( $I, - $pageID, - [ + urlOrPageID: $pageID, + options: [ 'visible_content' => '', 'member_content' => 'Member-only content.', ] From 0378df92808f8d382f5f11650dca9873a58089b4 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Sat, 24 May 2025 11:59:53 +0800 Subject: [PATCH 15/16] Fix failing test --- .../restrict-content/general/RestrictContentTagCest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php b/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php index dee67e9ec..e848ba7e1 100644 --- a/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php +++ b/tests/EndToEnd/restrict-content/general/RestrictContentTagCest.php @@ -353,7 +353,7 @@ public function testRestrictContentByTagWithRecaptchaEnabled(EndToEndTester $I) $I, urlOrPageID: $url, emailAddress: $I->generateEmailAddress(), - options: $options + options: $options['settings'] ); } @@ -504,7 +504,11 @@ public function testRestrictContentByTagUsingBulkEdit(EndToEndTester $I) // Iterate through Pages to run frontend tests. foreach ($pageIDs as $pageID) { // Test Restrict Content functionality. - $I->testRestrictedContentByTagOnFrontend($I, $pageID, $I->generateEmailAddress()); + $I->testRestrictedContentByTagOnFrontend( + $I, + urlOrPageID: $pageID, + emailAddress: $I->generateEmailAddress() + ); } } From 6074a98f44c79daa46df1e40dd64aa65429f80e2 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 28 May 2025 12:03:26 +0800 Subject: [PATCH 16/16] Tests: Fix spacing on named arguments --- .../products/PageBlockFormatterProductLinkCest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php b/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php index de86338d8..c3b3945ed 100644 --- a/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php +++ b/tests/EndToEnd/products/PageBlockFormatterProductLinkCest.php @@ -61,7 +61,7 @@ public function testProductLinkFormatter(EndToEndTester $I) $I->applyGutenbergFormatter( $I, formatterName: 'Kit Product Trigger', - formatterProgrammaticName:'convertkit-product-link', + formatterProgrammaticName: 'convertkit-product-link', formatterConfiguration:[ // Product. 'data-id' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], @@ -114,7 +114,7 @@ public function testProductLinkFormatterToggleProductSelection(EndToEndTester $I $I->applyGutenbergFormatter( $I, formatterName: 'Kit Product Trigger', - formatterProgrammaticName:'convertkit-product-link', + formatterProgrammaticName: 'convertkit-product-link', formatterConfiguration:[ // Product. 'data-id' => [ 'select', $_ENV['CONVERTKIT_API_PRODUCT_NAME'] ], @@ -125,9 +125,9 @@ public function testProductLinkFormatterToggleProductSelection(EndToEndTester $I $I->applyGutenbergFormatter( $I, formatterName: 'Kit Product Trigger', - formatterProgrammaticName:'convertkit-product-link', + formatterProgrammaticName: 'convertkit-product-link', formatterConfiguration:[ - // Form. + // Product. 'data-id' => [ 'select', 'None' ], ] ); @@ -177,9 +177,9 @@ public function testProductLinkFormatterWithNoProduct(EndToEndTester $I) $I->applyGutenbergFormatter( $I, formatterName: 'Kit Product Trigger', - formatterProgrammaticName:'convertkit-product-link', + formatterProgrammaticName: 'convertkit-product-link', formatterConfiguration:[ - // Form. + // Product. 'data-id' => [ 'select', 'None' ], ] );