reprocessEventModal.spec.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
  3. import {textWithMarkupMatcher} from 'sentry-test/utils';
  4. import {
  5. makeClosableHeader,
  6. makeCloseButton,
  7. ModalBody,
  8. ModalFooter,
  9. } from 'sentry/components/globalModal/components';
  10. import {ReprocessingEventModal} from 'sentry/components/modals/reprocessEventModal';
  11. const group = TestStubs.Group({
  12. id: '1337',
  13. pluginActions: [],
  14. pluginIssues: [],
  15. });
  16. describe('ReprocessEventModal', function () {
  17. it('form fields & info', function () {
  18. const {organization} = initializeOrg({
  19. organization: {
  20. id: '4660',
  21. slug: 'org',
  22. features: ['reprocessing-v2'],
  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. features: ['reprocessing-v2'],
  65. },
  66. });
  67. MockApiClient.addMockResponse({
  68. url: `/organizations/${organization.slug}/issues/${group.id}/reprocessing/`,
  69. method: 'POST',
  70. body: [],
  71. });
  72. jest.spyOn(window.location, 'reload').mockImplementation(() => {});
  73. const handleCloseModal = jest.fn();
  74. render(
  75. <ReprocessingEventModal
  76. Body={ModalBody}
  77. closeModal={handleCloseModal}
  78. CloseButton={makeCloseButton(jest.fn())}
  79. Header={makeClosableHeader(jest.fn())}
  80. Footer={ModalFooter}
  81. groupId="1337"
  82. organization={organization}
  83. />
  84. );
  85. expect(screen.getByRole('heading', {name: 'Reprocess Events'})).toBeInTheDocument();
  86. // Number of events to be reprocessed field
  87. expect(
  88. screen.getByRole('spinbutton', {name: 'Number of events to be reprocessed'})
  89. ).toHaveAttribute('placeholder', 'Reprocess all events');
  90. await userEvent.click(screen.getByRole('button', {name: 'Reprocess Events'}));
  91. await waitFor(() => expect(window.location.reload).toHaveBeenCalled());
  92. expect(handleCloseModal).toHaveBeenCalled();
  93. });
  94. });