@@ -20,6 +20,10 @@ const USER_CREDENTIALS = {
20202121 password : 'Password1234' ,
2222 } ,
23+ CAN_DELETE : {
24+ 25+ password : 'Password1234' ,
26+ } ,
2327}
2428
2529describe ( 'Permissions' , ( ) => {
@@ -184,7 +188,7 @@ describe('Permissions', () => {
184188 } )
185189 } )
186190
187- describe . only ( 'User with `collections.update` permission' , ( ) => {
191+ describe ( 'User with `collections.update` permission' , ( ) => {
188192 beforeEach ( ( ) => {
189193 cy . session (
190194 USER_CREDENTIALS . CAN_UPDATE . email ,
@@ -227,4 +231,78 @@ describe('Permissions', () => {
227231 cy . root ( ) . should ( 'not.contain' , 'button:contains("Save")' )
228232 } )
229233 } )
234+
235+ describe . only ( 'User with `collections.delete` permission' , ( ) => {
236+ beforeEach ( ( ) => {
237+ cy . session (
238+ USER_CREDENTIALS . CAN_DELETE . email ,
239+ ( ) => {
240+ loginUser ( {
241+ email : USER_CREDENTIALS . CAN_DELETE . email ,
242+ password : USER_CREDENTIALS . CAN_DELETE . password ,
243+ } )
244+ } ,
245+ {
246+ validate ( ) {
247+ cy . wait ( 1000 )
248+ cy . contains ( 'Hello User who can delete' ) . should ( 'be.visible' )
249+ } ,
250+ } ,
251+ )
252+ } )
253+
254+ it ( 'cannot update indexed data' , ( ) => {
255+ visitPluginPage ( )
256+
257+ cy . get ( 'button[role="checkbox"]' )
258+ . first ( )
259+ . should ( 'have.attr' , 'data-state' , 'checked' )
260+ cy . root ( ) . should ( 'not.contain' , 'button:contains("Update")' )
261+ } )
262+
263+ it ( 'can clear the collection index' , ( ) => {
264+ visitPluginPage ( )
265+
266+ cy . get ( 'tr:contains(user)' ) . first ( ) . contains ( 'Yes' ) . should ( 'be.visible' )
267+ cy . get ( 'tr:contains(user)' )
268+ . first ( )
269+ . contains ( 'Hooked' )
270+ . should ( 'be.visible' )
271+
272+ cy . get ( 'tr:contains(user)' )
273+ . first ( )
274+ . get ( 'button[role="checkbox"]' )
275+ . first ( )
276+ . click ( )
277+
278+ cy . get ( 'tr:contains(user)' )
279+ . first ( )
280+ . contains ( 'Reload needed' )
281+ . should ( 'be.visible' )
282+
283+ cy . reloadServer ( )
284+ } )
285+
286+ it ( 'cannot index data' , ( ) => {
287+ visitPluginPage ( )
288+
289+ cy . get ( 'button[role="checkbox"]' ) . should ( 'be.visible' )
290+
291+ cy . get ( 'button[role="checkbox"]' ) . first ( ) . click ( )
292+
293+ cy . get ( 'div[role="status"]' )
294+ . contains ( 'You do not have permission to do this action' )
295+ . should ( 'be.visible' )
296+
297+ cy . reload ( )
298+
299+ cy . get ( 'button[role="checkbox"]' ) . first ( ) . should ( 'not.be.checked' )
300+ } )
301+
302+ it ( 'cannot update settings' , ( ) => {
303+ visitPluginPage ( )
304+
305+ cy . root ( ) . should ( 'not.contain' , 'button:contains("Save")' )
306+ } )
307+ } )
230308} )
0 commit comments