awslambda.spec.tsx 3.4 KB

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