renderWithOnboardingLayout.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render} from 'sentry-test/reactTestingLibrary';
  3. import {OnboardingLayout} from 'sentry/components/onboarding/gettingStartedDoc/onboardingLayout';
  4. import type {
  5. BasePlatformOptions,
  6. Docs,
  7. SelectedPlatformOptions,
  8. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  9. import type {ReleaseRegistrySdk} from 'sentry/components/onboarding/gettingStartedDoc/useSourcePackageRegistries';
  10. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  11. import type {DeepPartial} from 'sentry/types/utils';
  12. interface Options<PlatformOptions extends BasePlatformOptions = BasePlatformOptions> {
  13. releaseRegistry?: DeepPartial<ReleaseRegistrySdk>;
  14. selectedOptions?: Partial<SelectedPlatformOptions<PlatformOptions>>;
  15. selectedProducts?: ProductSolution[];
  16. }
  17. export function renderWithOnboardingLayout<
  18. PlatformOptions extends BasePlatformOptions = BasePlatformOptions,
  19. >(docsConfig: Docs<PlatformOptions>, options: Options<PlatformOptions> = {}) {
  20. const {
  21. releaseRegistry = {},
  22. selectedProducts = [
  23. ProductSolution.PERFORMANCE_MONITORING,
  24. ProductSolution.PROFILING,
  25. ProductSolution.SESSION_REPLAY,
  26. ],
  27. selectedOptions = {},
  28. } = options;
  29. const {organization, router} = initializeOrg({
  30. router: {
  31. location: {
  32. query: selectedOptions,
  33. },
  34. },
  35. });
  36. MockApiClient.addMockResponse({
  37. url: `/organizations/${organization.slug}/sdks/`,
  38. body: releaseRegistry,
  39. });
  40. render(
  41. <OnboardingLayout
  42. docsConfig={docsConfig}
  43. projectSlug="test-project-slug"
  44. dsn="test-dsn"
  45. platformKey="java-spring-boot"
  46. projectId="test-project-id"
  47. activeProductSelection={selectedProducts}
  48. />,
  49. {
  50. organization,
  51. router,
  52. }
  53. );
  54. }