Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions includes/integrations/divi/class-convertkit-divi-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tests/EndToEnd.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
200 changes: 57 additions & 143 deletions tests/EndToEnd/integrations/divi-theme/DiviThemeBroadcastsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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');
}

Expand All @@ -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);
Expand All @@ -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('<time datetime="' . date( 'Y-m-d', strtotime( $_ENV['CONVERTKIT_API_BROADCAST_FIRST_DATE'] ) ) . '">' . date( 'F j, Y', strtotime( $_ENV['CONVERTKIT_API_BROADCAST_FIRST_DATE'] ) ) . '</time>');

// 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(
Expand All @@ -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(
Expand Down Expand Up @@ -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);
}
Expand Down
Loading