customCommitsResolutionModal.spec.jsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import selectEvent from 'react-select-event';
  2. import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import CustomCommitsResolutionModal from 'sentry/components/customCommitsResolutionModal';
  4. describe('CustomCommitsResolutionModal', function () {
  5. let commitsMock;
  6. beforeEach(function () {
  7. commitsMock = MockApiClient.addMockResponse({
  8. url: '/projects/org-slug/project-slug/commits/',
  9. body: [TestStubs.Commit()],
  10. });
  11. });
  12. it('can select a commit', async function () {
  13. const onSelected = jest.fn();
  14. render(
  15. <CustomCommitsResolutionModal
  16. Header={p => p.children}
  17. Body={p => p.children}
  18. Footer={p => p.children}
  19. orgSlug="org-slug"
  20. projectSlug="project-slug"
  21. onSelected={onSelected}
  22. closeModal={jest.fn()}
  23. />
  24. );
  25. await act(tick);
  26. expect(commitsMock).toHaveBeenCalled();
  27. await selectEvent.select(screen.getByText('e.g. d86b832'), 'f7f395d14b2f');
  28. userEvent.click(screen.getByRole('button', {name: 'Save Changes'}));
  29. expect(onSelected).toHaveBeenCalledWith({
  30. inCommit: {
  31. commit: 'f7f395d14b2fe29a4e253bf1d3094d61e6ad4434',
  32. repository: 'example/repo-name',
  33. },
  34. });
  35. });
  36. });