Homepage: Add tracks events to Stats List period changes (https://github.com/woocommerce/woocommerce-admin/pull/4448)
This commit is contained in:
parent
04e39480af
commit
54c00eecf9
|
@ -102,6 +102,11 @@ export const StatsOverview = ( { userPrefs, updateCurrentUserData } ) => {
|
|||
>
|
||||
<TabPanel
|
||||
className="woocommerce-stats-overview__tabs"
|
||||
onSelect={ ( period ) => {
|
||||
recordEvent( 'statsoverview_date_picker_update', {
|
||||
period,
|
||||
} );
|
||||
} }
|
||||
tabs={ [
|
||||
{
|
||||
title: __( 'Today', 'woocommerce-admin' ),
|
||||
|
|
|
@ -50,6 +50,29 @@ describe( 'StatsOverview tracking', () => {
|
|||
}
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'should record an event when a period is clicked', () => {
|
||||
render(
|
||||
<StatsOverview
|
||||
userPrefs={ {
|
||||
hiddenStats: null,
|
||||
} }
|
||||
updateCurrentUserData={ () => {} }
|
||||
/>
|
||||
);
|
||||
|
||||
const monthBtn = screen.getByRole( 'tab', {
|
||||
name: 'Month to date',
|
||||
} );
|
||||
fireEvent.click( monthBtn );
|
||||
|
||||
expect( recordEvent ).toHaveBeenCalledWith(
|
||||
'statsoverview_date_picker_update',
|
||||
{
|
||||
period: 'month',
|
||||
}
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
describe( 'StatsOverview toggle and persist stat preference', () => {
|
||||
|
|
Loading…
Reference in New Issue