pageHeaderActions.spec.tsx 878 B

123456789101112131415161718192021222324252627
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {PageHeaderActions} from 'sentry/views/metrics/pageHeaderActions';
  3. jest.mock('sentry/views/metrics/useCreateDashboard');
  4. jest.mock('sentry/utils/metrics/features', () => ({
  5. hasCustomMetrics: jest.fn(() => true),
  6. hasMetricsNewInputs: jest.fn(() => true),
  7. }));
  8. describe('Metrics Page Header Actions', function () {
  9. describe('add metric buttons', function () {
  10. it('display "add custom metrics" button', async function () {
  11. const addCustomMetric = jest.fn();
  12. render(<PageHeaderActions showAddMetricButton addCustomMetric={addCustomMetric} />);
  13. const button = screen.getByRole('button', {name: 'Add Custom Metrics'});
  14. expect(button).toBeInTheDocument();
  15. await userEvent.click(button);
  16. expect(addCustomMetric).toHaveBeenCalled();
  17. });
  18. });
  19. });