connect.spec.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout';
  3. import {screen} from 'sentry-test/reactTestingLibrary';
  4. import {textWithMarkupMatcher} from 'sentry-test/utils';
  5. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  6. import docs from './connect';
  7. describe('connect onboarding docs', function () {
  8. it('renders onboarding docs correctly', () => {
  9. renderWithOnboardingLayout(docs);
  10. // Renders main headings
  11. expect(screen.getByRole('heading', {name: 'Install'})).toBeInTheDocument();
  12. expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
  13. expect(screen.getByRole('heading', {name: 'Upload Source Maps'})).toBeInTheDocument();
  14. // Includes import statement
  15. const allMatches = screen.getAllByText(
  16. textWithMarkupMatcher(/import \* as Sentry from "@sentry\/node"/)
  17. );
  18. allMatches.forEach(match => {
  19. expect(match).toBeInTheDocument();
  20. });
  21. });
  22. it('includes error handler', () => {
  23. renderWithOnboardingLayout(docs);
  24. expect(
  25. screen.getByText(textWithMarkupMatcher(/Sentry\.setupConnectErrorHandler\(app\)/))
  26. ).toBeInTheDocument();
  27. });
  28. it('displays sample rates by default', () => {
  29. renderWithOnboardingLayout(docs, {
  30. selectedProducts: [
  31. ProductSolution.ERROR_MONITORING,
  32. ProductSolution.PERFORMANCE_MONITORING,
  33. ProductSolution.PROFILING,
  34. ],
  35. });
  36. expect(
  37. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  38. ).toBeInTheDocument();
  39. expect(
  40. screen.queryByText(textWithMarkupMatcher(/profilesSampleRate/))
  41. ).toBeInTheDocument();
  42. });
  43. it('enables performance setting the tracesSampleRate to 1', () => {
  44. renderWithOnboardingLayout(docs, {
  45. selectedProducts: [
  46. ProductSolution.ERROR_MONITORING,
  47. ProductSolution.PERFORMANCE_MONITORING,
  48. ],
  49. });
  50. expect(
  51. screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
  52. ).toBeInTheDocument();
  53. });
  54. it('enables profiling by setting profiling samplerates', () => {
  55. renderWithOnboardingLayout(docs, {
  56. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  57. });
  58. expect(
  59. screen.getByText(
  60. textWithMarkupMatcher(
  61. /const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
  62. )
  63. )
  64. ).toBeInTheDocument();
  65. expect(
  66. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  67. ).toBeInTheDocument();
  68. });
  69. it('continuous profiling', () => {
  70. const organization = OrganizationFixture({
  71. features: ['continuous-profiling'],
  72. });
  73. renderWithOnboardingLayout(
  74. docs,
  75. {},
  76. {
  77. organization,
  78. }
  79. );
  80. expect(
  81. screen.getByText(
  82. textWithMarkupMatcher(
  83. /const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
  84. )
  85. )
  86. ).toBeInTheDocument();
  87. // Profiles sample rate should not be set for continuous profiling
  88. expect(
  89. screen.queryByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  90. ).not.toBeInTheDocument();
  91. // Should have start and stop profiling calls
  92. expect(
  93. screen.queryByText(textWithMarkupMatcher(/Sentry.profiler.startProfiler/))
  94. ).toBeInTheDocument();
  95. expect(
  96. screen.queryByText(textWithMarkupMatcher(/Sentry.profiler.stopProfiler/))
  97. ).toBeInTheDocument();
  98. });
  99. });