reprocessEventModal.spec.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. features: ['reprocessing-v2'],
  24. },
  25. });
  26. render(
  27. <ReprocessingEventModal
  28. Body={ModalBody}
  29. closeModal={jest.fn()}
  30. CloseButton={makeCloseButton(jest.fn())}
  31. Header={makeClosableHeader(jest.fn())}
  32. Footer={ModalFooter}
  33. groupId="1337"
  34. organization={organization}
  35. />
  36. );
  37. // Reprocess impacts
  38. expect(
  39. screen.getByText(
  40. 'Reprocessing applies new debug files and grouping enhancements to this Issue. Please consider these impacts:'
  41. )
  42. ).toBeInTheDocument();
  43. // Reprocess impacts list
  44. expect(screen.getAllByRole('listitem')).toHaveLength(3);
  45. // Docs info
  46. expect(
  47. screen.getByText(
  48. textWithMarkupMatcher('For more information, please refer to the documentation.')
  49. )
  50. ).toBeInTheDocument();
  51. // Number of events to be reprocessed field
  52. expect(
  53. screen.getByRole('spinbutton', {name: 'Number of events to be reprocessed'})
  54. ).toBeInTheDocument();
  55. // Remaining events action field
  56. expect(
  57. screen.getByRole('radiogroup', {name: 'Remaining events'})
  58. ).toBeInTheDocument();
  59. });
  60. it('reprocess all events', async function () {
  61. const {organization} = initializeOrg({
  62. organization: {
  63. id: '4660',
  64. slug: 'org',
  65. features: ['reprocessing-v2'],
  66. },
  67. });
  68. MockApiClient.addMockResponse({
  69. url: `/organizations/${organization.slug}/issues/${group.id}/reprocessing/`,
  70. method: 'POST',
  71. body: [],
  72. });
  73. jest.spyOn(window.location, 'reload').mockImplementation(() => {});
  74. const handleCloseModal = jest.fn();
  75. render(
  76. <ReprocessingEventModal
  77. Body={ModalBody}
  78. closeModal={handleCloseModal}
  79. CloseButton={makeCloseButton(jest.fn())}
  80. Header={makeClosableHeader(jest.fn())}
  81. Footer={ModalFooter}
  82. groupId="1337"
  83. organization={organization}
  84. />
  85. );
  86. expect(screen.getByRole('heading', {name: 'Reprocess Events'})).toBeInTheDocument();
  87. // Number of events to be reprocessed field
  88. expect(
  89. screen.getByRole('spinbutton', {name: 'Number of events to be reprocessed'})
  90. ).toHaveAttribute('placeholder', 'Reprocess all events');
  91. await userEvent.click(screen.getByRole('button', {name: 'Reprocess Events'}));
  92. await waitFor(() => expect(window.location.reload).toHaveBeenCalled());
  93. expect(handleCloseModal).toHaveBeenCalled();
  94. });
  95. });