@@ -18,7 +18,7 @@ const USER_CREDENTIALS = {
1818 } ,
1919}
2020
21- describe ( 'Roles ' , ( ) => {
21+ describe ( 'Permissions ' , ( ) => {
2222 // TODO: refactor as Cypress command
2323 const loginUser = ( { email, password } ) => {
2424 cy . visit ( `${ adminUrl } ` )
@@ -36,7 +36,7 @@ describe('Roles', () => {
3636 cy . contains ( 'Settings' ) . should ( 'be.visible' )
3737 }
3838
39- describe ( 'User without plugin access ' , ( ) => {
39+ describe ( 'User without permission ' , ( ) => {
4040 beforeEach ( ( ) => {
4141 cy . session (
4242 USER_CREDENTIALS . NO_ACCESS . email ,
@@ -55,7 +55,7 @@ describe('Roles', () => {
5555 )
5656 } )
5757
58- it ( 'should not see the plugin in sidepanel' , ( ) => {
58+ it ( 'cannot see the plugin in the sidepanel' , ( ) => {
5959 cy . visit ( `${ adminUrl } ` )
6060 cy . get ( 'nav' ) . should ( 'not.contain' , 'a[aria-label="Meilisearch"]' )
6161 } )
@@ -68,7 +68,7 @@ describe('Roles', () => {
6868 } )
6969 } )
7070
71- describe ( 'User with `read` access ' , ( ) => {
71+ describe ( 'User with `read` permission ' , ( ) => {
7272 beforeEach ( ( ) => {
7373 cy . session (
7474 USER_CREDENTIALS . CAN_ACCESS . email ,
@@ -111,7 +111,7 @@ describe('Roles', () => {
111111 } )
112112 } )
113113
114- describe ( 'User with `create` access ' , ( ) => {
114+ describe ( 'User with `collections. create` permission ' , ( ) => {
115115 beforeEach ( ( ) => {
116116 cy . session (
117117 USER_CREDENTIALS . CAN_CREATE . email ,
@@ -137,7 +137,7 @@ describe('Roles', () => {
137137 cy . get ( 'button[role="checkbox"]' ) . should ( 'be.visible' )
138138 } )
139139
140- it . only ( 'can index the user collection' , ( ) => {
140+ it ( 'can index a collection' , ( ) => {
141141 visitPluginPage ( )
142142
143143 cy . get ( 'tr:contains("user") button[role="checkbox"]' ) . first ( ) . click ( )
@@ -146,5 +146,37 @@ describe('Roles', () => {
146146 cy . get ( 'tr:contains("user")' ) . contains ( '1 / 1' ) . should ( 'be.visible' )
147147 cy . get ( 'tr:contains("user")' ) . contains ( 'Hooked' ) . should ( 'be.visible' )
148148 } )
149+
150+ it ( 'cannot disable the collection indexing' , ( ) => {
151+ visitPluginPage ( )
152+
153+ cy . get ( 'tr:contains("user") button[role="checkbox"]' ) . first ( ) . click ( )
154+
155+ cy . get ( 'div[role="status"]' )
156+ . contains ( 'You do not have permission to do this action' )
157+ . should ( 'be.visible' )
158+
159+ cy . reload ( )
160+
161+ cy . get ( 'tr:contains("user")' ) . contains ( 'Yes' ) . should ( 'be.visible' )
162+ cy . get ( 'tr:contains("user")' ) . contains ( '1 / 1' ) . should ( 'be.visible' )
163+ cy . get ( 'tr:contains("user")' ) . contains ( 'Hooked' ) . should ( 'be.visible' )
164+ } )
165+
166+ it ( 'cannot update indexed data' , ( ) => {
167+ visitPluginPage ( )
168+
169+ cy . get ( 'tr:contains("user") button[role="checkbox"]' )
170+ . first ( )
171+ . should ( 'have.attr' , 'data-state' , 'checked' )
172+
173+ cy . root ( ) . should ( 'not.contain' , 'button:contains("Update")' )
174+ } )
175+
176+ it ( 'cannot update settings' , ( ) => {
177+ visitPluginPage ( )
178+
179+ cy . root ( ) . should ( 'not.contain' , 'button:contains("Save")' )
180+ } )
149181 } )
150182} )
0 commit comments