react.spec.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 './react';
  6. describe('javascript-react 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. expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument();
  14. // Includes import statement
  15. expect(
  16. screen.getByText(textWithMarkupMatcher(/import \* as Sentry from "@sentry\/react"/))
  17. ).toBeInTheDocument();
  18. });
  19. it('displays sample rates by default', () => {
  20. renderWithOnboardingLayout(docs, {
  21. selectedProducts: [
  22. ProductSolution.ERROR_MONITORING,
  23. ProductSolution.PERFORMANCE_MONITORING,
  24. ProductSolution.SESSION_REPLAY,
  25. ],
  26. });
  27. expect(
  28. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  29. ).toBeInTheDocument();
  30. expect(
  31. screen.queryByText(textWithMarkupMatcher(/replaysSessionSampleRate/))
  32. ).toBeInTheDocument();
  33. expect(
  34. screen.queryByText(textWithMarkupMatcher(/replaysOnErrorSampleRate/))
  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 replay by setting replay samplerates', () => {
  49. renderWithOnboardingLayout(docs, {
  50. selectedProducts: [
  51. ProductSolution.ERROR_MONITORING,
  52. ProductSolution.SESSION_REPLAY,
  53. ],
  54. });
  55. expect(
  56. screen.getByText(textWithMarkupMatcher(/replaysSessionSampleRate: 0\.1/))
  57. ).toBeInTheDocument();
  58. expect(
  59. screen.getByText(textWithMarkupMatcher(/replaysOnErrorSampleRate: 1\.0/))
  60. ).toBeInTheDocument();
  61. });
  62. it('enables profiling by setting profiling samplerates', () => {
  63. renderWithOnboardingLayout(docs, {
  64. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  65. });
  66. expect(
  67. screen.getByText(textWithMarkupMatcher(/Sentry.browserProfilingIntegration\(\)/))
  68. ).toBeInTheDocument();
  69. expect(
  70. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  71. ).toBeInTheDocument();
  72. });
  73. });