|
@@ -1,7 +1,14 @@
|
|
|
-import {mountGlobalModal} from 'sentry-test/modal';
|
|
|
-
|
|
|
-import {openReprocessEventModal} from 'sentry/actionCreators/modal';
|
|
|
-import ModalStore from 'sentry/stores/modalStore';
|
|
|
+import {initializeOrg} from 'sentry-test/initializeOrg';
|
|
|
+import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
|
|
|
+import {textWithMarkupMatcher} from 'sentry-test/utils';
|
|
|
+
|
|
|
+import {
|
|
|
+ makeClosableHeader,
|
|
|
+ makeCloseButton,
|
|
|
+ ModalBody,
|
|
|
+ ModalFooter,
|
|
|
+} from 'sentry/components/globalModal/components';
|
|
|
+import {ReprocessingEventModal} from 'sentry/components/modals/reprocessEventModal';
|
|
|
|
|
|
const group = TestStubs.Group({
|
|
|
id: '1337',
|
|
@@ -9,68 +16,67 @@ const group = TestStubs.Group({
|
|
|
pluginIssues: [],
|
|
|
});
|
|
|
|
|
|
-const organization = TestStubs.Organization({
|
|
|
- id: '4660',
|
|
|
- slug: 'org',
|
|
|
- features: ['reprocessing-v2'],
|
|
|
-});
|
|
|
-
|
|
|
-async function mountComponent() {
|
|
|
- const modal = await mountGlobalModal();
|
|
|
-
|
|
|
- openReprocessEventModal({organization, groupId: group.id});
|
|
|
-
|
|
|
- await tick();
|
|
|
- await tick();
|
|
|
- modal.update();
|
|
|
-
|
|
|
- return modal;
|
|
|
-}
|
|
|
-
|
|
|
describe('ReprocessEventModal', function () {
|
|
|
- let wrapper: any;
|
|
|
-
|
|
|
- beforeEach(async function () {
|
|
|
- wrapper = await mountComponent();
|
|
|
- });
|
|
|
-
|
|
|
- it('modal is open', () => {
|
|
|
- expect(wrapper.find('Header').text()).toEqual('Reprocess Events');
|
|
|
- });
|
|
|
+ it('form fields & info', function () {
|
|
|
+ const {organization} = initializeOrg({
|
|
|
+ ...initializeOrg(),
|
|
|
+ organization: {
|
|
|
+ id: '4660',
|
|
|
+ slug: 'org',
|
|
|
+ features: ['reprocessing-v2'],
|
|
|
+ },
|
|
|
+ });
|
|
|
|
|
|
- it('form fields & info', () => {
|
|
|
- // some info about reprocessing
|
|
|
- const introduction = wrapper.find('Introduction');
|
|
|
- expect(introduction).toBeTruthy();
|
|
|
- expect(introduction).toHaveLength(2);
|
|
|
+ render(
|
|
|
+ <ReprocessingEventModal
|
|
|
+ Body={ModalBody}
|
|
|
+ closeModal={jest.fn()}
|
|
|
+ CloseButton={makeCloseButton(jest.fn())}
|
|
|
+ Header={makeClosableHeader(jest.fn())}
|
|
|
+ Footer={ModalFooter}
|
|
|
+ groupId="1337"
|
|
|
+ organization={organization}
|
|
|
+ />
|
|
|
+ );
|
|
|
|
|
|
// Reprocess impacts
|
|
|
- expect(introduction.at(0).text()).toEqual(
|
|
|
- 'Reprocessing applies new debug files and grouping enhancements to this Issue. Please consider these impacts:'
|
|
|
- );
|
|
|
- const impacts = wrapper.find('StyledList');
|
|
|
- expect(impacts).toBeTruthy();
|
|
|
- expect(impacts.length).toBeGreaterThan(0);
|
|
|
+ expect(
|
|
|
+ screen.getByText(
|
|
|
+ 'Reprocessing applies new debug files and grouping enhancements to this Issue. Please consider these impacts:'
|
|
|
+ )
|
|
|
+ ).toBeInTheDocument();
|
|
|
|
|
|
- // Docs info
|
|
|
- expect(introduction.at(1).text()).toEqual(
|
|
|
- 'For more information, please refer to the documentation.'
|
|
|
- );
|
|
|
+ // Reprocess impacts list
|
|
|
+ expect(screen.getAllByRole('listitem')).toHaveLength(3);
|
|
|
|
|
|
- // Form
|
|
|
- const form = wrapper.find('Form');
|
|
|
- expect(form).toBeTruthy();
|
|
|
+ // Docs info
|
|
|
+ expect(
|
|
|
+ screen.getByText(
|
|
|
+ textWithMarkupMatcher('For more information, please refer to the documentation.')
|
|
|
+ )
|
|
|
+ ).toBeInTheDocument();
|
|
|
|
|
|
// Number of events to be reprocessed field
|
|
|
- const reprocessQuantityField = form.find('NumberField');
|
|
|
- expect(reprocessQuantityField).toBeTruthy();
|
|
|
+ expect(
|
|
|
+ screen.getByRole('spinbutton', {name: 'Number of events to be reprocessed'})
|
|
|
+ ).toBeInTheDocument();
|
|
|
|
|
|
// Remaining events action field
|
|
|
- const remainingEventsActionField = form.find('RadioField');
|
|
|
- expect(remainingEventsActionField).toBeTruthy();
|
|
|
+ expect(
|
|
|
+ screen.getByRole('radiogroup', {name: 'Remaining events'})
|
|
|
+ ).toBeInTheDocument();
|
|
|
});
|
|
|
|
|
|
- it('reprocess all events', async () => {
|
|
|
+ it('reprocess all events', async function () {
|
|
|
+ const {organization} = initializeOrg({
|
|
|
+ ...initializeOrg(),
|
|
|
+ organization: {
|
|
|
+ id: '4660',
|
|
|
+ slug: 'org',
|
|
|
+ features: ['reprocessing-v2'],
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
MockApiClient.addMockResponse({
|
|
|
url: `/organizations/${organization.slug}/issues/${group.id}/reprocessing/`,
|
|
|
method: 'POST',
|
|
@@ -78,21 +84,30 @@ describe('ReprocessEventModal', function () {
|
|
|
});
|
|
|
|
|
|
jest.spyOn(window.location, 'reload').mockImplementation(() => {});
|
|
|
- const closeModalFunc = jest.spyOn(ModalStore, 'closeModal');
|
|
|
-
|
|
|
- // Number of events to be reprocessed field
|
|
|
- const reprocessQuantityField = wrapper.find('NumberField input');
|
|
|
- expect(reprocessQuantityField.props().placeholder).toEqual('Reprocess all events');
|
|
|
- expect(reprocessQuantityField.props().value).toEqual(undefined);
|
|
|
+ const handleCloseModal = jest.fn();
|
|
|
+
|
|
|
+ render(
|
|
|
+ <ReprocessingEventModal
|
|
|
+ Body={ModalBody}
|
|
|
+ closeModal={handleCloseModal}
|
|
|
+ CloseButton={makeCloseButton(jest.fn())}
|
|
|
+ Header={makeClosableHeader(jest.fn())}
|
|
|
+ Footer={ModalFooter}
|
|
|
+ groupId="1337"
|
|
|
+ organization={organization}
|
|
|
+ />
|
|
|
+ );
|
|
|
|
|
|
- const submitButton = wrapper.find('[data-test-id="form-submit"]').hostNodes();
|
|
|
+ expect(screen.getByRole('heading', {name: 'Reprocess Events'})).toBeInTheDocument();
|
|
|
|
|
|
- submitButton.simulate('submit');
|
|
|
+ // Number of events to be reprocessed field
|
|
|
+ expect(
|
|
|
+ screen.getByRole('spinbutton', {name: 'Number of events to be reprocessed'})
|
|
|
+ ).toHaveAttribute('placeholder', 'Reprocess all events');
|
|
|
|
|
|
- await tick();
|
|
|
- wrapper.update();
|
|
|
+ userEvent.click(screen.getByRole('button', {name: 'Reprocess Events'}));
|
|
|
|
|
|
- expect(window.location.reload).toHaveBeenCalled();
|
|
|
- expect(closeModalFunc).toHaveBeenCalled();
|
|
|
+ await waitFor(() => expect(window.location.reload).toHaveBeenCalled());
|
|
|
+ expect(handleCloseModal).toHaveBeenCalled();
|
|
|
});
|
|
|
});
|