releaseContext.spec.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import {Organization} from 'sentry-fixture/organization';
  2. import {makeTestQueryClient} from 'sentry-test/queryClient';
  3. import {render, screen, within} from 'sentry-test/reactTestingLibrary';
  4. import ConfigStore from 'sentry/stores/configStore';
  5. import {QueryClientProvider} from 'sentry/utils/queryClient';
  6. import ReleaseContext from './releaseContext';
  7. import {defaultRow, mockedCommit, mockedUser1, mockedUser2} from './testUtils';
  8. export const mockedReleaseWithHealth = TestStubs.Release({
  9. id: '1',
  10. shortVersion: 'sentry-android-shop@1.2.0',
  11. version: 'sentry-android-shop@1.2.0',
  12. dateCreated: '2010-05-17T02:41:20Z',
  13. lastEvent: '2011-10-17T02:41:20Z',
  14. firstEvent: '2010-05-17T02:41:20Z',
  15. status: 'open',
  16. commitCount: 4,
  17. lastCommit: mockedCommit,
  18. newGroups: 21,
  19. authors: [mockedUser1, mockedUser2],
  20. });
  21. const renderReleaseContext = () => {
  22. const organization = Organization();
  23. render(
  24. <QueryClientProvider client={makeTestQueryClient()}>
  25. <ReleaseContext dataRow={defaultRow} organization={organization} />
  26. </QueryClientProvider>,
  27. {organization}
  28. );
  29. };
  30. describe('Quick Context Content Release Column', function () {
  31. beforeEach(() => {
  32. MockApiClient.addMockResponse({
  33. url: '/organizations/org-slug/releases/backend@22.10.0+aaf33944f93dc8fa4234ca046a8d88fb1dccfb76/',
  34. body: mockedReleaseWithHealth,
  35. });
  36. });
  37. afterEach(() => {
  38. MockApiClient.clearMockResponses();
  39. });
  40. it('Renders Release details for release', async () => {
  41. renderReleaseContext();
  42. expect(await screen.findByText(/Created/i)).toBeInTheDocument();
  43. expect(screen.getByText(/7 years ago/i)).toBeInTheDocument();
  44. expect(screen.getByText(/Last Event/i)).toBeInTheDocument();
  45. expect(screen.getByText(/6 years ago/i)).toBeInTheDocument();
  46. expect(screen.getByText(/New Issues/i)).toBeInTheDocument();
  47. expect(screen.getByText(/21/i)).toBeInTheDocument();
  48. });
  49. it('Renders Last Commit', async () => {
  50. renderReleaseContext();
  51. expect(await screen.findByText(/Last Commit/i)).toBeInTheDocument();
  52. expect(screen.getByTestId('quick-context-commit-row')).toBeInTheDocument();
  53. });
  54. it('Renders Commit Count and Author when user is NOT in list of authors', async () => {
  55. renderReleaseContext();
  56. const authorsSectionHeader = within(
  57. await screen.findByTestId('quick-context-release-author-header')
  58. );
  59. expect(authorsSectionHeader.getByText(/4/i)).toBeInTheDocument();
  60. expect(authorsSectionHeader.getByText(/commits by/i)).toBeInTheDocument();
  61. expect(authorsSectionHeader.getByText(/2/i)).toBeInTheDocument();
  62. expect(authorsSectionHeader.getByText(/authors/i)).toBeInTheDocument();
  63. expect(screen.getByText(/KN/i)).toBeInTheDocument();
  64. expect(screen.getByText(/VN/i)).toBeInTheDocument();
  65. });
  66. it('Renders Commit Count and Author when user is in list of authors', async () => {
  67. jest.spyOn(ConfigStore, 'get').mockImplementation(() => mockedUser1);
  68. renderReleaseContext();
  69. expect(await screen.findByText(/4/i)).toBeInTheDocument();
  70. expect(screen.getByText(/commits by you and 1 other/i)).toBeInTheDocument();
  71. expect(screen.getByText(/KN/i)).toBeInTheDocument();
  72. expect(screen.getByText(/VN/i)).toBeInTheDocument();
  73. });
  74. });