@@ -6,7 +6,8 @@ import { render, screen, fireEvent, mockedStore, cleanup } from 'uiSrc/utils/tes
6
6
import { changeSelectedTab , toggleInsightsPanel } from 'uiSrc/slices/panels/insights'
7
7
import { InsightsPanelTabs } from 'uiSrc/slices/interfaces/insights'
8
8
import { sendEventTelemetry , TELEMETRY_EMPTY_VALUE , TelemetryEvent } from 'uiSrc/telemetry'
9
- import { capabilities } from './constants'
9
+ import { MOCK_EXPLORE_GUIDES } from 'uiSrc/constants/mocks/mock-explore-guides'
10
+ import { findTutorialPath } from 'uiSrc/utils'
10
11
11
12
import CapabilityPromotion from './CapabilityPromotion'
12
13
@@ -15,6 +16,18 @@ jest.mock('uiSrc/telemetry', () => ({
15
16
sendEventTelemetry : jest . fn ( ) ,
16
17
} ) )
17
18
19
+ jest . mock ( 'uiSrc/slices/content/guide-links' , ( ) => ( {
20
+ ...jest . requireActual ( 'uiSrc/slices/content/guide-links' ) ,
21
+ guideLinksSelector : jest . fn ( ) . mockReturnValue ( {
22
+ data : MOCK_EXPLORE_GUIDES
23
+ } )
24
+ } ) )
25
+
26
+ jest . mock ( 'uiSrc/utils' , ( ) => ( {
27
+ ...jest . requireActual ( 'uiSrc/utils' ) ,
28
+ findTutorialPath : jest . fn ( ) ,
29
+ } ) )
30
+
18
31
let store : typeof mockedStore
19
32
beforeEach ( ( ) => {
20
33
cleanup ( )
@@ -30,16 +43,17 @@ describe('CapabilityPromotion', () => {
30
43
it ( 'should render capabilities' , ( ) => {
31
44
render ( < CapabilityPromotion /> )
32
45
33
- capabilities . forEach ( ( { id } ) => {
34
- expect ( screen . getByTestId ( `capability-promotion-${ id } ` ) ) . toBeInTheDocument ( )
46
+ MOCK_EXPLORE_GUIDES . forEach ( ( { tutorialId } ) => {
47
+ expect ( screen . getByTestId ( `capability-promotion-${ tutorialId } ` ) ) . toBeInTheDocument ( )
35
48
} )
36
49
} )
37
50
38
51
it ( 'should call proper actions and history push on click capability' , ( ) => {
39
52
const pushMock = jest . fn ( )
40
- reactRouterDom . useHistory = jest . fn ( ) . mockReturnValue ( { push : pushMock } )
53
+ reactRouterDom . useHistory = jest . fn ( ) . mockReturnValue ( { push : pushMock } ) ;
54
+ ( findTutorialPath as jest . Mock ) . mockImplementation ( ( ) => '0/1/0' )
41
55
42
- const id = capabilities [ 0 ] ?. id
56
+ const id = MOCK_EXPLORE_GUIDES [ 0 ] ?. tutorialId
43
57
render ( < CapabilityPromotion /> )
44
58
45
59
fireEvent . click ( screen . getByTestId ( `capability-promotion-${ id } ` ) )
@@ -50,16 +64,16 @@ describe('CapabilityPromotion', () => {
50
64
]
51
65
52
66
expect ( store . getActions ( ) ) . toEqual ( expectedActions )
53
- expect ( pushMock ) . toBeCalledWith ( {
54
- search : `guidePath= ${ id } `
67
+ expect ( pushMock ) . toHaveBeenCalledWith ( {
68
+ search : 'path=tutorials/0/1/0'
55
69
} )
56
70
} )
57
71
58
72
it ( 'should call proper telemetry after click capability' , ( ) => {
59
73
const sendEventTelemetryMock = jest . fn ( ) ;
60
74
( sendEventTelemetry as jest . Mock ) . mockImplementation ( ( ) => sendEventTelemetryMock )
61
75
62
- const id = capabilities [ 0 ] ?. id
76
+ const id = MOCK_EXPLORE_GUIDES [ 0 ] ?. tutorialId
63
77
render ( < CapabilityPromotion /> )
64
78
65
79
fireEvent . click ( screen . getByTestId ( `capability-promotion-${ id } ` ) )
0 commit comments