@@ -242,6 +242,37 @@ describe('Block Tests', () => {
242
242
} ) ;
243
243
} ) ;
244
244
245
+ it ( 'Proper error message should display if unsubscribed user try to subscribe' , ( ) => {
246
+ cy . visit ( `/wp-admin/post.php?post=${ postId } &action=edit` ) ;
247
+ cy . getBlockEditor ( ) . find ( 'h2[aria-label="Enter a header (optional)"]' ) . click ( ) ;
248
+ cy . openDocumentSettingsPanel ( 'Form Settings' , 'Block' ) ;
249
+ cy . get ( '.mailchimp-double-opt-in input.components-form-toggle__input' ) . first ( ) . uncheck ( ) ;
250
+ cy . get ( '.mailchimp-update-existing-subscribers input.components-form-toggle__input' )
251
+ . first ( )
252
+ . check ( ) ;
253
+ cy . get ( 'button.editor-post-publish-button' ) . click ( ) ;
254
+ cy . wait ( 500 ) ;
255
+
256
+ // Verify
257
+ cy . visit ( `/?p=${ postId } ` ) ;
258
+ cy . get ( '#mc_mv_EMAIL' ) . should ( 'exist' ) ;
259
+ cy . get ( '#mc_mv_EMAIL' ) . clear ( ) . type ( 'unsubscribed_user@gmail.com' ) ;
260
+ cy . get ( '#mc_signup_submit' ) . should ( 'exist' ) ;
261
+ cy . get ( '#mc_signup_submit' ) . click ( ) ;
262
+ cy . get ( '.mc_error_msg' ) . should ( 'exist' ) ;
263
+ cy . get ( '.mc_error_msg' ) . contains (
264
+ 'The email address cannot be subscribed because it was previously unsubscribed, bounced, or is under review. Please sign up here.' ,
265
+ ) ;
266
+
267
+ // Reset
268
+ cy . visit ( `/wp-admin/post.php?post=${ postId } &action=edit` ) ;
269
+ cy . getBlockEditor ( ) . find ( 'h2[aria-label="Enter a header (optional)"]' ) . click ( ) ;
270
+ cy . openDocumentSettingsPanel ( 'Form Settings' , 'Block' ) ;
271
+ cy . get ( '.mailchimp-double-opt-in input.components-form-toggle__input' ) . first ( ) . check ( ) ;
272
+ cy . get ( 'button.editor-post-publish-button' ) . click ( ) ;
273
+ cy . wait ( 500 ) ;
274
+ } ) ;
275
+
245
276
// TODO: Add tests for the Double Opt-in and Update existing subscribers settings.
246
277
// TODO: Add tests for the block styles settings.
247
278
// TODO: Add tests for the form submission.
0 commit comments