@@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event'
4
4
import { MemoryRouter , Route } from 'react-router-dom'
5
5
import { type Mock , vi } from 'vitest'
6
6
7
+ import { eventTracker } from 'services/events/events'
7
8
import { useLocationParams } from 'services/navigation'
8
9
9
10
import OnboardingOrg from './OnboardingOrg'
@@ -18,6 +19,7 @@ vi.mock('services/navigation', async () => {
18
19
useLocationParams : vi . fn ( ) ,
19
20
}
20
21
} )
22
+ vi . mock ( 'services/events/events' )
21
23
22
24
const mockedUseLocationParams = useLocationParams as Mock
23
25
@@ -79,4 +81,24 @@ describe('OnboardingOrg', () => {
79
81
// Modal should be closed
80
82
expect ( screen . queryByRole ( 'dialog' ) ) . not . toBeInTheDocument ( )
81
83
} )
84
+
85
+ it ( 'emits an event on clicking Install Codecov' , async ( ) => {
86
+ const user = userEvent . setup ( )
87
+ render ( < OnboardingOrg /> , { wrapper } )
88
+
89
+ // Modal should be closed initially
90
+ expect ( screen . queryByRole ( 'dialog' ) ) . not . toBeInTheDocument ( )
91
+
92
+ // Click install button to open the modal
93
+ const installButton = screen . getByText ( 'Install Codecov' )
94
+ await user . click ( installButton )
95
+
96
+ expect ( eventTracker ( ) . track ) . toHaveBeenCalledWith ( {
97
+ type : 'Button Clicked' ,
98
+ properties : {
99
+ buttonName : 'Open App Install Modal' ,
100
+ buttonLocation : 'Onboarding Container' ,
101
+ } ,
102
+ } )
103
+ } )
82
104
} )
0 commit comments