123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import {render, screen, within} from 'sentry-test/reactTestingLibrary';
- import ConfigStore from 'sentry/stores/configStore';
- import {QueryClient, QueryClientProvider} from 'sentry/utils/queryClient';
- import ReleaseContext from './releaseContext';
- import {defaultRow, mockedCommit, mockedUser1, mockedUser2} from './testUtils';
- const queryClient = new QueryClient({
- defaultOptions: {
- queries: {
- retry: false,
- },
- },
- });
- export const mockedReleaseWithHealth = TestStubs.Release({
- id: '1',
- shortVersion: 'sentry-android-shop@1.2.0',
- version: 'sentry-android-shop@1.2.0',
- dateCreated: '2010-05-17T02:41:20Z',
- lastEvent: '2011-10-17T02:41:20Z',
- firstEvent: '2010-05-17T02:41:20Z',
- status: 'open',
- commitCount: 4,
- lastCommit: mockedCommit,
- newGroups: 21,
- authors: [mockedUser1, mockedUser2],
- });
- const renderReleaseContext = () => {
- const organization = TestStubs.Organization();
- render(
- <QueryClientProvider client={queryClient}>
- <ReleaseContext dataRow={defaultRow} organization={organization} />
- </QueryClientProvider>,
- {organization}
- );
- };
- describe('Quick Context Content Release Column', function () {
- beforeEach(() => {
- MockApiClient.addMockResponse({
- url: '/organizations/org-slug/releases/backend@22.10.0+aaf33944f93dc8fa4234ca046a8d88fb1dccfb76/',
- body: mockedReleaseWithHealth,
- });
- });
- afterEach(() => {
- queryClient.clear();
- MockApiClient.clearMockResponses();
- });
- it('Renders Release details for release', async () => {
- renderReleaseContext();
- expect(await screen.findByText(/Created/i)).toBeInTheDocument();
- expect(screen.getByText(/7 years ago/i)).toBeInTheDocument();
- expect(screen.getByText(/Last Event/i)).toBeInTheDocument();
- expect(screen.getByText(/6 years ago/i)).toBeInTheDocument();
- expect(screen.getByText(/New Issues/i)).toBeInTheDocument();
- expect(screen.getByText(/21/i)).toBeInTheDocument();
- });
- it('Renders Last Commit', async () => {
- renderReleaseContext();
- expect(await screen.findByText(/Last Commit/i)).toBeInTheDocument();
- expect(screen.getByTestId('quick-context-commit-row')).toBeInTheDocument();
- });
- it('Renders Commit Count and Author when user is NOT in list of authors', async () => {
- renderReleaseContext();
- const authorsSectionHeader = within(
- await screen.findByTestId('quick-context-release-author-header')
- );
- expect(authorsSectionHeader.getByText(/4/i)).toBeInTheDocument();
- expect(authorsSectionHeader.getByText(/commits by/i)).toBeInTheDocument();
- expect(authorsSectionHeader.getByText(/2/i)).toBeInTheDocument();
- expect(authorsSectionHeader.getByText(/authors/i)).toBeInTheDocument();
- expect(screen.getByText(/KN/i)).toBeInTheDocument();
- expect(screen.getByText(/VN/i)).toBeInTheDocument();
- });
- it('Renders Commit Count and Author when user is in list of authors', async () => {
- jest.spyOn(ConfigStore, 'get').mockImplementation(() => mockedUser1);
- renderReleaseContext();
- expect(await screen.findByText(/4/i)).toBeInTheDocument();
- expect(screen.getByText(/commits by you and 1 other/i)).toBeInTheDocument();
- expect(screen.getByText(/KN/i)).toBeInTheDocument();
- expect(screen.getByText(/VN/i)).toBeInTheDocument();
- });
- });
|