renderWithOnboardingLayout.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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={{
  45. public: 'test-dsn',
  46. secret: 'test-secret',
  47. cdn: 'test-cdn',
  48. crons: 'test-crons',
  49. security: 'test-security',
  50. csp: 'test-csp',
  51. minidump: 'test-minidump',
  52. unreal: 'test-unreal',
  53. }}
  54. platformKey="java-spring-boot"
  55. projectId="test-project-id"
  56. activeProductSelection={selectedProducts}
  57. />,
  58. {
  59. organization,
  60. router,
  61. }
  62. );
  63. }