gcpfunctions.spec.tsx 3.4 KB

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