@@ -11,6 +11,7 @@ import { of } from 'rxjs'
1111import { DevicesService } from '../devices.service'
1212import { provideTranslateService } from '@ngx-translate/core'
1313import { By } from '@angular/platform-browser'
14+ import { Subject } from 'rxjs'
1415
1516describe ( 'GeneralComponent' , ( ) => {
1617 let component : GeneralComponent
@@ -32,7 +33,8 @@ describe('GeneralComponent', () => {
3233 'bulkPowerAction' ,
3334 'sendDeactivate' ,
3435 'sendBulkDeactivate' ,
35- 'getWsmanOperations'
36+ 'getWsmanOperations' ,
37+ 'setAmtFeatures'
3638 ] )
3739 const amtFeaturesResponse = {
3840 userConsent : 'ALL' ,
@@ -143,4 +145,38 @@ describe('GeneralComponent', () => {
143145 jasmine . objectContaining ( { remoteErase : true } )
144146 )
145147 } )
148+
149+ it ( 'should update only feature loading state while setAmtFeatures is in flight' , ( ) => {
150+ const response$ = new Subject < any > ( )
151+ devicesServiceSpy . setAmtFeatures . and . returnValue ( response$ )
152+ const loadingBefore = component . isLoading ( )
153+
154+ component . setAmtFeatures ( )
155+
156+ expect ( component . isUpdatingFeatures ( ) ) . toBeTrue ( )
157+ expect ( component . isLoading ( ) ) . toBe ( loadingBefore )
158+
159+ response$ . next ( { redirection : true , status : 'ok' } )
160+ response$ . complete ( )
161+
162+ expect ( component . isUpdatingFeatures ( ) ) . toBeFalse ( )
163+ expect ( component . isLoading ( ) ) . toBe ( loadingBefore )
164+ } )
165+
166+ it ( 'keeps summary loading state independent from feature update state' , ( ) => {
167+ const response$ = new Subject < any > ( )
168+ devicesServiceSpy . setAmtFeatures . and . returnValue ( response$ )
169+
170+ component . isLoading . set ( false )
171+ component . setAmtFeatures ( )
172+
173+ expect ( component . isLoading ( ) ) . toBeFalse ( )
174+ expect ( component . isUpdatingFeatures ( ) ) . toBeTrue ( )
175+
176+ response$ . next ( { redirection : true , status : 'ok' } )
177+ response$ . complete ( )
178+
179+ expect ( component . isLoading ( ) ) . toBeFalse ( )
180+ expect ( component . isUpdatingFeatures ( ) ) . toBeFalse ( )
181+ } )
146182} )
0 commit comments