modal.spec.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProjectOwnershipModal from './modal';
  3. describe('Project Ownership', () => {
  4. const org = TestStubs.Organization();
  5. const project = TestStubs.ProjectDetails();
  6. const issueId = '1234';
  7. beforeEach(() => {
  8. MockApiClient.addMockResponse({
  9. url: `/issues/${issueId}/tags/url/`,
  10. body: {
  11. key: 'url',
  12. name: 'URL',
  13. uniqueValues: 1,
  14. totalValues: 1,
  15. topValues: [
  16. {
  17. key: 'url',
  18. name: 'https://example.com/path',
  19. value: 'https://example.com/path',
  20. count: 1,
  21. lastSeen: '2022-08-27T03:24:53Z',
  22. firstSeen: '2022-08-27T03:24:53Z',
  23. },
  24. ],
  25. },
  26. });
  27. MockApiClient.addMockResponse({
  28. url: `/projects/${org.slug}/${project.slug}/ownership/`,
  29. body: {
  30. fallthrough: false,
  31. autoAssignment: 'Auto Assign to Suspect Commits',
  32. codeownersAutoSync: false,
  33. raw: null,
  34. },
  35. });
  36. const stacktrace = TestStubs.EventEntryStacktrace();
  37. // Set one frame to in-app
  38. stacktrace.data.frames[0].inApp = true;
  39. MockApiClient.addMockResponse({
  40. url: `/issues/${issueId}/events/latest/`,
  41. body: TestStubs.Event({
  42. entries: [stacktrace],
  43. }),
  44. });
  45. MockApiClient.addMockResponse({
  46. url: `/organizations/${org.slug}/members/`,
  47. body: TestStubs.Members(),
  48. });
  49. });
  50. afterEach(() => {
  51. MockApiClient.clearMockResponses();
  52. });
  53. it('renders stacktrace suggestions', () => {
  54. render(
  55. <ProjectOwnershipModal
  56. issueId={issueId}
  57. organization={org}
  58. project={project}
  59. onSave={() => {}}
  60. />
  61. );
  62. expect(screen.getByText(/Match against Issue Data/)).toBeInTheDocument();
  63. // First in-app frame is suggested
  64. expect(screen.getByText('raven/base.py')).toBeInTheDocument();
  65. expect(screen.getByText('https://example.com/path')).toBeInTheDocument();
  66. });
  67. });