processingIssueList.spec.jsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProcessingIssueList from 'sentry/components/stream/processingIssueList';
  3. describe('ProcessingIssueList', function () {
  4. let projects, organization, fetchIssueRequest;
  5. beforeEach(function () {
  6. fetchIssueRequest = MockApiClient.addMockResponse({
  7. url: '/organizations/org-slug/processingissues/',
  8. method: 'GET',
  9. body: [
  10. {
  11. project: 'test-project',
  12. numIssues: 1,
  13. hasIssues: true,
  14. lastSeen: '2019-01-16T15:39:11.081Z',
  15. },
  16. {
  17. project: 'other-project',
  18. numIssues: 1,
  19. hasIssues: true,
  20. lastSeen: '2019-01-16T15:39:11.081Z',
  21. },
  22. ],
  23. });
  24. organization = TestStubs.Organization();
  25. projects = [1, 2];
  26. });
  27. describe('componentDidMount', function () {
  28. it('fetches issues', async function () {
  29. render(<ProcessingIssueList organization={organization} projects={projects} />);
  30. await screen.findAllByText('Show details');
  31. expect(fetchIssueRequest).toHaveBeenCalled();
  32. });
  33. });
  34. describe('render', function () {
  35. it('renders multiple issues', async function () {
  36. render(<ProcessingIssueList organization={organization} projects={projects} />);
  37. const items = await screen.findAllByText(/There is 1 issue blocking/);
  38. expect(items).toHaveLength(2);
  39. });
  40. it('forwards the showProject prop', async function () {
  41. render(
  42. <ProcessingIssueList
  43. organization={organization}
  44. projects={projects}
  45. showProject
  46. />
  47. );
  48. const projectText = await screen.findByText(/test-project/);
  49. expect(projectText).toBeInTheDocument();
  50. const otherProject = screen.getByText(/other-project/);
  51. expect(otherProject).toBeInTheDocument();
  52. });
  53. });
  54. });