customResolutionModal.spec.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import selectEvent from 'react-select-event';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import CustomResolutionModal from 'sentry/components/customResolutionModal';
  4. describe('CustomResolutionModal', () => {
  5. let releasesMock;
  6. beforeEach(() => {
  7. releasesMock = MockApiClient.addMockResponse({
  8. url: '/projects/org-slug/project-slug/releases/',
  9. body: [TestStubs.Release()],
  10. });
  11. });
  12. it('can select a version', async () => {
  13. const onSelected = jest.fn();
  14. render(
  15. <CustomResolutionModal
  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. expect(releasesMock).toHaveBeenCalled();
  26. selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
  27. expect(await screen.findByText('1.2.0')).toBeInTheDocument();
  28. userEvent.click(screen.getByText('1.2.0'));
  29. userEvent.click(screen.getByText('Save Changes'));
  30. expect(onSelected).toHaveBeenCalledWith({
  31. inRelease: 'sentry-android-shop@1.2.0',
  32. });
  33. });
  34. });