@@ -20,7 +20,7 @@ import { TablesService } from './services/tables.service';
2020import { DomSanitizer } from '@angular/platform-browser' ;
2121import { ChangeDetectorRef } from '@angular/core' ;
2222
23- fdescribe ( 'AppComponent' , ( ) => {
23+ describe ( 'AppComponent' , ( ) => {
2424 let app : AppComponent ;
2525 let fixture : ComponentFixture < AppComponent > ;
2626 // let connectionsService: ConnectionsService;
@@ -56,7 +56,7 @@ fdescribe('AppComponent', () => {
5656 } ;
5757
5858 const mockCompanyService = {
59- getCompanyLogo : jasmine . createSpy ( 'getCompanyLogo ' )
59+ getWhiteLabelProperties : jasmine . createSpy ( 'getWhiteLabelProperties ' )
6060 } ;
6161
6262 const mockUiSettingsService = {
@@ -108,8 +108,15 @@ fdescribe('AppComponent', () => {
108108 beforeEach ( ( ) => {
109109 fixture = TestBed . createComponent ( AppComponent ) ;
110110 app = fixture . debugElement . componentInstance ;
111- // connectionsService = TestBed.inject(ConnectionsService);
112- // companyService = TestBed.inject(CompanyService);
111+
112+ app . navigationTabs = {
113+ 'dashboard' : { caption : 'Tables' } ,
114+ 'audit' : { caption : 'Audit' } ,
115+ 'permissions' : { caption : 'Permissions' } ,
116+ 'connection-settings' : { caption : 'Connection settings' } ,
117+ 'edit-db' : { caption : 'Edit connection' } ,
118+ } ;
119+
113120 fixture . detectChanges ( ) ;
114121
115122 spyOn ( app , 'logOut' ) ;
@@ -121,7 +128,7 @@ fdescribe('AppComponent', () => {
121128 ( app . logOut as jasmine . Spy ) ?. calls . reset ?.( ) ;
122129 ( app [ 'router' ] . navigate as jasmine . Spy ) ?. calls . reset ?.( ) ;
123130 mockUiSettingsService . getUiSettings . calls . reset ?.( ) ;
124- mockCompanyService . getCompanyLogo . calls . reset ?.( ) ;
131+ mockCompanyService . getWhiteLabelProperties . calls . reset ?.( ) ;
125132 mockUserService . fetchUser . calls . reset ?.( ) ;
126133 } ) ;
127134
@@ -130,19 +137,19 @@ fdescribe('AppComponent', () => {
130137 } ) ;
131138
132139 it ( 'should set userLoggedIn and logo on user session initialization' , fakeAsync ( ( ) => {
133- mockCompanyService . getCompanyLogo . and . returnValue ( of ( 'data:png;base64,some-base64-data' ) ) ;
140+ mockCompanyService . getWhiteLabelProperties . and . returnValue ( of ( { logo : 'data:png;base64,some-base64-data' } ) ) ;
134141 mockUiSettingsService . getUiSettings . and . returnValue ( of ( { settings : { globalSettings : { lastFeatureNotificationId : 'old-id' } } } ) ) ;
135142 app . initializeUserSession ( ) ;
136143 tick ( ) ;
137144
138145 expect ( app . currentUser . email ) . toBe ( '[email protected] ' ) ; 139- expect ( app . logo ) . toBe ( 'data:png;base64,some-base64-data' ) ;
146+ expect ( app . whiteLabelSettings . logo ) . toBe ( 'data:png;base64,some-base64-data' ) ;
140147 expect ( app . userLoggedIn ) . toBeTrue ( ) ;
141148 expect ( mockUiSettingsService . getUiSettings ) . toHaveBeenCalled ( ) ;
142149 } ) ) ;
143150
144151 it ( 'should render custom logo in navbar if it is set' , fakeAsync ( ( ) => {
145- mockCompanyService . getCompanyLogo . and . returnValue ( of ( 'data:png;base64,some-base64-data' ) ) ;
152+ mockCompanyService . getWhiteLabelProperties . and . returnValue ( of ( { logo : 'data:png;base64,some-base64-data' } ) ) ;
146153 mockUiSettingsService . getUiSettings . and . returnValue ( of ( { settings : { globalSettings : { lastFeatureNotificationId : 'old-id' } } } ) ) ;
147154 app . initializeUserSession ( ) ;
148155 tick ( ) ;
@@ -156,7 +163,7 @@ fdescribe('AppComponent', () => {
156163 } ) ) ;
157164
158165 it ( 'should render the link to Connetions list that contains the custom logo in the navbar' , fakeAsync ( ( ) => {
159- mockCompanyService . getCompanyLogo . and . returnValue ( of ( null ) ) ;
166+ mockCompanyService . getWhiteLabelProperties . and . returnValue ( of ( { logo : null } ) ) ;
160167 mockUiSettingsService . getUiSettings . and . returnValue ( of ( { settings : { globalSettings : { lastFeatureNotificationId : 'old-id' } } } ) ) ;
161168 app . initializeUserSession ( ) ;
162169 tick ( ) ;
@@ -184,7 +191,7 @@ fdescribe('AppComponent', () => {
184191
185192 it ( 'should render feature popup if isFeatureNotificationShown different on server and client' , fakeAsync ( ( ) => {
186193 app . currentFeatureNotificationId = 'new-id' ;
187- mockCompanyService . getCompanyLogo . and . returnValue ( of ( null ) ) ;
194+ mockCompanyService . getWhiteLabelProperties . and . returnValue ( of ( { logo : null } ) ) ;
188195 mockUiSettingsService . getUiSettings . and . returnValue ( of ( { globalSettings : { lastFeatureNotificationId : 'old-id' } } ) ) ;
189196 app . initializeUserSession ( ) ;
190197 tick ( ) ;
@@ -197,7 +204,7 @@ fdescribe('AppComponent', () => {
197204
198205 it ( 'should not render feature popup if isFeatureNotificationShown the same on server and client' , fakeAsync ( ( ) => {
199206 app . currentFeatureNotificationId = 'old-id' ;
200- mockCompanyService . getCompanyLogo . and . returnValue ( of ( null ) ) ;
207+ mockCompanyService . getWhiteLabelProperties . and . returnValue ( of ( { logo : null } ) ) ;
201208 mockUiSettingsService . getUiSettings . and . returnValue ( of ( { globalSettings : { lastFeatureNotificationId : 'old-id' } } ) ) ;
202209 app . initializeUserSession ( ) ;
203210 tick ( ) ;
@@ -238,7 +245,6 @@ fdescribe('AppComponent', () => {
238245
239246 it ( 'should handle user login flow when cast emits user with expires' , fakeAsync ( ( ) => {
240247 const expirationDate = new Date ( Date . now ( ) + 10_000 ) ; // 10s from now
241- // spyOn(app['router'], 'navigate');
242248 app [ 'currentFeatureNotificationId' ] = 'some-id' ;
243249
244250 app . ngOnInit ( ) ;
@@ -254,7 +260,7 @@ fdescribe('AppComponent', () => {
254260 expect ( app . userLoggedIn ) . toBeTrue ( ) ;
255261 expect ( app . currentUser . email ) . toBe ( '[email protected] ' ) ; 256262 expect ( mockUserService . fetchUser ) . toHaveBeenCalled ( ) ;
257- expect ( mockCompanyService . getCompanyLogo ) . toHaveBeenCalledWith ( 'company-12345678' ) ;
263+ expect ( mockCompanyService . getWhiteLabelProperties ) . toHaveBeenCalledWith ( 'company-12345678' ) ;
258264 expect ( mockUiSettingsService . getUiSettings ) . toHaveBeenCalled ( ) ;
259265 expect ( app . isFeatureNotificationShown ) . toBeTrue ( ) ;
260266 } ) ) ;
@@ -263,9 +269,6 @@ fdescribe('AppComponent', () => {
263269 const expiration = new Date ( Date . now ( ) + 5000 ) ; // 5s ahead
264270 localStorage . setItem ( 'token_expiration' , expiration . toString ( ) ) ;
265271
266- // spyOn(app['router'], 'navigate');
267- // spyOn(app, 'logOut');
268-
269272 spyOn ( app , 'initializeUserSession' ) . and . callFake ( ( ) => {
270273 app . userLoggedIn = true ;
271274 } ) ;
@@ -283,12 +286,10 @@ fdescribe('AppComponent', () => {
283286 expect ( app [ 'router' ] . navigate ) . toHaveBeenCalledWith ( [ '/login' ] ) ;
284287 } ) ) ;
285288
286- xit ( 'should immediately log out and navigate to login if token is expired' , fakeAsync ( ( ) => {
289+ it ( 'should immediately log out and navigate to login if token is expired' , fakeAsync ( ( ) => {
287290 const expiration = new Date ( Date . now ( ) - 5000 ) ; // Expired 5s ago
288291 localStorage . setItem ( 'token_expiration' , expiration . toString ( ) ) ;
289292
290- // spyOn(app['router'], 'navigate');
291- // spyOn(app, 'logOut');
292293 spyOn ( app , 'initializeUserSession' ) ;
293294
294295 app . userLoggedIn = true ;
0 commit comments