Skip to content

Commit 2439a14

Browse files
committed
Add E2E tests.
1 parent 717b938 commit 2439a14

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/cypress/e2e/settings.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,29 @@ describe('Admin can update plugin settings', () => {
194194
});
195195
});
196196

197+
it('Form data should persist if validation fails', () => {
198+
// Remove mailchimp CSS.
199+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
200+
cy.get('#mc_use_javascript').check();
201+
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
202+
203+
// Verify
204+
[shortcodePostURL, blockPostPostURL].forEach((url) => {
205+
const firstName = 'John';
206+
const lastName = 'Doe';
207+
cy.visit(url);
208+
cy.get('#mc_mv_EMAIL').should('exist');
209+
cy.get('#mc_mv_FNAME').clear().type(firstName);
210+
cy.get('#mc_mv_LNAME').clear().type(lastName);
211+
cy.get('#mc_signup_submit').should('exist');
212+
cy.get('#mc_signup_submit').click();
213+
cy.get('.mc_error_msg').should('exist');
214+
cy.get('.mc_error_msg').contains('Email Address: This value should not be blank.');
215+
cy.get('#mc_mv_FNAME').should('have.value', firstName);
216+
cy.get('#mc_mv_LNAME').should('have.value', lastName);
217+
});
218+
});
219+
197220
it('Admin can logout', () => {
198221
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
199222
cy.get('#mailchimp_sf_oauth_connect').should('not.exist');

0 commit comments

Comments
 (0)