@@ -15,6 +15,9 @@ import { Pages } from 'uiSrc/constants'
15
15
import { setWorkbenchEAMinimized } from 'uiSrc/slices/app/context'
16
16
import { dbAnalysisSelector , setDatabaseAnalysisViewTab } from 'uiSrc/slices/analytics/dbAnalysis'
17
17
import { DatabaseAnalysisViewTab } from 'uiSrc/slices/interfaces/analytics'
18
+ import { fetchRedisearchListAction , loadList } from 'uiSrc/slices/browser/redisearch'
19
+ import { stringToBuffer } from 'uiSrc/utils'
20
+ import { RedisResponseBuffer } from 'uiSrc/slices/interfaces'
18
21
import { ONBOARDING_FEATURES } from './OnboardingFeatures'
19
22
20
23
jest . mock ( 'uiSrc/slices/app/features' , ( ) => ( {
@@ -33,6 +36,12 @@ jest.mock('uiSrc/slices/browser/keys', () => ({
33
36
} )
34
37
} ) )
35
38
39
+ jest . mock ( 'uiSrc/slices/browser/redisearch' , ( ) => ( {
40
+ ...jest . requireActual ( 'uiSrc/slices/browser/redisearch' ) ,
41
+ fetchRedisearchListAction : jest . fn ( )
42
+ . mockImplementation ( jest . requireActual ( 'uiSrc/slices/browser/redisearch' ) . fetchRedisearchListAction )
43
+ } ) )
44
+
36
45
jest . mock ( 'uiSrc/slices/analytics/dbAnalysis' , ( ) => ( {
37
46
...jest . requireActual ( 'uiSrc/slices/analytics/dbAnalysis' ) ,
38
47
dbAnalysisSelector : jest . fn ( ) . mockReturnValue ( {
@@ -341,12 +350,40 @@ describe('ONBOARDING_FEATURES', () => {
341
350
checkAllTelemetryButtons ( OnboardingStepName . WorkbenchIntro , sendEventTelemetry as jest . Mock )
342
351
} )
343
352
353
+ it ( 'should call proper actions on mount' , ( ) => {
354
+ render ( < OnboardingTour options = { ONBOARDING_FEATURES . WORKBENCH_PAGE } > < span /> </ OnboardingTour > )
355
+
356
+ const expectedActions = [ loadList ( ) ]
357
+ expect ( clearStoreActions ( store . getActions ( ) ) ) . toEqual ( clearStoreActions ( expectedActions ) )
358
+ } )
359
+
360
+ it ( 'should render FT.INFO when there are indexes in database' , ( ) => {
361
+ const fetchRedisearchListActionMock = ( onSuccess ?: ( indexes : RedisResponseBuffer [ ] ) => void ) =>
362
+ jest . fn ( ) . mockImplementation ( ( ) => onSuccess ?.( [ stringToBuffer ( 'someIndex' ) ] ) ) ;
363
+
364
+ ( fetchRedisearchListAction as jest . Mock ) . mockImplementation ( fetchRedisearchListActionMock )
365
+ render ( < OnboardingTour options = { ONBOARDING_FEATURES . WORKBENCH_PAGE } > < span /> </ OnboardingTour > )
366
+
367
+ expect ( screen . getByTestId ( 'wb-onboarding-command' ) ) . toHaveTextContent ( 'FT.INFO someIndex' )
368
+ } )
369
+
370
+ it ( 'should render CLIENT LIST when there are no indexes in database' , ( ) => {
371
+ const fetchRedisearchListActionMock = ( onSuccess ?: ( indexes : RedisResponseBuffer [ ] ) => void ) =>
372
+ jest . fn ( ) . mockImplementation ( ( ) => onSuccess ?.( [ ] ) ) ;
373
+
374
+ ( fetchRedisearchListAction as jest . Mock ) . mockImplementation ( fetchRedisearchListActionMock )
375
+ render ( < OnboardingTour options = { ONBOARDING_FEATURES . WORKBENCH_PAGE } > < span /> </ OnboardingTour > )
376
+
377
+ expect ( screen . getByTestId ( 'wb-onboarding-command' ) ) . toHaveTextContent ( 'CLIENT LIST' )
378
+ } )
379
+
344
380
it ( 'should call proper actions on back' , ( ) => {
345
381
render ( < OnboardingTour options = { ONBOARDING_FEATURES . WORKBENCH_PAGE } > < span /> </ OnboardingTour > )
346
382
fireEvent . click ( screen . getByTestId ( 'back-btn' ) )
347
383
348
384
const expectedActions = [ showMonitor ( ) , setOnboardPrevStep ( ) ]
349
- expect ( clearStoreActions ( store . getActions ( ) ) ) . toEqual ( clearStoreActions ( expectedActions ) )
385
+ expect ( clearStoreActions ( store . getActions ( ) . slice ( - 2 ) ) )
386
+ . toEqual ( clearStoreActions ( expectedActions ) )
350
387
} )
351
388
352
389
it ( 'should properly push history on back' , ( ) => {
0 commit comments