Skip to content

Commit 567c398

Browse files
committed
Add E2E tests.
1 parent 758ce7c commit 567c398

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/cypress/e2e/mailchimp-block.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,29 @@ describe('Block Tests', () => {
246246
});
247247
});
248248

249+
it('Spam protection should work as expected', () => {
250+
// Show error message to spam bots.
251+
cy.visit(`/?p=${postId}`);
252+
cy.get('#mc_signup').should('exist');
253+
cy.get('input[name="mailchimp_sf_alt_email"]').then((el) => {
254+
el.val('123');
255+
});
256+
cy.get('#mc_signup_submit').should('exist');
257+
cy.get('#mc_signup_submit').click();
258+
cy.get('.mc_error_msg').should('exist');
259+
cy.get('.mc_error_msg').contains(
260+
"We couldn't process your submission as it was flagged as potential spam",
261+
);
262+
263+
// Normal user should not see the error message.
264+
cy.visit(`/?p=${postId}`);
265+
cy.get('#mc_signup').should('exist');
266+
cy.get('#mc_signup_submit').should('exist');
267+
cy.get('#mc_signup_submit').click();
268+
cy.get('.mc_error_msg').should('exist');
269+
cy.get('.mc_error_msg').contains('Email Address: This value should not be blank.');
270+
});
271+
249272
// TODO: Add tests for the Double Opt-in and Update existing subscribers settings.
250273
// TODO: Add tests for the block styles settings.
251274
// TODO: Add tests for the form submission.

tests/cypress/e2e/settings.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,27 @@ describe('Admin can update plugin settings', () => {
153153
cy.get('#mc_unsub_link').should('not.exist');
154154
});
155155
});
156+
157+
it('Spam protection should work as expected', () => {
158+
// Show error message to spam bots.
159+
cy.visit(shortcodePostURL);
160+
cy.get('#mc_signup').should('exist');
161+
cy.get('input[name="mailchimp_sf_alt_email"]').then((el) => {
162+
el.val('123');
163+
});
164+
cy.get('#mc_signup_submit').should('exist');
165+
cy.get('#mc_signup_submit').click();
166+
cy.get('.mc_error_msg').should('exist');
167+
cy.get('.mc_error_msg').contains(
168+
"We couldn't process your submission as it was flagged as potential spam",
169+
);
170+
171+
// Normal user should not see the error message.
172+
cy.visit(shortcodePostURL);
173+
cy.get('#mc_signup').should('exist');
174+
cy.get('#mc_signup_submit').should('exist');
175+
cy.get('#mc_signup_submit').click();
176+
cy.get('.mc_error_msg').should('exist');
177+
cy.get('.mc_error_msg').contains('Email Address: This value should not be blank.');
178+
});
156179
});

0 commit comments

Comments
 (0)