@@ -176,6 +176,45 @@ describe('[MODX] Model', () => {
176176 assert . deepEqual ( authorizationSet , expected ) ;
177177 } ) ;
178178
179+ it ( '[MOAL] Get Authorizations from items override correctly authorized level' , async ( ) => {
180+ const itemKeys = [ 'profile-name' ] ;
181+ const options = { preRequest : [ { streamId : 'profile' , level : 'contribute' } ] } ;
182+ const authorizationSet = model . authorizationForItemKeys ( itemKeys , options ) ;
183+ const expected = [
184+ { streamId : 'profile' , level : 'contribute' , defaultName : 'Profile' }
185+ ] ;
186+ assert . deepEqual ( authorizationSet , expected ) ;
187+ } ) ;
188+
189+ it ( '[MOAV] Get Authorizations from items override correctly authorized level' , async ( ) => {
190+ const itemKeys = [ 'profile-name' ] ;
191+ const options = {
192+ defaultLevel : 'manage' ,
193+ preRequest : [ { streamId : 'profile' , level : 'read' } ]
194+ } ;
195+ const authorizationSet = model . authorizationForItemKeys ( itemKeys , options ) ;
196+ const expected = [
197+ { streamId : 'profile' , level : 'read' , defaultName : 'Profile' } ,
198+ { streamId : 'profile-name' , defaultName : 'Name' , level : 'manage' }
199+ ] ;
200+ assert . deepEqual ( authorizationSet , expected ) ;
201+ } ) ;
202+
203+ it ( '[MOAM] Get Authorizations from items mix correctly authorized level' , async ( ) => {
204+ const levels = [ { request : 'manage' , expect : 'manage' } , { request : 'contribute' , expect : 'contribute' } , { request : 'writeOnly' , expect : 'contribute' } ] ;
205+ for ( const level of levels ) {
206+ const itemKeys = [ 'profile-name' ] ;
207+ const options = {
208+ preRequest : [ { streamId : 'profile-name' , level : level . request } ]
209+ } ;
210+ const authorizationSet = model . authorizationForItemKeys ( itemKeys , options ) ;
211+ const expected = [
212+ { streamId : 'profile-name' , level : level . expect , defaultName : 'Name' }
213+ ] ;
214+ assert . deepEqual ( authorizationSet , expected ) ;
215+ }
216+ } ) ;
217+
179218 it ( '[MOAO] Get Authorizations from items with overrides' , async ( ) => {
180219 const itemKeys = [
181220 'body-vulva-mucus-inspect' ,
0 commit comments