@@ -3,8 +3,10 @@ import {UserFixture} from 'sentry-fixture/user';
33
44import { render , screen , userEvent , within } from 'sentry-test/reactTestingLibrary' ;
55
6+ import { CUSTOM_REFERRER_KEY } from 'sentry/constants' ;
67import ConfigStore from 'sentry/stores/configStore' ;
78import OrganizationsStore from 'sentry/stores/organizationsStore' ;
9+ import sessionStorage from 'sentry/utils/sessionStorage' ;
810import { OrgDropdown } from 'sentry/views/nav/orgDropdown' ;
911
1012describe ( 'OrgDropdown' , ( ) => {
@@ -102,4 +104,16 @@ describe('OrgDropdown', () => {
102104 within ( inactiveGroup ) . getByRole ( 'menuitemradio' , { name : / D e l e t i n g o r g / } )
103105 ) . toBeInTheDocument ( ) ;
104106 } ) ;
107+
108+ it ( 'clicking project sets referrer in session storage' , async ( ) => {
109+ render ( < OrgDropdown /> , { organization} ) ;
110+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Toggle organization menu' } ) ) ;
111+ // We use onAction to navigate, no href is set:
112+ expect ( screen . getByRole ( 'menuitemradio' , { name : 'Projects' } ) ) . not . toHaveAttribute (
113+ 'href'
114+ ) ;
115+ // onClick should take precedence setting session storage value and navigating:
116+ await userEvent . click ( screen . getByRole ( 'menuitemradio' , { name : 'Projects' } ) ) ;
117+ expect ( sessionStorage . getItem ( CUSTOM_REFERRER_KEY ) ) . toBe ( '"org-dropdown"' ) ;
118+ } ) ;
105119} ) ;
0 commit comments