@@ -108,7 +108,7 @@ describe('header utils', () => {
108108 } ) ;
109109 const actualItems =
110110 renderHook ( ( ) => useSettingMenuItems ( 'course-123' ) , { wrapper : createWrapper ( ) } ) . result . current ;
111- expect ( actualItems ) . toHaveLength ( 6 ) ;
111+ expect ( actualItems ) . toHaveLength ( 7 ) ;
112112 } ) ;
113113 it ( 'when certificate page disabled should not include certificates option' , ( ) => {
114114 setConfig ( {
@@ -117,7 +117,7 @@ describe('header utils', () => {
117117 } ) ;
118118 const actualItems =
119119 renderHook ( ( ) => useSettingMenuItems ( 'course-123' ) , { wrapper : createWrapper ( ) } ) . result . current ;
120- expect ( actualItems ) . toHaveLength ( 5 ) ;
120+ expect ( actualItems ) . toHaveLength ( 6 ) ;
121121 } ) ;
122122 it ( 'when user has access to advanced settings should include advanced settings option' , ( ) => {
123123 const actualItemsTitle = renderHook ( ( ) => useSettingMenuItems ( 'course-123' ) , { wrapper : createWrapper ( ) } ) . result
@@ -174,6 +174,20 @@ describe('header utils', () => {
174174 expect ( actualItemsTitle ) . not . toContain ( 'Advanced Settings' ) ;
175175 } ) ;
176176 } ) ;
177+
178+ it ( 'should include roles and permissions option' , ( ) => {
179+ setConfig ( {
180+ ...getConfig ( ) ,
181+ ADMIN_CONSOLE_URL : 'http://admin-console.example.com' ,
182+ } ) ;
183+ const actualItems =
184+ renderHook ( ( ) => useSettingMenuItems ( 'course-123' ) , { wrapper : createWrapper ( ) } ) . result . current ;
185+ const rolesPermissionsItem = actualItems . find ( item => item . title === 'Roles and Permissions' ) ;
186+ expect ( rolesPermissionsItem ) . toEqual ( {
187+ href : 'http://admin-console.example.com/authz?scope=course-123' ,
188+ title : 'Roles and Permissions' ,
189+ } ) ;
190+ } ) ;
177191 } ) ;
178192
179193 describe ( 'getToolsMenuItems' , ( ) => {
@@ -227,7 +241,21 @@ describe('header utils', () => {
227241 } ) ;
228242
229243 describe ( 'useLibrarySettingsMenuItems' , ( ) => {
244+ let originalConfig : any ;
245+
246+ beforeEach ( ( ) => {
247+ originalConfig = { ...getConfig ( ) } ;
248+ } ) ;
249+
250+ afterEach ( ( ) => {
251+ setConfig ( originalConfig ) ;
252+ } ) ;
253+
230254 it ( 'should contain team access url' , ( ) => {
255+ const configWithoutAdminConsole = { ...getConfig ( ) } ;
256+ delete configWithoutAdminConsole . ADMIN_CONSOLE_URL ;
257+ setConfig ( configWithoutAdminConsole ) ;
258+
231259 const items =
232260 renderHook ( ( ) => useLibrarySettingsMenuItems ( 'library-123' , false ) , { wrapper : createWrapper ( ) } ) . result
233261 . current ;
0 commit comments