nestjs.spec.tsx 2.6 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 './nestjs';
  6. describe('Nest.js 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(
  26. textWithMarkupMatcher(
  27. /Sentry\.setupNestErrorHandler\(app, new BaseExceptionFilter\(httpAdapter\)\)/
  28. )
  29. )
  30. ).toBeInTheDocument();
  31. });
  32. it('displays sample rates by default', () => {
  33. renderWithOnboardingLayout(docs, {
  34. selectedProducts: [
  35. ProductSolution.ERROR_MONITORING,
  36. ProductSolution.PERFORMANCE_MONITORING,
  37. ProductSolution.PROFILING,
  38. ],
  39. });
  40. expect(
  41. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  42. ).toBeInTheDocument();
  43. expect(
  44. screen.queryByText(textWithMarkupMatcher(/profilesSampleRate/))
  45. ).toBeInTheDocument();
  46. });
  47. it('enables performance setting the tracesSampleRate to 1', () => {
  48. renderWithOnboardingLayout(docs, {
  49. selectedProducts: [
  50. ProductSolution.ERROR_MONITORING,
  51. ProductSolution.PERFORMANCE_MONITORING,
  52. ],
  53. });
  54. expect(
  55. screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
  56. ).toBeInTheDocument();
  57. });
  58. it('enables profiling by setting profiling samplerates', () => {
  59. renderWithOnboardingLayout(docs, {
  60. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  61. });
  62. expect(
  63. screen.getByText(
  64. textWithMarkupMatcher(
  65. /import \{ nodeProfilingIntegration } from "@sentry\/profiling-node"/
  66. )
  67. )
  68. ).toBeInTheDocument();
  69. expect(
  70. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  71. ).toBeInTheDocument();
  72. });
  73. });