angular.spec.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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, {AngularConfigType} from './angular';
  6. describe('javascript-angular 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.getAllByText(
  17. textWithMarkupMatcher(/import \* as Sentry from "@sentry\/angular";/)
  18. )
  19. ).toHaveLength(2);
  20. });
  21. it('displays sample rates by default', () => {
  22. renderWithOnboardingLayout(docs, {
  23. selectedOptions: {
  24. configType: AngularConfigType.APP,
  25. },
  26. selectedProducts: [
  27. ProductSolution.ERROR_MONITORING,
  28. ProductSolution.PERFORMANCE_MONITORING,
  29. ProductSolution.SESSION_REPLAY,
  30. ],
  31. });
  32. expect(
  33. screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
  34. ).toBeInTheDocument();
  35. expect(
  36. screen.queryByText(textWithMarkupMatcher(/replaysSessionSampleRate/))
  37. ).toBeInTheDocument();
  38. expect(
  39. screen.queryByText(textWithMarkupMatcher(/replaysOnErrorSampleRate/))
  40. ).toBeInTheDocument();
  41. });
  42. it('enables performance setting the tracesSampleRate to 1', () => {
  43. renderWithOnboardingLayout(docs, {
  44. selectedOptions: {
  45. configType: AngularConfigType.APP,
  46. },
  47. selectedProducts: [
  48. ProductSolution.ERROR_MONITORING,
  49. ProductSolution.PERFORMANCE_MONITORING,
  50. ],
  51. });
  52. expect(
  53. screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
  54. ).toBeInTheDocument();
  55. });
  56. it('enables replay by setting replay samplerates', () => {
  57. renderWithOnboardingLayout(docs, {
  58. selectedOptions: {
  59. configType: AngularConfigType.APP,
  60. },
  61. selectedProducts: [
  62. ProductSolution.ERROR_MONITORING,
  63. ProductSolution.SESSION_REPLAY,
  64. ],
  65. });
  66. expect(
  67. screen.getByText(textWithMarkupMatcher(/replaysSessionSampleRate: 0\.1/))
  68. ).toBeInTheDocument();
  69. expect(
  70. screen.getByText(textWithMarkupMatcher(/replaysOnErrorSampleRate: 1\.0/))
  71. ).toBeInTheDocument();
  72. });
  73. it('enables profiling by setting profiling sample rates', () => {
  74. renderWithOnboardingLayout(docs, {
  75. selectedOptions: {
  76. configType: AngularConfigType.APP,
  77. },
  78. selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
  79. });
  80. expect(
  81. screen.getByText(textWithMarkupMatcher(/Sentry.browserProfilingIntegration\(\)/))
  82. ).toBeInTheDocument();
  83. expect(
  84. screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
  85. ).toBeInTheDocument();
  86. });
  87. });