import selectEvent from 'react-select-event'; import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; import CustomResolutionModal from 'sentry/components/customResolutionModal'; import ConfigStore from 'sentry/stores/configStore'; describe('CustomResolutionModal', () => { let releasesMock; beforeEach(() => { ConfigStore.init(); releasesMock = MockApiClient.addMockResponse({ url: '/projects/org-slug/project-slug/releases/', body: [TestStubs.Release({authors: [TestStubs.User()]})], }); }); afterEach(() => { MockApiClient.clearMockResponses(); }); it('can select a version', async () => { const onSelected = jest.fn(); render( p.children} Body={p => p.children} Footer={p => p.children} orgSlug="org-slug" projectSlug="project-slug" onSelected={onSelected} closeModal={jest.fn()} /> ); expect(releasesMock).toHaveBeenCalled(); selectEvent.openMenu(screen.getByText('e.g. 1.0.4')); expect(await screen.findByText('1.2.0')).toBeInTheDocument(); userEvent.click(screen.getByText('1.2.0')); userEvent.click(screen.getByText('Save Changes')); expect(onSelected).toHaveBeenCalledWith({ inRelease: 'sentry-android-shop@1.2.0', }); }); it('indicates which releases had commits from the user', async () => { const user = TestStubs.User(); ConfigStore.set('user', user); render( p.children} Body={p => p.children} Footer={p => p.children} orgSlug="org-slug" projectSlug="project-slug" closeModal={jest.fn()} /> ); expect(releasesMock).toHaveBeenCalled(); selectEvent.openMenu(screen.getByText('e.g. 1.0.4')); expect(await screen.findByText(/You committed/)).toBeInTheDocument(); }); });