header.spec.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import {browserHistory} from 'react-router';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import {IssueCategory} from 'sentry/types';
  4. import GroupHeader from 'sentry/views/issueDetails/header';
  5. import {ReprocessingStatus} from 'sentry/views/issueDetails/utils';
  6. describe('groupDetails', () => {
  7. const baseUrl = 'BASE_URL/';
  8. const organization = TestStubs.Organization();
  9. const project = TestStubs.Project({teams: [TestStubs.Team()]});
  10. describe('issue category: error', () => {
  11. const defaultProps = {
  12. organization,
  13. baseUrl,
  14. group: TestStubs.Group({issueCategory: IssueCategory.ERROR}),
  15. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  16. project,
  17. };
  18. it('displays the correct tabs with all features enabled', async () => {
  19. const orgWithFeatures = TestStubs.Organization({
  20. features: ['grouping-tree-ui', 'similarity-view', 'event-attachments'],
  21. });
  22. const projectWithSimilarityView = TestStubs.Project({
  23. features: ['similarity-view'],
  24. });
  25. render(
  26. <GroupHeader
  27. {...defaultProps}
  28. organization={orgWithFeatures}
  29. project={projectWithSimilarityView}
  30. />,
  31. {organization: orgWithFeatures}
  32. );
  33. await userEvent.click(screen.getByRole('tab', {name: /details/i}));
  34. expect(browserHistory.push).toHaveBeenLastCalledWith('BASE_URL/');
  35. await userEvent.click(screen.getByRole('tab', {name: /activity/i}));
  36. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/activity/');
  37. await userEvent.click(screen.getByRole('tab', {name: /user feedback/i}));
  38. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/feedback/');
  39. await userEvent.click(screen.getByRole('tab', {name: /attachments/i}));
  40. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/attachments/');
  41. await userEvent.click(screen.getByRole('tab', {name: /tags/i}));
  42. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/tags/');
  43. await userEvent.click(screen.getByRole('tab', {name: /all events/i}));
  44. expect(browserHistory.push).toHaveBeenCalledWith({
  45. pathname: 'BASE_URL/events/',
  46. query: {},
  47. });
  48. await userEvent.click(screen.getByRole('tab', {name: /merged issues/i}));
  49. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/merged/');
  50. await userEvent.click(screen.getByRole('tab', {name: /grouping/i}));
  51. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/grouping/');
  52. await userEvent.click(screen.getByRole('tab', {name: /similar issues/i}));
  53. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/similar/');
  54. });
  55. });
  56. describe('issue category: performance', () => {
  57. const defaultProps = {
  58. organization,
  59. baseUrl,
  60. group: TestStubs.Group({issueCategory: IssueCategory.PERFORMANCE}),
  61. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  62. project,
  63. };
  64. it('displays the correct tabs with all features enabled', async () => {
  65. const orgWithFeatures = TestStubs.Organization({
  66. features: ['grouping-tree-ui', 'similarity-view', 'event-attachments'],
  67. });
  68. const projectWithSimilarityView = TestStubs.Project({
  69. features: ['similarity-view'],
  70. });
  71. render(
  72. <GroupHeader
  73. {...defaultProps}
  74. organization={orgWithFeatures}
  75. project={projectWithSimilarityView}
  76. />,
  77. {organization: orgWithFeatures}
  78. );
  79. await userEvent.click(screen.getByRole('tab', {name: /details/i}));
  80. expect(browserHistory.push).toHaveBeenLastCalledWith('BASE_URL/');
  81. await userEvent.click(screen.getByRole('tab', {name: /tags/i}));
  82. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/tags/');
  83. await userEvent.click(screen.getByRole('tab', {name: /all events/i}));
  84. expect(browserHistory.push).toHaveBeenCalledWith({
  85. pathname: 'BASE_URL/events/',
  86. query: {},
  87. });
  88. expect(screen.queryByRole('tab', {name: /user feedback/i})).not.toBeInTheDocument();
  89. expect(screen.queryByRole('tab', {name: /attachments/i})).not.toBeInTheDocument();
  90. expect(screen.queryByRole('tab', {name: /merged issues/i})).not.toBeInTheDocument();
  91. expect(screen.queryByRole('tab', {name: /grouping/i})).not.toBeInTheDocument();
  92. expect(
  93. screen.queryByRole('tab', {name: /similar issues/i})
  94. ).not.toBeInTheDocument();
  95. });
  96. });
  97. });