projectQuickLinks.spec.jsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import ProjectQuickLinks from 'sentry/views/projectDetail/projectQuickLinks';
  4. describe('ProjectDetail > ProjectQuickLinks', function () {
  5. const {organization, router} = initializeOrg({
  6. organization: {features: ['performance-view']},
  7. });
  8. it('renders a list', function () {
  9. const wrapper = mountWithTheme(
  10. <ProjectQuickLinks
  11. organization={organization}
  12. location={router.location}
  13. project={TestStubs.Project()}
  14. />
  15. );
  16. expect(wrapper.find('SectionHeading').text()).toBe('Quick Links');
  17. expect(wrapper.find('QuickLink a').length).toBe(3);
  18. const userFeedback = wrapper.find('QuickLink').at(0);
  19. const keyTransactions = wrapper.find('QuickLink').at(1);
  20. const mostChangedTransactions = wrapper.find('QuickLink').at(2);
  21. expect(userFeedback.text()).toBe('User Feedback');
  22. expect(userFeedback.prop('to')).toEqual({
  23. pathname: '/organizations/org-slug/user-feedback/',
  24. query: {project: '2'},
  25. });
  26. expect(keyTransactions.text()).toBe('View Transactions');
  27. expect(keyTransactions.prop('to')).toEqual({
  28. pathname: '/organizations/org-slug/performance/',
  29. query: {project: '2'},
  30. });
  31. expect(mostChangedTransactions.text()).toBe('Most Improved/Regressed Transactions');
  32. expect(mostChangedTransactions.prop('to')).toEqual({
  33. pathname: '/organizations/org-slug/performance/trends/',
  34. query: {
  35. cursor: undefined,
  36. project: '2',
  37. query: 'tpm():>0.01 transaction.duration:>0 transaction.duration:<15min',
  38. },
  39. });
  40. });
  41. it('disables link if feature is missing', function () {
  42. const wrapper = mountWithTheme(
  43. <ProjectQuickLinks
  44. organization={{...organization, features: []}}
  45. location={router.location}
  46. project={TestStubs.Project()}
  47. />
  48. );
  49. const keyTransactions = wrapper.find('QuickLink').at(1);
  50. const tooltip = wrapper.find('Tooltip').at(1);
  51. expect(keyTransactions.prop('disabled')).toBeTruthy();
  52. expect(keyTransactions.find('a').exists()).toBeFalsy();
  53. expect(tooltip.prop('title')).toBe("You don't have access to this feature");
  54. expect(tooltip.prop('disabled')).toBeFalsy();
  55. });
  56. });