@@ -27,13 +27,13 @@ describe('checkRolePermission', () => {
2727 }
2828 } )
2929
30- it ( 'should allow add operation' , ( ) => {
31- const result = checkRolePermission ( 'admin' , 'add' )
30+ it ( 'should allow batch- add-blocks operation' , ( ) => {
31+ const result = checkRolePermission ( 'admin' , 'batch- add-blocks ' )
3232 expectPermissionAllowed ( result )
3333 } )
3434
35- it ( 'should allow remove operation' , ( ) => {
36- const result = checkRolePermission ( 'admin' , 'remove' )
35+ it ( 'should allow batch- remove-blocks operation' , ( ) => {
36+ const result = checkRolePermission ( 'admin' , 'batch- remove-blocks ' )
3737 expectPermissionAllowed ( result )
3838 } )
3939
@@ -42,8 +42,8 @@ describe('checkRolePermission', () => {
4242 expectPermissionAllowed ( result )
4343 } )
4444
45- it ( 'should allow duplicate operation' , ( ) => {
46- const result = checkRolePermission ( 'admin' , 'duplicate ' )
45+ it ( 'should allow batch-update-positions operation' , ( ) => {
46+ const result = checkRolePermission ( 'admin' , 'batch-update-positions ' )
4747 expectPermissionAllowed ( result )
4848 } )
4949
@@ -63,13 +63,13 @@ describe('checkRolePermission', () => {
6363 }
6464 } )
6565
66- it ( 'should allow add operation' , ( ) => {
67- const result = checkRolePermission ( 'write' , 'add' )
66+ it ( 'should allow batch- add-blocks operation' , ( ) => {
67+ const result = checkRolePermission ( 'write' , 'batch- add-blocks ' )
6868 expectPermissionAllowed ( result )
6969 } )
7070
71- it ( 'should allow remove operation' , ( ) => {
72- const result = checkRolePermission ( 'write' , 'remove' )
71+ it ( 'should allow batch- remove-blocks operation' , ( ) => {
72+ const result = checkRolePermission ( 'write' , 'batch- remove-blocks ' )
7373 expectPermissionAllowed ( result )
7474 } )
7575
@@ -85,14 +85,14 @@ describe('checkRolePermission', () => {
8585 expectPermissionAllowed ( result )
8686 } )
8787
88- it ( 'should deny add operation for read role' , ( ) => {
89- const result = checkRolePermission ( 'read' , 'add' )
88+ it ( 'should deny batch- add-blocks operation for read role' , ( ) => {
89+ const result = checkRolePermission ( 'read' , 'batch- add-blocks ' )
9090 expectPermissionDenied ( result , 'read' )
91- expectPermissionDenied ( result , 'add' )
91+ expectPermissionDenied ( result , 'batch- add-blocks ' )
9292 } )
9393
94- it ( 'should deny remove operation for read role' , ( ) => {
95- const result = checkRolePermission ( 'read' , 'remove' )
94+ it ( 'should deny batch- remove-blocks operation for read role' , ( ) => {
95+ const result = checkRolePermission ( 'read' , 'batch- remove-blocks ' )
9696 expectPermissionDenied ( result , 'read' )
9797 } )
9898
@@ -101,9 +101,9 @@ describe('checkRolePermission', () => {
101101 expectPermissionDenied ( result , 'read' )
102102 } )
103103
104- it ( 'should deny duplicate operation for read role' , ( ) => {
105- const result = checkRolePermission ( 'read' , 'duplicate ' )
106- expectPermissionDenied ( result , 'read' )
104+ it ( 'should allow batch-update-positions operation for read role' , ( ) => {
105+ const result = checkRolePermission ( 'read' , 'batch-update-positions ' )
106+ expectPermissionAllowed ( result )
107107 } )
108108
109109 it ( 'should deny replace-state operation for read role' , ( ) => {
@@ -117,7 +117,8 @@ describe('checkRolePermission', () => {
117117 } )
118118
119119 it ( 'should deny all write operations for read role' , ( ) => {
120- const writeOperations = SOCKET_OPERATIONS . filter ( ( op ) => op !== 'update-position' )
120+ const readAllowedOps = [ 'update-position' , 'batch-update-positions' ]
121+ const writeOperations = SOCKET_OPERATIONS . filter ( ( op ) => ! readAllowedOps . includes ( op ) )
121122
122123 for ( const operation of writeOperations ) {
123124 const result = checkRolePermission ( 'read' , operation )
@@ -138,7 +139,7 @@ describe('checkRolePermission', () => {
138139 } )
139140
140141 it ( 'should deny operations for empty role' , ( ) => {
141- const result = checkRolePermission ( '' , 'add' )
142+ const result = checkRolePermission ( '' , 'batch- add-blocks ' )
142143 expectPermissionDenied ( result )
143144 } )
144145 } )
@@ -186,15 +187,21 @@ describe('checkRolePermission', () => {
186187
187188 it ( 'should verify read has minimal permissions' , ( ) => {
188189 const readOps = ROLE_ALLOWED_OPERATIONS . read
189- expect ( readOps ) . toHaveLength ( 1 )
190+ expect ( readOps ) . toHaveLength ( 2 )
190191 expect ( readOps ) . toContain ( 'update-position' )
192+ expect ( readOps ) . toContain ( 'batch-update-positions' )
191193 } )
192194 } )
193195
194196 describe ( 'specific operations' , ( ) => {
195197 const testCases = [
196- { operation : 'add' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
197- { operation : 'remove' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
198+ { operation : 'batch-add-blocks' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
199+ {
200+ operation : 'batch-remove-blocks' ,
201+ adminAllowed : true ,
202+ writeAllowed : true ,
203+ readAllowed : false ,
204+ } ,
198205 { operation : 'update' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
199206 { operation : 'update-position' , adminAllowed : true , writeAllowed : true , readAllowed : true } ,
200207 { operation : 'update-name' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
@@ -214,7 +221,12 @@ describe('checkRolePermission', () => {
214221 readAllowed : false ,
215222 } ,
216223 { operation : 'toggle-handles' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
217- { operation : 'duplicate' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
224+ {
225+ operation : 'batch-update-positions' ,
226+ adminAllowed : true ,
227+ writeAllowed : true ,
228+ readAllowed : true ,
229+ } ,
218230 { operation : 'replace-state' , adminAllowed : true , writeAllowed : true , readAllowed : false } ,
219231 ]
220232
@@ -238,13 +250,13 @@ describe('checkRolePermission', () => {
238250
239251 describe ( 'reason messages' , ( ) => {
240252 it ( 'should include role in denial reason' , ( ) => {
241- const result = checkRolePermission ( 'read' , 'add' )
253+ const result = checkRolePermission ( 'read' , 'batch- add-blocks ' )
242254 expect ( result . reason ) . toContain ( "'read'" )
243255 } )
244256
245257 it ( 'should include operation in denial reason' , ( ) => {
246- const result = checkRolePermission ( 'read' , 'add' )
247- expect ( result . reason ) . toContain ( "'add'" )
258+ const result = checkRolePermission ( 'read' , 'batch- add-blocks ' )
259+ expect ( result . reason ) . toContain ( "'batch- add-blocks '" )
248260 } )
249261
250262 it ( 'should have descriptive denial message format' , ( ) => {
0 commit comments