1+ /*
2+ *
3+ * ADOBE CONFIDENTIAL
4+ * ___________________
5+ *
6+ * Copyright 2023 Adobe Systems Incorporated
7+ * All Rights Reserved.
8+ *
9+ * NOTICE: All information contained herein is, and remains
10+ * the property of Adobe Systems Incorporated and its suppliers,
11+ * if any. The intellectual and technical concepts contained
12+ * herein are proprietary to Adobe Systems Incorporated and its
13+ * suppliers and are protected by trade secret or copyright law.
14+ * Dissemination of this information or reproduction of this material
15+ * is strictly forbidden unless prior written permission is obtained
16+ * from Adobe Systems Incorporated.
17+ */
18+
19+ describe ( 'Test UpdateEnum, UpdateEnumName for RadioButton' , ( ) => {
20+ const pagePath = "/content/forms/af/core-components-it/samples/customfunctions/populate-radiobuttonv2.html" ;
21+ let formContainer = null ;
22+
23+ let addEnumNameBtn1 = '#button-4f38b76fd2-widget' ,
24+ addEnumBtn1 = '#button-d4b00ec0b8-widget' ,
25+ addBothBtn1 = '#button-eaa3f23f0b-widget' ,
26+
27+ addEnumNameBtn2 = '#button-56661f131d-widget' ,
28+ addEnumBtn2 = '#button-0c6ee72db4-widget' ,
29+ addBothBtn2 = '#button-69bf3d3a88-widget' ,
30+
31+ addEnumNameBtn3 = '#button-4ecaf3bc01-widget' ,
32+ addEnumBtn3 = '#button-4dc9bdc9a3-widget' ,
33+ addBothBtn3 = '#button-54180ffb16-widget' ,
34+
35+ addEnumNameBtn4 = '#button-a48e23295a-widget' ,
36+ addEnumBtn4 = '#button-933aa82bb7-widget' ,
37+ addBothBtn4 = '#button-26157ea292-widget' ,
38+ clearBtn = '#button-3e6807207c-widget' ;
39+
40+ let radiobutton1 = '#radiobutton-9810c51fa5-widget' ,
41+ radiobutton2 = '#radiobutton-7842f66371-widget' ,
42+ radiobutton3 = '#radiobutton-073bbdd83c-widget' ,
43+ radiobutton4 = '#radiobutton-6bc17edce1-widget' ;
44+
45+ let enums = [ "one" , "two" , "three" ] ,
46+ enumNames = [ "India" , "US" , "Singapore" ] ;
47+
48+ /**
49+ * initialization of form container before every test
50+ * */
51+ beforeEach ( ( ) => {
52+ cy . previewForm ( pagePath ) . then ( p => {
53+ formContainer = p ;
54+ } )
55+ } ) ;
56+
57+ describe ( 'Radiobutton with no options' , ( ) => {
58+ it ( 'add enums' , ( ) => {
59+ cy . get ( addEnumBtn1 ) . click ( ) . then ( ( ) => {
60+ cy . get ( radiobutton1 ) . children ( ) . should ( 'have.length' , 3 ) ;
61+ cy . get ( radiobutton1 ) . children ( ) . each ( ( option , index ) => {
62+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
63+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enums [ index ] ) ;
64+ } )
65+ } )
66+ } ) ;
67+
68+ it ( 'add enums Names' , ( ) => {
69+ cy . get ( addEnumNameBtn1 ) . click ( ) . then ( ( ) => {
70+ cy . get ( radiobutton1 ) . children ( ) . should ( 'have.length' , 3 ) ;
71+ cy . get ( radiobutton1 ) . children ( ) . each ( ( option , index ) => {
72+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enumNames [ index ] ) ;
73+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
74+ } )
75+ } )
76+ } ) ;
77+
78+ it ( 'add both' , ( ) => {
79+ cy . get ( addBothBtn1 ) . click ( ) . then ( ( ) => {
80+ cy . get ( radiobutton1 ) . children ( ) . should ( 'have.length' , 3 ) ;
81+ cy . get ( radiobutton1 ) . children ( ) . each ( ( option , index ) => {
82+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
83+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
84+ } )
85+ } )
86+ } ) ;
87+ } ) ;
88+
89+ describe ( 'length of current options = length of new enums, enumNames' , ( ) => {
90+ it ( 'add enums' , ( ) => {
91+ cy . get ( addEnumBtn2 ) . click ( ) . then ( ( ) => {
92+ cy . get ( radiobutton2 ) . children ( ) . should ( 'have.length' , 3 ) ;
93+ cy . get ( radiobutton2 ) . children ( ) . each ( ( option , index ) => {
94+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
95+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( `country${ index + 1 } ` ) ;
96+ } )
97+ } )
98+ } ) ;
99+
100+ it ( 'add enums Names' , ( ) => {
101+ cy . get ( addEnumNameBtn2 ) . click ( ) . then ( ( ) => {
102+ cy . get ( radiobutton2 ) . children ( ) . should ( 'have.length' , 3 ) ;
103+ cy . get ( radiobutton2 ) . children ( ) . each ( ( option , index ) => {
104+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( `${ index + 1 } ` ) ;
105+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
106+ } )
107+ } )
108+ } ) ;
109+
110+ it ( 'add both' , ( ) => {
111+ cy . get ( addBothBtn2 ) . click ( ) . then ( ( ) => {
112+ cy . get ( radiobutton2 ) . children ( ) . should ( 'have.length' , 3 ) ;
113+ cy . get ( radiobutton2 ) . children ( ) . each ( ( option , index ) => {
114+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
115+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
116+ } )
117+ } )
118+ } ) ;
119+ } ) ;
120+
121+ describe ( 'length of current options < length of new enums, enumNames' , ( ) => {
122+ it ( 'add enums' , ( ) => {
123+ cy . get ( addEnumBtn3 ) . click ( ) . then ( ( ) => {
124+ cy . get ( radiobutton3 ) . children ( ) . should ( 'have.length' , 3 ) ;
125+ cy . get ( radiobutton3 ) . children ( ) . each ( ( option , index ) => {
126+ if ( index < 2 ) {
127+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
128+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( `country${ index + 1 } ` ) ;
129+ } else {
130+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
131+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enums [ index ] ) ;
132+ }
133+ } )
134+ } )
135+ } ) ;
136+
137+ it ( 'add enums Names' , ( ) => {
138+ cy . get ( addEnumNameBtn3 ) . click ( ) . then ( ( ) => {
139+ cy . get ( radiobutton3 ) . children ( ) . should ( 'have.length' , 2 ) ;
140+ cy . get ( radiobutton3 ) . children ( ) . each ( ( option , index ) => {
141+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( `${ index + 1 } ` ) ;
142+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
143+ } )
144+ } )
145+ } ) ;
146+
147+ it ( 'add both' , ( ) => {
148+ cy . get ( addBothBtn3 ) . click ( ) . then ( ( ) => {
149+ cy . get ( radiobutton3 ) . children ( ) . should ( 'have.length' , 3 ) ;
150+ cy . get ( radiobutton3 ) . children ( ) . each ( ( option , index ) => {
151+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
152+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
153+ } )
154+ } )
155+ } ) ;
156+ } ) ;
157+
158+ describe ( 'length of current options > length of new enums, enumNames' , ( ) => {
159+ it ( 'add enums' , ( ) => {
160+ cy . get ( addEnumBtn4 ) . click ( ) . then ( ( ) => {
161+ cy . get ( radiobutton4 ) . children ( ) . should ( 'have.length' , 3 ) ;
162+ cy . get ( radiobutton4 ) . children ( ) . each ( ( option , index ) => {
163+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
164+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( `country${ index + 1 } ` ) ;
165+ } )
166+ } )
167+ } ) ;
168+
169+ it ( 'add enums Names' , ( ) => {
170+ cy . get ( addEnumNameBtn4 ) . click ( ) . then ( ( ) => {
171+ cy . get ( radiobutton4 ) . children ( ) . should ( 'have.length' , 4 ) ;
172+ cy . get ( radiobutton4 ) . children ( ) . each ( ( option , index ) => {
173+ if ( index < 3 ) {
174+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( `${ index + 1 } ` ) ;
175+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
176+ } else {
177+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( `${ index + 1 } ` ) ;
178+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( `${ index + 1 } ` ) ;
179+ }
180+
181+ } )
182+ } )
183+ } ) ;
184+
185+ it ( 'add both' , ( ) => {
186+ cy . get ( addBothBtn4 ) . click ( ) . then ( ( ) => {
187+ cy . get ( radiobutton4 ) . children ( ) . should ( 'have.length' , 3 ) ;
188+ cy . get ( radiobutton4 ) . children ( ) . each ( ( option , index ) => {
189+ expect ( option . find ( 'input' ) . val ( ) ) . to . be . eq ( enums [ index ] ) ;
190+ expect ( option . find ( 'span' ) . text ( ) ) . to . be . eq ( enumNames [ index ] ) ;
191+ } )
192+ } )
193+ } ) ;
194+
195+ } ) ;
196+
197+ describe ( 'Clear all RadioButton options' , ( ) => {
198+ it ( 'check clear' , ( ) => {
199+ cy . get ( clearBtn ) . click ( ) . then ( ( ) => {
200+ cy . get ( radiobutton4 ) . children ( ) . should ( 'have.length' , 0 ) ; // only the blank option
201+ } )
202+ } ) ;
203+ } ) ;
204+ } )
0 commit comments