Skip to content

Commit d61ab47

Browse files
committed
Add settings, shortcode and block tests.
1 parent 74fae4c commit d61ab47

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

tests/cypress/e2e/settings.test.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* eslint-disable no-undef */
2+
describe('Admin can update plugin settings', () => {
3+
let shortcodePostId = 0;
4+
let blockPostId = 0;
5+
6+
before(() => {
7+
cy.login();
8+
});
9+
10+
it('Admin can see list and save it', () => {
11+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
12+
13+
cy.get('.mc-h2').contains('Your Lists');
14+
cy.get('#mc_list_id').select('10up');
15+
cy.get('input[value="Update List"]').click();
16+
cy.get('#mc-message .success_msg b').contains('Success!');
17+
});
18+
19+
it('Admin can create a Signup form using the shortcode', () => {
20+
const postTitle = 'Mailchimp signup form - shortcode';
21+
const beforeSave = () => {
22+
cy.insertBlock('core/shortcode').then((id) => {
23+
cy.get(`#${id} .blocks-shortcode__textarea`).type('[mailchimpsf_form]');
24+
});
25+
};
26+
cy.createPost({ title: postTitle, content: '', beforeSave }).then((post) => {
27+
if (post) {
28+
shortcodePostId = post.id;
29+
cy.visit(`/?p=${shortcodePostId}`);
30+
cy.get('#mc_signup').should('exist');
31+
cy.get('#mc_mv_EMAIL').should('exist');
32+
cy.get('#mc_signup_submit').should('exist');
33+
cy.get('#mc_signup_submit').click();
34+
cy.get('.mc_error_msg').should('exist');
35+
cy.get('.mc_error_msg').contains(': This value should not be blank.');
36+
}
37+
});
38+
});
39+
40+
it('Admin can create a Signup form using Mailchimp block', () => {
41+
const postTitle = 'Mailchimp signup form - Block';
42+
const beforeSave = () => {
43+
cy.insertBlock('mailchimp/mailchimp');
44+
};
45+
cy.createPost({ title: postTitle, content: '', beforeSave }).then((post) => {
46+
if (post) {
47+
blockPostId = post.id;
48+
cy.visit(`/?p=${shortcodePostId}`);
49+
cy.get('#mc_signup').should('exist');
50+
cy.get('#mc_mv_EMAIL').should('exist');
51+
cy.get('#mc_signup_submit').should('exist');
52+
cy.get('#mc_signup_submit').click();
53+
cy.get('.mc_error_msg').should('exist');
54+
cy.get('.mc_error_msg').contains(': This value should not be blank.');
55+
}
56+
});
57+
});
58+
59+
it('Admin can set content options for signup form', () => {
60+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
61+
62+
// Set content options
63+
const header = 'Subscribe to our newsletter';
64+
const subHeader =
65+
'Join our mailing list to receive the latest news and updates from our team.';
66+
const button = 'Subscribe Now';
67+
cy.get('#mc_header_content').clear().type(header);
68+
cy.get('#mc_subheader_content').clear().type(subHeader);
69+
cy.get('#mc_submit_text').clear().type(button);
70+
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
71+
72+
// Verify content options
73+
cy.visit(`/?p=${shortcodePostId}`);
74+
cy.get('.mc_custom_border_hdr').contains(header);
75+
cy.get('#mc_subheader').contains(subHeader);
76+
cy.get('#mc_signup_submit').contains(button);
77+
78+
cy.visit(`/?p=${blockPostId}`);
79+
cy.get('.mc_custom_border_hdr').contains(header);
80+
cy.get('#mc_subheader').contains(subHeader);
81+
cy.get('#mc_signup_submit').contains(button);
82+
});
83+
});

0 commit comments

Comments
 (0)