123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- import {EventFixture} from 'sentry-fixture/event';
- import {EventEntryStacktraceFixture} from 'sentry-fixture/eventEntryStacktrace';
- import {MembersFixture} from 'sentry-fixture/members';
- import {OrganizationFixture} from 'sentry-fixture/organization';
- import {ProjectFixture} from 'sentry-fixture/project';
- import {UserFixture} from 'sentry-fixture/user';
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import ConfigStore from 'sentry/stores/configStore';
- import ProjectOwnershipModal from './modal';
- describe('Project Ownership', () => {
- const org = OrganizationFixture();
- const project = ProjectFixture();
- const issueId = '1234';
- const stacktrace = EventEntryStacktraceFixture();
- const event = EventFixture({
- entries: [stacktrace],
- });
- const user = UserFixture();
- beforeEach(() => {
- ConfigStore.set('user', user);
- MockApiClient.addMockResponse({
- url: `/issues/${issueId}/tags/url/`,
- body: {
- key: 'url',
- name: 'URL',
- uniqueValues: 1,
- totalValues: 1,
- topValues: [
- {
- key: 'url',
- name: 'https://example.com/path',
- value: 'https://example.com/path',
- count: 1,
- lastSeen: '2022-08-27T03:24:53Z',
- firstSeen: '2022-08-27T03:24:53Z',
- },
- ],
- },
- });
- MockApiClient.addMockResponse({
- url: `/projects/${org.slug}/${project.slug}/ownership/`,
- body: {
- fallthrough: false,
- autoAssignment: 'Auto Assign to Suspect Commits',
- codeownersAutoSync: false,
- raw: null,
- },
- });
- // Set one frame to in-app
- stacktrace.data.frames![0].inApp = true;
- MockApiClient.addMockResponse({
- url: `/organizations/${org.slug}/members/`,
- body: MembersFixture(),
- });
- });
- afterEach(() => {
- MockApiClient.clearMockResponses();
- });
- it('renders stacktrace suggestions', () => {
- render(
- <ProjectOwnershipModal
- issueId={issueId}
- organization={org}
- project={project}
- eventData={event}
- onCancel={() => {}}
- />
- );
- // Description
- expect(screen.getByText(/Assign issues based on custom rules/)).toBeInTheDocument();
- // Suggestions
- expect(
- screen.getByText(/Here’s some suggestions based on this issue/)
- ).toBeInTheDocument();
- expect(
- screen.getByText(`path:raven/base.py ${user.email}`, {exact: false})
- ).toBeInTheDocument();
- expect(
- screen.getByText(`url:*/path ${user.email}`, {exact: false})
- ).toBeInTheDocument();
- });
- it('can cancel', async () => {
- const onCancel = jest.fn();
- render(
- <ProjectOwnershipModal
- issueId={issueId}
- organization={org}
- project={project}
- eventData={event}
- onCancel={onCancel}
- />
- );
- // Cancel
- await userEvent.click(screen.getByText('Cancel'));
- expect(onCancel).toHaveBeenCalled();
- });
- });
|