Skip to content

Commit 5bfe73e

Browse files
committed
Added some more settings tests.
1 parent ee0884e commit 5bfe73e

File tree

1 file changed

+86
-32
lines changed

1 file changed

+86
-32
lines changed

tests/cypress/e2e/settings.test.js

Lines changed: 86 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,12 @@ describe('Admin can update plugin settings', () => {
7070
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
7171

7272
// 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);
73+
[shortcodePostId, blockPostId].forEach((postId) => {
74+
cy.visit(`/?p=${postId}`);
75+
cy.get('.mc_custom_border_hdr').contains(header);
76+
cy.get('#mc_subheader').contains(subHeader);
77+
cy.get('#mc_signup_submit').contains(button);
78+
});
8279
});
8380

8481
it('Admin can remove mailchimp CSS', () => {
@@ -88,27 +85,25 @@ describe('Admin can update plugin settings', () => {
8885
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
8986

9087
// Verify
91-
cy.visit(`/?p=${shortcodePostId}`);
92-
cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
93-
94-
cy.visit(`/?p=${blockPostId}`);
95-
cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
88+
[shortcodePostId, blockPostId].forEach((postId) => {
89+
cy.visit(`/?p=${postId}`);
90+
cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
91+
});
9692

9793
// Enable mailchimp CSS.
9894
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
9995
cy.get('#mc_nuke_all_styles').uncheck();
10096
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
10197

10298
// Verify
103-
cy.visit(`/?p=${shortcodePostId}`);
104-
cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
105-
106-
cy.visit(`/?p=${blockPostId}`);
107-
cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
99+
[shortcodePostId, blockPostId].forEach((postId) => {
100+
cy.visit(`/?p=${postId}`);
101+
cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
102+
});
108103
});
109104

110105
it('Admin can set custom styling on signup form', () => {
111-
// Remove mailchimp CSS.
106+
// Enable custom styling and set values.
112107
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
113108
cy.get('#mc_custom_style').check();
114109
cy.get('#mc_form_border_width').clear().type('10');
@@ -118,21 +113,80 @@ describe('Admin can update plugin settings', () => {
118113
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
119114

120115
// Verify
121-
cy.visit(`/?p=${shortcodePostId}`);
122-
cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
123-
cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
124-
cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
125-
cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
126-
127-
cy.visit(`/?p=${blockPostId}`);
128-
cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
129-
cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
130-
cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
131-
cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
116+
[shortcodePostId, blockPostId].forEach((postId) => {
117+
cy.visit(`/?p=${postId}`);
118+
cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
119+
cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
120+
cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
121+
cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
122+
});
132123

133-
// Enable mailchimp CSS.
124+
// Reset
134125
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
135126
cy.get('#mc_custom_style').uncheck();
136127
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
137128
});
129+
130+
it('Admin can set Merge Fields Included settings', () => {
131+
// Remove mailchimp CSS.
132+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
133+
cy.get('#mc_mv_FNAME').uncheck();
134+
cy.get('#mc_mv_LNAME').uncheck();
135+
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
136+
137+
// Verify
138+
[shortcodePostId, blockPostId].forEach((postId) => {
139+
cy.visit(`/?p=${postId}`);
140+
cy.get('#mc_mv_FNAME').should('not.exist');
141+
cy.get('#mc_mv_LNAME').should('not.exist');
142+
});
143+
144+
// Reset
145+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
146+
cy.get('#mc_mv_FNAME').check();
147+
cy.get('#mc_mv_LNAME').check();
148+
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
149+
150+
// Verify
151+
[shortcodePostId, blockPostId].forEach((postId) => {
152+
cy.visit(`/?p=${postId}`);
153+
cy.get('#mc_mv_FNAME').should('exist');
154+
cy.get('#mc_mv_LNAME').should('exist');
155+
});
156+
});
157+
158+
it('Admin can set list options settings', () => {
159+
// Remove mailchimp CSS.
160+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
161+
cy.get('#mc_use_javascript').uncheck();
162+
cy.get('#mc_use_datepicker').uncheck();
163+
cy.get('#mc_use_unsub_link').check();
164+
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
165+
166+
// Verify
167+
[shortcodePostId, blockPostId].forEach((postId) => {
168+
cy.visit(`/?p=${postId}`);
169+
cy.get('#mc_submit_type').should('have.value', 'html');
170+
cy.get('#mc_mv_BIRTHDAY').should('not.have.class', 'hasDatepicker');
171+
cy.get('#mc_mv_BIRTHDAY').click();
172+
cy.get('#ui-datepicker-div').should('not.exist');
173+
cy.get('#mc_unsub_link').should('exist');
174+
});
175+
176+
// Reset
177+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
178+
cy.get('#mc_use_javascript').check();
179+
cy.get('#mc_use_datepicker').check();
180+
cy.get('#mc_use_unsub_link').uncheck();
181+
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
182+
183+
[shortcodePostId, blockPostId].forEach((postId) => {
184+
cy.visit(`/?p=${postId}`);
185+
cy.get('#mc_submit_type').should('have.value', 'js');
186+
cy.get('#mc_mv_BIRTHDAY').should('have.class', 'hasDatepicker');
187+
cy.get('#mc_mv_BIRTHDAY').click();
188+
cy.get('#ui-datepicker-div').should('exist');
189+
cy.get('#mc_unsub_link').should('not.exist');
190+
});
191+
});
138192
});

0 commit comments

Comments
 (0)