Skip to content
Draft
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
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"
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"
Expand Down
21 changes: 1 addition & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions tests/Support/Helper/KitForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,45 @@
* @param bool|string $element Element the form should display after.
* @param bool|string $elementIndex Number of elements before the form should display.
* @param bool $isShortcode Test if this is a form shortcode or block.
*/

Check failure on line 24 in tests/Support/Helper/KitForms.php

View workflow job for this annotation

GitHub Actions / Coding Standards / WordPress latest / PHP 8.1

Missing @throws tag in function comment

Check failure on line 24 in tests/Support/Helper/KitForms.php

View workflow job for this annotation

GitHub Actions / Coding Standards / WordPress latest / PHP 8.3

Missing @throws tag in function comment
public function seeFormOutput($I, $formID, $position = false, $element = false, $elementIndex = 0, $isShortcode = 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);

Expand Down
Loading