@@ -3,43 +3,59 @@ import { JobTemplate } from '../../../../frontend/awx/interfaces/JobTemplate';
3
3
import { Organization } from '../../../../frontend/awx/interfaces/Organization' ;
4
4
import { Project } from '../../../../frontend/awx/interfaces/Project' ;
5
5
import { ReusableTemplateSurveyTestSuite } from './sharedTemplateSurvey' ;
6
+ import { randomE2Ename } from '../../../support/utils' ;
6
7
7
8
describe ( 'Job Templates Surveys' , function ( ) {
8
9
let inventory : Inventory ;
9
10
let jobTemplate : JobTemplate ;
11
+ let organization : Organization ;
12
+ let project : Project ;
10
13
let reusableTemplateSurveyTestSuite : ReusableTemplateSurveyTestSuite ;
11
14
12
- // FLAKY_06_13_2024
13
- describe . skip ( 'JT Surveys: Create, Edit and Delete' , function ( ) {
15
+ describe ( 'JT Surveys: Create, Edit and Delete' , function ( ) {
14
16
const question = {
15
17
question_name : "Who's that?" ,
16
18
question_description : 'The person behind this.' ,
17
19
variable : 'who_is_that' ,
18
20
default : 'John Doe' ,
19
21
type : 'text' ,
20
- label : 'Text' ,
22
+ max : 1024 ,
23
+ min : 0 ,
24
+ new_question : true ,
25
+ required : true ,
26
+ choices : [ ] ,
21
27
} ;
22
28
23
29
before ( function ( ) {
24
- cy . createAwxInventory ( { organization : ( this . globalAwxOrganization as Organization ) . id } ) . then (
25
- ( inv ) => {
26
- inventory = inv ;
27
-
28
- cy . createAwxJobTemplate ( {
29
- organization : ( this . globalAwxOrganization as Organization ) . id ,
30
- project : ( this . globalProject as Project ) . id ,
31
- inventory : inventory . id ,
32
- } ) . then ( ( jT ) => {
33
- jobTemplate = jT ;
34
- reusableTemplateSurveyTestSuite = new ReusableTemplateSurveyTestSuite ( jobTemplate ) ;
35
-
36
- cy . visit ( `/templates/job-template/${ jobTemplate . id } /survey` ) ;
37
- } ) ;
38
- }
39
- ) ;
30
+ cy . createAwxOrganization ( randomE2Ename ( ) ) . then ( ( org ) => {
31
+ organization = org ;
32
+ cy . createAwxProject ( { organization : organization . id } ) . then ( ( proj ) => {
33
+ project = proj ;
34
+ } ) ;
35
+ } ) ;
36
+ } ) ;
37
+
38
+ after ( ( ) => {
39
+ cy . deleteAwxProject ( project , { failOnStatusCode : false } ) ;
40
+ cy . deleteAwxOrganization ( organization , { failOnStatusCode : false } ) ;
41
+ } ) ;
42
+
43
+ beforeEach ( ( ) => {
44
+ cy . createAwxInventory ( { organization : organization . id } ) . then ( ( inv ) => {
45
+ inventory = inv ;
46
+
47
+ cy . createAwxJobTemplate ( {
48
+ organization : organization . id ,
49
+ project : project . id ,
50
+ inventory : inventory . id ,
51
+ } ) . then ( ( jT ) => {
52
+ jobTemplate = jT ;
53
+ reusableTemplateSurveyTestSuite = new ReusableTemplateSurveyTestSuite ( jobTemplate ) ;
54
+ } ) ;
55
+ } ) ;
40
56
} ) ;
41
57
42
- after ( function ( ) {
58
+ afterEach ( function ( ) {
43
59
cy . deleteAwxJobTemplate ( jobTemplate , { failOnStatusCode : false } ) ;
44
60
cy . deleteAwxInventory ( inventory , { failOnStatusCode : false } ) ;
45
61
} ) ;
@@ -51,101 +67,229 @@ describe('Job Templates Surveys', function () {
51
67
reusableTemplateSurveyTestSuite . canEditSurvey ( question ) ) ;
52
68
53
69
it ( 'can delete a JT survey from the surveys list view and assert deletion' , ( ) =>
54
- reusableTemplateSurveyTestSuite . canDeleteSurvey ( ) ) ;
70
+ reusableTemplateSurveyTestSuite . canDeleteSurvey ( question ) ) ;
55
71
56
72
it ( 'can create multiple surveys, assert order, change order, and assert new order, then bulk delete all surveys' , ( ) =>
57
73
reusableTemplateSurveyTestSuite . canCreateMultipleSurvey ( ) ) ;
58
74
} ) ;
59
75
60
76
describe ( 'JT Surveys: Launch JT with Survey Enabled' , function ( ) {
61
- before ( function ( ) {
62
- cy . createAwxInventory ( { organization : ( this . globalAwxOrganization as Organization ) . id } ) . then (
63
- ( inv ) => {
64
- inventory = inv ;
65
-
66
- cy . createAwxJobTemplate ( {
67
- organization : ( this . globalAwxOrganization as Organization ) . id ,
68
- project : ( this . globalProject as Project ) . id ,
69
- inventory : inventory . id ,
70
- } ) . then ( ( jT ) => {
71
- jobTemplate = jT ;
72
- reusableTemplateSurveyTestSuite = new ReusableTemplateSurveyTestSuite ( jobTemplate ) ;
73
-
74
- cy . visit ( `/templates/job-template/${ jobTemplate . id } /survey` ) ;
75
- } ) ;
76
- }
77
- ) ;
77
+ before ( ( ) => {
78
+ cy . createAwxOrganization ( randomE2Ename ( ) ) . then ( ( org ) => {
79
+ organization = org ;
80
+ cy . createAwxProject ( { organization : organization . id } ) . then ( ( proj ) => {
81
+ project = proj ;
82
+ } ) ;
83
+ } ) ;
84
+ } ) ;
85
+
86
+ after ( ( ) => {
87
+ cy . deleteAwxProject ( project , { failOnStatusCode : false } ) ;
88
+ cy . deleteAwxOrganization ( organization , { failOnStatusCode : false } ) ;
78
89
} ) ;
79
90
80
- after ( function ( ) {
91
+ beforeEach ( ( ) => {
92
+ cy . createAwxInventory ( { organization : organization . id } ) . then ( ( inv ) => {
93
+ inventory = inv ;
94
+
95
+ cy . createAwxJobTemplate ( {
96
+ organization : organization . id ,
97
+ project : project . id ,
98
+ inventory : inventory . id ,
99
+ } ) . then ( ( jt ) => {
100
+ jobTemplate = jt ;
101
+ reusableTemplateSurveyTestSuite = new ReusableTemplateSurveyTestSuite ( jobTemplate ) ;
102
+ } ) ;
103
+ } ) ;
104
+ } ) ;
105
+
106
+ afterEach ( ( ) => {
81
107
cy . deleteAwxJobTemplate ( jobTemplate , { failOnStatusCode : false } ) ;
82
108
cy . deleteAwxInventory ( inventory , { failOnStatusCode : false } ) ;
83
109
} ) ;
84
110
85
- const surveyTypes = [
86
- {
87
- type : 'text' ,
88
- label : 'Text' ,
89
- question_name : 'Text Answer' ,
90
- question_description : 'Text description.' ,
91
- variable : 'text_answer' ,
92
- default : 'default text answer' ,
93
- } ,
94
- {
95
- type : 'textarea' ,
96
- label : 'Textarea' ,
97
- question_name : 'Textarea Answer' ,
98
- question_description : 'Textarea description.' ,
99
- variable : 'textarea_answer' ,
100
- default : 'default textarea answer' ,
101
- } ,
102
- {
103
- type : 'password' ,
104
- label : 'Password' ,
105
- question_name : 'Password Answer' ,
106
- question_description : 'Password description.' ,
107
- variable : 'password_answer' ,
108
- default : 'default password answer' ,
109
- } ,
110
- {
111
- type : 'integer' ,
112
- label : 'Integer' ,
113
- question_name : 'Integer Answer' ,
114
- question_description : 'Integer description.' ,
115
- variable : 'integer_answer' ,
116
- max : 1338 ,
117
- default : '1337' ,
118
- } ,
119
- {
120
- type : 'float' ,
121
- label : 'Float' ,
122
- question_name : 'Float Answer' ,
123
- question_description : 'Float description.' ,
124
- variable : 'float_answer' ,
125
- default : '13.37' ,
126
- } ,
127
- {
128
- type : 'multiplechoice' ,
129
- label : 'Multiple Choice (single select)' ,
130
- question_name : 'Multiplechoice Answer' ,
131
- question_description : 'multiplechoice description.' ,
132
- variable : 'multiplechoice_answer' ,
133
- choices : [ 'foo' , 'bar' , 'baz' ] ,
134
- default : 'bar' ,
135
- } ,
136
- {
137
- type : 'multiselect' ,
138
- label : 'Multiple Choice (multiple select)' ,
139
- question_name : 'Multiselect Answer' ,
140
- question_description : 'Multiselect description.' ,
141
- variable : 'multiselect_answer' ,
142
- choices : [ 'foo' , 'bar' , 'baz' ] ,
143
- default : 'foo\nbar' ,
144
- } ,
145
- ] ;
146
-
147
- // FLAKY_06_19_2024
148
- it . skip ( 'can create all 7 types of survey types, enable survey, launch JT, view default survey answer, complete launch, and assert survey answer on completed job' , ( ) =>
149
- reusableTemplateSurveyTestSuite . canCreateAllSurveyTypes ( surveyTypes ) ) ;
111
+ describe ( 'can create all 7 types of survey types, enable survey, launch WFJT, view default survey answer, complete launch, and assert survey answer on completed job' , ( ) => {
112
+ it ( 'Text survey type' , ( ) => {
113
+ const question = {
114
+ question_name : 'Text answer' ,
115
+ question_description : 'Text description.' ,
116
+ variable : 'text_answer' ,
117
+ default : 'default text answer' ,
118
+ type : 'text' ,
119
+ max : 1024 ,
120
+ min : 0 ,
121
+ new_question : true ,
122
+ required : true ,
123
+ choices : [ ] ,
124
+ } ;
125
+ cy . createTemplateSurvey ( jobTemplate , 'Text' , question ) ;
126
+ reusableTemplateSurveyTestSuite . canEnableSurvey ( question ) ;
127
+ const groupType = reusableTemplateSurveyTestSuite . canLaunchSurvey ( question ) ;
128
+
129
+ cy . getByDataCy ( groupType )
130
+ . getByDataCy ( `survey-${ question . type . toLowerCase ( ) } -answer` )
131
+ . should ( 'have.value' , question . default ) ;
132
+
133
+ reusableTemplateSurveyTestSuite . canFinishSurvey ( question ) ;
134
+ } ) ;
135
+
136
+ it ( 'Textarea survey type' , ( ) => {
137
+ const question = {
138
+ question_name : 'Textarea answer' ,
139
+ question_description : 'Textarea description.' ,
140
+ variable : 'textarea_answer' ,
141
+ default : 'default textarea answer' ,
142
+ type : 'textarea' ,
143
+ max : 1024 ,
144
+ min : 0 ,
145
+ new_question : true ,
146
+ required : true ,
147
+ choices : [ ] ,
148
+ } ;
149
+ cy . createTemplateSurvey ( jobTemplate , 'Textarea' , question ) ;
150
+ reusableTemplateSurveyTestSuite . canEnableSurvey ( question ) ;
151
+ const groupType = reusableTemplateSurveyTestSuite . canLaunchSurvey ( question ) ;
152
+
153
+ cy . getByDataCy ( groupType )
154
+ . getByDataCy ( `survey-${ question . type . toLowerCase ( ) } -answer` )
155
+ . should ( 'have.value' , question . default ) ;
156
+
157
+ reusableTemplateSurveyTestSuite . canFinishSurvey ( question ) ;
158
+ } ) ;
159
+
160
+ it ( 'Password survey type' , ( ) => {
161
+ const question = {
162
+ question_name : 'Password answer' ,
163
+ question_description : 'Password description.' ,
164
+ variable : 'password_answer' ,
165
+ default : 'default password answer' ,
166
+ type : 'password' ,
167
+ max : 1024 ,
168
+ min : 0 ,
169
+ new_question : true ,
170
+ required : true ,
171
+ choices : [ ] ,
172
+ } ;
173
+ cy . createTemplateSurvey ( jobTemplate , 'Password' , question ) ;
174
+ reusableTemplateSurveyTestSuite . canEnableSurvey ( question ) ;
175
+ const groupType = reusableTemplateSurveyTestSuite . canLaunchSurvey ( question ) ;
176
+
177
+ cy . getByDataCy ( groupType )
178
+ . getByDataCy ( `survey-${ question . type . toLowerCase ( ) } -answer` )
179
+ . should ( 'have.value' , '$encrypted$' ) ;
180
+
181
+ reusableTemplateSurveyTestSuite . canFinishSurvey ( question ) ;
182
+ } ) ;
183
+
184
+ it ( 'Integer survey type' , ( ) => {
185
+ const question = {
186
+ question_name : 'Integer answer' ,
187
+ question_description : 'Integer description.' ,
188
+ variable : 'integer_answer' ,
189
+ default : 1337 ,
190
+ type : 'integer' ,
191
+ max : 1338 ,
192
+ min : 0 ,
193
+ new_question : true ,
194
+ required : true ,
195
+ choices : [ ] ,
196
+ } ;
197
+ cy . createTemplateSurvey ( jobTemplate , 'Integer' , question ) ;
198
+ reusableTemplateSurveyTestSuite . canEnableSurvey ( question ) ;
199
+ const groupType = reusableTemplateSurveyTestSuite . canLaunchSurvey ( question ) ;
200
+
201
+ cy . getByDataCy ( groupType )
202
+ . getByDataCy ( `survey-${ question . type . toLowerCase ( ) } -answer` )
203
+ . should ( 'have.value' , question . default ) ;
204
+
205
+ reusableTemplateSurveyTestSuite . canFinishSurvey ( question ) ;
206
+ } ) ;
207
+
208
+ it ( 'Float survey type' , ( ) => {
209
+ const question = {
210
+ question_name : 'Float answer' ,
211
+ question_description : 'Float description.' ,
212
+ variable : 'float_answer' ,
213
+ default : '13.37' ,
214
+ type : 'float' ,
215
+ max : 1024 ,
216
+ min : 0 ,
217
+ new_question : true ,
218
+ required : true ,
219
+ choices : [ ] ,
220
+ } ;
221
+ cy . createTemplateSurvey ( jobTemplate , 'Float' , question ) ;
222
+ reusableTemplateSurveyTestSuite . canEnableSurvey ( question ) ;
223
+ const groupType = reusableTemplateSurveyTestSuite . canLaunchSurvey ( question ) ;
224
+
225
+ cy . getByDataCy ( groupType )
226
+ . getByDataCy ( `survey-${ question . type . toLowerCase ( ) } -answer` )
227
+ . should ( 'have.value' , question . default ) ;
228
+
229
+ reusableTemplateSurveyTestSuite . canFinishSurvey ( question ) ;
230
+ } ) ;
231
+
232
+ it ( 'Multiple choice (single select) survey type' , ( ) => {
233
+ const question = {
234
+ question_name : 'Multiplechoice answer' ,
235
+ question_description : 'multiplechoice description.' ,
236
+ variable : 'multiplechoice_answer' ,
237
+ default : 'bar' ,
238
+ type : 'multiplechoice' ,
239
+ max : 1024 ,
240
+ min : 0 ,
241
+ new_question : true ,
242
+ required : true ,
243
+ choices : [ 'foo' , 'bar' , 'baz' ] ,
244
+ } ;
245
+ cy . createTemplateSurvey ( jobTemplate , 'Multiple Choice (single select)' , question ) ;
246
+ reusableTemplateSurveyTestSuite . canEnableSurvey ( question ) ;
247
+ const groupType = reusableTemplateSurveyTestSuite . canLaunchSurvey ( question ) ;
248
+
249
+ cy . getByDataCy ( groupType ) . within ( ( ) => {
250
+ cy . contains ( question . default ) ;
251
+ cy . get ( 'div[data-ouia-component-id="menu-select"]' ) . click ( ) ;
252
+ question ?. choices ?. forEach ( ( choice ) => {
253
+ cy . getByDataCy ( 'survey-multiplechoice-answer' ) . contains ( choice ) ;
254
+ } ) ;
255
+ } ) ;
256
+
257
+ reusableTemplateSurveyTestSuite . canFinishSurvey ( question ) ;
258
+ } ) ;
259
+
260
+ it ( 'Multiple Choice (multiple select) survey type' , ( ) => {
261
+ const question = {
262
+ question_name : 'Multiselect answer' ,
263
+ question_description : 'Multiselect description.' ,
264
+ variable : 'multiselect_answer' ,
265
+ default : 'foo\nbar' ,
266
+ type : 'multiselect' ,
267
+ max : 1024 ,
268
+ min : 0 ,
269
+ new_question : true ,
270
+ required : true ,
271
+ choices : [ 'foo' , 'bar' , 'baz' ] ,
272
+ } ;
273
+ cy . createTemplateSurvey ( jobTemplate , 'Multiple Choice (multiple select)' , question ) ;
274
+ reusableTemplateSurveyTestSuite . canEnableSurvey ( question ) ;
275
+ const groupType = reusableTemplateSurveyTestSuite . canLaunchSurvey ( question ) ;
276
+
277
+ cy . getByDataCy ( groupType ) . within ( ( ) => {
278
+ const defaults = question . default . toString ( ) . split ( '\n' ) ;
279
+ defaults . forEach ( ( defaultValue ) => {
280
+ cy . contains ( defaultValue ) ;
281
+ } ) ;
282
+ cy . get ( '#survey-multiselect-answer' ) . click ( ) ;
283
+ } ) ;
284
+
285
+ cy . get ( '#survey-multiselect-answer-select' ) . within ( ( ) => {
286
+ question ?. choices ?. forEach ( ( choice ) => {
287
+ cy . getByDataCy ( choice ) ;
288
+ } ) ;
289
+ } ) ;
290
+
291
+ reusableTemplateSurveyTestSuite . canFinishSurvey ( question ) ;
292
+ } ) ;
293
+ } ) ;
150
294
} ) ;
151
295
} ) ;
0 commit comments