customResolutionModal.spec.jsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. });
  17. it('can select a version', async () => {
  18. const onSelected = jest.fn();
  19. render(
  20. <CustomResolutionModal
  21. Header={p => p.children}
  22. Body={p => p.children}
  23. Footer={p => p.children}
  24. orgSlug="org-slug"
  25. projectSlug="project-slug"
  26. onSelected={onSelected}
  27. closeModal={jest.fn()}
  28. />
  29. );
  30. expect(releasesMock).toHaveBeenCalled();
  31. selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
  32. expect(await screen.findByText('1.2.0')).toBeInTheDocument();
  33. userEvent.click(screen.getByText('1.2.0'));
  34. userEvent.click(screen.getByText('Save Changes'));
  35. expect(onSelected).toHaveBeenCalledWith({
  36. inRelease: 'sentry-android-shop@1.2.0',
  37. });
  38. });
  39. it('indicates which releases had commits from the user', async () => {
  40. const user = TestStubs.User();
  41. ConfigStore.set('user', user);
  42. render(
  43. <CustomResolutionModal
  44. Header={p => p.children}
  45. Body={p => p.children}
  46. Footer={p => p.children}
  47. orgSlug="org-slug"
  48. projectSlug="project-slug"
  49. closeModal={jest.fn()}
  50. />
  51. );
  52. expect(releasesMock).toHaveBeenCalled();
  53. selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
  54. expect(await screen.findByText(/You committed/)).toBeInTheDocument();
  55. });
  56. });