releaseContext.spec.tsx 3.1 KB

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