@@ -89,13 +89,12 @@ describe('Admin can update plugin settings', () => {
89
89
. scrollIntoView ( { offset : { top : - 100 , left : 0 } } )
90
90
. should ( 'be.visible' ) // Check if the button is visible
91
91
. and ( 'not.be.disabled' ) ; // Ensure the button is not disabled
92
- // .click(); // Perform the click action
93
92
94
93
// Ensure that custom CSS does not cover submit button
95
94
cy . get ( '#mc_signup_submit' )
96
95
. then ( ( $el ) => {
97
96
const rect = $el [ 0 ] . getBoundingClientRect ( ) ;
98
-
97
+
99
98
// Check that the element is within the viewport
100
99
cy . window ( ) . then ( ( win ) => {
101
100
const windowHeight = win . innerHeight ;
@@ -112,7 +111,7 @@ describe('Admin can update plugin settings', () => {
112
111
// Check if the center of the element is not covered by another element
113
112
const centerX = rect . x + $el [ 0 ] . offsetWidth / 2 ;
114
113
const centerY = rect . y + $el [ 0 ] . offsetHeight / 2 ;
115
-
114
+
116
115
cy . document ( ) . then ( ( doc ) => {
117
116
const topElement = doc . elementFromPoint ( centerX , centerY ) ;
118
117
expect ( topElement ) . to . equal ( $el [ 0 ] ) ;
@@ -228,43 +227,43 @@ describe('Admin can update plugin settings', () => {
228
227
// Step 1: Visit Mailchimp settings page
229
228
cy . visit ( '/wp-admin/admin.php?page=mailchimp_sf_options' ) ;
230
229
cy . get ( '#mailchimp_sf_oauth_connect' ) . should ( 'not.exist' ) ;
231
-
230
+
232
231
// Step 2: Set an option different from the default
233
232
const customHeader = 'My Custom Header' ;
234
233
cy . get ( '#mc_header_content' ) . clear ( ) . type ( customHeader ) ;
235
234
cy . get ( 'input[value="Update Subscribe Form Settings"]' ) . first ( ) . click ( ) ;
236
-
235
+
237
236
// Verify the custom header is saved
238
237
cy . get ( '#mc-message .success_msg b' ) . contains ( 'Success!' ) ;
239
238
cy . get ( '#mc_header_content' ) . should ( 'have.value' , customHeader ) ;
240
-
239
+
241
240
// Step 3: Log out of the Mailchimp account
242
241
cy . get ( 'input[value="Logout"]' ) . click ( ) ;
243
242
// Verify the logout was successful
244
243
cy . get ( '#mailchimp_sf_oauth_connect' ) . should ( 'exist' ) ;
245
-
244
+
246
245
// Step 4: Log in with a different Mailchimp account
247
246
// TODO: BLOCKED - We need a separate Mailchimp account to test the login here
248
247
cy . mailchimpLogin ( 'different@mailchimp.com' , 'password123' ) ; // TODO: CHANGE LOG IN HERE
249
248
cy . visit ( '/wp-admin/admin.php?page=mailchimp_sf_options' ) ;
250
-
249
+
251
250
// Verify the default options are displayed for the new account
252
251
cy . get ( '#mc_header_content' ) . should ( 'not.have.value' , customHeader ) ; // Expect default value
253
-
252
+
254
253
// Step 5: Set another option with the second account to test persistence
255
254
const differentHeader = 'Another Custom Header' ;
256
255
cy . get ( '#mc_header_content' ) . clear ( ) . type ( differentHeader ) ;
257
256
cy . get ( 'input[value="Update Subscribe Form Settings"]' ) . first ( ) . click ( ) ;
258
-
257
+
259
258
// Verify the new setting is saved for the second account
260
259
cy . get ( '#mc-message .success_msg b' ) . contains ( 'Success!' ) ;
261
260
cy . get ( '#mc_header_content' ) . should ( 'have.value' , differentHeader ) ;
262
-
261
+
263
262
// Step 6: Log back in with the original Mailchimp account
264
263
cy . get ( 'input[value="Logout"]' ) . click ( ) ;
265
264
cy . mailchimpLogin ( ) ; // Default to user set in env
266
265
cy . visit ( '/wp-admin/admin.php?page=mailchimp_sf_options' ) ;
267
-
266
+
268
267
// Step 7: Ensure the original settings persist
269
268
cy . get ( '#mc_header_content' ) . should ( 'have.value' , customHeader ) ;
270
269
} ) ;
0 commit comments