azurefunctions.spec.tsx 3.3 KB

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