@@ -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
0 commit comments