releaseContext.spec.tsx 3.4 KB

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