Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions static/app/components/actions/resolve.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
userEvent,
within,
} from 'sentry-test/reactTestingLibrary';
import selectEvent from 'sentry-test/selectEvent';

import ResolveActions from 'sentry/components/actions/resolve';

Expand Down Expand Up @@ -169,9 +168,10 @@ describe('ResolveActions', () => {
await userEvent.click(screen.getByLabelText('More resolve options'));
await userEvent.click(screen.getByText('Another existing release…'));

await selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
expect(await screen.findByText('1.2.0')).toBeInTheDocument();
await userEvent.click(screen.getByText('1.2.0'));
const versionTrigger = screen.getByRole('button', {name: /version/i});
await userEvent.click(versionTrigger);
const option = await screen.findByRole('option', {name: /1\.2\.0/});
await userEvent.click(option);

const modal = screen.getByRole('dialog');
await userEvent.click(within(modal).getByRole('button', {name: 'Resolve'}));
Expand Down
1 change: 0 additions & 1 deletion static/app/components/actions/resolve.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ function ResolveActions({
onSelected={(statusDetails: ResolvedStatusDetails) =>
handleAnotherExistingReleaseResolution(statusDetails)
}
organization={organization}
projectSlug={projectSlug}
/>
));
Comment on lines 340 to 345

This comment was marked as outdated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modal has OrganizationContext now

Expand Down
87 changes: 74 additions & 13 deletions static/app/components/customResolutionModal.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import styled from '@emotion/styled';
import {OrganizationFixture} from 'sentry-fixture/organization';
import {ReleaseFixture} from 'sentry-fixture/release';
import {UserFixture} from 'sentry-fixture/user';

import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
import selectEvent from 'sentry-test/selectEvent';

import CustomResolutionModal from 'sentry/components/customResolutionModal';
import {makeCloseButton} from 'sentry/components/globalModal/components';
import ConfigStore from 'sentry/stores/configStore';

describe('CustomResolutionModal', () => {
let releasesMock: any;
const organization = OrganizationFixture();
beforeEach(() => {
ConfigStore.init();
releasesMock = MockApiClient.addMockResponse({
Expand All @@ -34,7 +31,6 @@ describe('CustomResolutionModal', () => {
Header={p => <span>{p.children}</span>}
Body={wrapper()}
Footer={wrapper()}
organization={organization}
projectSlug="project-slug"
onSelected={onSelected}
closeModal={jest.fn()}
Expand All @@ -43,9 +39,10 @@ describe('CustomResolutionModal', () => {
);
expect(releasesMock).toHaveBeenCalled();

await selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
expect(await screen.findByText('1.2.0')).toBeInTheDocument();
await userEvent.click(screen.getByText('1.2.0'));
const trigger = screen.getByRole('button', {name: /version/i});
await userEvent.click(trigger);
const option = await screen.findByRole('option', {name: /1\.2\.0/i});
await userEvent.click(option);

await userEvent.click(screen.getByText('Resolve'));
expect(onSelected).toHaveBeenCalledWith({
Expand All @@ -61,7 +58,6 @@ describe('CustomResolutionModal', () => {
Header={p => <span>{p.children}</span>}
Body={wrapper()}
Footer={wrapper()}
organization={organization}
projectSlug="project-slug"
onSelected={jest.fn()}
closeModal={jest.fn()}
Expand All @@ -70,7 +66,8 @@ describe('CustomResolutionModal', () => {
);
expect(releasesMock).toHaveBeenCalled();

await selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
const trigger = screen.getByRole('button', {name: /version/i});
await userEvent.click(trigger);
expect(await screen.findByText(/You committed/)).toBeInTheDocument();
});

Expand Down Expand Up @@ -112,20 +109,84 @@ describe('CustomResolutionModal', () => {
Header={p => <span>{p.children}</span>}
Body={wrapper()}
Footer={wrapper()}
organization={organization}
projectSlug="project-slug"
onSelected={jest.fn()}
closeModal={jest.fn()}
CloseButton={makeCloseButton(() => null)}
/>
);

await selectEvent.openMenu(screen.getByText('e.g. 1.0.4'));
const trigger = screen.getByRole('button', {name: /version/i});
await userEvent.click(trigger);
expect(
await screen.findByRole('menuitemradio', {name: 'abcdef (non-semver)'})
await screen.findByRole('option', {name: 'abcdef (non-semver)'})
).toBeInTheDocument();
expect(screen.getByRole('option', {name: '1.2.3 (semver)'})).toBeInTheDocument();
});

it('shows an inline error when submitting with no selection', async () => {
const onSelected = jest.fn();
render(
<CustomResolutionModal
Header={p => <span>{p.children}</span>}
Body={wrapper()}
Footer={wrapper()}
projectSlug="project-slug"
onSelected={onSelected}
closeModal={jest.fn()}
CloseButton={makeCloseButton(() => null)}
/>
);

await userEvent.click(screen.getByRole('button', {name: /resolve/i}));
expect(await screen.findByText('Please select a release.')).toBeInTheDocument();
expect(onSelected).not.toHaveBeenCalled();

// selecting clears the error
const trigger = screen.getByRole('button', {name: /version/i});
await userEvent.click(trigger);
const option = await screen.findByRole('option', {name: /1\.2\.0/i});
await userEvent.click(option);
expect(screen.queryByText('Please select a release.')).not.toBeInTheDocument();
});

it('prepends exact-match release even if not in list and avoids duplicates', async () => {
MockApiClient.addMockResponse({
url: '/organizations/org-slug/releases/',
match: [MockApiClient.matchQuery({query: 'search-me@3.0.0'})],
body: [ReleaseFixture({version: 'other@2.0.0'})],
});
MockApiClient.addMockResponse({
url: `/organizations/org-slug/releases/${encodeURIComponent('search-me@3.0.0')}/`,
body: ReleaseFixture({version: 'search-me@3.0.0'}),
});

render(
<CustomResolutionModal
Header={p => <span>{p.children}</span>}
Body={wrapper()}
Footer={wrapper()}
projectSlug="project-slug"
onSelected={jest.fn()}
closeModal={jest.fn()}
CloseButton={makeCloseButton(() => null)}
/>
);

const trigger = screen.getByRole('button', {name: /version/i});
await userEvent.click(trigger);
const searchInput = await screen.findByRole('textbox');
await userEvent.click(searchInput);
await userEvent.paste('search-me@3.0.0');

expect(
screen.getByRole('menuitemradio', {name: '1.2.3 (semver)'})
await screen.findByRole('option', {name: /sentry-android-shop.*3\.0\.0/i})
).toBeInTheDocument();

// Ensure no duplicates
const matches = screen.getAllByRole('option', {
name: /sentry-android-shop.*3\.0\.0/i,
});
expect(matches).toHaveLength(1);
});
});
Loading
Loading