31
31
*/
32
32
33
33
describe ( 'Form delegation' , ( ) => {
34
- const uuid = new Date ( ) . getTime ( ) ;
34
+ let uuid = new Date ( ) . getTime ( ) ;
35
+
36
+ beforeEach ( ( ) => {
37
+ uuid = new Date ( ) . getTime ( ) ;
38
+ } ) ;
35
39
36
40
it ( 'can choice my notifications preferences' , ( ) => {
37
41
createFormAndRenderIt ( ) ;
@@ -53,7 +57,7 @@ describe('Form delegation', () => {
53
57
cy . findByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
54
58
55
59
// Go to the created ticket
56
- cy . findByRole ( 'link' , { name : ' My test form' } ) . click ( ) ;
60
+ cy . findByRole ( 'link' , { name : ` My test form - ${ uuid } ` } ) . click ( ) ;
57
61
58
62
cy . findByRole ( 'region' , { name : 'Actors' } ) . within ( ( ) => {
59
63
cy . findByRole ( 'listitem' , { name : 'E2E Tests' } ) . should ( 'exist' ) ;
@@ -95,7 +99,55 @@ describe('Form delegation', () => {
95
99
cy . findByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
96
100
97
101
// Go to the created ticket
98
- cy . findByRole ( 'link' , { name : 'My test form' } ) . click ( ) ;
102
+ cy . findByRole ( 'link' , { name : `My test form - ${ uuid } ` } ) . click ( ) ;
103
+
104
+ cy . findByRole ( 'region' , { name : 'Actors' } ) . within ( ( ) => {
105
+ cy . findByRole ( 'listitem' , { name : `Test user - ${ uuid } ` } ) . should ( 'exist' ) ;
106
+ cy . findByRole ( 'listitem' , { name : 'E2E Tests' } ) . should ( 'not.exist' ) ;
107
+ cy . findByRole ( 'button' , { name : 'Email followup' } ) . click ( ) ;
108
+ cy . findByRole ( 'checkbox' , { name : 'Email followup' } ) . should ( 'be.checked' ) ;
109
+ cy . findByRole ( 'textbox' , { name :
'Email address' } ) . should ( 'have.value' , '[email protected] ' ) ;
110
+ } ) ;
111
+ } ) ;
112
+
113
+ it ( 'can delegate in self-service' , ( ) => {
114
+ initDelegationWithAPI ( ) ;
115
+ createFormAndRenderIt ( ) ;
116
+ cy . changeProfile ( 'Self-Service' ) ;
117
+ cy . reload ( ) ;
118
+
119
+ // Check values
120
+ cy . getDropdownByLabelText ( 'Select the user to delegate' ) . should ( 'have.text' , 'Myself' ) ;
121
+ cy . getDropdownByLabelText ( 'Select the user to delegate' ) . click ( ) ;
122
+ cy . get ( '.select2-results__options' ) . contains ( `Test user - ${ uuid } ` ) ;
123
+
124
+ cy . getDropdownByLabelText ( 'Do you want to be notified of future events of this ticket' ) . should ( 'have.text' , 'I want' ) ;
125
+ cy . getDropdownByLabelText ( 'Do you want to be notified of future events of this ticket' ) . click ( ) ;
126
+ cy . get ( '.select2-results__options' ) . contains ( 'I don\'t want' ) ;
127
+
128
+ // Select user to delegate
129
+ cy . getDropdownByLabelText ( 'Select the user to delegate' ) . selectDropdownValue ( `Test user - ${ uuid } ` ) ;
130
+
131
+ // Check values
132
+ cy . getDropdownByLabelText ( 'Do you want to be notified of future events of this ticket' ) . should ( 'have.text' , 'He wants' ) ;
133
+ cy . getDropdownByLabelText ( 'Do you want to be notified of future events of this ticket' ) . click ( ) ;
134
+ cy . get ( '.select2-results__options' ) . contains ( 'He doesn\'t want' ) ;
135
+
136
+ // Define email address
137
+ cy . findByRole ( 'button' , { name : 'Address to send the notification' } ) . click ( ) ;
138
+ cy . findByRole ( 'textbox' , { name :
'Address to send the notification' } ) . type ( '[email protected] ' ) ;
139
+
140
+ // Fill form
141
+ cy . findByRole ( 'textbox' , { name : 'Name' } ) . type ( 'Test' ) ;
142
+
143
+ // Submit form
144
+ cy . findByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
145
+
146
+ // Change profile to view ticket properties
147
+ cy . changeProfile ( 'Super-Admin' ) ;
148
+
149
+ // Go to the created ticket
150
+ cy . findByRole ( 'link' , { name : `My test form - ${ uuid } ` } ) . click ( ) ;
99
151
100
152
cy . findByRole ( 'region' , { name : 'Actors' } ) . within ( ( ) => {
101
153
cy . findByRole ( 'listitem' , { name : `Test user - ${ uuid } ` } ) . should ( 'exist' ) ;
@@ -108,7 +160,10 @@ describe('Form delegation', () => {
108
160
109
161
function createFormAndRenderIt ( ) {
110
162
cy . login ( ) ;
111
- cy . createFormWithAPI ( ) . as ( 'form_id' ) . then ( ( form_id ) => {
163
+ cy . createFormWithAPI ( {
164
+ name : `My test form - ${ uuid } ` ,
165
+ is_active : true
166
+ } ) . as ( 'form_id' ) . then ( ( form_id ) => {
112
167
cy . addQuestionToDefaultSectionWithAPI (
113
168
form_id ,
114
169
'Name' ,
0 commit comments