@@ -9,6 +9,7 @@ import { addErrorNotification, addInfiniteNotification, removeInfiniteNotificati
9
9
import { RootState } from 'uiSrc/slices/store'
10
10
import { loadInstances } from 'uiSrc/slices/instances/instances'
11
11
import { INFINITE_MESSAGES , InfiniteMessagesIds } from 'uiSrc/components/notifications/components'
12
+ import { CustomErrorCodes } from 'uiSrc/constants'
12
13
import OAuthJobs from './OAuthJobs'
13
14
14
15
jest . mock ( 'react-redux' , ( ) => ( {
@@ -128,8 +129,68 @@ describe('OAuthJobs', () => {
128
129
rerender ( < OAuthJobs /> )
129
130
130
131
const expectedActions = [
131
- removeInfiniteNotification ( InfiniteMessagesIds . oAuthProgress ) ,
132
132
addErrorNotification ( { response : { data : error } } as AxiosError ) ,
133
+ removeInfiniteNotification ( InfiniteMessagesIds . oAuthProgress ) ,
134
+ ]
135
+ expect ( clearStoreActions ( store . getActions ( ) ) ) . toEqual (
136
+ clearStoreActions ( expectedActions )
137
+ )
138
+ } )
139
+
140
+ it ( 'should call addInfiniteNotification and removeInfiniteNotification when errorCode is 11_108' , async ( ) => {
141
+ const mockDatabaseId = '123'
142
+ const error = {
143
+ errorCode : CustomErrorCodes . CloudDatabaseAlreadyExistsFree ,
144
+ resource : {
145
+ databaseId : mockDatabaseId
146
+ }
147
+ } ;
148
+ ( oauthCloudJobSelector as jest . Mock ) . mockImplementation ( ( ) => ( {
149
+ status : ''
150
+ } ) )
151
+
152
+ const { rerender } = render ( < OAuthJobs /> ) ;
153
+
154
+ ( oauthCloudJobSelector as jest . Mock ) . mockImplementation ( ( ) => ( {
155
+ status : CloudJobStatus . Failed ,
156
+ error,
157
+ } ) )
158
+
159
+ rerender ( < OAuthJobs /> )
160
+
161
+ const expectedActions = [
162
+ addInfiniteNotification ( INFINITE_MESSAGES . DATABASE_EXISTS ( ) ) ,
163
+ removeInfiniteNotification ( InfiniteMessagesIds . oAuthProgress ) ,
164
+ ]
165
+ expect ( clearStoreActions ( store . getActions ( ) ) ) . toEqual (
166
+ clearStoreActions ( expectedActions )
167
+ )
168
+ } )
169
+
170
+ it ( 'should call addInfiniteNotification and removeInfiniteNotification when errorCode is 11_114' , async ( ) => {
171
+ const mockDatabaseId = '123'
172
+ const error = {
173
+ errorCode : CustomErrorCodes . CloudSubscriptionAlreadyExistsFree ,
174
+ resource : {
175
+ databaseId : mockDatabaseId
176
+ }
177
+ } ;
178
+ ( oauthCloudJobSelector as jest . Mock ) . mockImplementation ( ( ) => ( {
179
+ status : ''
180
+ } ) )
181
+
182
+ const { rerender } = render ( < OAuthJobs /> ) ;
183
+
184
+ ( oauthCloudJobSelector as jest . Mock ) . mockImplementation ( ( ) => ( {
185
+ status : CloudJobStatus . Failed ,
186
+ error,
187
+ } ) )
188
+
189
+ rerender ( < OAuthJobs /> )
190
+
191
+ const expectedActions = [
192
+ addInfiniteNotification ( INFINITE_MESSAGES . DATABASE_EXISTS ( ) ) ,
193
+ removeInfiniteNotification ( InfiniteMessagesIds . oAuthProgress ) ,
133
194
]
134
195
expect ( clearStoreActions ( store . getActions ( ) ) ) . toEqual (
135
196
clearStoreActions ( expectedActions )
0 commit comments