11const {
2+ apiKey,
23 env,
3- [ env ] : { adminUrl } ,
4+ [ env ] : { host , adminUrl } ,
45} = Cypress . env ( )
56
67const USER_CREDENTIALS = {
@@ -24,6 +25,10 @@ const USER_CREDENTIALS = {
24252526 password : 'Password1234' ,
2627 } ,
28+ CAN_MANAGE : {
29+ 30+ password : 'Password1234' ,
31+ } ,
2732}
2833
2934describe ( 'Permissions' , ( ) => {
@@ -232,7 +237,7 @@ describe('Permissions', () => {
232237 } )
233238 } )
234239
235- describe . only ( 'User with `collections.delete` permission' , ( ) => {
240+ describe ( 'User with `collections.delete` permission' , ( ) => {
236241 beforeEach ( ( ) => {
237242 cy . session (
238243 USER_CREDENTIALS . CAN_DELETE . email ,
@@ -305,4 +310,68 @@ describe('Permissions', () => {
305310 cy . root ( ) . should ( 'not.contain' , 'button:contains("Save")' )
306311 } )
307312 } )
313+
314+ describe ( 'User with `settings.edit` permission' , ( ) => {
315+ beforeEach ( ( ) => {
316+ cy . session (
317+ USER_CREDENTIALS . CAN_MANAGE . email ,
318+ ( ) => {
319+ loginUser ( {
320+ email : USER_CREDENTIALS . CAN_MANAGE . email ,
321+ password : USER_CREDENTIALS . CAN_MANAGE . password ,
322+ } )
323+ } ,
324+ {
325+ validate ( ) {
326+ cy . wait ( 1000 )
327+ cy . contains ( 'Hello User who can manage settings' ) . should (
328+ 'be.visible' ,
329+ )
330+ } ,
331+ } ,
332+ )
333+ } )
334+
335+ it ( 'cannot create/clear index' , ( ) => {
336+ visitPluginPage ( )
337+ cy . root ( ) . should ( 'not.contain' , 'button[role="checkbox"]' )
338+ } )
339+
340+ it ( 'cannot update indexed data' , ( ) => {
341+ visitPluginPage ( )
342+ cy . root ( ) . should ( 'not.contain' , 'button:contains("Update")' )
343+ } )
344+
345+ it ( 'can update settings' , ( ) => {
346+ visitPluginPage ( )
347+ cy . get ( 'button:contains("Settings")' ) . click ( )
348+
349+ cy . contains ( 'button' , 'Save' ) . should ( 'be.visible' )
350+
351+ cy . get ( 'input[name="host"]' ) . clear ( )
352+ cy . get ( 'input[name="host"]' ) . type ( 'http://localhost:7777' )
353+ cy . get ( 'input[name="apiKey"]' ) . clear ( )
354+ cy . get ( 'input[name="apiKey"]' ) . type ( 'test' )
355+
356+ cy . contains ( 'button' , 'Save' ) . click ( )
357+
358+ visitPluginPage ( )
359+ cy . get ( 'button:contains("Settings")' ) . click ( )
360+
361+ cy . get ( 'input[name="host"]' ) . should ( 'have.value' , 'http://localhost:7777' )
362+ cy . get ( 'input[name="apiKey"]' ) . should ( 'have.value' , 'test' )
363+
364+ cy . get ( 'input[name="host"]' ) . clear ( )
365+ cy . get ( 'input[name="host"]' ) . type ( host )
366+ cy . get ( 'input[name="apiKey"]' ) . clear ( )
367+ cy . get ( 'input[name="apiKey"]' ) . type ( apiKey )
368+ cy . contains ( 'button' , 'Save' ) . click ( )
369+
370+ visitPluginPage ( )
371+ cy . get ( 'button:contains("Settings")' ) . click ( )
372+
373+ cy . get ( 'input[name="host"]' ) . should ( 'have.value' , host )
374+ cy . get ( 'input[name="apiKey"]' ) . should ( 'have.value' , apiKey )
375+ } )
376+ } )
308377} )
0 commit comments