codecovLegend.spec.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProjectsStore from 'sentry/stores/projectsStore';
  3. import {CodecovStatusCode, Frame} from 'sentry/types';
  4. import {CodecovLegend} from './codecovLegend';
  5. describe('Frame - Codecov Legend', function () {
  6. const organization = TestStubs.Organization({
  7. features: ['codecov-stacktrace-integration'],
  8. codecovAccess: true,
  9. });
  10. const platform = 'python';
  11. const project = TestStubs.Project({});
  12. const event = TestStubs.Event({
  13. projectID: project.id,
  14. release: TestStubs.Release({lastCommit: TestStubs.Commit()}),
  15. platform,
  16. });
  17. const integration = TestStubs.GitHubIntegration();
  18. const repo = TestStubs.Repository({integrationId: integration.id});
  19. const frame = {filename: '/sentry/app.py', lineNo: 233} as Frame;
  20. const config = TestStubs.RepositoryProjectPathConfig({project, repo, integration});
  21. beforeEach(function () {
  22. jest.clearAllMocks();
  23. MockApiClient.clearMockResponses();
  24. ProjectsStore.loadInitialData([project]);
  25. });
  26. it('should render codecov legend', async function () {
  27. MockApiClient.addMockResponse({
  28. url: `/projects/${organization.slug}/${project.slug}/stacktrace-link/`,
  29. body: {
  30. config,
  31. sourceUrl: null,
  32. integrations: [integration],
  33. codecov: {status: CodecovStatusCode.COVERAGE_EXISTS},
  34. },
  35. });
  36. render(<CodecovLegend event={event} frame={frame} organization={organization} />, {
  37. context: TestStubs.routerContext(),
  38. organization,
  39. project,
  40. });
  41. expect(await screen.findByText('Covered')).toBeInTheDocument();
  42. expect(await screen.findByText('Uncovered')).toBeInTheDocument();
  43. expect(await screen.findByText('Partial')).toBeInTheDocument();
  44. });
  45. });