fastify.spec.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 './fastify';
  7. describe('fastify 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. expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument();
  15. // Includes import statement
  16. const allMatches = screen.getAllByText(
  17. textWithMarkupMatcher(/import \* as Sentry from "@sentry\/node"/)
  18. );
  19. allMatches.forEach(match => {
  20. expect(match).toBeInTheDocument();
  21. });
  22. });
  23. it('includes error handler', () => {
  24. renderWithOnboardingLayout(docs);
  25. expect(
  26. screen.getByText(textWithMarkupMatcher(/Sentry\.setupFastifyErrorHandler\(app\)/))
  27. ).toBeInTheDocument();
  28. });
  29. it('displays sample rates by default', () => {
  30. renderWithOnboardingLayout(docs, {
  31. selectedProducts: [
  32. ProductSolution.ERROR_MONITORING,
  33. ProductSolution.PERFORMANCE_MONITORING,
  34. ProductSolution.PROFILING,
  35. ],
  36. });
  37. expect(
  38. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  39. ).toBeInTheDocument();
  40. expect(
  41. screen.queryByText(textWithMarkupMatcher(/profilesSampleRate/))
  42. ).toBeInTheDocument();
  43. });
  44. it('enables performance setting the tracesSampleRate to 1', () => {
  45. renderWithOnboardingLayout(docs, {
  46. selectedProducts: [
  47. ProductSolution.ERROR_MONITORING,
  48. ProductSolution.PERFORMANCE_MONITORING,
  49. ],
  50. });
  51. expect(
  52. screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
  53. ).toBeInTheDocument();
  54. });
  55. it('enables profiling by setting profiling samplerates', () => {
  56. renderWithOnboardingLayout(docs, {
  57. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  58. });
  59. expect(
  60. screen.getByText(
  61. textWithMarkupMatcher(
  62. /const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
  63. )
  64. )
  65. ).toBeInTheDocument();
  66. expect(
  67. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  68. ).toBeInTheDocument();
  69. });
  70. it('continuous profiling', () => {
  71. const organization = OrganizationFixture({
  72. features: ['continuous-profiling'],
  73. });
  74. renderWithOnboardingLayout(
  75. docs,
  76. {},
  77. {
  78. organization,
  79. }
  80. );
  81. expect(
  82. screen.getByText(
  83. textWithMarkupMatcher(
  84. /const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
  85. )
  86. )
  87. ).toBeInTheDocument();
  88. // Profiles sample rate should not be set for continuous profiling
  89. expect(
  90. screen.queryByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  91. ).not.toBeInTheDocument();
  92. // Should have start and stop profiling calls
  93. expect(
  94. screen.queryByText(textWithMarkupMatcher(/Sentry.profiler.startProfiling/))
  95. ).toBeInTheDocument();
  96. expect(
  97. screen.queryByText(textWithMarkupMatcher(/Sentry.profiler.stopProfiling/))
  98. ).toBeInTheDocument();
  99. });
  100. });