assigneeSelector.spec.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {ActorFixture} from 'sentry-fixture/actor';
  2. import {EventFixture} from 'sentry-fixture/event';
  3. import {GroupFixture} from 'sentry-fixture/group';
  4. import {MemberFixture} from 'sentry-fixture/member';
  5. import {OrganizationFixture} from 'sentry-fixture/organization';
  6. import {ProjectFixture} from 'sentry-fixture/project';
  7. import {UserFixture} from 'sentry-fixture/user';
  8. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  9. import type {EventOwners} from 'sentry/components/group/assignedTo';
  10. import MemberListStore from 'sentry/stores/memberListStore';
  11. import type {Committer} from 'sentry/types/integrations';
  12. import {GroupHeaderAssigneeSelector} from './assigneeSelector';
  13. describe('GroupHeaderAssigneeSelector', () => {
  14. const organization = OrganizationFixture();
  15. const group = GroupFixture();
  16. const project = ProjectFixture();
  17. const event = EventFixture();
  18. beforeEach(() => {
  19. MemberListStore.reset();
  20. });
  21. it('should render suggested assignees', async () => {
  22. const commitUser = UserFixture({id: '91', email: 'frodo@sentry.io', name: 'Frodo'});
  23. const committer: Committer = {
  24. author: commitUser,
  25. commits: [],
  26. };
  27. const ownerActor = ActorFixture({id: '101', email: 'sam@sentry.io', name: 'Sam'});
  28. const eventOwners: EventOwners = {
  29. owners: [ownerActor],
  30. rule: ['codeowners', '/issues'],
  31. rules: [[['codeowners', '/issues'], [['user', ownerActor.email!]]]],
  32. };
  33. MockApiClient.addMockResponse({
  34. url: `/projects/${organization.slug}/${project.slug}/events/${event.id}/owners/`,
  35. body: eventOwners,
  36. });
  37. MockApiClient.addMockResponse({
  38. url: `/projects/${organization.slug}/${project.slug}/events/${event.id}/committers/`,
  39. body: {committers: [committer]},
  40. });
  41. MockApiClient.addMockResponse({
  42. url: `/organizations/${organization.slug}/users/`,
  43. body: [
  44. MemberFixture({user: commitUser}),
  45. MemberFixture({user: UserFixture({...ownerActor})}),
  46. ],
  47. });
  48. render(<GroupHeaderAssigneeSelector group={group} project={project} event={event} />);
  49. await userEvent.click(await screen.findByLabelText('Modify issue assignee'));
  50. expect(await screen.findByText(commitUser.name)).toBeInTheDocument();
  51. expect(screen.getByText('Suspect commit author')).toBeInTheDocument();
  52. expect(screen.getByText(ownerActor.name)).toBeInTheDocument();
  53. expect(screen.getByText('Codeowners:/issues')).toBeInTheDocument();
  54. });
  55. });