diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5897b2574..6cf311f85 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,7 +34,7 @@ jobs: WORDPRESS_DB_SQL_DUMP_FILE: tests/Support/Data/dump.sql INSTALL_PLUGINS: "admin-menu-editor autoptimize beaver-builder-lite-version block-visibility contact-form-7 classic-editor custom-post-type-ui debloat elementor forminator jetpack-boost mailchimp-for-wp rocket-lazy-load woocommerce wordpress-seo wpforms-lite litespeed-cache wp-crontrol wp-super-cache w3-total-cache wp-fastest-cache wp-optimize sg-cachepress" # Don't include this repository's Plugin here. INSTALL_PLUGINS_URLS: "https://downloads.wordpress.org/plugin/convertkit-for-woocommerce.1.6.4.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/01/convertkit-action-filter-tests.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/11/disable-doing-it-wrong-notices.zip http://cktestplugins.wpengine.com/wp-content/uploads/2025/03/uncode-js_composer.7.8.zip http://cktestplugins.wpengine.com/wp-content/uploads/2025/03/uncode-core.zip" # URLs to specific third party Plugins - INSTALL_THEMES_URLS: "http://cktestplugins.wpengine.com/wp-content/uploads/2025/03/uncode.zip http://cktestplugins.wpengine.com/wp-content/uploads/2025/04/Divi.zip http://cktestplugins.wpengine.com/wp-content/uploads/2026/01/impeka.zip" + INSTALL_THEMES_URLS: "http://cktestplugins.wpengine.com/wp-content/uploads/2025/03/uncode.zip http://cktestplugins.wpengine.com/wp-content/uploads/2026/03/Divi_5.zip http://cktestplugins.wpengine.com/wp-content/uploads/2026/01/impeka.zip" CONVERTKIT_API_KEY: ${{ secrets.CONVERTKIT_API_KEY }} # ConvertKit API Key, stored in the repository's Settings > Secrets CONVERTKIT_API_SECRET: ${{ secrets.CONVERTKIT_API_SECRET }} # ConvertKit API Secret, stored in the repository's Settings > Secrets CONVERTKIT_API_KEY_NO_DATA: ${{ secrets.CONVERTKIT_API_KEY_NO_DATA }} # ConvertKit API Key for ConvertKit account with no data, stored in the repository's Settings > Secrets diff --git a/includes/integrations/divi/class-convertkit-divi-module.php b/includes/integrations/divi/class-convertkit-divi-module.php index ef4c5c95f..429a18158 100644 --- a/includes/integrations/divi/class-convertkit-divi-module.php +++ b/includes/integrations/divi/class-convertkit-divi-module.php @@ -98,6 +98,12 @@ public function get_fields() { return array(); } + // Bail if the block is false. + // This happens on Divi 5 theme activation. + if ( ! $this->block ) { + return array(); + } + // Bail if no fields i.e. this is a frontend request. if ( ! array_key_exists( 'fields', $this->block ) ) { return array(); diff --git a/tests/EndToEnd.suite.yml b/tests/EndToEnd.suite.yml index 7cf15b9ed..8e565cf34 100644 --- a/tests/EndToEnd.suite.yml +++ b/tests/EndToEnd.suite.yml @@ -27,6 +27,7 @@ modules: - \Tests\Support\Helper\KitProducts - \Tests\Support\Helper\KitRestrictContent - \Tests\Support\Helper\CustomPostType + - \Tests\Support\Helper\Divi5Theme - \Tests\Support\Helper\DiviBuilder - \Tests\Support\Helper\Email - \Tests\Support\Helper\Select2 diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php index 64d54b1b4..38b7c87df 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginBroadcastsCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Broadcasts Divi Module using the Divi Builder Plugin. + * Tests for the Kit Broadcasts Divi Module using the Divi 4 Builder Plugin. * * @since 2.5.7 */ diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php index e8584bfbc..b7f07d6b1 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Form's Divi Module using the Divi Builder Plugin. + * Tests for the Kit Form's Divi Module using the Divi 4 Builder Plugin. * * @since 2.5.6 */ diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php index 668fa4e44..eb7d567c3 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Form's Divi Module using the Divi Builder Plugin. + * Tests for the Kit Form's Divi Module using the Divi 4 Builder Plugin. * * @since 2.5.7 */ diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php index 24e55d916..659abfc97 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginProductCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Product's Divi Module using the Divi Builder Plugin. + * Tests for the Kit Product's Divi Module using the Divi 4 Builder Plugin. * * @since 2.5.7 */ diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php index 05cecc22a..9aac59cb8 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Broadcasts Divi Module using the Divi Theme. + * Tests for the Kit Broadcasts Divi Module using the Divi 5 Theme. * * @since 2.8.0 */ @@ -21,7 +21,6 @@ class DiviThemeBroadcastsCest public function _before(EndToEndTester $I) { $I->activateKitPlugin($I); - $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->useTheme('Divi'); } @@ -32,81 +31,80 @@ public function _before(EndToEndTester $I) * * @param EndToEndTester $I Tester. */ - public function testBroadcastsModuleInBackendEditorConditionalFields(EndToEndTester $I) + public function testBroadcastsModuleConditionalFields(EndToEndTester $I) { // Setup Plugin, without defining default Forms. $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - // Create a Divi Page in the backend editor. - $I->createDiviPageInBackendEditor($I, 'Kit: Page: Broadcasts: Divi: Backend Editor: Conditional Fields'); + // Create a Divi Page. + $I->createDivi5Page( + $I, + title: 'Kit: Page: Broadcasts: Divi 5: Conditional Fields', + ); // Insert the Broadcasts module. - $I->insertDiviRowWithModule( + $I->insertDivi5RowWithModule( $I, name: 'Kit Broadcasts', - programmaticName:'convertkit_broadcasts' + programmaticName:'convertkit_broadcasts', ); // Confirm conditional fields are not displayed. - $I->dontSeeElementInDOM('#read_more_label'); - $I->dontSeeElementInDOM('#paginate_label_prev'); - $I->dontSeeElementInDOM('#paginate_label_next'); + $I->dontSeeElementInDOM('input[name="et-vb-field-input-text-read_more_label"]'); + $I->dontSeeElementInDOM('input[name="et-vb-field-input-text-paginate_label_prev"]'); + $I->dontSeeElementInDOM('input[name="et-vb-field-input-text-paginate_label_next"]'); // Enable 'Display read more links' and confirm the conditional field displays. - $I->wait(1); - $I->click('//input[@name="display_read_more"]/ancestor::div[contains(@class, "et-core-control-toggle--off")]'); - $I->waitForElementVisible('input[name="read_more_label"]'); + $I->click('div[aria-label="Toggle display_read_more"]'); + $I->waitForElementVisible('input[name="et-vb-field-input-text-read_more_label"]'); // Disable 'Display read more links' to confirm the conditional field is hidden. - $I->wait(1); - $I->click('//input[@name="display_read_more"]/ancestor::div[contains(@class, "et-core-control-toggle--on")]'); - $I->waitForElementNotVisible('input[name="read_more_label"]'); + $I->click('div[aria-label="Toggle display_read_more"]'); + $I->waitForElementNotVisible('input[name="et-vb-field-input-text-read_more_label"]'); // Enable 'Display pagination' and confirm the conditional fields display. - $I->wait(1); - $I->click('//input[@name="paginate"]/ancestor::div[contains(@class, "et-core-control-toggle--off")]'); - $I->waitForElementVisible('input[name="paginate_label_prev"]'); - $I->waitForElementVisible('input[name="paginate_label_next"]'); + $I->click('div[aria-label="Toggle paginate"]'); + $I->waitForElementVisible('input[name="et-vb-field-input-text-paginate_label_prev"]'); + $I->waitForElementVisible('input[name="et-vb-field-input-text-paginate_label_next"]'); // Disable 'Display pagination' to confirm the conditional fields are hidden. - $I->wait(1); - $I->click('//input[@name="paginate"]/ancestor::div[contains(@class, "et-core-control-toggle--on")]'); - $I->waitForElementNotVisible('input[name="paginate_label_prev"]'); - $I->waitForElementNotVisible('input[name="paginate_label_next"]'); + $I->click('div[aria-label="Toggle paginate"]'); + $I->waitForElementNotVisible('input[name="et-vb-field-input-text-paginate_label_prev"]'); + $I->waitForElementNotVisible('input[name="et-vb-field-input-text-paginate_label_next"]'); - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInBackendEditorAndViewPage($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); } /** - * Test the Broadcasts module works when added - * using Divi's backend editor. + * Test the Broadcasts module works. * * @since 2.8.0 * * @param EndToEndTester $I Tester. */ - public function testBroadcastsModuleInBackendEditor(EndToEndTester $I) + public function testBroadcastsModule(EndToEndTester $I) { // Setup Plugin, without defining default Forms. $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - $I->amOnAdminPage('themes.php'); - - // Create a Divi Page in the backend editor. - $I->createDiviPageInBackendEditor($I, 'Kit: Page: Broadcasts: Divi: Backend Editor'); + // Create a Divi Page. + $I->createDivi5Page( + $I, + title: 'Kit: Page: Broadcasts: Divi 5', + ); // Insert the Broadcasts module. - $I->insertDiviRowWithModule( + $I->insertDivi5RowWithModule( $I, name: 'Kit Broadcasts', - programmaticName: 'convertkit_broadcasts' + programmaticName: 'convertkit_broadcasts', ); - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInBackendEditorAndViewPage($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that the block displays. $I->seeBroadcastsOutput($I); @@ -122,120 +120,28 @@ public function testBroadcastsModuleInBackendEditor(EndToEndTester $I) $I->grabAttributeFrom('div.convertkit-broadcasts ul.convertkit-broadcasts-list li.convertkit-broadcast:nth-child(2) a', 'href'), $_ENV['CONVERTKIT_API_BROADCAST_FIRST_URL'] . '?utm_source=wordpress&utm_term=en_US&utm_content=convertkit' ); - - // Deactivate Classic Editor. - $I->deactivateThirdPartyPlugin($I, 'classic-editor'); } /** - * Test the Broadcasts module's conditional fields work when added - * using Divi's frontend editor. - * - * @since 3.0.6 - * - * @param EndToEndTester $I Tester. - */ - public function testBroadcastsModuleInFrontendEditorConditionalFields(EndToEndTester $I) - { - // Setup Plugin, without defining default Forms. - $I->setupKitPluginNoDefaultForms($I); - $I->setupKitPluginResources($I); - - // Create a Divi Page in the frontend editor. - $url = $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Broadcasts: Divi: Frontend Editor: Conditional Fields'); - - // Insert the Broadcasts module. - $I->insertDiviRowWithModule( - $I, - name: 'Kit Broadcasts', - programmaticName:'convertkit_broadcasts' - ); - - // Confirm conditional fields are not displayed. - $I->dontSeeElementInDOM('#read_more_label'); - $I->dontSeeElementInDOM('#paginate_label_prev'); - $I->dontSeeElementInDOM('#paginate_label_next'); - - // Enable 'Display read more links' and confirm the conditional field displays. - $I->wait(1); - $I->click('//input[@name="display_read_more"]/ancestor::div[contains(@class, "et-core-control-toggle--off")]'); - $I->waitForElementVisible('input[name="read_more_label"]'); - - // Disable 'Display read more links' to confirm the conditional field is hidden. - $I->wait(1); - $I->click('//input[@name="display_read_more"]/ancestor::div[contains(@class, "et-core-control-toggle--on")]'); - $I->waitForElementNotVisible('input[name="read_more_label"]'); - - // Enable 'Display pagination' and confirm the conditional fields display. - $I->wait(1); - $I->click('//input[@name="paginate"]/ancestor::div[contains(@class, "et-core-control-toggle--off")]'); - $I->waitForElementVisible('input[name="paginate_label_prev"]'); - $I->waitForElementVisible('input[name="paginate_label_next"]'); - - // Disable 'Display pagination' to confirm the conditional fields are hidden. - $I->wait(1); - $I->click('//input[@name="paginate"]/ancestor::div[contains(@class, "et-core-control-toggle--on")]'); - $I->waitForElementNotVisible('input[name="paginate_label_prev"]'); - $I->waitForElementNotVisible('input[name="paginate_label_next"]'); - - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInFrontendEditorAndViewPage($I, $url); - } - - /** - * Test the Broadcasts module works when added - * using Divi's frontend editor. + * Test the Broadcasts module displays the expected message when the Plugin has no credentials. * * @since 2.8.0 * * @param EndToEndTester $I Tester. */ - public function testBroadcastsModuleInFrontendEditor(EndToEndTester $I) + public function testBroadcastsModuleWhenNoCredentials(EndToEndTester $I) { - // Setup Plugin, without defining default Forms. - $I->setupKitPluginNoDefaultForms($I); - $I->setupKitPluginResources($I); - - // Create a Divi Page in the frontend editor. - $url = $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Broadcasts: Divi: Frontend Editor'); + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No Credentials notice cannot be displayed until modules upgraded to Divi 5.'); - // Insert the Broadcasts module. - $I->insertDiviRowWithModule( + // Create a Divi Page in the backend editor. + $I->createDiviPageInBackendEditor( $I, - name: 'Kit Broadcasts', - programmaticName: 'convertkit_broadcasts' - ); - - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInFrontendEditorAndViewPage($I, $url); - - // Confirm that the block displays. - $I->seeBroadcastsOutput($I); - - // Confirm that the default date format is as expected. - $I->seeInSource(''); - - // Confirm that the default expected number of Broadcasts are displayed. - $I->seeNumberOfElements('li.convertkit-broadcast', [ 1, 10 ]); - - // Confirm that the expected Broadcast name is displayed first links to the expected URL, with UTM parameters. - $I->assertEquals( - $I->grabAttributeFrom('div.convertkit-broadcasts ul.convertkit-broadcasts-list li.convertkit-broadcast:nth-child(2) a', 'href'), - $_ENV['CONVERTKIT_API_BROADCAST_FIRST_URL'] . '?utm_source=wordpress&utm_term=en_US&utm_content=convertkit' + title: 'Kit: Page: Broadcasts: Divi 5: No Credentials' ); - } - - /** - * Test the Broadcasts module displays the expected message when the Plugin has no credentials - * - * @since 2.8.0 - * - * @param EndToEndTester $I Tester. - */ - public function testBroadcastsModuleInFrontendEditorWhenNoCredentials(EndToEndTester $I) - { - // Create a Divi Page in the frontend editor. - $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Broadcasts: Divi: Frontend: No Credentials', false); // Insert the Broadcasts module. $I->insertDiviRowWithModule( @@ -260,14 +166,23 @@ public function testBroadcastsModuleInFrontendEditorWhenNoCredentials(EndToEndTe * * @param EndToEndTester $I Tester. */ - public function testBroadcastsModuleInFrontendEditorWhenNoBroadcasts(EndToEndTester $I) + public function testBroadcastsModuleWhenNoBroadcasts(EndToEndTester $I) { + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No resources notice cannot be displayed until modules upgraded to Divi 5.'); + // Setup Plugin. $I->setupKitPluginCredentialsNoData($I); $I->setupKitPluginResourcesNoData($I); - // Create a Divi Page in the frontend editor. - $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Broadcasts: Divi: Frontend: No Broadcasts'); + // Create a Divi Page in the backend editor. + $I->createDiviPageInBackendEditor( + $I, + title: 'Kit: Page: Broadcasts: Divi 5: No Broadcasts' + ); // Insert the Broadcasts module. $I->insertDiviRowWithModule( @@ -296,7 +211,6 @@ public function testBroadcastsModuleInFrontendEditorWhenNoBroadcasts(EndToEndTes public function _passed(EndToEndTester $I) { $I->useTheme('twentytwentytwo'); - $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateKitPlugin($I); $I->resetKitPlugin($I); } diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php index 096c140cc..003d2d08b 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Form's Divi Module using the Divi Theme. + * Tests for the Kit Form's Divi Module using the Divi 5 Theme. * * @since 2.8.0 */ @@ -21,38 +21,40 @@ class DiviThemeFormCest public function _before(EndToEndTester $I) { $I->activateKitPlugin($I); - $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->useTheme('Divi'); } /** - * Test the Form module works when a valid Form is selected - * using Divi's backend editor. + * Test the Form module works when a valid Form is selected. * * @since 2.8.0 * * @param EndToEndTester $I Tester. */ - public function testFormModuleInBackendEditor(EndToEndTester $I) + public function testFormModule(EndToEndTester $I) { // Setup Plugin, without defining default Forms. $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - // Create a Divi Page in the backend editor. - $I->createDiviPageInBackendEditor($I, 'Kit: Page: Form: Divi: Backend Editor'); + // Create a Divi Page. + $I->createDivi5Page( + $I, + title: 'Kit: Page: Form: Divi 5', + ); // Insert the Form module. - $I->insertDiviRowWithModule( + $I->insertDivi5RowWithModule( $I, name: 'Kit Form', programmaticName: 'convertkit_form', fieldName: 'form', - fieldValue: $_ENV['CONVERTKIT_API_FORM_ID'] + fieldValue: $_ENV['CONVERTKIT_API_FORM_ID'], + fieldType: 'select' ); - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInBackendEditorAndViewPage($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that one Kit Form is output in the DOM. // This confirms that there is only one script on the page for this form, which renders the form. @@ -62,40 +64,6 @@ public function testFormModuleInBackendEditor(EndToEndTester $I) $I->deactivateThirdPartyPlugin($I, 'classic-editor'); } - /** - * Test the Form module works when a valid Form is selected - * using Divi's backend editor. - * - * @since 2.8.0 - * - * @param EndToEndTester $I Tester. - */ - public function testFormModuleInFrontendEditor(EndToEndTester $I) - { - // Setup Plugin, without defining default Forms. - $I->setupKitPluginNoDefaultForms($I); - $I->setupKitPluginResources($I); - - // Create a Divi Page in the frontend editor. - $url = $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Form: Divi: Frontend Editor'); - - // Insert the Form module. - $I->insertDiviRowWithModule( - $I, - 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. - $I->saveDiviModuleInFrontendEditorAndViewPage($I, $url); - - // Confirm that one Kit Form is output in the DOM. - // 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']); - } - /** * Test the Form module displays the expected message when the Plugin has no credentials * @@ -103,8 +71,14 @@ public function testFormModuleInFrontendEditor(EndToEndTester $I) * * @param EndToEndTester $I Tester. */ - public function testFormModuleInFrontendEditorWhenNoCredentials(EndToEndTester $I) + public function testFormModuleWhenNoCredentials(EndToEndTester $I) { + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No Credentials notice cannot be displayed until modules upgraded to Divi 5.'); + // Create a Divi Page in the frontend editor. $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Form: Divi: Frontend: No Credentials', false); @@ -131,8 +105,14 @@ public function testFormModuleInFrontendEditorWhenNoCredentials(EndToEndTester $ * * @param EndToEndTester $I Tester. */ - public function testFormModuleInFrontendEditorWhenNoForms(EndToEndTester $I) + public function testFormModuleWhenNoForms(EndToEndTester $I) { + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No resources notice cannot be displayed until modules upgraded to Divi 5.'); + // Setup Plugin. $I->setupKitPluginCredentialsNoData($I); $I->setupKitPluginResourcesNoData($I); @@ -177,20 +157,24 @@ public function testFormModuleWithValidLegacyFormParameter(EndToEndTester $I) ); $I->setupKitPluginResources($I); - // Create Page with Form module in Divi. - $pageID = $I->createPageWithDiviModuleProgrammatically( + // Create a Divi Page. + $I->createDivi5Page( $I, - title: 'Kit: Legacy Form: Divi Module: Valid Form Param', + title: 'Kit: Page: Form: Legacy: Divi 5', + ); + + // Insert the Form module. + $I->insertDivi5RowWithModule( + $I, + name: 'Kit Form', programmaticName: 'convertkit_form', fieldName: 'form', - fieldValue: $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] + fieldValue: $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], + fieldType: 'select' ); - // Load Page. - $I->amOnPage('?p=' . $pageID); - - // Check that no PHP warnings or notices were output. - $I->checkNoWarningsAndNoticesOnScreen($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that the Kit Form is displayed. $I->seeInSource('
'); @@ -209,20 +193,21 @@ public function testFormModuleWithNoFormParameter(EndToEndTester $I) $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - // Create Page with Form module in Divi. - $pageID = $I->createPageWithDiviModuleProgrammatically( + // Create a Divi Page. + $I->createDivi5Page( $I, - title: 'Kit: Legacy Form: Divi Module: No Form Param', - programmaticName: 'convertkit_form', - fieldName: 'form', - fieldValue: '' + title: 'Kit: Page: Form: None: Divi 5', ); - // Load Page. - $I->amOnPage('?p=' . $pageID); + // Insert the Form module. + $I->insertDivi5RowWithModule( + $I, + name: 'Kit Form', + programmaticName: 'convertkit_form' + ); - // Check that no PHP warnings or notices were output. - $I->checkNoWarningsAndNoticesOnScreen($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that no Kit Form is displayed. $I->dontSeeElementInDOM('form[data-sv-form]'); @@ -240,7 +225,6 @@ public function testFormModuleWithNoFormParameter(EndToEndTester $I) public function _passed(EndToEndTester $I) { $I->useTheme('twentytwentytwo'); - $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateKitPlugin($I); $I->resetKitPlugin($I); } diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php index 21e782231..6c2fe182c 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Form's Divi Module using the Divi Theme. + * Tests for the Kit Form's Divi Module using the Divi 5 Theme. * * @since 2.8.0 */ @@ -21,78 +21,40 @@ class DiviThemeFormTriggerCest public function _before(EndToEndTester $I) { $I->activateKitPlugin($I); - $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->useTheme('Divi'); } /** - * Test the Form module works when a valid Form is selected - * using Divi's backend editor. + * Test the Form module works when a valid Form is selected. * * @since 2.8.0 * * @param EndToEndTester $I Tester. */ - public function testFormTriggerModuleInBackendEditor(EndToEndTester $I) + public function testFormTriggerModule(EndToEndTester $I) { // Setup Plugin, without defining default Forms. $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - // Create a Divi Page in the backend editor. - $I->createDiviPageInBackendEditor($I, 'Kit: Page: Form Trigger: Divi: Backend Editor'); - - // Insert the Form module. - $I->insertDiviRowWithModule( + // Create a Divi Page. + $I->createDivi5Page( $I, - name: 'Kit Form Trigger', - programmaticName: 'convertkit_formtrigger', - fieldName: 'form', - fieldValue: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] + title: 'Kit: Page: Form Trigger: Divi 5', ); - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInBackendEditorAndViewPage($I); - - // Confirm that the block displays. - $I->seeFormTriggerOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_URL'], 'Subscribe'); - - // Confirm that one Kit Form is output in the DOM. - // This confirms that there is only one script on the page for this form, which renders the form. - $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1); - - // Deactivate Classic Editor. - $I->deactivateThirdPartyPlugin($I, 'classic-editor'); - } - - /** - * Test the Form module works when a valid Form is selected - * using Divi's backend editor. - * - * @since 2.8.0 - * - * @param EndToEndTester $I Tester. - */ - public function testFormTriggerModuleInFrontendEditor(EndToEndTester $I) - { - // Setup Plugin, without defining default Forms. - $I->setupKitPluginNoDefaultForms($I); - $I->setupKitPluginResources($I); - - // Create a Divi Page in the frontend editor. - $url = $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Form Trigger: Divi: Frontend Editor'); - // Insert the Form module. - $I->insertDiviRowWithModule( + $I->insertDivi5RowWithModule( $I, name: 'Kit Form Trigger', programmaticName: 'convertkit_formtrigger', fieldName: 'form', - fieldValue: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] + fieldValue: $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'], + fieldType: 'select' ); - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInFrontendEditorAndViewPage($I, $url); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that the block displays. $I->seeFormTriggerOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_URL'], 'Subscribe'); @@ -102,6 +64,7 @@ public function testFormTriggerModuleInFrontendEditor(EndToEndTester $I) $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1); } + /** * Test the Form module displays the expected message when the Plugin has no credentials * @@ -109,8 +72,14 @@ public function testFormTriggerModuleInFrontendEditor(EndToEndTester $I) * * @param EndToEndTester $I Tester. */ - public function testFormTriggerModuleInFrontendEditorWhenNoCredentials(EndToEndTester $I) + public function testFormTriggerModuleWhenNoCredentials(EndToEndTester $I) { + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No Credentials notice cannot be displayed until modules upgraded to Divi 5.'); + // Create a Divi Page in the frontend editor. $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Form Trigger: Divi: Frontend: No Credentials', false); @@ -139,6 +108,12 @@ public function testFormTriggerModuleInFrontendEditorWhenNoCredentials(EndToEndT */ public function testFormTriggerModuleInFrontendEditorWhenNoForms(EndToEndTester $I) { + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No resources notice cannot be displayed until modules upgraded to Divi 5.'); + // Setup Plugin. $I->setupKitPluginCredentialsNoData($I); $I->setupKitPluginResourcesNoData($I); @@ -174,20 +149,21 @@ public function testFormTriggerModuleWithNoFormParameter(EndToEndTester $I) $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - // Create Page with Form module in Divi. - $pageID = $I->createPageWithDiviModuleProgrammatically( + // Create a Divi Page. + $I->createDivi5Page( $I, - title: 'Kit: Legacy Form Trigger: Divi Module: No Form Param', - programmaticName: 'convertkit_formtrigger', - fieldName: 'form', - fieldValue: '' + title: 'Kit: Page: Form Trigger: None: Divi 5', ); - // Load Page. - $I->amOnPage('?p=' . $pageID); + // Insert the Form module. + $I->insertDivi5RowWithModule( + $I, + name: 'Kit Form Trigger', + programmaticName: 'convertkit_formtrigger' + ); - // Check that no PHP warnings or notices were output. - $I->checkNoWarningsAndNoticesOnScreen($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that no Kit Form trigger button is displayed. $I->dontSeeFormTriggerOutput($I); @@ -205,7 +181,6 @@ public function testFormTriggerModuleWithNoFormParameter(EndToEndTester $I) public function _passed(EndToEndTester $I) { $I->useTheme('twentytwentytwo'); - $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateKitPlugin($I); $I->resetKitPlugin($I); } diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php index c0c457c8a..ec6e61edf 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeProductCest.php @@ -5,7 +5,7 @@ use Tests\Support\EndToEndTester; /** - * Tests for the Kit Product's Divi Module using the Divi Theme. + * Tests for the Kit Product's Divi Module using the Divi 5 Theme. * * @since 2.8.0 */ @@ -21,38 +21,40 @@ class DiviThemeProductCest public function _before(EndToEndTester $I) { $I->activateKitPlugin($I); - $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->useTheme('Divi'); } /** - * Test the Product module works when a valid Product is selected - * using Divi's backend editor. + * Test the Product module works when a valid Product is selected. * * @since 2.8.0 * * @param EndToEndTester $I Tester. */ - public function testProductModuleInBackendEditor(EndToEndTester $I) + public function testProductModule(EndToEndTester $I) { // Setup Plugin, without defining default Forms. $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - // Create a Divi Page in the backend editor. - $I->createDiviPageInBackendEditor($I, 'Kit: Page: Product: Divi: Backend Editor'); + // Create a Divi Page. + $I->createDivi5Page( + $I, + title: 'Kit: Page: Product: Divi 5', + ); // Insert the Product module. - $I->insertDiviRowWithModule( + $I->insertDivi5RowWithModule( $I, name: 'Kit Product', programmaticName: 'convertkit_product', fieldName: 'product', - fieldValue: $_ENV['CONVERTKIT_API_PRODUCT_ID'] + fieldValue: $_ENV['CONVERTKIT_API_PRODUCT_ID'], + fieldType: 'select' ); - // Save Divi module and view the page on the frontend site. - $I->saveDiviModuleInBackendEditorAndViewPage($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that the module displays. $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); @@ -61,39 +63,6 @@ public function testProductModuleInBackendEditor(EndToEndTester $I) $I->deactivateThirdPartyPlugin($I, 'classic-editor'); } - /** - * Test the Product module works when a valid Product is selected - * using Divi's backend editor. - * - * @since 2.8.0 - * - * @param EndToEndTester $I Tester. - */ - public function testProductModuleInFrontendEditor(EndToEndTester $I) - { - // Setup Plugin, without defining default Forms. - $I->setupKitPluginNoDefaultForms($I); - $I->setupKitPluginResources($I); - - // Create a Divi Page in the frontend editor. - $url = $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Product: Divi: Frontend Editor'); - - // Insert the Product module. - $I->insertDiviRowWithModule( - $I, - 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. - $I->saveDiviModuleInFrontendEditorAndViewPage($I, $url); - - // Confirm that the module displays. - $I->seeProductOutput($I, $_ENV['CONVERTKIT_API_PRODUCT_URL'], 'Buy my product'); - } - /** * Test the Product module displays the expected message when the Plugin has no credentials * @@ -101,8 +70,14 @@ public function testProductModuleInFrontendEditor(EndToEndTester $I) * * @param EndToEndTester $I Tester. */ - public function testProductModuleInFrontendEditorWhenNoCredentials(EndToEndTester $I) + public function testProductModuleWhenNoCredentials(EndToEndTester $I) { + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No Credentials notice cannot be displayed until modules upgraded to Divi 5.'); + // Create a Divi Page in the frontend editor. $I->createDiviPageInFrontendEditor($I, 'Kit: Page: Product: Divi: Frontend: No Credentials', false); @@ -129,8 +104,14 @@ public function testProductModuleInFrontendEditorWhenNoCredentials(EndToEndTeste * * @param EndToEndTester $I Tester. */ - public function testProductModuleInFrontendEditorWhenNoProducts(EndToEndTester $I) + public function testProductModuleWhenNoProducts(EndToEndTester $I) { + // Skip test until modules upgraded to Divi 5. + $I->useTheme('twentytwentytwo'); + $I->deactivateKitPlugin($I); + $I->resetKitPlugin($I); + $I->markTestSkipped('No resources notice cannot be displayed until modules upgraded to Divi 5.'); + // Setup Plugin. $I->setupKitPluginCredentialsNoData($I); $I->setupKitPluginResourcesNoData($I); @@ -166,20 +147,21 @@ public function testProductModuleWithNoProductParameter(EndToEndTester $I) $I->setupKitPluginNoDefaultForms($I); $I->setupKitPluginResources($I); - // Create Page with Product module in Divi. - $pageID = $I->createPageWithDiviModuleProgrammatically( + // Create a Divi Page. + $I->createDivi5Page( $I, - title: 'Kit: Product: Divi Module: No Product Param', - programmaticName: 'convertkit_product', - fieldName: 'product', - fieldValue: '' + title: 'Kit: Page: Product: None: Divi 5', ); - // Load Page. - $I->amOnPage('?p=' . $pageID); + // Insert the Form module. + $I->insertDivi5RowWithModule( + $I, + name: 'Kit Product', + programmaticName: 'convertkit_product' + ); - // Check that no PHP warnings or notices were output. - $I->checkNoWarningsAndNoticesOnScreen($I); + // Save and view page. + $I->saveDivi5PageAndViewOnFrontend($I); // Confirm that no Kit Product is displayed. $I->dontSeeProductOutput($I); @@ -198,7 +180,6 @@ public function testProductModuleWithNoProductParameter(EndToEndTester $I) public function _passed(EndToEndTester $I) { $I->useTheme('twentytwentytwo'); - $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateKitPlugin($I); $I->resetKitPlugin($I); } diff --git a/tests/Support/Helper/Divi5Theme.php b/tests/Support/Helper/Divi5Theme.php new file mode 100644 index 000000000..4a3077432 --- /dev/null +++ b/tests/Support/Helper/Divi5Theme.php @@ -0,0 +1,138 @@ +{yourFunctionName}. + * + * @since 3.2.1 + */ +class Divi5Theme extends \Codeception\Module +{ + /** + * Helper method to create a Divi Page in the WordPress Administration interface. + * + * @since 2.5.7 + * + * @param EndToEndTester $I EndToEnd Tester. + * @param string $title Page Title. + * @param bool $configureMetaBox Configure Plugin's Meta Box to set Form = None (set to false if running a test with no credentials). + */ + public function createDivi5Page($I, $title, $configureMetaBox = true) + { + // Add a Page using the Gutenberg editor. + // We don't use addGutenbergPage(), as when the Divi Builder is used, the iframed Gutenberg editor is not used, + // and addGutenbergPage() may switch to an iframe based on the value of the WORDPRESS_V3_BLOCK_EDITOR_ENABLED environment variable. + // Navigate to Post Type (e.g. Pages / Posts) > Add New. + $I->amOnAdminPage('post-new.php?post_type=page'); + $I->waitForElementVisible('body.post-new-php'); + + // Define the Title. + $I->fillField('.editor-post-title__input', $title); + + // Configure metabox's Form setting = None, ensuring we only test the Divi block. + if ($configureMetaBox) { + $I->configureMetaboxSettings( + $I, + 'wp-convertkit-meta-box', + [ + 'form' => [ 'select2', 'None' ], + ] + ); + } + + // Publish Page. + $I->publishGutenbergPage($I); + + // Click Divi Builder button. + $I->click('#et-switch-to-divi'); + + // Wait for Divi Builder to load. + $I->waitForElementVisible('body.et_pb_pagebuilder_layout'); + } + + /** + * Helper method to insert a given Divi module in to a page edited with Divi 5. + * + * @since 3.2.1 + * + * @param EndToEndTester $I EndToEnd Tester. + * @param string $name Module Name. + * @param string $programmaticName Programmatic Module Name. + * @param bool|string $fieldName Field Name. + * @param bool|string $fieldValue Field Value. + * @param string $fieldType Field Type. + */ + public function insertDivi5RowWithModule($I, $name, $programmaticName, $fieldName = false, $fieldValue = false, $fieldType = 'text') + { + // Switch to editor iframe. + $I->switchToIFrame('iframe[id="et-vb-app-frame"]'); + + // Insert row. + $I->waitForElementVisible('button.et-vb-add-module'); + $I->click('button.et-vb-add-module'); + + // Switch back to main window. + $I->switchToIFrame(); + + // Select 1 column layout. + $I->waitForElementVisible('button[value="equal-columns_1"]'); + $I->click('button[value="equal-columns_1"]'); + + // Search for module. + $I->waitForElementVisible('input[name="et-vb-field-input-text-filter-option"]'); + $I->fillField('et-vb-field-input-text-filter-option', $name); + + // Insert module. + $I->waitForElementVisible('button[value="divi/shortcode-module/' . $programmaticName . '"]'); + $I->click('button[value="divi/shortcode-module/' . $programmaticName . '"]'); + + // Switch to editor iframe. + $I->switchToIFrame('iframe[id="et-vb-app-frame"]'); + + // Wait for module to load. + $I->waitForElementVisible('div.et_pb_shortcode_module_inner div.' . $programmaticName); + + // Switch to main window. + $I->switchToIFrame(); + + // Select field value. + if ($fieldName && $fieldValue) { + switch ($fieldType) { + case 'select': + $I->click('div#et-vb-' . $fieldName); + $I->waitForElementVisible('#et-vb-' . $fieldName . ' li[data-value="' . $fieldValue . '"]'); + $I->click('#et-vb-' . $fieldName . ' li[data-value="' . $fieldValue . '"]'); + break; + + default: + $I->waitForElementVisible('input[name="et-vb-field-input-text-' . $fieldName . '"]'); + $I->fillField('input[name="et-vb-field-input-text-' . $fieldName . '"]', $fieldValue); + break; + } + } + } + + /** + * Helper method to save a page created using Divi 5. + * + * @since 3.2.1 + * + * @param EndToEndTester $I EndToEnd Tester. + */ + public function saveDivi5PageAndViewOnFrontend($I) + { + // Save page. + $I->waitForElementVisible('.et-vb-page-bar-dropdown-button.et-vb-page-bar-dropdown-button--fill'); + $I->click('.et-vb-page-bar-dropdown-button.et-vb-page-bar-dropdown-button--fill button.et-vb-page-bar-action-button'); + $I->waitForElementNotVisible('.et-vb-page-bar-dropdown-button--saving'); + + // Load the Page on the frontend site. + $I->click('div[aria-label="Exit Dropdown"]'); + $I->waitForElementVisible('button[value="view-page"]'); + $I->click('button[value="view-page"]'); + + // Check that no PHP warnings or notices were output. + $I->checkNoWarningsAndNoticesOnScreen($I); + } +}