Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1789255
Add named arguments to CPTFormCest
n7studios May 21, 2025
1b3d5c5
Merge branch 'tests-use-named-arguments' into tests-use-named-argumen…
n7studios May 21, 2025
fe9b63c
Tests: Added named arguments to PageFormCest
n7studios May 21, 2025
5a0c198
Tests: Add named arguments to other and post-types form tests
n7studios May 21, 2025
dfaec29
Tests: Integrations
n7studios May 21, 2025
6107b02
Merge remote-tracking branch 'origin/tests-use-named-arguments' into …
n7studios May 21, 2025
9300040
Merge remote-tracking branch 'origin/tests-use-named-arguments' into …
n7studios May 23, 2025
06276b9
Fix failing tests
n7studios May 23, 2025
c909a13
Fix failing tests
n7studios May 23, 2025
1392bf6
Fix failing test
n7studios May 23, 2025
e85c08c
Fix failing test
n7studios May 23, 2025
92cd912
Coding standards
n7studios May 23, 2025
6e9f1e3
Tests: Contact Form 7: Wait for API to update before checking subscri…
n7studios May 23, 2025
21d8e89
Tests: Forminator: Wait for API to update before checking subscriber …
n7studios May 23, 2025
4d9c161
Tests: Use Named Arguments, Part 3
n7studios May 24, 2025
b35c2f7
Add named arguments to Tag and some Restrict Content tests
n7studios May 24, 2025
71015d7
Use named arguments on remaining Restrict Content tests
n7studios May 24, 2025
0378df9
Fix failing test
n7studios May 24, 2025
6074a98
Tests: Fix spacing on named arguments
n7studios May 28, 2025
da6c814
Merge pull request #827 from Kit/tests-use-named-arguments-3
n7studios May 28, 2025
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
178 changes: 130 additions & 48 deletions tests/EndToEnd/forms/post-types/CPTFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public function testAccessibility(EndToEndTester $I)
public function testNoOptionsOrOutputOnPrivateCustomPostType(EndToEndTester $I)
{
// Add a Private CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'private', 'Kit: Private: Form: None');
$I->addGutenbergPage(
$I,
postType: 'private',
title: 'Kit: Private: Form: None'
);

// Check that the metabox is not displayed.
$I->dontSeeElementInDOM('#wp-convertkit-meta-box');
Expand Down Expand Up @@ -128,7 +132,11 @@ public function testAddNewCPTUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin(
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: None');
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default: None'
);

// Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms.
$I->checkSelectFormOptionOrder(
Expand All @@ -143,8 +151,8 @@ public function testAddNewCPTUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin(
// Configure metabox's Form setting = Default.
$I->configureMetaboxSettings(
$I,
'wp-convertkit-meta-box',
[
metabox: 'wp-convertkit-meta-box',
configuration: [
'form' => [ 'select2', 'Default' ],
]
);
Expand Down Expand Up @@ -176,13 +184,17 @@ public function testAddNewCPTUsingDefaultForm(EndToEndTester $I)
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default');
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default'
);

// Configure metabox's Form setting = Default.
$I->configureMetaboxSettings(
$I,
'wp-convertkit-meta-box',
[
metabox: 'wp-convertkit-meta-box',
configuration: [
'form' => [ 'select2', 'Default' ],
]
);
Expand Down Expand Up @@ -217,16 +229,20 @@ public function testAddNewCPTUsingDefaultFormBeforeContent(EndToEndTester $I)
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: Before Content');
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default: Before Content'
);

// Add paragraph to CPT.
$I->addGutenbergParagraphBlock($I, 'CPT content');

// Configure metabox's Form setting = Default.
$I->configureMetaboxSettings(
$I,
'wp-convertkit-meta-box',
[
metabox: 'wp-convertkit-meta-box',
configuration: [
'form' => [ 'select2', 'Default' ],
]
);
Expand Down Expand Up @@ -261,16 +277,20 @@ public function testAddNewCPTUsingDefaultFormBeforeAndAfterContent(EndToEndTeste
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: Before and After Content');
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default: Before and After Content'
);

// Add paragraph to CPT.
$I->addGutenbergParagraphBlock($I, 'CPT content');

// Configure metabox's Form setting = Default.
$I->configureMetaboxSettings(
$I,
'wp-convertkit-meta-box',
[
metabox: 'wp-convertkit-meta-box',
configuration: [
'form' => [ 'select2', 'Default' ],
]
);
Expand All @@ -279,7 +299,11 @@ public function testAddNewCPTUsingDefaultFormBeforeAndAfterContent(EndToEndTeste
$I->publishAndViewGutenbergPage($I);

// Confirm that two Kit Forms are output in the DOM before and after the CPT content.
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'before_after_content');
$I->seeFormOutput(
$I,
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
position: 'before_after_content'
);
}

/**
Expand All @@ -306,7 +330,11 @@ public function testAddNewCPTUsingDefaultFormAfterParagraphElement(EndToEndTeste
$I->setupKitPluginResources($I);

// Setup Article with placeholder content.
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 3rd Paragraph Element');
$pageID = $I->addGutenbergPageToDatabase(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default: After 3rd Paragraph Element'
);

// View the CPT on the frontend site.
$I->amOnPage('?p=' . $pageID);
Expand All @@ -315,7 +343,13 @@ public function testAddNewCPTUsingDefaultFormAfterParagraphElement(EndToEndTeste
$I->checkNoWarningsAndNoticesOnScreen($I);

// Confirm that one Kit Form is output in the DOM after the third paragraph.
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3);
$I->seeFormOutput(
$I,
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
position: 'after_element',
element: 'p',
elementIndex: 3
);

// 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 @@ -348,7 +382,11 @@ public function testAddNewCPTUsingDefaultNonInlineFormAfterParagraphElement(EndT
$I->setupKitPluginResources($I);

// Setup CPT with placeholder content.
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Non-Inline Form: Default: After 3rd Paragraph Element');
$pageID = $I->addGutenbergPageToDatabase(
$I,
postType: 'article',
title: 'Kit: CPT: Non-Inline Form: Default: After 3rd Paragraph Element'
);

// View the Page on the frontend site.
$I->amOnPage('?p=' . $pageID);
Expand Down Expand Up @@ -391,7 +429,11 @@ public function testAddNewCPTUsingDefaultFormAfterHeadingElement(EndToEndTester
$I->setupKitPluginResources($I);

// Setup Article with placeholder content.
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 2nd H2 Element');
$pageID = $I->addGutenbergPageToDatabase(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default: After 2nd H2 Element'
);

// View the CPT on the frontend site.
$I->amOnPage('?p=' . $pageID);
Expand All @@ -400,7 +442,13 @@ public function testAddNewCPTUsingDefaultFormAfterHeadingElement(EndToEndTester
$I->checkNoWarningsAndNoticesOnScreen($I);

// Confirm that one Kit Form is output in the DOM after the second <h2> element.
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2);
$I->seeFormOutput(
$I,
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
position: 'after_element',
element: 'h2',
elementIndex: 2
);

// 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 @@ -433,7 +481,11 @@ public function testAddNewCPTUsingDefaultFormAfterImageElement(EndToEndTester $I
$I->setupKitPluginResources($I);

// Setup Article with placeholder content.
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 2nd Image Element');
$pageID = $I->addGutenbergPageToDatabase(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default: After 2nd Image Element'
);

// View the CPT on the frontend site.
$I->amOnPage('?p=' . $pageID);
Expand All @@ -442,7 +494,13 @@ public function testAddNewCPTUsingDefaultFormAfterImageElement(EndToEndTester $I
$I->checkNoWarningsAndNoticesOnScreen($I);

// Confirm that one Kit Form is output in the DOM after the second <img> element.
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2);
$I->seeFormOutput(
$I,
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
position: 'after_element',
element: 'img',
elementIndex: 2
);

// 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 @@ -475,7 +533,11 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(EndToEndTes
$I->setupKitPluginResources($I);

// Setup Article with placeholder content.
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 9th Paragraph Element');
$pageID = $I->addGutenbergPageToDatabase(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Default: After 9th Paragraph Element'
);

// View the CPT on the frontend site.
$I->amOnPage('?p=' . $pageID);
Expand All @@ -485,7 +547,11 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(EndToEndTes

// Confirm that one Kit Form is output in the DOM after the content, as
// the number of paragraphs is less than the position.
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content');
$I->seeFormOutput(
$I,
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
position: 'after_content'
);

// 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 @@ -516,7 +582,11 @@ public function testAddNewCPTUsingDefaultLegacyForm(EndToEndTester $I)
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Legacy: Default');
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: Legacy: Default'
);

// Configure metabox's Form setting = Default.
$I->configureMetaboxSettings(
Expand Down Expand Up @@ -554,13 +624,17 @@ public function testAddNewCPTUsingNoForm(EndToEndTester $I)
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: None');
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: None'
);

// Configure metabox's Form setting = None.
$I->configureMetaboxSettings(
$I,
'wp-convertkit-meta-box',
[
metabox: 'wp-convertkit-meta-box',
configuration: [
'form' => [ 'select2', 'None' ],
]
);
Expand Down Expand Up @@ -592,13 +666,17 @@ public function testAddNewCPTUsingDefinedForm(EndToEndTester $I)
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME']);
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME']
);

// Configure metabox's Form setting = None.
$I->configureMetaboxSettings(
$I,
'wp-convertkit-meta-box',
[
metabox: 'wp-convertkit-meta-box',
configuration: [
'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_NAME'] ],
]
);
Expand Down Expand Up @@ -633,13 +711,17 @@ public function testAddNewCPTUsingDefinedLegacyForm(EndToEndTester $I)
$I->setupKitPluginResources($I);

// Add a CPT using the Gutenberg editor.
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME']);
$I->addGutenbergPage(
$I,
postType: 'article',
title: 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME']
);

// Configure metabox's Form setting = None.
$I->configureMetaboxSettings(
$I,
'wp-convertkit-meta-box',
[
metabox: 'wp-convertkit-meta-box',
configuration: [
'form' => [ 'select2', $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] ],
]
);
Expand Down Expand Up @@ -735,9 +817,9 @@ public function testQuickEditUsingDefaultForm(EndToEndTester $I)
// Quick Edit the CPT in the CPTs WP_List_Table.
$I->quickEdit(
$I,
'article',
$postID,
[
postType: 'article',
postID: $postID,
configuration: [
'form' => [ 'select', 'Default' ],
]
);
Expand Down Expand Up @@ -783,9 +865,9 @@ public function testQuickEditUsingDefinedForm(EndToEndTester $I)
// Quick Edit the CPT in the CPTs WP_List_Table.
$I->quickEdit(
$I,
'article',
$postID,
[
postType: 'article',
postID: $postID,
configuration: [
'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ],
]
);
Expand Down Expand Up @@ -839,9 +921,9 @@ public function testBulkEditUsingDefaultForm(EndToEndTester $I)
// Bulk Edit the CPTs in the CPTs WP_List_Table.
$I->bulkEdit(
$I,
'article',
$postIDs,
[
postType: 'article',
postIDs: $postIDs,
configuration: [
'form' => [ 'select', 'Default' ],
]
);
Expand Down Expand Up @@ -898,9 +980,9 @@ public function testBulkEditUsingDefinedForm(EndToEndTester $I)
// Bulk Edit the CPTs in the CPTs WP_List_Table.
$I->bulkEdit(
$I,
'article',
$postIDs,
[
postType: 'article',
postIDs: $postIDs,
configuration: [
'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ],
]
);
Expand Down Expand Up @@ -971,9 +1053,9 @@ public function testBulkEditWithNoChanges(EndToEndTester $I)
// Bulk Edit the CPTs in the CPTs WP_List_Table.
$I->bulkEdit(
$I,
'article',
$postIDs,
[
postType: 'article',
postIDs: $postIDs,
configuration: [
'form' => [ 'select', '— No Change —' ],
]
);
Expand Down
Loading