rq.spec.tsx 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout';
  3. import {screen} from 'sentry-test/reactTestingLibrary';
  4. import {textWithMarkupMatcher} from 'sentry-test/utils';
  5. import docs from './rq';
  6. describe('rq onboarding docs', function () {
  7. it('renders doc correctly', function () {
  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: 'Verify'})).toBeInTheDocument();
  13. expect(screen.getByRole('heading', {name: 'Job definition'})).toBeInTheDocument();
  14. expect(
  15. screen.getByRole('heading', {name: 'Settings for worker'})
  16. ).toBeInTheDocument();
  17. expect(screen.getByRole('heading', {name: 'Main Python Script'})).toBeInTheDocument();
  18. // Renders install instructions
  19. expect(
  20. screen.getByText(textWithMarkupMatcher(/pip install --upgrade 'sentry-sdk\[rq\]'/))
  21. ).toBeInTheDocument();
  22. });
  23. it('renders without tracing', function () {
  24. renderWithOnboardingLayout(docs, {
  25. selectedProducts: [],
  26. });
  27. // Does not render config option
  28. expect(
  29. screen.queryByText(textWithMarkupMatcher(/profiles_sample_rate=1\.0,/))
  30. ).not.toBeInTheDocument();
  31. // Does not render config option
  32. expect(
  33. screen.queryByText(textWithMarkupMatcher(/traces_sample_rate=1\.0,/))
  34. ).not.toBeInTheDocument();
  35. });
  36. it('renders transaction profiling', function () {
  37. renderWithOnboardingLayout(docs);
  38. // Does not render continuous profiling config
  39. expect(
  40. screen.queryByText(textWithMarkupMatcher(/sentry_sdk.profiler.start_profiler\(\)/))
  41. ).not.toBeInTheDocument();
  42. expect(
  43. screen.queryByText(textWithMarkupMatcher(/sentry_sdk.profiler.stop_profiler\(\)/))
  44. ).not.toBeInTheDocument();
  45. // Does render transaction profiling config
  46. const matches = screen.getAllByText(
  47. textWithMarkupMatcher(/profiles_sample_rate=1\.0,/)
  48. );
  49. expect(matches.length).toBeGreaterThan(0);
  50. matches.forEach(match => expect(match).toBeInTheDocument());
  51. });
  52. it('renders continuous profiling', function () {
  53. const organization = OrganizationFixture({
  54. features: ['continuous-profiling'],
  55. });
  56. renderWithOnboardingLayout(
  57. docs,
  58. {},
  59. {
  60. organization,
  61. }
  62. );
  63. // Does not render transaction profiling config
  64. expect(
  65. screen.queryByText(textWithMarkupMatcher(/profiles_sample_rate=1\.0,/))
  66. ).not.toBeInTheDocument();
  67. // Does render continuous profiling config
  68. const startMatches = screen.queryAllByText(
  69. textWithMarkupMatcher(/sentry_sdk.profiler.start_profiler\(\)/)
  70. );
  71. expect(startMatches.length).toBeGreaterThan(0);
  72. startMatches.forEach(match => expect(match).toBeInTheDocument());
  73. const stopMatches = screen.queryAllByText(
  74. textWithMarkupMatcher(/sentry_sdk.profiler.stop_profiler\(\)/)
  75. );
  76. expect(stopMatches.length).toBeGreaterThan(0);
  77. stopMatches.forEach(match => expect(match).toBeInTheDocument());
  78. });
  79. });