koa.spec.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 './koa';
  6. describe('koa 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. 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('includes error handler', () => {
  23. renderWithOnboardingLayout(docs);
  24. expect(
  25. screen.getByText(textWithMarkupMatcher(/Sentry\.setupKoaErrorHandler\(app\)/))
  26. ).toBeInTheDocument();
  27. });
  28. it('displays sample rates by default', () => {
  29. renderWithOnboardingLayout(docs, {
  30. selectedProducts: [
  31. ProductSolution.ERROR_MONITORING,
  32. ProductSolution.PERFORMANCE_MONITORING,
  33. ProductSolution.PROFILING,
  34. ],
  35. });
  36. expect(
  37. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  38. ).toBeInTheDocument();
  39. expect(
  40. screen.queryByText(textWithMarkupMatcher(/profilesSampleRate/))
  41. ).toBeInTheDocument();
  42. });
  43. it('enables performance setting the tracesSampleRate to 1', () => {
  44. renderWithOnboardingLayout(docs, {
  45. selectedProducts: [
  46. ProductSolution.ERROR_MONITORING,
  47. ProductSolution.PERFORMANCE_MONITORING,
  48. ],
  49. });
  50. expect(
  51. screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
  52. ).toBeInTheDocument();
  53. });
  54. it('enables profiling by setting profiling samplerates', () => {
  55. renderWithOnboardingLayout(docs, {
  56. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  57. });
  58. expect(
  59. screen.getByText(
  60. textWithMarkupMatcher(
  61. /const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
  62. )
  63. )
  64. ).toBeInTheDocument();
  65. expect(
  66. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  67. ).toBeInTheDocument();
  68. });
  69. });