reprocessEventModal.spec.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import {mountGlobalModal} from 'sentry-test/modal';
  2. import {openReprocessEventModal} from 'sentry/actionCreators/modal';
  3. import ModalStore from 'sentry/stores/modalStore';
  4. const group = TestStubs.Group({
  5. id: '1337',
  6. pluginActions: [],
  7. pluginIssues: [],
  8. });
  9. const organization = TestStubs.Organization({
  10. id: '4660',
  11. slug: 'org',
  12. features: ['reprocessing-v2'],
  13. });
  14. async function mountComponent() {
  15. const modal = await mountGlobalModal();
  16. openReprocessEventModal({organization, groupId: group.id});
  17. await tick();
  18. await tick();
  19. modal.update();
  20. return modal;
  21. }
  22. describe('ReprocessEventModal', function () {
  23. let wrapper: any;
  24. beforeEach(async function () {
  25. wrapper = await mountComponent();
  26. });
  27. it('modal is open', () => {
  28. expect(wrapper.find('Header').text()).toEqual('Reprocess Events');
  29. });
  30. it('form fields & info', () => {
  31. // some info about reprocessing
  32. const introduction = wrapper.find('Introduction');
  33. expect(introduction).toBeTruthy();
  34. expect(introduction).toHaveLength(2);
  35. // Reprocess impacts
  36. expect(introduction.at(0).text()).toEqual(
  37. 'Reprocessing applies new debug files and grouping enhancements to this Issue. Please consider these impacts:'
  38. );
  39. const impacts = wrapper.find('StyledList');
  40. expect(impacts).toBeTruthy();
  41. expect(impacts.length).toBeGreaterThan(0);
  42. // Docs info
  43. expect(introduction.at(1).text()).toEqual(
  44. 'For more information, please refer to the documentation.'
  45. );
  46. // Form
  47. const form = wrapper.find('Form');
  48. expect(form).toBeTruthy();
  49. // Number of events to be reprocessed field
  50. const reprocessQuantityField = form.find('NumberField');
  51. expect(reprocessQuantityField).toBeTruthy();
  52. // Remaining events action field
  53. const remainingEventsActionField = form.find('RadioField');
  54. expect(remainingEventsActionField).toBeTruthy();
  55. });
  56. it('reprocess all events', async () => {
  57. MockApiClient.addMockResponse({
  58. url: `/organizations/${organization.slug}/issues/${group.id}/reprocessing/`,
  59. method: 'POST',
  60. body: [],
  61. });
  62. jest.spyOn(window.location, 'reload').mockImplementation(() => {});
  63. const closeModalFunc = jest.spyOn(ModalStore, 'closeModal');
  64. // Number of events to be reprocessed field
  65. const reprocessQuantityField = wrapper.find('NumberField input');
  66. expect(reprocessQuantityField.props().placeholder).toEqual('Reprocess all events');
  67. expect(reprocessQuantityField.props().value).toEqual(undefined);
  68. const submitButton = wrapper.find('[data-test-id="form-submit"]').hostNodes();
  69. submitButton.simulate('submit');
  70. await tick();
  71. wrapper.update();
  72. expect(window.location.reload).toHaveBeenCalled();
  73. expect(closeModalFunc).toHaveBeenCalled();
  74. });
  75. });