discoverSplitAlert.spec.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {WidgetFixture} from 'sentry-fixture/widget';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import {DatasetSource} from 'sentry/utils/discover/types';
  4. import localStorage from 'sentry/utils/localStorage';
  5. import {DiscoverSplitAlert} from 'sentry/views/dashboards/discoverSplitAlert';
  6. import {WidgetType} from 'sentry/views/dashboards/types';
  7. describe('DiscoverSplitAlert', () => {
  8. beforeEach(() => {
  9. localStorage.clear();
  10. });
  11. it('renders if the widget has a forced split decision', async () => {
  12. render(
  13. <DiscoverSplitAlert
  14. widget={{
  15. ...WidgetFixture(),
  16. datasetSource: DatasetSource.FORCED,
  17. widgetType: WidgetType.ERRORS,
  18. }}
  19. />
  20. );
  21. await userEvent.hover(screen.getByLabelText('Dataset split warning'));
  22. expect(
  23. await screen.findByText(/We're splitting our datasets up/)
  24. ).toBeInTheDocument();
  25. });
  26. it('does not render if there the widget has not been forced', () => {
  27. render(<DiscoverSplitAlert widget={WidgetFixture()} />);
  28. expect(screen.queryByText(/We're splitting our datasets up/)).not.toBeInTheDocument();
  29. });
  30. });