issueContext.spec.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import {GroupStatus} from 'sentry/types/group';
  6. import type {EventData} from 'sentry/utils/discover/eventView';
  7. import IssueContext from './issueContext';
  8. import {defaultRow} from './testUtils';
  9. const mockedGroup = GroupFixture({
  10. id: '3512441874',
  11. project: ProjectFixture({
  12. id: '1',
  13. slug: 'cool-team',
  14. }),
  15. status: GroupStatus.IGNORED,
  16. assignedTo: {
  17. id: '12312',
  18. name: 'ingest',
  19. type: 'team',
  20. },
  21. count: '2500000',
  22. userCount: 64000,
  23. title: 'typeError: error description',
  24. });
  25. const renderIssueContext = (dataRow: EventData = defaultRow) => {
  26. const organization = OrganizationFixture();
  27. render(<IssueContext dataRow={dataRow} organization={organization} />, {organization});
  28. };
  29. describe('Quick Context Content Issue Column', function () {
  30. beforeEach(() => {
  31. MockApiClient.addMockResponse({
  32. url: '/organizations/org-slug/issues/3512441874/',
  33. method: 'GET',
  34. body: mockedGroup,
  35. });
  36. });
  37. afterEach(function () {
  38. MockApiClient.clearMockResponses();
  39. });
  40. it('Renders ignored issue status context', async () => {
  41. renderIssueContext();
  42. expect(await screen.findByText(/Issue Status/i)).toBeInTheDocument();
  43. expect(screen.getByText(/Ignored/i)).toBeInTheDocument();
  44. expect(screen.getByTestId('quick-context-ignored-icon')).toBeInTheDocument();
  45. });
  46. it('Renders resolved issue status context', async () => {
  47. const group = {...mockedGroup, status: GroupStatus.RESOLVED};
  48. MockApiClient.addMockResponse({
  49. url: '/organizations/org-slug/issues/3512441874/',
  50. method: 'GET',
  51. body: group,
  52. });
  53. renderIssueContext();
  54. expect(await screen.findByText(/Issue Status/i)).toBeInTheDocument();
  55. expect(screen.getByText(/Resolved/i)).toBeInTheDocument();
  56. expect(screen.getByTestId('icon-check-mark')).toBeInTheDocument();
  57. });
  58. it('Renders unresolved issue status context', async () => {
  59. const group = {...mockedGroup, status: GroupStatus.UNRESOLVED};
  60. MockApiClient.addMockResponse({
  61. url: '/organizations/org-slug/issues/3512441874/',
  62. method: 'GET',
  63. body: group,
  64. });
  65. renderIssueContext();
  66. expect(await screen.findByText(/Issue Status/i)).toBeInTheDocument();
  67. expect(screen.getByText(/Unresolved/i)).toBeInTheDocument();
  68. expect(screen.getByTestId('quick-context-unresolved-icon')).toBeInTheDocument();
  69. });
  70. it('Renders event and user counts', async () => {
  71. renderIssueContext();
  72. expect(await screen.findByText(/Events/i)).toBeInTheDocument();
  73. expect(screen.getByText(/2.5m/i)).toBeInTheDocument();
  74. expect(screen.getByText(/Users/i)).toBeInTheDocument();
  75. expect(screen.getByText(/64k/i)).toBeInTheDocument();
  76. });
  77. it('Renders assigned to context', async () => {
  78. renderIssueContext();
  79. expect(await screen.findByText(/Assigned To/i)).toBeInTheDocument();
  80. expect(screen.getByText(/#ingest/i)).toBeInTheDocument();
  81. });
  82. it('Renders title', async () => {
  83. renderIssueContext();
  84. expect(await screen.findByText(/Title/i)).toBeInTheDocument();
  85. expect(screen.getByText(/typeError: error description/i)).toBeInTheDocument();
  86. });
  87. });