releaseContext.spec.tsx 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/${encodeURIComponent(
  34. 'backend@22.10.0+aaf33944f93dc8fa4234ca046a8d88fb1dccfb76'
  35. )}/`,
  36. body: mockedReleaseWithHealth,
  37. });
  38. });
  39. afterEach(() => {
  40. MockApiClient.clearMockResponses();
  41. });
  42. it('Renders Release details for release', async () => {
  43. renderReleaseContext();
  44. expect(await screen.findByText(/Created/i)).toBeInTheDocument();
  45. expect(screen.getByText(/7 years ago/i)).toBeInTheDocument();
  46. expect(screen.getByText(/Last Event/i)).toBeInTheDocument();
  47. expect(screen.getByText(/6 years ago/i)).toBeInTheDocument();
  48. expect(screen.getByText(/New Issues/i)).toBeInTheDocument();
  49. expect(screen.getByText(/21/i)).toBeInTheDocument();
  50. });
  51. it('Renders Last Commit', async () => {
  52. renderReleaseContext();
  53. expect(await screen.findByText(/Last Commit/i)).toBeInTheDocument();
  54. expect(screen.getByTestId('quick-context-commit-row')).toBeInTheDocument();
  55. });
  56. it('Renders Commit Count and Author when user is NOT in list of authors', async () => {
  57. renderReleaseContext();
  58. const authorsSectionHeader = within(
  59. await screen.findByTestId('quick-context-release-author-header')
  60. );
  61. expect(authorsSectionHeader.getByText(/4/i)).toBeInTheDocument();
  62. expect(authorsSectionHeader.getByText(/commits by/i)).toBeInTheDocument();
  63. expect(authorsSectionHeader.getByText(/2/i)).toBeInTheDocument();
  64. expect(authorsSectionHeader.getByText(/authors/i)).toBeInTheDocument();
  65. expect(screen.getByText(/KN/i)).toBeInTheDocument();
  66. expect(screen.getByText(/VN/i)).toBeInTheDocument();
  67. });
  68. it('Renders Commit Count and Author when user is in list of authors', async () => {
  69. jest.spyOn(ConfigStore, 'get').mockImplementation(() => mockedUser1);
  70. renderReleaseContext();
  71. expect(await screen.findByText(/4/i)).toBeInTheDocument();
  72. expect(screen.getByText(/commits by you and 1 other/i)).toBeInTheDocument();
  73. expect(screen.getByText(/KN/i)).toBeInTheDocument();
  74. expect(screen.getByText(/VN/i)).toBeInTheDocument();
  75. });
  76. });