@@ -4,25 +4,11 @@ import { generateRandomEmail } from '../../support/functions/utility';
44/**
55 * Test for Phone Number Validation
66 */
7- describe ( 'US Multi-Input Phone Number Validation' , ( ) => {
7+ describe ( 'Phone Number Validation' , ( ) => {
88 let blockPostPostURL ;
99
10- const validPhones = [
11- { area : '123' , detail1 : '456' , detail2 : '7890' } ,
12- { area : '987' , detail1 : '654' , detail2 : '3210' } ,
13- ] ;
14- const invalidPhones = [
15- { area : '123' , detail1 : '456' , detail2 : '78a0' } ,
16- { area : '123' , detail1 : '45!' , detail2 : '7890' } ,
17- ] ;
18- const tooShortPhones = [
19- { area : '12' , detail1 : '456' , detail2 : '789' } ,
20- { area : '1' , detail1 : '45' , detail2 : '7890' } ,
21- ] ;
22- const tooLongPhones = [
23- { area : '1234' , detail1 : '567' , detail2 : '890' } ,
24- { area : '123' , detail1 : '4567' , detail2 : '8901' } ,
25- ] ;
10+ const validPhones = [ '1234567890' , '+1 (234) 567-890' ] ;
11+ const invalidPhones = [ '12345678a0' , '12345!7890' ] ;
2612
2713 before ( ( ) => {
2814 cy . login ( ) ;
@@ -54,9 +40,7 @@ describe('US Multi-Input Phone Number Validation', () => {
5440 } ) ;
5541
5642 function fillPhoneInputs ( phone ) {
57- cy . get ( '#mc_mv_PHONE-area' ) . clear ( ) . type ( phone . area ) ;
58- cy . get ( '#mc_mv_PHONE-detail1' ) . clear ( ) . type ( phone . detail1 ) ;
59- cy . get ( '#mc_mv_PHONE-detail2' ) . clear ( ) . type ( phone . detail2 ) ;
43+ cy . get ( '#mc_mv_PHONE' ) . clear ( ) . type ( phone ) ;
6044 }
6145
6246 it ( 'Valid phone numbers' , ( ) => {
@@ -81,27 +65,7 @@ describe('US Multi-Input Phone Number Validation', () => {
8165 cy . get ( '#mc_mv_EMAIL' ) . type ( email ) ;
8266 fillPhoneInputs ( phone ) ;
8367 cy . submitFormAndVerifyError ( ) ;
84- cy . get ( '.mc_error_msg' ) . contains ( 'must consist of only numbers' ) ;
85- } ) ;
86- } ) ;
87-
88- it ( 'Phone length validation' , ( ) => {
89- cy . visit ( blockPostPostURL ) ;
90-
91- tooShortPhones . forEach ( ( phone ) => {
92- const email = generateRandomEmail ( 'shortphone' ) ;
93- cy . get ( '#mc_mv_EMAIL' ) . type ( email ) ;
94- fillPhoneInputs ( phone ) ;
95- cy . submitFormAndVerifyError ( ) ;
96- cy . get ( '.mc_error_msg' ) . contains ( 'should be 10 digits long' ) ;
97- } ) ;
98-
99- tooLongPhones . forEach ( ( phone ) => {
100- const email = generateRandomEmail ( 'longphone' ) ;
101- cy . get ( '#mc_mv_EMAIL' ) . type ( email ) ;
102- fillPhoneInputs ( phone ) ;
103- cy . submitFormAndVerifyError ( ) ;
104- cy . get ( '.mc_error_msg' ) . contains ( 'should be 10 digits long' ) ;
68+ cy . get ( '.mc_error_msg' ) . contains ( 'Please enter a valid Phone Number.' ) ;
10569 } ) ;
10670 } ) ;
10771} ) ;
0 commit comments