reprocessEventModal.spec.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
  4. import {textWithMarkupMatcher} from 'sentry-test/utils';
  5. import {
  6. makeClosableHeader,
  7. makeCloseButton,
  8. ModalBody,
  9. ModalFooter,
  10. } from 'sentry/components/globalModal/components';
  11. import {ReprocessingEventModal} from 'sentry/components/modals/reprocessEventModal';
  12. const group = GroupFixture({
  13. id: '1337',
  14. pluginActions: [],
  15. pluginIssues: [],
  16. });
  17. describe('ReprocessEventModal', function () {
  18. it('form fields & info', function () {
  19. const {organization} = initializeOrg({
  20. organization: {
  21. id: '4660',
  22. slug: 'org',
  23. },
  24. });
  25. render(
  26. <ReprocessingEventModal
  27. Body={ModalBody}
  28. closeModal={jest.fn()}
  29. CloseButton={makeCloseButton(jest.fn())}
  30. Header={makeClosableHeader(jest.fn())}
  31. Footer={ModalFooter}
  32. groupId="1337"
  33. organization={organization}
  34. />
  35. );
  36. // Reprocess impacts
  37. expect(
  38. screen.getByText(
  39. 'Reprocessing applies new debug files and grouping enhancements to this Issue. Please consider these impacts:'
  40. )
  41. ).toBeInTheDocument();
  42. // Reprocess impacts list
  43. expect(screen.getAllByRole('listitem')).toHaveLength(3);
  44. // Docs info
  45. expect(
  46. screen.getByText(
  47. textWithMarkupMatcher('For more information, please refer to the documentation.')
  48. )
  49. ).toBeInTheDocument();
  50. // Number of events to be reprocessed field
  51. expect(
  52. screen.getByRole('spinbutton', {name: 'Number of events to be reprocessed'})
  53. ).toBeInTheDocument();
  54. // Remaining events action field
  55. expect(
  56. screen.getByRole('radiogroup', {name: 'Remaining events'})
  57. ).toBeInTheDocument();
  58. });
  59. it('reprocess all events', async function () {
  60. const {organization} = initializeOrg({
  61. organization: {
  62. id: '4660',
  63. slug: 'org',
  64. },
  65. });
  66. MockApiClient.addMockResponse({
  67. url: `/organizations/${organization.slug}/issues/${group.id}/reprocessing/`,
  68. method: 'POST',
  69. body: [],
  70. });
  71. jest.spyOn(window.location, 'reload').mockImplementation(() => {});
  72. const handleCloseModal = jest.fn();
  73. render(
  74. <ReprocessingEventModal
  75. Body={ModalBody}
  76. closeModal={handleCloseModal}
  77. CloseButton={makeCloseButton(jest.fn())}
  78. Header={makeClosableHeader(jest.fn())}
  79. Footer={ModalFooter}
  80. groupId="1337"
  81. organization={organization}
  82. />
  83. );
  84. expect(screen.getByRole('heading', {name: 'Reprocess Events'})).toBeInTheDocument();
  85. // Number of events to be reprocessed field
  86. expect(
  87. screen.getByRole('spinbutton', {name: 'Number of events to be reprocessed'})
  88. ).toHaveAttribute('placeholder', 'Reprocess all events');
  89. await userEvent.click(screen.getByRole('button', {name: 'Reprocess Events'}));
  90. await waitFor(() => expect(window.location.reload).toHaveBeenCalled());
  91. expect(handleCloseModal).toHaveBeenCalled();
  92. });
  93. });