@@ -7,7 +7,7 @@ import { act, cleanup, mockedStore, render, screen,
7
7
mockedStoreFn ,
8
8
} from 'uiSrc/utils/test-utils'
9
9
10
- import { getUserInfo , logoutUser , oauthCloudUserSelector } from 'uiSrc/slices/oauth/cloud'
10
+ import { getUserInfo , logoutUser , oauthCloudUserSelector , setInitialLoadingState } from 'uiSrc/slices/oauth/cloud'
11
11
import { sendEventTelemetry , TelemetryEvent } from 'uiSrc/telemetry'
12
12
import { loadSubscriptionsRedisCloud , setSSOFlow } from 'uiSrc/slices/instances/cloud'
13
13
import { OAuthSocialAction , OAuthSocialSource } from 'uiSrc/slices/interfaces'
@@ -24,6 +24,7 @@ jest.mock('uiSrc/slices/oauth/cloud', () => ({
24
24
loading : false ,
25
25
data : null ,
26
26
error : '' ,
27
+ initialLoading : false
27
28
} ) ,
28
29
} ) )
29
30
@@ -53,6 +54,12 @@ describe('OAuthUserProfile', () => {
53
54
} )
54
55
55
56
it ( 'should render loading spinner initially' , ( ) => {
57
+ ( oauthCloudUserSelector as jest . Mock ) . mockReturnValueOnce ( {
58
+ loading : false ,
59
+ data : null ,
60
+ error : '' ,
61
+ initialLoading : true
62
+ } )
56
63
render ( < OAuthUserProfile { ...mockedProps } /> )
57
64
58
65
expect ( screen . getByTestId ( 'oath-user-profile-spinner' ) ) . toBeInTheDocument ( )
@@ -132,7 +139,11 @@ describe('OAuthUserProfile', () => {
132
139
}
133
140
} )
134
141
135
- expect ( store . getActions ( ) ) . toEqual ( [ setSSOFlow ( OAuthSocialAction . Import ) , loadSubscriptionsRedisCloud ( ) ] ) ;
142
+ expect ( store . getActions ( ) ) . toEqual ( [
143
+ setInitialLoadingState ( false ) ,
144
+ setSSOFlow ( OAuthSocialAction . Import ) ,
145
+ loadSubscriptionsRedisCloud ( )
146
+ ] ) ;
136
147
137
148
( sendEventTelemetry as jest . Mock ) . mockRestore ( )
138
149
} )
@@ -154,7 +165,7 @@ describe('OAuthUserProfile', () => {
154
165
155
166
fireEvent . click ( screen . getByTestId ( 'profile-account-2' ) )
156
167
157
- expect ( store . getActions ( ) ) . toEqual ( [ getUserInfo ( ) ] ) ;
168
+ expect ( store . getActions ( ) ) . toEqual ( [ setInitialLoadingState ( false ) , getUserInfo ( ) ] ) ;
158
169
159
170
( sendEventTelemetry as jest . Mock ) . mockRestore ( )
160
171
} )
@@ -195,6 +206,6 @@ describe('OAuthUserProfile', () => {
195
206
196
207
fireEvent . click ( screen . getByTestId ( 'profile-logout' ) )
197
208
198
- expect ( store . getActions ( ) ) . toEqual ( [ logoutUser ( ) , setSSOFlow ( ) ] )
209
+ expect ( store . getActions ( ) ) . toEqual ( [ setInitialLoadingState ( false ) , logoutUser ( ) , setSSOFlow ( ) ] )
199
210
} )
200
211
} )
0 commit comments