connect.spec.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout';
  2. import {screen} from 'sentry-test/reactTestingLibrary';
  3. import {textWithMarkupMatcher} from 'sentry-test/utils';
  4. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  5. import docs from './connect';
  6. describe('connect onboarding docs', function () {
  7. it('renders onboarding docs correctly', () => {
  8. renderWithOnboardingLayout(docs);
  9. // Renders main headings
  10. expect(screen.getByRole('heading', {name: 'Install'})).toBeInTheDocument();
  11. expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
  12. expect(screen.getByRole('heading', {name: 'Upload Source Maps'})).toBeInTheDocument();
  13. // Includes import statement
  14. const allMatches = screen.getAllByText(
  15. textWithMarkupMatcher(/import \* as Sentry from "@sentry\/node"/)
  16. );
  17. allMatches.forEach(match => {
  18. expect(match).toBeInTheDocument();
  19. });
  20. });
  21. it('includes error handler', () => {
  22. renderWithOnboardingLayout(docs);
  23. expect(
  24. screen.getByText(textWithMarkupMatcher(/Sentry\.setupConnectErrorHandler\(app\)/))
  25. ).toBeInTheDocument();
  26. });
  27. it('displays sample rates by default', () => {
  28. renderWithOnboardingLayout(docs, {
  29. selectedProducts: [
  30. ProductSolution.ERROR_MONITORING,
  31. ProductSolution.PERFORMANCE_MONITORING,
  32. ProductSolution.PROFILING,
  33. ],
  34. });
  35. expect(
  36. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  37. ).toBeInTheDocument();
  38. expect(
  39. screen.queryByText(textWithMarkupMatcher(/profilesSampleRate/))
  40. ).toBeInTheDocument();
  41. });
  42. it('enables performance setting the tracesSampleRate to 1', () => {
  43. renderWithOnboardingLayout(docs, {
  44. selectedProducts: [
  45. ProductSolution.ERROR_MONITORING,
  46. ProductSolution.PERFORMANCE_MONITORING,
  47. ],
  48. });
  49. expect(
  50. screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
  51. ).toBeInTheDocument();
  52. });
  53. it('enables profiling by setting profiling samplerates', () => {
  54. renderWithOnboardingLayout(docs, {
  55. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  56. });
  57. expect(
  58. screen.getByText(
  59. textWithMarkupMatcher(
  60. /const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
  61. )
  62. )
  63. ).toBeInTheDocument();
  64. expect(
  65. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  66. ).toBeInTheDocument();
  67. });
  68. });