1
|
|
|
// / <reference types="Cypress" /> |
2
|
|
|
|
3
|
|
|
describe('User: Test acl privileges', () => { |
4
|
|
|
beforeEach(() => { |
5
|
|
|
cy.setToInitialState() |
|
|
|
|
6
|
|
|
.then(() => { |
7
|
|
|
return cy.loginViaApi(); |
|
|
|
|
8
|
|
|
}) |
9
|
|
|
.then(() => { |
10
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/dashboard/index`); |
|
|
|
|
11
|
|
|
}); |
12
|
|
|
}); |
13
|
|
|
|
14
|
|
|
it('@settings: view user', () => { |
15
|
|
|
cy.window().then((win) => { |
|
|
|
|
16
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
17
|
|
|
return; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
key: 'users_and_permissions', |
23
|
|
|
role: 'viewer' |
24
|
|
|
} |
25
|
|
|
]); |
26
|
|
|
|
27
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/users/permissions/index`); |
|
|
|
|
28
|
|
|
|
29
|
|
|
cy.get('.sw-users-permissions-user-listing .sw-data-grid__row--0 .sw-data-grid__cell--username a') |
30
|
|
|
.click(); |
31
|
|
|
|
32
|
|
|
cy.get('#sw-field--user-email') |
33
|
|
|
.should('be.visible') |
34
|
|
|
.should('have.value', '[email protected]'); |
35
|
|
|
}); |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
it('@settings: edit user', () => { |
39
|
|
|
cy.window().then((win) => { |
|
|
|
|
40
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
41
|
|
|
return; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
key: 'users_and_permissions', |
47
|
|
|
role: 'viewer' |
48
|
|
|
}, |
49
|
|
|
{ |
50
|
|
|
key: 'users_and_permissions', |
51
|
|
|
role: 'editor' |
52
|
|
|
} |
53
|
|
|
]); |
54
|
|
|
|
55
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/users/permissions/index`); |
|
|
|
|
56
|
|
|
|
57
|
|
|
cy.get('.sw-users-permissions-user-listing .sw-data-grid__row--0 .sw-data-grid__cell--username a') |
58
|
|
|
.click(); |
59
|
|
|
|
60
|
|
|
// Request we want to wait for later |
61
|
|
|
cy.server(); |
62
|
|
|
cy.route({ |
63
|
|
|
url: '/api/oauth/token', |
64
|
|
|
method: 'post' |
65
|
|
|
}).as('oauthCall'); |
66
|
|
|
|
67
|
|
|
cy.get('#sw-field--user-email') |
68
|
|
|
.should('be.visible') |
69
|
|
|
.click() |
70
|
|
|
.clear() |
71
|
|
|
.type('[email protected]'); |
72
|
|
|
|
73
|
|
|
cy.get('.sw-settings-user-detail__save-action') |
74
|
|
|
.should('be.visible') |
75
|
|
|
.click(); |
76
|
|
|
|
77
|
|
|
// expect modal to be open |
78
|
|
|
cy.get('.sw-modal') |
79
|
|
|
.should('be.visible'); |
80
|
|
|
cy.get('.sw-modal__title') |
81
|
|
|
.contains('Enter your current password to confirm'); |
82
|
|
|
|
83
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary') |
84
|
|
|
.should('be.disabled'); |
85
|
|
|
|
86
|
|
|
cy.get('.sw-modal__body input[name="sw-field--confirm-password"]') |
87
|
|
|
.should('be.visible') |
88
|
|
|
.typeAndCheck('Passw0rd!'); |
89
|
|
|
|
90
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary > .sw-button__content') |
91
|
|
|
.should('not.be.disabled') |
92
|
|
|
.click(); |
93
|
|
|
|
94
|
|
|
cy.wait('@oauthCall').then((xhr) => { |
95
|
|
|
expect(xhr).to.have.property('status', 200); |
96
|
|
|
}); |
97
|
|
|
|
98
|
|
|
cy.get('.sw-modal') |
99
|
|
|
.should('not.be.visible'); |
100
|
|
|
|
101
|
|
|
cy.get('#sw-field--user-email') |
102
|
|
|
.should('be.visible') |
103
|
|
|
.should('have.value', '[email protected]'); |
104
|
|
|
}); |
105
|
|
|
}); |
106
|
|
|
|
107
|
|
|
it('@settings: edit user role', () => { |
108
|
|
|
cy.window().then((win) => { |
|
|
|
|
109
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
110
|
|
|
return; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
114
|
|
|
{ |
115
|
|
|
key: 'users_and_permissions', |
116
|
|
|
role: 'viewer' |
117
|
|
|
}, |
118
|
|
|
{ |
119
|
|
|
key: 'users_and_permissions', |
120
|
|
|
role: 'editor' |
121
|
|
|
} |
122
|
|
|
]); |
123
|
|
|
|
124
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/users/permissions/index`); |
|
|
|
|
125
|
|
|
|
126
|
|
|
cy.get('.sw-card.sw-users-permissions-role-listing .sw-data-grid__row--0 .sw-data-grid__cell--name a') |
127
|
|
|
.click(); |
128
|
|
|
|
129
|
|
|
// Request we want to wait for later |
130
|
|
|
cy.server(); |
131
|
|
|
cy.route({ |
132
|
|
|
url: '/api/oauth/token', |
133
|
|
|
method: 'post' |
134
|
|
|
}).as('oauthCall'); |
135
|
|
|
cy.route({ |
136
|
|
|
url: `${Cypress.env('apiPath')}/acl-role/*`, |
137
|
|
|
method: 'patch' |
138
|
|
|
}).as('saveRole'); |
139
|
|
|
|
140
|
|
|
cy.get('#sw-field--role-description') |
141
|
|
|
.should('be.visible') |
142
|
|
|
.clearTypeAndCheck('This is a description'); |
143
|
|
|
|
144
|
|
|
cy.get('.sw-users-permissions-role-detail__button-save') |
145
|
|
|
.should('be.visible') |
146
|
|
|
.click(); |
147
|
|
|
|
148
|
|
|
// expect modal to be open |
149
|
|
|
cy.get('.sw-modal') |
150
|
|
|
.should('be.visible'); |
151
|
|
|
cy.get('.sw-modal__title') |
152
|
|
|
.contains('Enter your current password to confirm'); |
153
|
|
|
|
154
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary') |
155
|
|
|
.should('be.disabled'); |
156
|
|
|
|
157
|
|
|
cy.get('.sw-modal__body input[name="sw-field--confirm-password"]') |
158
|
|
|
.should('be.visible') |
159
|
|
|
.typeAndCheck('Passw0rd!'); |
160
|
|
|
|
161
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary > .sw-button__content') |
162
|
|
|
.should('not.be.disabled') |
163
|
|
|
.click(); |
164
|
|
|
|
165
|
|
|
cy.wait('@oauthCall').then((xhr) => { |
166
|
|
|
expect(xhr).to.have.property('status', 200); |
167
|
|
|
}); |
168
|
|
|
|
169
|
|
|
cy.wait('@saveRole').then((xhr) => { |
170
|
|
|
expect(xhr).to.have.property('status', 204); |
171
|
|
|
}); |
172
|
|
|
|
173
|
|
|
cy.get('.sw-modal') |
174
|
|
|
.should('not.be.visible'); |
175
|
|
|
|
176
|
|
|
cy.get('#sw-field--role-description') |
177
|
|
|
.should('be.visible') |
178
|
|
|
.should('have.value', 'This is a description'); |
179
|
|
|
}); |
180
|
|
|
}); |
181
|
|
|
|
182
|
|
|
it('@settings: create user', () => { |
183
|
|
|
cy.window().then((win) => { |
|
|
|
|
184
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
185
|
|
|
return; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
189
|
|
|
{ |
190
|
|
|
key: 'users_and_permissions', |
191
|
|
|
role: 'viewer' |
192
|
|
|
}, |
193
|
|
|
{ |
194
|
|
|
key: 'users_and_permissions', |
195
|
|
|
role: 'editor' |
196
|
|
|
}, |
197
|
|
|
{ |
198
|
|
|
key: 'users_and_permissions', |
199
|
|
|
role: 'creator' |
200
|
|
|
} |
201
|
|
|
]); |
202
|
|
|
|
203
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/users/permissions/index`); |
|
|
|
|
204
|
|
|
|
205
|
|
|
|
206
|
|
|
// Requests we want to wait for later |
207
|
|
|
cy.server(); |
208
|
|
|
cy.route({ |
209
|
|
|
url: `${Cypress.env('apiPath')}/search/user`, |
210
|
|
|
method: 'post' |
211
|
|
|
}).as('searchCall'); |
212
|
|
|
cy.route({ |
213
|
|
|
url: `${Cypress.env('apiPath')}/user`, |
214
|
|
|
method: 'post' |
215
|
|
|
}).as('createCall'); |
216
|
|
|
cy.route({ |
217
|
|
|
url: '/api/oauth/token', |
218
|
|
|
method: 'post' |
219
|
|
|
}).as('oauthCall'); |
220
|
|
|
|
221
|
|
|
// create a new user |
222
|
|
|
cy.get('.sw-users-permissions-user-listing__add-user-button') |
223
|
|
|
.should('be.visible') |
224
|
|
|
.click(); |
225
|
|
|
|
226
|
|
|
// fill in the user information |
227
|
|
|
const userFields = { |
228
|
|
|
'#sw-field--user-firstName': 'Abraham', |
229
|
|
|
'#sw-field--user-lastName': 'Allison', |
230
|
|
|
'#sw-field--user-email': '[email protected]', |
231
|
|
|
'#sw-field--user-username': 'abraham', |
232
|
|
|
'.sw-field--password__container > input[type=password]': 'mesecurepassword' |
233
|
|
|
}; |
234
|
|
|
|
235
|
|
|
Object.keys(userFields).forEach((key) => { |
236
|
|
|
cy.get(key) |
|
|
|
|
237
|
|
|
.should('be.visible') |
238
|
|
|
.clear() |
239
|
|
|
.type(userFields[key]); |
240
|
|
|
}); |
241
|
|
|
|
242
|
|
|
// expect successful save |
243
|
|
|
cy.get('.sw-settings-user-detail__save-action') |
244
|
|
|
.should('be.visible') |
245
|
|
|
.click(); |
246
|
|
|
|
247
|
|
|
// expect modal to be open |
248
|
|
|
cy.get('.sw-modal') |
249
|
|
|
.should('be.visible'); |
250
|
|
|
cy.get('.sw-modal__title') |
251
|
|
|
.contains('Enter your current password to confirm'); |
252
|
|
|
|
253
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary') |
254
|
|
|
.should('be.disabled'); |
255
|
|
|
|
256
|
|
|
cy.get('.sw-modal__body input[name="sw-field--confirm-password"]') |
257
|
|
|
.should('be.visible') |
258
|
|
|
.typeAndCheck('Passw0rd!'); |
259
|
|
|
|
260
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary > .sw-button__content') |
261
|
|
|
.should('not.be.disabled') |
262
|
|
|
.click(); |
263
|
|
|
|
264
|
|
|
cy.wait('@oauthCall').then((xhr) => { |
265
|
|
|
expect(xhr).to.have.property('status', 200); |
266
|
|
|
}); |
267
|
|
|
|
268
|
|
|
cy.wait('@createCall').then((xhr) => { |
269
|
|
|
expect(xhr).to.have.property('status', 204); |
270
|
|
|
}); |
271
|
|
|
}); |
272
|
|
|
}); |
273
|
|
|
|
274
|
|
|
it('@settings: create user and delete them', () => { |
275
|
|
|
cy.window().then((win) => { |
|
|
|
|
276
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
277
|
|
|
return; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
281
|
|
|
{ |
282
|
|
|
key: 'users_and_permissions', |
283
|
|
|
role: 'viewer' |
284
|
|
|
}, |
285
|
|
|
{ |
286
|
|
|
key: 'users_and_permissions', |
287
|
|
|
role: 'editor' |
288
|
|
|
}, |
289
|
|
|
{ |
290
|
|
|
key: 'users_and_permissions', |
291
|
|
|
role: 'creator' |
292
|
|
|
}, |
293
|
|
|
{ |
294
|
|
|
key: 'users_and_permissions', |
295
|
|
|
role: 'deleter' |
296
|
|
|
} |
297
|
|
|
]); |
298
|
|
|
|
299
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/users/permissions/index`); |
|
|
|
|
300
|
|
|
|
301
|
|
|
// Requests we want to wait for later |
302
|
|
|
cy.server(); |
303
|
|
|
cy.route({ |
304
|
|
|
url: `${Cypress.env('apiPath')}/search/user`, |
305
|
|
|
method: 'post' |
306
|
|
|
}).as('searchCall'); |
307
|
|
|
cy.route({ |
308
|
|
|
url: `${Cypress.env('apiPath')}/user`, |
309
|
|
|
method: 'post' |
310
|
|
|
}).as('createCall'); |
311
|
|
|
cy.route({ |
312
|
|
|
url: `${Cypress.env('apiPath')}/user/**`, |
313
|
|
|
method: 'delete' |
314
|
|
|
}).as('deleteCall'); |
315
|
|
|
cy.route({ |
316
|
|
|
url: '/api/oauth/token', |
317
|
|
|
method: 'post' |
318
|
|
|
}).as('oauthCall'); |
319
|
|
|
|
320
|
|
|
// create a new user |
321
|
|
|
cy.get('.sw-users-permissions-user-listing__add-user-button') |
322
|
|
|
.should('be.visible') |
323
|
|
|
.click(); |
324
|
|
|
|
325
|
|
|
// fill in the user information |
326
|
|
|
const userFields = { |
327
|
|
|
'#sw-field--user-firstName': 'Abraham', |
328
|
|
|
'#sw-field--user-lastName': 'Allison', |
329
|
|
|
'#sw-field--user-email': '[email protected]', |
330
|
|
|
'#sw-field--user-username': 'abraham', |
331
|
|
|
'.sw-field--password__container > input[type=password]': 'mesecurepassword' |
332
|
|
|
}; |
333
|
|
|
|
334
|
|
|
Object.keys(userFields).forEach((key) => { |
335
|
|
|
cy.get(key) |
|
|
|
|
336
|
|
|
.should('be.visible') |
337
|
|
|
.clear() |
338
|
|
|
.type(userFields[key]); |
339
|
|
|
}); |
340
|
|
|
|
341
|
|
|
// expect successful save |
342
|
|
|
cy.get('.sw-settings-user-detail__save-action') |
343
|
|
|
.should('be.visible') |
344
|
|
|
.click(); |
345
|
|
|
|
346
|
|
|
// expect modal to be open |
347
|
|
|
cy.get('.sw-modal') |
348
|
|
|
.should('be.visible'); |
349
|
|
|
cy.get('.sw-modal__title') |
350
|
|
|
.contains('Enter your current password to confirm'); |
351
|
|
|
|
352
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary') |
353
|
|
|
.should('be.disabled'); |
354
|
|
|
|
355
|
|
|
cy.get('.sw-modal__body input[name="sw-field--confirm-password"]') |
356
|
|
|
.should('be.visible') |
357
|
|
|
.typeAndCheck('Passw0rd!'); |
358
|
|
|
|
359
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary > .sw-button__content') |
360
|
|
|
.should('not.be.disabled') |
361
|
|
|
.click(); |
362
|
|
|
|
363
|
|
|
cy.wait('@oauthCall').then((xhr) => { |
364
|
|
|
expect(xhr).to.have.property('status', 200); |
365
|
|
|
}); |
366
|
|
|
|
367
|
|
|
cy.wait('@createCall').then((xhr) => { |
368
|
|
|
expect(xhr).to.have.property('status', 204); |
369
|
|
|
}); |
370
|
|
|
|
371
|
|
|
cy.get('.sw-modal') |
372
|
|
|
.should('not.be.visible'); |
373
|
|
|
|
374
|
|
|
// should be able to delete the user |
375
|
|
|
cy.get('a.smart-bar__back-btn').click(); |
376
|
|
|
|
377
|
|
|
cy.wait('@searchCall').then((xhr) => { |
378
|
|
|
expect(xhr).to.have.property('status', 200); |
379
|
|
|
}); |
380
|
|
|
|
381
|
|
|
cy.get('.sw-simple-search-field input').first().type('abraham'); |
382
|
|
|
|
383
|
|
|
cy.wait('@searchCall').then((xhr) => { |
384
|
|
|
expect(xhr).to.have.property('status', 200); |
385
|
|
|
}); |
386
|
|
|
|
387
|
|
|
cy.clickContextMenuItem( |
388
|
|
|
'.sw-settings-user-list__user-delete-action', |
389
|
|
|
'.sw-context-button__button', |
390
|
|
|
'.sw-users-permissions-user-listing .sw-data-grid__row--0' |
391
|
|
|
); |
392
|
|
|
|
393
|
|
|
// expect modal to be open |
394
|
|
|
cy.get('.sw-modal') |
395
|
|
|
.should('be.visible'); |
396
|
|
|
cy.get('.sw-modal__title') |
397
|
|
|
.contains('Warning'); |
398
|
|
|
|
399
|
|
|
cy.get('.sw-modal__footer > .sw-button--danger') |
400
|
|
|
.should('be.disabled'); |
401
|
|
|
|
402
|
|
|
cy.get('.sw-modal__body input[name="sw-field--confirm-password"]') |
403
|
|
|
.should('be.visible') |
404
|
|
|
.typeAndCheck('Passw0rd!'); |
405
|
|
|
|
406
|
|
|
cy.get('.sw-modal__footer > .sw-button--danger > .sw-button__content') |
407
|
|
|
.should('not.be.disabled') |
408
|
|
|
.click(); |
409
|
|
|
|
410
|
|
|
cy.wait('@deleteCall').then((xhr) => { |
411
|
|
|
expect(xhr).to.have.property('status', 204); |
412
|
|
|
}); |
413
|
|
|
|
414
|
|
|
cy.get('.sw-modal') |
415
|
|
|
.should('not.be.visible'); |
416
|
|
|
|
417
|
|
|
cy.awaitAndCheckNotification('User "Abraham Allison " has been deleted.'); |
418
|
|
|
}); |
419
|
|
|
}); |
420
|
|
|
}); |
421
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.