discoverSplitAlert.spec.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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. describe('DiscoverSplitAlert', () => {
  7. beforeEach(() => {
  8. localStorage.clear();
  9. });
  10. it('renders if the widget has a forced split decision', async () => {
  11. render(
  12. <DiscoverSplitAlert
  13. widget={{...WidgetFixture(), datasetSource: DatasetSource.FORCED}}
  14. />
  15. );
  16. await userEvent.hover(screen.getByLabelText('Dataset split warning'));
  17. expect(
  18. await screen.findByText(/We're splitting our datasets up/)
  19. ).toBeInTheDocument();
  20. });
  21. it('does not render if there the widget has not been forced', () => {
  22. render(<DiscoverSplitAlert widget={WidgetFixture()} />);
  23. expect(screen.queryByText(/We're splitting our datasets up/)).not.toBeInTheDocument();
  24. });
  25. });