Skip to content

Commit 1ccef1c

Browse files
committed
Merge branch 'delete-tokens-401' into add-resource-tests
2 parents df38eb9 + 3c0e334 commit 1ccef1c

3 files changed

Lines changed: 90 additions & 1 deletion

File tree

tests/EndToEnd.suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ modules:
2525
- \Tests\Support\Helper\Plugin
2626
- \Tests\Support\Helper\ThirdPartyPlugin
2727
- \Tests\Support\Helper\WPForms
28+
- \Tests\Support\Helper\WPNotices
2829
- \Tests\Support\Helper\Xdebug
2930
config:
3031
lucatume\WPBrowser\Module\WPWebDriver:
@@ -40,7 +41,6 @@ modules:
4041
capabilities:
4142
"goog:chromeOptions":
4243
args:
43-
- "--headless"
4444
- "--disable-gpu"
4545
- "--disable-dev-shm-usage"
4646
- "--disable-software-rasterizer"

tests/EndToEnd/general/IntegrationsCest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,58 @@ public function testAddIntegrationWithInvalidAPICredentials(EndToEndTester $I)
126126
$I->see($errorDescription);
127127
}
128128

129+
/**
130+
* Test that an error notification is displayed when the API credentials are invalid.
131+
*
132+
* @since 1.8.9
133+
*
134+
* @param EndToEndTester $I Tester.
135+
*/
136+
public function testInvalidCredentials(EndToEndTester $I)
137+
{
138+
// Define connection with invalid API credentials.
139+
$I->setupWPFormsIntegration(
140+
$I,
141+
'fakeAccessToken',
142+
'fakeRefreshToken'
143+
);
144+
145+
// Setup WPForms Form and configuration for this test.
146+
// Create Form.
147+
$wpFormsID = $I->createWPFormsForm($I);
148+
149+
// Load WPForms Editor.
150+
$I->amOnAdminPage('admin.php?page=wpforms-builder&view=fields&form_id=' . $wpFormsID);
151+
152+
// Click Marketing icon.
153+
$I->waitForElementVisible('.wpforms-panel-providers-button');
154+
$I->click('.wpforms-panel-providers-button');
155+
156+
// Click ConvertKit tab.
157+
$I->click('#wpforms-panel-providers a.wpforms-panel-sidebar-section-convertkit');
158+
159+
// Click Add New Connection.
160+
$I->click('Add New Connection');
161+
162+
// Define name for connection.
163+
$I->waitForElementVisible('.jconfirm-content');
164+
$I->fillField('#provider-connection-name', 'Kit');
165+
$I->click('OK');
166+
167+
// Get the connection ID.
168+
$I->waitForElementVisible('.wpforms-provider-connections .wpforms-provider-connection');
169+
$connectionID = $I->grabAttributeFrom('.wpforms-provider-connections .wpforms-provider-connection', 'data-connection_id');
170+
171+
// Specify field values.
172+
$I->waitForElementVisible('div[data-connection_id="' . $connectionID . '"] .wpforms-provider-fields', 30);
173+
174+
// Navigate to the WordPress Admin.
175+
$I->amOnAdminPage('index.php');
176+
177+
// Check that a notice is displayed that the API credentials are invalid.
178+
$I->seeErrorNotice($I, 'Kit for WPForms: Authorization failed. Please reconnect your Kit account.');
179+
}
180+
129181
/**
130182
* Deactivate and reset Plugin(s) after each test, if the test passes.
131183
* We don't use _after, as this would provide a screenshot of the Plugin

tests/Support/Helper/WPNotices.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
namespace Tests\Support\Helper;
3+
4+
/**
5+
* Helper methods and actions related to WordPress' Admin Notices,
6+
* which are then available using $I->{yourFunctionName}.
7+
*
8+
* @since 1.8.9
9+
*/
10+
class WPNotices extends \Codeception\Module
11+
{
12+
/**
13+
* Confirms that an error notification is output with the given text.
14+
*
15+
* @since 1.8.9
16+
*
17+
* @param EndToEndTester $I EndToEnd Tester.
18+
* @param string $message Message.
19+
*/
20+
public function seeErrorNotice($I, $message)
21+
{
22+
$I->see($message, 'div.notice-error');
23+
}
24+
25+
/**
26+
* Confirms that an error notification is not output with the given text.
27+
*
28+
* @since 1.8.9
29+
*
30+
* @param EndToEndTester $I EndToEnd Tester.
31+
* @param string $message Message.
32+
*/
33+
public function dontSeeErrorNotice($I, $message)
34+
{
35+
$I->dontSee($message, 'div.notice-error');
36+
}
37+
}

0 commit comments

Comments
 (0)