@@ -87,12 +87,11 @@ describe('Admin can update plugin settings', () => {
87
87
// Form is able to be submitted with custom styles
88
88
cy . get ( '#mc_signup_submit' )
89
89
. scrollIntoView ( { offset : { top : - 100 , left : 0 } } )
90
- . should ( 'be.visible' ) // Check if the button is visible
90
+ . should ( 'be.visible' ) // Check if the button is visible
91
91
. and ( 'not.be.disabled' ) ; // Ensure the button is not disabled
92
92
93
93
// Ensure that custom CSS does not cover submit button
94
- cy . get ( '#mc_signup_submit' )
95
- . then ( ( $el ) => {
94
+ cy . get ( '#mc_signup_submit' ) . then ( ( $el ) => {
96
95
const rect = $el [ 0 ] . getBoundingClientRect ( ) ;
97
96
98
97
// Check that the element is within the viewport
@@ -106,17 +105,17 @@ describe('Admin can update plugin settings', () => {
106
105
expect ( windowWidth ) . to . be . greaterThan ( 0 ) ;
107
106
expect ( rect . bottom ) . to . be . lessThan ( windowHeight ) ;
108
107
expect ( rect . right ) . to . be . lessThan ( windowWidth ) ;
109
- } ) ;
108
+ } ) ;
110
109
111
- // Check if the center of the element is not covered by another element
112
- const centerX = rect . x + $el [ 0 ] . offsetWidth / 2 ;
113
- const centerY = rect . y + $el [ 0 ] . offsetHeight / 2 ;
110
+ // Check if the center of the element is not covered by another element
111
+ const centerX = rect . x + $el [ 0 ] . offsetWidth / 2 ;
112
+ const centerY = rect . y + $el [ 0 ] . offsetHeight / 2 ;
114
113
115
- cy . document ( ) . then ( ( doc ) => {
116
- const topElement = doc . elementFromPoint ( centerX , centerY ) ;
117
- expect ( topElement ) . to . equal ( $el [ 0 ] ) ;
118
- } ) ;
114
+ cy . document ( ) . then ( ( doc ) => {
115
+ const topElement = doc . elementFromPoint ( centerX , centerY ) ;
116
+ expect ( topElement ) . to . equal ( $el [ 0 ] ) ;
119
117
} ) ;
118
+ } ) ;
120
119
} ) ;
121
120
122
121
// Reset
@@ -222,8 +221,8 @@ describe('Admin can update plugin settings', () => {
222
221
} ) ;
223
222
} ) ;
224
223
225
- // TODO: BLOCKED - Need separate Mailchimp user to finish this test
226
- it . skip ( 'Ensure settings persist between logging out and logging back in of Mailchimp account' , ( ) => {
224
+ // TODO: Add case for separate account login and settings get reset.
225
+ it ( 'Ensure settings persist between logging out and logging back in of Mailchimp account' , ( ) => {
227
226
// Step 1: Visit Mailchimp settings page
228
227
cy . visit ( '/wp-admin/admin.php?page=mailchimp_sf_options' ) ;
229
228
cy . get ( '#mailchimp_sf_oauth_connect' ) . should ( 'not.exist' ) ;
@@ -234,37 +233,22 @@ describe('Admin can update plugin settings', () => {
234
233
cy . get ( 'input[value="Update Subscribe Form Settings"]' ) . first ( ) . click ( ) ;
235
234
236
235
// Verify the custom header is saved
237
- cy . get ( '#mc-message .success_msg b' ) . contains ( 'Success!' ) ;
236
+ cy . get ( '#mc-message .success_msg' ) . contains (
237
+ 'Successfully Updated your List Subscribe Form Settings!' ,
238
+ ) ;
238
239
cy . get ( '#mc_header_content' ) . should ( 'have.value' , customHeader ) ;
239
240
240
241
// Step 3: Log out of the Mailchimp account
241
242
cy . get ( 'input[value="Logout"]' ) . click ( ) ;
243
+
242
244
// Verify the logout was successful
243
245
cy . get ( '#mailchimp_sf_oauth_connect' ) . should ( 'exist' ) ;
244
246
245
- // Step 4: Log in with a different Mailchimp account
246
- // TODO: BLOCKED - We need a separate Mailchimp account to test the login here
247
- cy . mailchimpLogin ( 'different@mailchimp.com' , 'password123' ) ; // TODO: CHANGE LOG IN HERE
248
- cy . visit ( '/wp-admin/admin.php?page=mailchimp_sf_options' ) ;
249
-
250
- // Verify the default options are displayed for the new account
251
- cy . get ( '#mc_header_content' ) . should ( 'not.have.value' , customHeader ) ; // Expect default value
252
-
253
- // Step 5: Set another option with the second account to test persistence
254
- const differentHeader = 'Another Custom Header' ;
255
- cy . get ( '#mc_header_content' ) . clear ( ) . type ( differentHeader ) ;
256
- cy . get ( 'input[value="Update Subscribe Form Settings"]' ) . first ( ) . click ( ) ;
257
-
258
- // Verify the new setting is saved for the second account
259
- cy . get ( '#mc-message .success_msg b' ) . contains ( 'Success!' ) ;
260
- cy . get ( '#mc_header_content' ) . should ( 'have.value' , differentHeader ) ;
261
-
262
- // Step 6: Log back in with the original Mailchimp account
263
- cy . get ( 'input[value="Logout"]' ) . click ( ) ;
264
- cy . mailchimpLogin ( ) ; // Default to user set in env
247
+ // Step 4: Log in back
248
+ cy . mailchimpLogin ( ) ;
265
249
cy . visit ( '/wp-admin/admin.php?page=mailchimp_sf_options' ) ;
266
250
267
- // Step 7 : Ensure the original settings persist
251
+ // Step 5 : Ensure the original settings persist
268
252
cy . get ( '#mc_header_content' ) . should ( 'have.value' , customHeader ) ;
269
253
} ) ;
270
254
} ) ;
0 commit comments