sidebarDropdownMenu.spec.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import SidebarDropdown from 'sentry/components/sidebar/sidebarDropdown';
  4. import HookStore from 'sentry/stores/hookStore';
  5. import hookSidebarDropdownMenu from 'getsentry/hooks/sidebarDropdownMenu';
  6. describe('sidebar:organization-dropdown-menu', function () {
  7. beforeEach(function () {
  8. HookStore.init();
  9. });
  10. it('renders "Support" link', async function () {
  11. HookStore.add('sidebar:organization-dropdown-menu', hookSidebarDropdownMenu);
  12. render(<SidebarDropdown orientation="top" collapsed={false} />);
  13. await userEvent.click(screen.getByTestId('sidebar-dropdown'));
  14. expect(screen.queryByText('Billing')).not.toBeInTheDocument();
  15. expect(screen.getByRole('link', {name: 'Support'})).toHaveAttribute(
  16. 'href',
  17. 'https://sentry.zendesk.com/hc/en-us'
  18. );
  19. });
  20. it('renders "Usage & Billing" link only for `org:billing` access', async function () {
  21. HookStore.add('sidebar:organization-dropdown-menu', hookSidebarDropdownMenu);
  22. const billingOrg = OrganizationFixture({access: ['org:billing']});
  23. render(<SidebarDropdown orientation="top" collapsed={false} />, {
  24. organization: billingOrg,
  25. });
  26. await userEvent.click(screen.getByTestId('sidebar-dropdown'));
  27. expect(screen.getByRole('link', {name: 'Usage & Billing'})).toHaveAttribute(
  28. 'href',
  29. '/settings/org-slug/billing/'
  30. );
  31. });
  32. });