header.spec.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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: ['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: /similar issues/i}));
  51. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/similar/');
  52. });
  53. });
  54. describe('issue category: performance', () => {
  55. const defaultProps = {
  56. organization,
  57. baseUrl,
  58. group: TestStubs.Group({issueCategory: IssueCategory.PERFORMANCE}),
  59. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  60. project,
  61. };
  62. it('displays the correct tabs with all features enabled', async () => {
  63. const orgWithFeatures = TestStubs.Organization({
  64. features: ['similarity-view', 'event-attachments'],
  65. });
  66. const projectWithSimilarityView = TestStubs.Project({
  67. features: ['similarity-view'],
  68. });
  69. render(
  70. <GroupHeader
  71. {...defaultProps}
  72. organization={orgWithFeatures}
  73. project={projectWithSimilarityView}
  74. />,
  75. {organization: orgWithFeatures}
  76. );
  77. await userEvent.click(screen.getByRole('tab', {name: /details/i}));
  78. expect(browserHistory.push).toHaveBeenLastCalledWith('BASE_URL/');
  79. await userEvent.click(screen.getByRole('tab', {name: /tags/i}));
  80. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/tags/');
  81. await userEvent.click(screen.getByRole('tab', {name: /all events/i}));
  82. expect(browserHistory.push).toHaveBeenCalledWith({
  83. pathname: 'BASE_URL/events/',
  84. query: {},
  85. });
  86. expect(screen.queryByRole('tab', {name: /user feedback/i})).not.toBeInTheDocument();
  87. expect(screen.queryByRole('tab', {name: /attachments/i})).not.toBeInTheDocument();
  88. expect(screen.queryByRole('tab', {name: /merged issues/i})).not.toBeInTheDocument();
  89. expect(
  90. screen.queryByRole('tab', {name: /similar issues/i})
  91. ).not.toBeInTheDocument();
  92. });
  93. });
  94. });