renderWithOnboardingLayout.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import {ProjectKeysFixture} from 'sentry-fixture/projectKeys';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render} from 'sentry-test/reactTestingLibrary';
  4. import {OnboardingLayout} from 'sentry/components/onboarding/gettingStartedDoc/onboardingLayout';
  5. import type {
  6. BasePlatformOptions,
  7. Docs,
  8. SelectedPlatformOptions,
  9. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  10. import type {ReleaseRegistrySdk} from 'sentry/components/onboarding/gettingStartedDoc/useSourcePackageRegistries';
  11. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  12. import type {Organization} from 'sentry/types/organization';
  13. import type {DeepPartial} from 'sentry/types/utils';
  14. interface Options<PlatformOptions extends BasePlatformOptions = BasePlatformOptions> {
  15. releaseRegistry?: DeepPartial<ReleaseRegistrySdk>;
  16. selectedOptions?: Partial<SelectedPlatformOptions<PlatformOptions>>;
  17. selectedProducts?: ProductSolution[];
  18. }
  19. type RenderOptions = {
  20. organization?: Organization;
  21. };
  22. export function renderWithOnboardingLayout<
  23. PlatformOptions extends BasePlatformOptions = BasePlatformOptions,
  24. >(
  25. docsConfig: Docs<PlatformOptions>,
  26. options: Options<PlatformOptions> = {},
  27. renderOptions: RenderOptions = {}
  28. ) {
  29. const {
  30. releaseRegistry = {},
  31. selectedProducts = [
  32. ProductSolution.PERFORMANCE_MONITORING,
  33. ProductSolution.PROFILING,
  34. ProductSolution.SESSION_REPLAY,
  35. ],
  36. selectedOptions = {},
  37. } = options;
  38. const {organization, project, router} = initializeOrg({
  39. organization: renderOptions.organization,
  40. router: {
  41. location: {
  42. query: selectedOptions,
  43. },
  44. },
  45. });
  46. const projectKey = 'test-project-key-id';
  47. MockApiClient.addMockResponse({
  48. url: `/organizations/${organization.slug}/sdks/`,
  49. body: releaseRegistry,
  50. });
  51. MockApiClient.addMockResponse({
  52. url: `/projects/${organization.slug}/${project.slug}/keys/${projectKey}/`,
  53. method: 'PUT',
  54. body: [ProjectKeysFixture()[0]],
  55. });
  56. render(
  57. <OnboardingLayout
  58. docsConfig={docsConfig}
  59. projectSlug={project.slug}
  60. dsn={{
  61. public: 'test-dsn',
  62. secret: 'test-secret',
  63. cdn: 'test-cdn',
  64. crons: 'test-crons',
  65. security: 'test-security',
  66. csp: 'test-csp',
  67. minidump: 'test-minidump',
  68. unreal: 'test-unreal',
  69. }}
  70. platformKey="java-spring-boot"
  71. projectId="test-project-id"
  72. activeProductSelection={selectedProducts}
  73. projectKeyId={projectKey}
  74. />,
  75. {
  76. organization,
  77. router,
  78. }
  79. );
  80. }