Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .env.dist.testing
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ CHROMEDRIVER_HOST=localhost
CHROMEDRIVER_PORT=9515

# The user agents used in end-to-end tests.
TEST_SITE_HTTP_USER_AGENT=HeadlessChrome
TEST_SITE_HTTP_USER_AGENT_MOBILE=HeadlessChromeMobile
TEST_SITE_HTTP_USER_AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com"
TEST_SITE_HTTP_USER_AGENT_MOBILE="Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Mobile Safari/537.36 WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com"

# Kit specific variables
CONVERTKIT_API_SUBSCRIBER_EMAIL="optin@n7studios.com"
Expand Down
6 changes: 3 additions & 3 deletions includes/class-convertkit-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ public function get_default_settings() {

$defaults = array(
'form' => '-1', // -1: Plugin Default Form, 0: No Form, 1+: Specific Form ID on ConvertKit.
'landing_page' => '',
'tag' => '',
'restrict_content' => '',
'landing_page' => '0', // 0: None, 1+: Specific Landing Page ID.
'tag' => '0', // 0: None, 1+: Specific Tag ID.
'restrict_content' => '0', // 0: None, form_<id> / tag_<id> / product_<id>: restrict to that resource.
);

/**
Expand Down
1 change: 1 addition & 0 deletions tests/EndToEnd.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ modules:
port: '%CHROMEDRIVER_PORT%'
path: '/wd/hub'
window_size: 1920x1080
log_js_errors: true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appends any JS errors to the HTML artifact when a test fails. Useful for the future for debugging JS issues.

capabilities:
"goog:chromeOptions":
args:
Expand Down
42 changes: 21 additions & 21 deletions tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ public function testFormBlockWithValidModalFormParameter(EndToEndTester $I)
// Publish and view the Page on the frontend site.
$I->publishAndViewGutenbergPage($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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);

// Confirm that the Form block container is not output.
$I->dontSeeElementInDOM('div.convertkit-form.wp-block-convertkit-form');

// 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_FORMAT_MODAL_ID']);
}

/**
Expand Down Expand Up @@ -223,7 +223,7 @@ public function testFormBlocksWithValidModalFormParameter(EndToEndTester $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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);

// Confirm that the Form block container is not output.
$I->dontSeeElementInDOM('div.convertkit-form.wp-block-convertkit-form');
Expand Down Expand Up @@ -272,12 +272,12 @@ public function testFormBlockWithValidSlideInFormParameter(EndToEndTester $I)
// Publish and view the Page on the frontend site.
$I->publishAndViewGutenbergPage($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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_SLIDE_IN_ID'] . '"]', 1);

// Confirm that the Form block container is not output.
$I->dontSeeElementInDOM('div.convertkit-form.wp-block-convertkit-form');

// 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_FORMAT_SLIDE_IN_ID']);
}

/**
Expand Down Expand Up @@ -333,12 +333,12 @@ public function testFormBlocksWithValidSlideInFormParameter(EndToEndTester $I)
// Publish and view the Page on the frontend site.
$I->publishAndViewGutenbergPage($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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_SLIDE_IN_ID'] . '"]', 1);

// Confirm that the Form block container is not output.
$I->dontSeeElementInDOM('div.convertkit-form.wp-block-convertkit-form');

// 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_FORMAT_SLIDE_IN_ID']);
}

/**
Expand Down Expand Up @@ -384,12 +384,12 @@ public function testFormBlockWithValidStickyBarFormParameter(EndToEndTester $I)
// Publish and view the Page on the frontend site.
$I->publishAndViewGutenbergPage($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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1);

// Confirm that the Form block container is not output.
$I->dontSeeElementInDOM('div.convertkit-form.wp-block-convertkit-form');

// 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_FORMAT_STICKY_BAR_ID']);
}

/**
Expand Down Expand Up @@ -445,12 +445,12 @@ public function testFormBlocksWithValidStickyBarFormParameter(EndToEndTester $I)
// Publish and view the Page on the frontend site.
$I->publishAndViewGutenbergPage($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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1);

// Confirm that the Form block container is not output.
$I->dontSeeElementInDOM('div.convertkit-form.wp-block-convertkit-form');

// 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_FORMAT_STICKY_BAR_ID']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testFormTriggerBlocksWithValidFormParameter(EndToEndTester $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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testFormTriggerFormatterWithModalForm(EndToEndTester $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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions tests/EndToEnd/forms/general/NonInlineFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public function testDefaultNonInlineForm(EndToEndTester $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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);

// View Page.
$I->amOnPage('/kit-default-non-inline-global');

// 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_STICKY_BAR_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);

// View a search page.
$I->amOnPage('/?s=test');
Expand Down Expand Up @@ -129,15 +129,15 @@ public function testDefaultNonInlineForms(EndToEndTester $I)
$I->amOnPage('/');

// Confirm that two Kit Forms are output in the DOM.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1);
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);

// View Page.
$I->amOnPage('/kit-default-non-inline-global-forms');

// Confirm that two Kit Forms are output in the DOM.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1);
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);

// View a search page.
$I->amOnPage('/?s=test');
Expand Down Expand Up @@ -697,7 +697,7 @@ public function testNonInlineFormLimitPerSession(EndToEndTester $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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);

// View Page.
$I->amOnPage('/kit-non-inline-form-limit-per-session');
Expand Down Expand Up @@ -750,7 +750,7 @@ public function testNonInlineFormLimitPerSessionDoesNotSetCookieWhenDisabled(End

// 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_STICKY_BAR_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);

// Confirm no cookie is set.
$I->dontSeeCookie('ck_non_inline_form_displayed');
Expand All @@ -760,7 +760,7 @@ public function testNonInlineFormLimitPerSessionDoesNotSetCookieWhenDisabled(End

// 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_STICKY_BAR_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);

// Confirm no cookie is set.
$I->dontSeeCookie('ck_non_inline_form_displayed');
Expand Down Expand Up @@ -803,14 +803,14 @@ public function testDefaultNonInlineFormOnUpgrade(EndToEndTester $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.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);

// View Page.
$I->amOnPage('/kit-default-non-inline-global-upgrade');

// 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_STICKY_BAR_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID']);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions tests/EndToEnd/forms/post-types/BlockEditorFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public function testAddNewPostTypeUsingDefaultNonInlineFormAfterParagraphElement

// 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);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);

// Confirm character encoding is not broken due to using DOMDocument.
$I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium');
Expand Down Expand Up @@ -676,7 +676,7 @@ public function testAddNewPostTypeUsingModalFormWithAutoptimizePlugin(EndToEndTe
// 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,
// and that Autoptimize hasn't moved the script embed to the footer of the site.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

// Deactivate Autoptimize Plugin.
Expand Down Expand Up @@ -725,7 +725,7 @@ public function testAddNewPostTypeUsingModalFormWithDebloatPlugin(EndToEndTester
// 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,
// and that Debloat hasn't moved the script embed to the footer of the site.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

// Deactivate Debloat Plugin.
Expand Down Expand Up @@ -776,7 +776,7 @@ public function testAddNewPostTypeUsingModalFormWithJetpackBoostPlugin(EndToEndT
// 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,
// and that Jetpack Boost hasn't moved the script embed to the footer of the site.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

// Deactivate Jetpack Boost Plugin.
Expand Down Expand Up @@ -826,7 +826,7 @@ public function testAddNewPostTypeUsingModalFormWithLiteSpeedCachePlugin(EndToEn
// 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,
// and that LiteSpeed Cache hasn't moved the script embed to the footer of the site.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

// Deactivate LiteSpeed Cache Plugin.
Expand Down Expand Up @@ -877,7 +877,7 @@ public function testAddNewPostTypeUsingModalFormWithSitegroundSpeedOptimizerPlug
$I->publishAndViewGutenbergPage($I);

// Confirm that one Kit Form is output in the DOM.
$I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

// Deactivate Siteground Speed Optimizer Plugin.
Expand Down Expand Up @@ -934,7 +934,7 @@ public function testAddNewPostTypeUsingModalFormWithPerfmattersPlugin(EndToEndTe

// Confirm that one Kit Form is output in the DOM within the <main> element.
// 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);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

// Deactivate Perfmatters Plugin.
Expand Down Expand Up @@ -983,7 +983,7 @@ public function testAddNewPostTypeUsingModalFormWithWPRocketPlugin(EndToEndTeste

// Confirm that one Kit Form is output in the DOM within the <main> element.
// 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);
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID']);
}

// Deactivate WP Rocket Plugin.
Expand Down
Loading
Loading