renderWithOnboardingLayout.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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: org} = renderOptions;
  39. const {organization, project, router} = initializeOrg({
  40. organization: org,
  41. router: {
  42. location: {
  43. query: selectedOptions,
  44. },
  45. },
  46. });
  47. const projectKey = 'test-project-key-id';
  48. MockApiClient.addMockResponse({
  49. url: `/organizations/${organization.slug}/sdks/`,
  50. body: releaseRegistry,
  51. });
  52. MockApiClient.addMockResponse({
  53. url: `/projects/${organization.slug}/${project.slug}/keys/${projectKey}/`,
  54. method: 'PUT',
  55. body: [ProjectKeysFixture()[0]],
  56. });
  57. render(
  58. <OnboardingLayout
  59. docsConfig={docsConfig}
  60. projectSlug={project.slug}
  61. dsn={{
  62. public: 'test-dsn',
  63. secret: 'test-secret',
  64. cdn: 'test-cdn',
  65. crons: 'test-crons',
  66. security: 'test-security',
  67. csp: 'test-csp',
  68. minidump: 'test-minidump',
  69. unreal: 'test-unreal',
  70. }}
  71. platformKey="java-spring-boot"
  72. projectId="test-project-id"
  73. activeProductSelection={selectedProducts}
  74. projectKeyId={projectKey}
  75. />,
  76. {
  77. organization,
  78. router,
  79. }
  80. );
  81. }