releaseContext.spec.tsx 3.4 KB

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