rule.spec.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import {ServerSideSamplingStore} from 'sentry/stores/serverSideSamplingStore';
  3. import {SamplingRuleOperator} from 'sentry/types/sampling';
  4. import {Rule} from './rule';
  5. import {uniformRule} from './testUtils';
  6. export const samplingBreakdownTitle = 'Transaction Breakdown';
  7. describe('Server-Side Sampling - Rule', function () {
  8. beforeEach(function () {
  9. ServerSideSamplingStore.reset();
  10. });
  11. it('renders toggle placeholders', function () {
  12. render(
  13. <Rule
  14. operator={SamplingRuleOperator.IF}
  15. hideGrabButton={false}
  16. rule={uniformRule}
  17. onEditRule={() => {}}
  18. onDeleteRule={() => {}}
  19. onActivate={() => {}}
  20. noPermission={false}
  21. upgradeSdkForProjects={[]}
  22. listeners={undefined}
  23. dragging={false}
  24. sorting={false}
  25. loadingRecommendedSdkUpgrades
  26. />
  27. );
  28. expect(screen.getByTestId('loading-placeholder')).toBeInTheDocument();
  29. expect(screen.queryByLabelText('Activate Rule')).not.toBeInTheDocument();
  30. });
  31. it('can be deactivated even with unsupported SDKs', function () {
  32. ServerSideSamplingStore.sdkVersionsRequestSuccess([
  33. {
  34. project: 'javascript',
  35. latestSDKVersion: '1.0.3',
  36. latestSDKName: 'sentry.javascript.react',
  37. isSendingSampleRate: true,
  38. isSendingSource: true,
  39. isSupportedPlatform: false,
  40. },
  41. ]);
  42. render(
  43. <Rule
  44. operator={SamplingRuleOperator.IF}
  45. hideGrabButton={false}
  46. rule={{...uniformRule, active: true}}
  47. onEditRule={() => {}}
  48. onDeleteRule={() => {}}
  49. onActivate={() => {}}
  50. noPermission={false}
  51. upgradeSdkForProjects={['javascript']}
  52. listeners={undefined}
  53. dragging={false}
  54. sorting={false}
  55. loadingRecommendedSdkUpgrades={false}
  56. />
  57. );
  58. expect(screen.queryByTestId('loading-placeholder')).not.toBeInTheDocument();
  59. expect(screen.getByLabelText('Deactivate Rule')).toBeInTheDocument();
  60. expect(screen.getByRole('checkbox', {name: 'Deactivate Rule'})).toBeEnabled();
  61. });
  62. });