javascript.spec.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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, {InstallationMode} from './javascript';
  6. describe('javascript onboarding docs', function () {
  7. it('renders onboarding docs correctly', () => {
  8. renderWithOnboardingLayout(docs, {
  9. selectedOptions: {
  10. installationMode: InstallationMode.MANUAL,
  11. },
  12. });
  13. // Renders main headings
  14. expect(screen.getByRole('heading', {name: 'Install'})).toBeInTheDocument();
  15. expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
  16. expect(screen.getByRole('heading', {name: 'Upload Source Maps'})).toBeInTheDocument();
  17. expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument();
  18. // Includes import statement
  19. expect(
  20. screen.getByText(
  21. textWithMarkupMatcher(/import \* as Sentry from "@sentry\/browser"/)
  22. )
  23. ).toBeInTheDocument();
  24. });
  25. it('displays sample rates by default', () => {
  26. renderWithOnboardingLayout(docs, {
  27. selectedProducts: [
  28. ProductSolution.ERROR_MONITORING,
  29. ProductSolution.PERFORMANCE_MONITORING,
  30. ProductSolution.SESSION_REPLAY,
  31. ],
  32. selectedOptions: {
  33. installationMode: InstallationMode.MANUAL,
  34. },
  35. });
  36. expect(
  37. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  38. ).toBeInTheDocument();
  39. expect(
  40. screen.queryByText(textWithMarkupMatcher(/replaysSessionSampleRate/))
  41. ).toBeInTheDocument();
  42. expect(
  43. screen.queryByText(textWithMarkupMatcher(/replaysOnErrorSampleRate/))
  44. ).toBeInTheDocument();
  45. });
  46. it('enables performance setting the tracesSampleRate to 1', () => {
  47. renderWithOnboardingLayout(docs, {
  48. selectedProducts: [
  49. ProductSolution.ERROR_MONITORING,
  50. ProductSolution.PERFORMANCE_MONITORING,
  51. ],
  52. selectedOptions: {
  53. installationMode: InstallationMode.MANUAL,
  54. },
  55. });
  56. expect(
  57. screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
  58. ).toBeInTheDocument();
  59. });
  60. it('enables replay by setting replay samplerates', () => {
  61. renderWithOnboardingLayout(docs, {
  62. selectedProducts: [
  63. ProductSolution.ERROR_MONITORING,
  64. ProductSolution.SESSION_REPLAY,
  65. ],
  66. selectedOptions: {
  67. installationMode: InstallationMode.MANUAL,
  68. },
  69. });
  70. expect(
  71. screen.getByText(textWithMarkupMatcher(/replaysSessionSampleRate: 0\.1/))
  72. ).toBeInTheDocument();
  73. expect(
  74. screen.getByText(textWithMarkupMatcher(/replaysOnErrorSampleRate: 1\.0/))
  75. ).toBeInTheDocument();
  76. });
  77. it('enables profiling by setting profiling sample rates', () => {
  78. renderWithOnboardingLayout(docs, {
  79. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  80. selectedOptions: {
  81. installationMode: InstallationMode.MANUAL,
  82. },
  83. });
  84. expect(
  85. screen.getByText(textWithMarkupMatcher(/Sentry.browserProfilingIntegration\(\)/))
  86. ).toBeInTheDocument();
  87. expect(
  88. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  89. ).toBeInTheDocument();
  90. });
  91. it('renders Loader Script by default', function () {
  92. renderWithOnboardingLayout(docs);
  93. expect(screen.getByRole('radio', {name: 'Loader Script'})).toBeChecked();
  94. expect(
  95. screen.getByRole('heading', {name: 'Configure SDK (Optional)'})
  96. ).toBeInTheDocument();
  97. });
  98. it('renders package manager installation', function () {
  99. renderWithOnboardingLayout(docs, {
  100. selectedOptions: {
  101. installationMode: InstallationMode.MANUAL,
  102. },
  103. });
  104. expect(screen.getByRole('radio', {name: 'Npm/Yarn'})).toBeChecked();
  105. expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
  106. });
  107. });