platformOrIntegration.spec.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import {ProjectFixture} from 'sentry-fixture/project';
  2. import {ProjectKeysFixture} from 'sentry-fixture/projectKeys';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import ProjectsStore from 'sentry/stores/projectsStore';
  6. import type {Project} from 'sentry/types/project';
  7. import PlatformOrIntegration from './platformOrIntegration';
  8. type ProjectWithBadPlatform = Omit<Project, 'platform'> & {
  9. platform: string;
  10. };
  11. function mockProjectApiResponses(projects: (Project | ProjectWithBadPlatform)[]) {
  12. MockApiClient.addMockResponse({
  13. method: 'GET',
  14. url: '/projects/org-slug/project-slug/rules/',
  15. body: [],
  16. });
  17. MockApiClient.addMockResponse({
  18. method: 'GET',
  19. url: '/projects/org-slug/project-slug/',
  20. body: projects,
  21. });
  22. MockApiClient.addMockResponse({
  23. url: '/projects/org-slug/project-slug/keys/',
  24. method: 'GET',
  25. body: [ProjectKeysFixture()[0]],
  26. });
  27. MockApiClient.addMockResponse({
  28. url: `/projects/org-slug/project-slug/keys/${ProjectKeysFixture()[0].public}/`,
  29. method: 'PUT',
  30. body: {},
  31. });
  32. }
  33. describe('ProjectInstallPlatform', function () {
  34. it('should render getting started docs for correct platform', async function () {
  35. const project = ProjectFixture({platform: 'javascript'});
  36. const {routerProps, router} = initializeOrg({
  37. router: {
  38. params: {
  39. projectId: project.slug,
  40. platform: 'python',
  41. },
  42. },
  43. });
  44. ProjectsStore.loadInitialData([project]);
  45. mockProjectApiResponses([project]);
  46. render(<PlatformOrIntegration {...routerProps} />, {
  47. router,
  48. });
  49. expect(
  50. await screen.findByRole('heading', {
  51. name: 'Configure Browser JavaScript SDK',
  52. })
  53. ).toBeInTheDocument();
  54. expect(screen.getByText('Take me to Issues')).toBeInTheDocument();
  55. });
  56. });