From d2366d8967be7973a51939052a5fe97fd5fd9a80 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 24 Jul 2026 16:37:44 +0800 Subject: [PATCH 01/19] Settings: Post: Defaults: Use `0` instead of blank string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This mirrors how settings are saved when adding/editing a Page, Post or CPT in WordPress and setting Landing Page, Add a Tag and/or Member Content functionality to ‘None’ / ‘Don’t restrict’, which would store these settings as 0, not a blank string. --- includes/class-convertkit-post.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/class-convertkit-post.php b/includes/class-convertkit-post.php index 58d1a4ab8..b13cf01b2 100644 --- a/includes/class-convertkit-post.php +++ b/includes/class-convertkit-post.php @@ -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_ / tag_ / product_: restrict to that resource. ); /** From 40b2203c1611a9e271fd105bc75485f220141f8a Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 24 Jul 2026 18:00:00 +0800 Subject: [PATCH 02/19] Tests: Fix User Agent --- .env.dist.testing | 4 ++-- .github/workflows/tests.yml | 21 +-------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/.env.dist.testing b/.env.dist.testing index 31a59c636..182d7671f 100644 --- a/.env.dist.testing +++ b/.env.dist.testing @@ -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" +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" # Kit specific variables CONVERTKIT_API_SUBSCRIBER_EMAIL="optin@n7studios.com" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1e6581ad2..6ad6f1a79 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,28 +33,9 @@ jobs: fail-fast: false matrix: wp-version: [ 'latest' ] - php-version: [ '8.1', '8.2', '8.3', '8.4' ] + php-version: [ '8.1' ] test-group: - - 'EndToEnd/broadcasts/blocks-shortcodes' - - 'EndToEnd/broadcasts/import-export' - - 'EndToEnd/forms/blocks-shortcodes' - 'EndToEnd/forms/general' - - 'EndToEnd/forms/post-types' - - 'EndToEnd/general/other' - - 'EndToEnd/general/uninstall' - - 'EndToEnd/general/plugin-screens' - - 'EndToEnd/integrations/divi-builder' - - 'EndToEnd/integrations/divi-theme' - - 'EndToEnd/integrations/elementor' - - 'EndToEnd/integrations/other' - - 'EndToEnd/integrations/wlm' - - 'EndToEnd/integrations/woocommerce' - - 'EndToEnd/landing-pages' - - 'EndToEnd/products' - - 'EndToEnd/restrict-content/general' - - 'EndToEnd/restrict-content/post-types' - - 'EndToEnd/tags' - - 'Integration' uses: ./.github/workflows/_run-tests.yml secrets: inherit From 9723c5f1bdacd14faa02a823c98e68253ba19f69 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 24 Jul 2026 18:17:25 +0800 Subject: [PATCH 03/19] seeFormOutput: Wait for the form to render --- tests/Support/Helper/KitForms.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index dc31b371d..74f482bd3 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -27,6 +27,16 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, // Calculate how many times the Form should be in the DOM. $count = ( ( $position === 'before_after_content' ) ? 2 : 1 ); + // Wait for the Form to be injected into the DOM by Kit's async JS. + $I->waitForJS( + sprintf( + 'return document.querySelectorAll(\'form[data-sv-form="%s"]\').length >= %d;', + $formID, + $count + ), + 10 + ); + // Confirm the Form is in the DOM the expected number of times. $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); From 1b90ac4e74fde797ef907449f93c4f80a8a22123 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 24 Jul 2026 18:24:26 +0800 Subject: [PATCH 04/19] Debug test failure --- tests/Support/Helper/KitForms.php | 39 ++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index 74f482bd3..1dd161dad 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -28,14 +28,37 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, $count = ( ( $position === 'before_after_content' ) ? 2 : 1 ); // Wait for the Form to be injected into the DOM by Kit's async JS. - $I->waitForJS( - sprintf( - 'return document.querySelectorAll(\'form[data-sv-form="%s"]\').length >= %d;', - $formID, - $count - ), - 10 - ); + try { + $I->waitForJS( + sprintf( + 'return document.querySelectorAll(\'form[data-sv-form="%s"]\').length >= %d;', + $formID, + $count + ), + 10 + ); + } catch ( \Facebook\WebDriver\Exception\TimeoutException $e ) { + // Diagnostic: dump the browser-side state so CI failures show + // why Kit's embed script didn't inject the form (CDN blocked, + // script errored, hostname rejected, etc.). Remove once the + // underlying cause is understood. + $diag = $I->executeJS( + sprintf( + 'return JSON.stringify({ + script_tags: Array.from(document.querySelectorAll(\'script[src*=".kit.com"]\')).map(s => ({src: s.src, async: s.async})), + form_count: document.querySelectorAll(\'form[data-sv-form="%s"]\').length, + any_kit_form_count: document.querySelectorAll(\'form[data-sv-form]\').length, + page_url: document.location.href, + page_host: document.location.hostname, + user_agent: navigator.userAgent, + webdriver: navigator.webdriver, + });', + $formID + ) + ); + codecept_debug( 'Kit form injection failed. State: ' . $diag ); + throw $e; + } // Confirm the Form is in the DOM the expected number of times. $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); From d66b73951e5a82088263150ad6e87a657d029459 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 27 Jul 2026 14:38:47 +0800 Subject: [PATCH 05/19] Log JS errors --- tests/EndToEnd.suite.yml | 1 + tests/Support/Helper/KitForms.php | 33 ------------------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/tests/EndToEnd.suite.yml b/tests/EndToEnd.suite.yml index 85037bdcf..f00924664 100644 --- a/tests/EndToEnd.suite.yml +++ b/tests/EndToEnd.suite.yml @@ -55,6 +55,7 @@ modules: port: '%CHROMEDRIVER_PORT%' path: '/wd/hub' window_size: 1920x1080 + log_js_errors: true capabilities: "goog:chromeOptions": args: diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index 1dd161dad..dc31b371d 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -27,39 +27,6 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, // Calculate how many times the Form should be in the DOM. $count = ( ( $position === 'before_after_content' ) ? 2 : 1 ); - // Wait for the Form to be injected into the DOM by Kit's async JS. - try { - $I->waitForJS( - sprintf( - 'return document.querySelectorAll(\'form[data-sv-form="%s"]\').length >= %d;', - $formID, - $count - ), - 10 - ); - } catch ( \Facebook\WebDriver\Exception\TimeoutException $e ) { - // Diagnostic: dump the browser-side state so CI failures show - // why Kit's embed script didn't inject the form (CDN blocked, - // script errored, hostname rejected, etc.). Remove once the - // underlying cause is understood. - $diag = $I->executeJS( - sprintf( - 'return JSON.stringify({ - script_tags: Array.from(document.querySelectorAll(\'script[src*=".kit.com"]\')).map(s => ({src: s.src, async: s.async})), - form_count: document.querySelectorAll(\'form[data-sv-form="%s"]\').length, - any_kit_form_count: document.querySelectorAll(\'form[data-sv-form]\').length, - page_url: document.location.href, - page_host: document.location.hostname, - user_agent: navigator.userAgent, - webdriver: navigator.webdriver, - });', - $formID - ) - ); - codecept_debug( 'Kit form injection failed. State: ' . $diag ); - throw $e; - } - // Confirm the Form is in the DOM the expected number of times. $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); From 2ccf690057b8c792c3860e23f2d589d2caad0cd9 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 27 Jul 2026 14:45:14 +0800 Subject: [PATCH 06/19] Tweak user agents --- .env.dist.testing | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.dist.testing b/.env.dist.testing index 182d7671f..94b6fdfab 100644 --- a/.env.dist.testing +++ b/.env.dist.testing @@ -28,8 +28,8 @@ CHROMEDRIVER_HOST=localhost CHROMEDRIVER_PORT=9515 # The user agents used in end-to-end tests. -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" -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" +TEST_SITE_HTTP_USER_AGENT="WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com" +TEST_SITE_HTTP_USER_AGENT_MOBILE="WordPress/7.0.1;PHP/8.4.1;ConvertKitMobile/3.3.6;http://example.com" # Kit specific variables CONVERTKIT_API_SUBSCRIBER_EMAIL="optin@n7studios.com" From 1ec055cceee24dbc21cd9d9ed7f253e224f78747 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 27 Jul 2026 15:07:03 +0800 Subject: [PATCH 07/19] seeFormOutput: Change user-agent before assertions --- tests/Support/Helper/KitForms.php | 104 +++++++++++++++++++----------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index dc31b371d..88fbb6271 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -27,46 +27,76 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, // Calculate how many times the Form should be in the DOM. $count = ( ( $position === 'before_after_content' ) ? 2 : 1 ); - // Confirm the Form is in the DOM the expected number of times. - $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); + try { + // Set user agent that permits form embeds. + $I->executeInSelenium( + function ($driver) { + $driver->executeCdpCommand( + 'Network.setUserAgentOverride', + [ 'userAgent' => 'WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com' ] + ); + } + ); - // Assert position of form, if required. - if ( ! $position) { - return; - } + // Reload page with new user agent. + $I->reloadPage(); + + // Wait for the injected
before asserting on it. + $I->waitForElement('form[data-sv-form="' . $formID . '"]', 10); + + // Confirm the Form is in the DOM the expected number of times. + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); + + // Assert position of form, if required. + if ( ! $position) { + return; + } + + // Assert that the first and/or last child element is the Form ID, depending on the position. + switch ($position) { + case 'before_after_content': + $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); + $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); + break; - // Assert that the first and/or last child element is the Form ID, depending on the position. - switch ($position) { - case 'before_after_content': - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); - break; - - case 'before_content': - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); - break; - - case 'after_content': - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); - break; - - case 'after_element': - // The block editor automatically adds CSS classes to some elements. - switch ( $element ) { - case 'p': - $I->seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-paragraph"' ) . '>Item #' . $elementIndex . 'seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $elementIndex . '">seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-heading"' ) . '>Item #' . $elementIndex . 'assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); + break; + + case 'after_content': + $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); + break; + + case 'after_element': + // The block editor automatically adds CSS classes to some elements. + switch ( $element ) { + case 'p': + $I->seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-paragraph"' ) . '>Item #' . $elementIndex . 'seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $elementIndex . '">seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-heading"' ) . '>Item #' . $elementIndex . 'executeInSelenium( + function ($driver) { + $driver->executeCdpCommand( + 'Network.setUserAgentOverride', + [ 'userAgent' => $_ENV['TEST_SITE_HTTP_USER_AGENT'] ] + ); } - break; + ); } } From 5a143c07d82fd4db96da6e46192996c5f15cac3c Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 27 Jul 2026 15:35:38 +0800 Subject: [PATCH 08/19] Swtich user agents on seeFormOutput assertions --- .env.dist.testing | 4 +- tests/Support/Helper/KitForms.php | 107 +++++++++++++---------------- tests/Support/Helper/KitPlugin.php | 93 ++++++++++++++----------- 3 files changed, 100 insertions(+), 104 deletions(-) diff --git a/.env.dist.testing b/.env.dist.testing index 94b6fdfab..31a59c636 100644 --- a/.env.dist.testing +++ b/.env.dist.testing @@ -28,8 +28,8 @@ CHROMEDRIVER_HOST=localhost CHROMEDRIVER_PORT=9515 # The user agents used in end-to-end tests. -TEST_SITE_HTTP_USER_AGENT="WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com" -TEST_SITE_HTTP_USER_AGENT_MOBILE="WordPress/7.0.1;PHP/8.4.1;ConvertKitMobile/3.3.6;http://example.com" +TEST_SITE_HTTP_USER_AGENT=HeadlessChrome +TEST_SITE_HTTP_USER_AGENT_MOBILE=HeadlessChromeMobile # Kit specific variables CONVERTKIT_API_SUBSCRIBER_EMAIL="optin@n7studios.com" diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index 88fbb6271..61f76e0bc 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -27,77 +27,62 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, // Calculate how many times the Form should be in the DOM. $count = ( ( $position === 'before_after_content' ) ? 2 : 1 ); - try { - // Set user agent that permits form embeds. - $I->executeInSelenium( - function ($driver) { - $driver->executeCdpCommand( - 'Network.setUserAgentOverride', - [ 'userAgent' => 'WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com' ] - ); - } - ); + // Get current URL. + $url = $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl(); - // Reload page with new user agent. - $I->reloadPage(); + // Change user agent. + $I->changeUserAgent('WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com'); - // Wait for the injected before asserting on it. - $I->waitForElement('form[data-sv-form="' . $formID . '"]', 10); + // Load page. + $I->amOnUrl($url); - // Confirm the Form is in the DOM the expected number of times. - $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); + // Wait for the injected before asserting on it. + $I->waitForElement('form[data-sv-form="' . $formID . '"]', 10); - // Assert position of form, if required. - if ( ! $position) { - return; - } + // Confirm the Form is in the DOM the expected number of times. + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); - // Assert that the first and/or last child element is the Form ID, depending on the position. - switch ($position) { - case 'before_after_content': - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); - break; + // Assert position of form, if required. + if ( ! $position) { + return; + } - case 'before_content': - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); - break; + // Assert that the first and/or last child element is the Form ID, depending on the position. + switch ($position) { + case 'before_after_content': + $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); + $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); + break; - case 'after_content': - $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); - break; + case 'before_content': + $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:first-child', 'data-sv-form')); + break; - case 'after_element': - // The block editor automatically adds CSS classes to some elements. - switch ( $element ) { - case 'p': - $I->seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-paragraph"' ) . '>Item #' . $elementIndex . 'seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $elementIndex . '">seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-heading"' ) . '>Item #' . $elementIndex . 'executeInSelenium( - function ($driver) { - $driver->executeCdpCommand( - 'Network.setUserAgentOverride', - [ 'userAgent' => $_ENV['TEST_SITE_HTTP_USER_AGENT'] ] - ); + case 'after_content': + $I->assertEquals($formID, $I->grabAttributeFrom('div.entry-content > *:last-child', 'data-sv-form')); + break; + + case 'after_element': + // The block editor automatically adds CSS classes to some elements. + switch ( $element ) { + case 'p': + $I->seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-paragraph"' ) . '>Item #' . $elementIndex . 'seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $elementIndex . '">seeInSource('<' . $element . ( $isShortcode ? '' : ' class="wp-block-heading"' ) . '>Item #' . $elementIndex . 'changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT']); } /** diff --git a/tests/Support/Helper/KitPlugin.php b/tests/Support/Helper/KitPlugin.php index 790877f81..473622aa2 100644 --- a/tests/Support/Helper/KitPlugin.php +++ b/tests/Support/Helper/KitPlugin.php @@ -1103,35 +1103,9 @@ public function selectAllText($I, $selector) */ public function enableMobileEmulation() { - $this->getModule(\lucatume\WPBrowser\Module\WPWebDriver::class)->_restart( - [ - 'browser' => 'chrome', - 'capabilities' => [ - 'goog:chromeOptions' => [ - 'args' => [ - '--headless', - '--disable-gpu', - '--disable-dev-shm-usage', - "--proxy-server='direct://'", - '--proxy-bypass-list=*', - '--no-sandbox', - '--user-agent=' . $_ENV['TEST_SITE_HTTP_USER_AGENT_MOBILE'], - ], - 'mobileEmulation' => [ - 'deviceMetrics' => [ - 'width' => 430, - 'height' => 932, - 'pixelRatio' => 1, - ], - 'clientHints' => [ - 'platform' => 'Android', - 'mobile' => true, - ], - 'userAgent' => $_ENV['TEST_SITE_HTTP_USER_AGENT_MOBILE'], - ], - ], - ], - ] + $this->changeUserAgent( + userAgent: $_ENV['TEST_SITE_HTTP_USER_AGENT_MOBILE'], + isMobile: true ); } @@ -1143,22 +1117,59 @@ public function enableMobileEmulation() */ public function disableMobileEmulation() { + $this->changeUserAgent( + userAgent: $_ENV['TEST_SITE_HTTP_USER_AGENT'], + isMobile: false + ); + } + + /** + * Changes the WPWebBrowser Chrome User Agent, + * restarting the headless Chrome instance. + * + * @since 3.3.6 + * + * @param string $userAgent User Agent. + * @param bool $isMobile Whether the user agent is for a mobile device. + */ + public function changeUserAgent($userAgent, $isMobile = false) + { + // Build base options. + $options = [ + 'args' => [ + '--headless', + '--disable-gpu', + '--disable-dev-shm-usage', + '--disable-software-rasterizer', + "--proxy-server='direct://'", + '--proxy-bypass-list=*', + '--no-sandbox', + '--user-agent=' . $userAgent, + ], + ]; + + // If mobile, add mobile emulation options. + if ($isMobile) { + $options['mobileEmulation'] = [ + 'deviceMetrics' => [ + 'width' => 430, + 'height' => 932, + 'pixelRatio' => 1, + ], + 'clientHints' => [ + 'platform' => 'Android', + 'mobile' => true, + ], + 'userAgent' => $userAgent, + ]; + } + + // Restart chromedriver with the new options. $this->getModule(\lucatume\WPBrowser\Module\WPWebDriver::class)->_restart( [ 'browser' => 'chrome', 'capabilities' => [ - 'goog:chromeOptions' => [ - 'args' => [ - '--headless', - '--disable-gpu', - '--disable-dev-shm-usage', - "--proxy-server='direct://'", - '--proxy-bypass-list=*', - '--no-sandbox', - '--user-agent=' . $_ENV['TEST_SITE_HTTP_USER_AGENT'], - ], - // excluding mobileEmulation arguments here makes chromedriver behave in desktop mode. - ], + 'goog:chromeOptions' => $options, ], ] ); From 29663089af8fcdf62a8fd2bf39ca91e043e0fccd Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 27 Jul 2026 15:51:16 +0800 Subject: [PATCH 09/19] seeFormOutput: Revert user agent if not asserting form position --- tests/Support/Helper/KitForms.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index 61f76e0bc..f29135428 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -42,8 +42,9 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, // Confirm the Form is in the DOM the expected number of times. $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); - // Assert position of form, if required. + // If no position is specified, revert user agent and return. if ( ! $position) { + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT']); return; } From a73975a7098d097307139b88f4f47acacf9a0c6e Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 27 Jul 2026 16:27:41 +0800 Subject: [PATCH 10/19] Use seeFormOutput --- .env.dist.testing | 1 + .../blocks-shortcodes/PageBlockFormCest.php | 42 +++++++++---------- .../PageBlockFormTriggerCest.php | 2 +- .../PageBlockFormatterFormTriggerCest.php | 2 +- .../forms/general/CategoryFormCest.php | 24 +++++++++++ .../forms/general/NonInlineFormCest.php | 22 +++++----- .../forms/post-types/BlockEditorFormCest.php | 16 +++---- .../post-types/ClassicEditorFormCest.php | 16 +++---- .../PluginSettingsGeneralCest.php | 6 +-- .../DiviPluginFormTriggerCest.php | 4 +- .../divi-theme/DiviThemeFormTriggerCest.php | 2 +- tests/Support/Helper/KitForms.php | 2 +- 12 files changed, 82 insertions(+), 57 deletions(-) diff --git a/.env.dist.testing b/.env.dist.testing index 31a59c636..f53024763 100644 --- a/.env.dist.testing +++ b/.env.dist.testing @@ -30,6 +30,7 @@ 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_FRONTEND="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" diff --git a/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormCest.php b/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormCest.php index ab6c101ad..578098015 100644 --- a/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormCest.php +++ b/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormCest.php @@ -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']); } /** @@ -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'); @@ -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']); } /** @@ -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']); } /** @@ -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']); } /** @@ -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']); } /** diff --git a/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormTriggerCest.php b/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormTriggerCest.php index 9046ecbde..be76aebd6 100644 --- a/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormTriggerCest.php +++ b/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormTriggerCest.php @@ -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']); } /** diff --git a/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormatterFormTriggerCest.php b/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormatterFormTriggerCest.php index e96e4e00e..f748740d8 100644 --- a/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormatterFormTriggerCest.php +++ b/tests/EndToEnd/forms/blocks-shortcodes/PageBlockFormatterFormTriggerCest.php @@ -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']); } /** diff --git a/tests/EndToEnd/forms/general/CategoryFormCest.php b/tests/EndToEnd/forms/general/CategoryFormCest.php index 0d8e85e29..73e67e3b0 100644 --- a/tests/EndToEnd/forms/general/CategoryFormCest.php +++ b/tests/EndToEnd/forms/general/CategoryFormCest.php @@ -304,6 +304,9 @@ public function testAddCategoryWithFormPositionBefore(EndToEndTester $I) ] ); + // Change user agent. + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); + // Load the Category archive on the frontend site. $I->amOnPage('/category/kit-position-before'); @@ -317,6 +320,9 @@ public function testAddCategoryWithFormPositionBefore(EndToEndTester $I)
changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // 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']); @@ -366,6 +372,9 @@ public function testAddCategoryWithFormPositionAfter(EndToEndTester $I) ] ); + // Change user agent. + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); + // Load the Category archive on the frontend site. $I->amOnPage('/category/kit-position-after'); @@ -378,6 +387,9 @@ public function testAddCategoryWithFormPositionAfter(EndToEndTester $I)
changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // 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']); @@ -437,6 +449,9 @@ public function testEditCategoryWithFormPositionBefore(EndToEndTester $I) // Check that no PHP warnings or notices were output. $I->checkNoWarningsAndNoticesOnScreen($I); + // Change user agent. + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); + // Load the Category archive on the frontend site. $I->amOnPage('/category/kit-edit-position-before'); @@ -450,6 +465,9 @@ public function testEditCategoryWithFormPositionBefore(EndToEndTester $I)
changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // 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']); @@ -509,6 +527,9 @@ public function testEditCategoryWithFormPositionAfter(EndToEndTester $I) // Check that no PHP warnings or notices were output. $I->checkNoWarningsAndNoticesOnScreen($I); + // Change user agent. + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); + // Load the Category archive on the frontend site. $I->amOnPage('/category/kit-edit-position-after'); @@ -521,6 +542,9 @@ public function testEditCategoryWithFormPositionAfter(EndToEndTester $I)
changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // 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']); diff --git a/tests/EndToEnd/forms/general/NonInlineFormCest.php b/tests/EndToEnd/forms/general/NonInlineFormCest.php index c626e82b4..5a1cdcca5 100644 --- a/tests/EndToEnd/forms/general/NonInlineFormCest.php +++ b/tests/EndToEnd/forms/general/NonInlineFormCest.php @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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']); } /** diff --git a/tests/EndToEnd/forms/post-types/BlockEditorFormCest.php b/tests/EndToEnd/forms/post-types/BlockEditorFormCest.php index 50f84b9d6..403f65a6c 100644 --- a/tests/EndToEnd/forms/post-types/BlockEditorFormCest.php +++ b/tests/EndToEnd/forms/post-types/BlockEditorFormCest.php @@ -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'); @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -934,7 +934,7 @@ public function testAddNewPostTypeUsingModalFormWithPerfmattersPlugin(EndToEndTe // Confirm that one Kit Form is output in the DOM within the
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. @@ -983,7 +983,7 @@ public function testAddNewPostTypeUsingModalFormWithWPRocketPlugin(EndToEndTeste // Confirm that one Kit Form is output in the DOM within the
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. diff --git a/tests/EndToEnd/forms/post-types/ClassicEditorFormCest.php b/tests/EndToEnd/forms/post-types/ClassicEditorFormCest.php index c46126e96..1a587c81f 100644 --- a/tests/EndToEnd/forms/post-types/ClassicEditorFormCest.php +++ b/tests/EndToEnd/forms/post-types/ClassicEditorFormCest.php @@ -379,7 +379,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'); @@ -761,7 +761,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. @@ -813,7 +813,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. @@ -867,7 +867,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. @@ -920,7 +920,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. @@ -974,7 +974,7 @@ public function testAddNewPostTypeUsingModalFormWithSitegroundSpeedOptimizerPlug $I->publishAndViewClassicEditorPage($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. @@ -1034,7 +1034,7 @@ public function testAddNewPostTypeUsingModalFormWithPerfmattersPlugin(EndToEndTe // Confirm that one Kit Form is output in the DOM within the
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. @@ -1086,7 +1086,7 @@ public function testAddNewPostTypeUsingModalFormWithWPRocketPlugin(EndToEndTeste // Confirm that one Kit Form is output in the DOM within the
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. diff --git a/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php b/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php index c938f0bc8..1f949ca9c 100644 --- a/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php +++ b/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php @@ -372,7 +372,7 @@ public function testChangeDefaultSiteWideFormsSettingAndPreviewFormLinks(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. - $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']); // Close newly opened tab. $I->closeTab(); @@ -395,8 +395,8 @@ public function testChangeDefaultSiteWideFormsSettingAndPreviewFormLinks(EndToEn $I->seeElementInDOM('body.home'); // 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']); // Close newly opened tab. $I->closeTab(); diff --git a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php index eb7d567c3..048278bf2 100644 --- a/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php +++ b/tests/EndToEnd/integrations/divi-builder/DiviPluginFormTriggerCest.php @@ -59,7 +59,7 @@ public function testFormTriggerModuleInBackendEditor(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']); // Deactivate Classic Editor. $I->deactivateThirdPartyPlugin($I, 'classic-editor'); @@ -99,7 +99,7 @@ public function testFormTriggerModuleInFrontendEditor(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']); } /** diff --git a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php index 984d5ea02..0a0cba483 100644 --- a/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php +++ b/tests/EndToEnd/integrations/divi-theme/DiviThemeFormTriggerCest.php @@ -61,7 +61,7 @@ public function testFormTriggerModule(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']); } /** diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index f29135428..e04b6f64e 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -31,7 +31,7 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, $url = $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl(); // Change user agent. - $I->changeUserAgent('WordPress/7.0.1;PHP/8.4.1;ConvertKit/3.3.6;http://example.com'); + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); // Load page. $I->amOnUrl($url); From f02acd682aad284f62f5364d30689ccc9ce00210 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 27 Jul 2026 17:10:36 +0800 Subject: [PATCH 11/19] Change user agent for Form Triggers and Products --- .../forms/general/CategoryFormCest.php | 12 ++++++++++ tests/Support/Helper/KitForms.php | 12 ++++++++++ tests/Support/Helper/KitProducts.php | 24 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/tests/EndToEnd/forms/general/CategoryFormCest.php b/tests/EndToEnd/forms/general/CategoryFormCest.php index 73e67e3b0..f2edefe88 100644 --- a/tests/EndToEnd/forms/general/CategoryFormCest.php +++ b/tests/EndToEnd/forms/general/CategoryFormCest.php @@ -323,6 +323,9 @@ public function testAddCategoryWithFormPositionBefore(EndToEndTester $I) // Revert user agent. $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // Load the Category archive on the frontend site. + $I->amOnPage('/category/kit-position-before'); + // 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']); @@ -390,6 +393,9 @@ public function testAddCategoryWithFormPositionAfter(EndToEndTester $I) // Revert user agent. $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // Load the Category archive on the frontend site. + $I->amOnPage('/category/kit-position-after'); + // 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']); @@ -468,6 +474,9 @@ public function testEditCategoryWithFormPositionBefore(EndToEndTester $I) // Revert user agent. $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // Load the Category archive on the frontend site. + $I->amOnPage('/category/kit-edit-position-before'); + // 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']); @@ -545,6 +554,9 @@ public function testEditCategoryWithFormPositionAfter(EndToEndTester $I) // Revert user agent. $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); + // Load the Category archive on the frontend site. + $I->amOnPage('/category/kit-edit-position-after'); + // 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']); diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index e04b6f64e..f50931cc3 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -104,6 +104,15 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, */ public function seeFormTriggerOutput($I, $formURL, $text = false, $textColor = false, $backgroundColor = false, $cssClasses = false, $styles = false, $isBlock = false) { + // Get current URL. + $url = $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl(); + + // Change user agent. + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); + + // Load page. + $I->amOnUrl($url); + // Confirm that the button stylesheet loaded. $I->seeInSource('seeElementInDOM('iframe[data-active]'); + + // Revert user agent. + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT']); } /** @@ -60,6 +72,15 @@ public function seeProductLink($I, $productURL, $text = false) */ public function seeProductOutput($I, $productURL, $text = false, $textColor = false, $backgroundColor = false, $cssClasses = false, $styles = false, $isBlock = false) { + // Get current URL. + $url = $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl(); + + // Change user agent. + $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); + + // Load page. + $I->amOnUrl($url); + // Confirm that the product stylesheet loaded. $I->seeInSource('changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT']); + $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT']); return; } @@ -82,8 +76,8 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, break; } - // Revert user agent. - $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT']); + // Revert user agent and reload current URL. + $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT']); } /** @@ -104,14 +98,8 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, */ public function seeFormTriggerOutput($I, $formURL, $text = false, $textColor = false, $backgroundColor = false, $cssClasses = false, $styles = false, $isBlock = false) { - // Get current URL. - $url = $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl(); - - // Change user agent. - $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - - // Load page. - $I->amOnUrl($url); + // Change user agent and reload current URL. + $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); // Confirm that the button stylesheet loaded. $I->seeInSource('seeElementInDOM('iframe[data-active]'); - // Revert user agent. - $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT']); + // Revert user agent and reload current URL. + $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT']); } /** @@ -72,14 +66,8 @@ public function seeProductLink($I, $productURL, $text = false) */ public function seeProductOutput($I, $productURL, $text = false, $textColor = false, $backgroundColor = false, $cssClasses = false, $styles = false, $isBlock = false) { - // Get current URL. - $url = $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl(); - - // Change user agent. - $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - - // Load page. - $I->amOnUrl($url); + // Change user agent and reload current URL. + $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); // Confirm that the product stylesheet loaded. $I->seeInSource(' Date: Tue, 28 Jul 2026 11:17:16 +0800 Subject: [PATCH 14/19] Revert form helpers back to original --- tests/Support/Helper/KitForms.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tests/Support/Helper/KitForms.php b/tests/Support/Helper/KitForms.php index e43925c37..dc31b371d 100644 --- a/tests/Support/Helper/KitForms.php +++ b/tests/Support/Helper/KitForms.php @@ -24,21 +24,14 @@ class KitForms extends \Codeception\Module */ public function seeFormOutput($I, $formID, $position = false, $element = false, $elementIndex = 0, $isShortcode = false) { - // Change user agent and reload current URL. - $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - // Calculate how many times the Form should be in the DOM. $count = ( ( $position === 'before_after_content' ) ? 2 : 1 ); - // Wait for the injected before asserting on it. - $I->waitForElement('form[data-sv-form="' . $formID . '"]', 10); - // Confirm the Form is in the DOM the expected number of times. $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $formID . '"]', $count); - // If no position is specified, revert user agent and return. + // Assert position of form, if required. if ( ! $position) { - $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT']); return; } @@ -75,9 +68,6 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, } break; } - - // Revert user agent and reload current URL. - $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT']); } /** @@ -98,9 +88,6 @@ public function seeFormOutput($I, $formID, $position = false, $element = false, */ public function seeFormTriggerOutput($I, $formURL, $text = false, $textColor = false, $backgroundColor = false, $cssClasses = false, $styles = false, $isBlock = false) { - // Change user agent and reload current URL. - $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - // Confirm that the button stylesheet loaded. $I->seeInSource('changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); - - // Load the Category archive on the frontend site. - $I->amOnPage('/category/kit-position-before'); - // 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']); @@ -375,9 +366,6 @@ public function testAddCategoryWithFormPositionAfter(EndToEndTester $I) ] ); - // Change user agent. - $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - // Load the Category archive on the frontend site. $I->amOnPage('/category/kit-position-after'); @@ -390,12 +378,6 @@ public function testAddCategoryWithFormPositionAfter(EndToEndTester $I)
changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); - - // Load the Category archive on the frontend site. - $I->amOnPage('/category/kit-position-after'); - // 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']); @@ -455,9 +437,6 @@ public function testEditCategoryWithFormPositionBefore(EndToEndTester $I) // Check that no PHP warnings or notices were output. $I->checkNoWarningsAndNoticesOnScreen($I); - // Change user agent. - $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - // Load the Category archive on the frontend site. $I->amOnPage('/category/kit-edit-position-before'); @@ -471,12 +450,6 @@ public function testEditCategoryWithFormPositionBefore(EndToEndTester $I)
changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); - - // Load the Category archive on the frontend site. - $I->amOnPage('/category/kit-edit-position-before'); - // 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']); @@ -536,9 +509,6 @@ public function testEditCategoryWithFormPositionAfter(EndToEndTester $I) // Check that no PHP warnings or notices were output. $I->checkNoWarningsAndNoticesOnScreen($I); - // Change user agent. - $I->changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - // Load the Category archive on the frontend site. $I->amOnPage('/category/kit-edit-position-after'); @@ -551,12 +521,6 @@ public function testEditCategoryWithFormPositionAfter(EndToEndTester $I)
changeUserAgent($_ENV['TEST_SITE_HTTP_USER_AGENT'], false); - - // Load the Category archive on the frontend site. - $I->amOnPage('/category/kit-edit-position-after'); - // 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']); From 1532cfd64cee3aef4ab6267c14c7d5770c605518 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 28 Jul 2026 11:27:47 +0800 Subject: [PATCH 16/19] Revert user agent changes --- tests/Support/Helper/KitPlugin.php | 21 --------------------- tests/Support/Helper/KitProducts.php | 12 ------------ 2 files changed, 33 deletions(-) diff --git a/tests/Support/Helper/KitPlugin.php b/tests/Support/Helper/KitPlugin.php index 13f3cc74c..473622aa2 100644 --- a/tests/Support/Helper/KitPlugin.php +++ b/tests/Support/Helper/KitPlugin.php @@ -1175,27 +1175,6 @@ public function changeUserAgent($userAgent, $isMobile = false) ); } - /** - * Changes the WPWebBrowser Chrome User Agent and reloads the current URL. - * - * @since 3.3.6 - * - * @param EndToEndTester $I EndToEndTester. - * @param string $userAgent User Agent. - * @param bool $isMobile Whether the user agent is for a mobile device. - */ - public function changeUserAgentAndReloadCurrentURL($I, $userAgent, $isMobile = false) - { - // Get current URL. - $url = $_ENV['WORDPRESS_URL'] . $I->grabFromCurrentUrl(); - - // Change user agent. - $I->changeUserAgent($userAgent, $isMobile); - - // Load page. - $I->amOnUrl($url); - } - /** * Truncates the given database table. * diff --git a/tests/Support/Helper/KitProducts.php b/tests/Support/Helper/KitProducts.php index 7acad5633..b8d067d23 100644 --- a/tests/Support/Helper/KitProducts.php +++ b/tests/Support/Helper/KitProducts.php @@ -22,9 +22,6 @@ class KitProducts extends \Codeception\Module */ public function seeProductLink($I, $productURL, $text = false) { - // Change user agent and reload current URL. - $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - // Confirm that the commerce.js script exists. $I->seeInSource('commerce.js'); @@ -43,9 +40,6 @@ public function seeProductLink($I, $productURL, $text = false) // necessary Kit scripts have been loaded. $I->click('a[href="' . $productURL . '"]'); $I->seeElementInDOM('iframe[data-active]'); - - // Revert user agent and reload current URL. - $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT']); } /** @@ -66,9 +60,6 @@ public function seeProductLink($I, $productURL, $text = false) */ public function seeProductOutput($I, $productURL, $text = false, $textColor = false, $backgroundColor = false, $cssClasses = false, $styles = false, $isBlock = false) { - // Change user agent and reload current URL. - $I->changeUserAgentAndReloadCurrentURL($I, $_ENV['TEST_SITE_HTTP_USER_AGENT_FRONTEND']); - // Confirm that the product stylesheet loaded. $I->seeInSource('