@@ -25,7 +25,7 @@ import { of, ReplaySubject } from 'rxjs'
25
25
import { Config } from '../../types/togglz.endpoint'
26
26
import { MatIconModule } from '@angular/material/icon'
27
27
import { MatIconHarness } from '@angular/material/icon/testing'
28
- import { MatMenuHarness } from '@angular/material/menu/testing'
28
+ import { MatMenuHarness , MatMenuItemHarness } from '@angular/material/menu/testing'
29
29
30
30
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
31
31
@@ -85,6 +85,28 @@ describe('UserMenuComponent', () => {
85
85
expect ( component ) . toBeTruthy ( )
86
86
} )
87
87
88
+ it ( 'should display user admin actions option if user is admin' , async ( ) => {
89
+ let mockUserSessionResponse : UserSession = getUserSession ( ) ;
90
+ mockUserSessionResponse . userInfo . ADMIN_MENU = 'true' ;
91
+
92
+ component . userInfo = mockUserSessionResponse . userInfo ;
93
+
94
+ fixture . detectChanges ( )
95
+
96
+ const matMenu = await loader . getHarness ( MatMenuHarness )
97
+ await matMenu . open ( )
98
+
99
+ fixture . detectChanges ( )
100
+
101
+ const isMatMenuOpen = await matMenu . isOpen ( )
102
+ const matMenuItems : MatMenuItemHarness [ ] = await matMenu . getItems ( )
103
+ const adminPageItem = await matMenuItems [ 5 ] . getText ( )
104
+
105
+ expect ( isMatMenuOpen ) . toBe ( true )
106
+ expect ( matMenuItems . length ) . toBe ( 7 )
107
+ expect ( adminPageItem ) . toContain ( 'Admin page' )
108
+ } )
109
+
88
110
it ( 'should display 3 as unread notifications count' , async ( ) => {
89
111
const userMenuButton = fixture . debugElement . query ( By . css ( '#cy-user-info' ) )
90
112
userMenuButton . triggerEventHandler ( 'click' , null )
@@ -107,6 +129,7 @@ function getUserSession(): UserSession {
107
129
userSession . userInfo = {
108
130
REAL_USER_ORCID : '0000-0000-0000-000X' ,
109
131
EFFECTIVE_USER_ORCID : '0000-0000-0000-000X' ,
132
+ IN_DELEGATION_MODE : 'false' ,
110
133
} as UserInfo
111
134
userSession . loggedIn = true
112
135
userSession . displayName = 'Test Name'
0 commit comments