customResolutionModal.spec.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import selectEvent from 'react-select-event';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import CustomResolutionModal from 'sentry/components/customResolutionModal';
  4. import ConfigStore from 'sentry/stores/configStore';
  5. describe('CustomResolutionModal', () => {
  6. let releasesMock;
  7. beforeEach(() => {
  8. ConfigStore.init();
  9. releasesMock = MockApiClient.addMockResponse({
  10. url: '/projects/org-slug/project-slug/releases/',
  11. body: [TestStubs.Release({authors: [TestStubs.User()]})],
  12. });
  13. });
  14. afterEach(() => {
  15. MockApiClient.clearMockResponses();
  16. ConfigStore.teardown();
  17. });
  18. it('can select a version', async () => {
  19. const onSelected = jest.fn();
  20. render(
  21. <CustomResolutionModal
  22. Header={p => p.children}
  23. Body={p => p.children}
  24. Footer={p => p.children}
  25. orgSlug="org-slug"
  26. projectSlug="project-slug"
  27. onSelected={onSelected}
  28. closeModal={jest.fn()}
  29. />
  30. );
  31. expect(releasesMock).toHaveBeenCalled();
  32. selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
  33. expect(await screen.findByText('1.2.0')).toBeInTheDocument();
  34. userEvent.click(screen.getByText('1.2.0'));
  35. userEvent.click(screen.getByText('Save Changes'));
  36. expect(onSelected).toHaveBeenCalledWith({
  37. inRelease: 'sentry-android-shop@1.2.0',
  38. });
  39. });
  40. it('indicates which releases had commits from the user', async () => {
  41. const user = TestStubs.User();
  42. ConfigStore.set('user', user);
  43. render(
  44. <CustomResolutionModal
  45. Header={p => p.children}
  46. Body={p => p.children}
  47. Footer={p => p.children}
  48. orgSlug="org-slug"
  49. projectSlug="project-slug"
  50. closeModal={jest.fn()}
  51. />
  52. );
  53. expect(releasesMock).toHaveBeenCalled();
  54. selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
  55. expect(await screen.findByText(/You committed/)).toBeInTheDocument();
  56. });
  57. });