processingIssueHint.spec.jsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProcessingIssueHint from 'sentry/components/stream/processingIssueHint';
  3. describe('ProcessingIssueHint', function () {
  4. let issue, container;
  5. const orgId = 'test-org';
  6. const projectId = 'test-project';
  7. beforeEach(() => {
  8. issue = {
  9. hasIssues: false,
  10. hasMoreResolveableIssues: false,
  11. issuesProcessing: 0,
  12. lastSeen: '2019-01-16T15:38:38Z',
  13. numIssues: 0,
  14. resolveableIssues: 0,
  15. signedLink: null,
  16. };
  17. });
  18. function renderComponent(issueData, showProject = false) {
  19. const result = render(
  20. <ProcessingIssueHint
  21. issue={issueData}
  22. orgId={orgId}
  23. projectId={projectId}
  24. showProject={showProject}
  25. />
  26. );
  27. container = result.container;
  28. }
  29. describe('numIssues state', function () {
  30. beforeEach(() => {
  31. issue.numIssues = 9;
  32. });
  33. it('displays a button', function () {
  34. renderComponent(issue);
  35. const button = screen.getByRole('button');
  36. expect(button).toBeInTheDocument();
  37. expect(button).toHaveAttribute(
  38. 'href',
  39. `/settings/${orgId}/projects/${projectId}/processing-issues/`
  40. );
  41. });
  42. it('displays an icon', function () {
  43. renderComponent(issue);
  44. const icon = container.querySelector('svg');
  45. expect(icon).toBeInTheDocument();
  46. });
  47. it('displays text', function () {
  48. renderComponent(issue);
  49. expect(screen.getByText(/issues blocking/)).toBeInTheDocument();
  50. });
  51. });
  52. describe('issuesProcessing state', function () {
  53. beforeEach(() => {
  54. issue.issuesProcessing = 9;
  55. });
  56. it('does not display a button', function () {
  57. renderComponent(issue);
  58. expect(screen.queryByRole('button')).not.toBeInTheDocument();
  59. });
  60. it('displays an icon', function () {
  61. renderComponent(issue);
  62. const icon = container.querySelector('svg');
  63. expect(icon).toBeInTheDocument();
  64. });
  65. it('displays text', function () {
  66. renderComponent(issue);
  67. expect(screen.getByText(/Reprocessing/)).toBeInTheDocument();
  68. });
  69. });
  70. describe('resolvableIssues state', function () {
  71. beforeEach(() => {
  72. issue.resolveableIssues = 9;
  73. });
  74. it('displays a button', function () {
  75. renderComponent(issue);
  76. const button = screen.getByRole('button');
  77. expect(button).toBeInTheDocument();
  78. expect(button).toHaveAttribute(
  79. 'href',
  80. `/settings/${orgId}/projects/${projectId}/processing-issues/`
  81. );
  82. });
  83. it('displays an icon', function () {
  84. renderComponent(issue);
  85. const icon = container.querySelector('svg');
  86. expect(icon).toBeInTheDocument();
  87. });
  88. it('displays text', function () {
  89. renderComponent(issue);
  90. expect(
  91. screen.getByText('There are 9 events pending reprocessing.')
  92. ).toBeInTheDocument();
  93. });
  94. });
  95. describe('showProject state', function () {
  96. beforeEach(() => {
  97. issue.numIssues = 9;
  98. });
  99. it('displays the project slug', function () {
  100. renderComponent(issue, true);
  101. expect(screen.getByText(projectId)).toBeInTheDocument();
  102. });
  103. });
  104. });