indexedEventsSelectionAlert.spec.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {WidgetFixture} from 'sentry-fixture/widget';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  4. import {DashboardsMEPContext} from './widgetCard/dashboardsMEPContext';
  5. import {IndexedEventsSelectionAlert} from './indexedEventsSelectionAlert';
  6. import {WidgetType} from './types';
  7. describe('IndexedEventsSelectionAlert', () => {
  8. const widget = WidgetFixture({
  9. widgetType: WidgetType.DISCOVER,
  10. });
  11. it('Shows warning if falling through to indexed events', async () => {
  12. render(
  13. <MEPSettingProvider forceTransactions>
  14. <DashboardsMEPContext.Provider
  15. value={{isMetricsData: false, setIsMetricsData: () => {}}}
  16. >
  17. <IndexedEventsSelectionAlert widget={widget} />
  18. </DashboardsMEPContext.Provider>
  19. </MEPSettingProvider>
  20. );
  21. await screen.findByText(/we've automatically adjusted your results/i);
  22. });
  23. it('Does not show warning if using metrics successfully', () => {
  24. render(
  25. <MEPSettingProvider>
  26. <DashboardsMEPContext.Provider
  27. value={{isMetricsData: true, setIsMetricsData: () => {}}}
  28. >
  29. <IndexedEventsSelectionAlert widget={widget} />
  30. </DashboardsMEPContext.Provider>
  31. </MEPSettingProvider>
  32. );
  33. expect(
  34. screen.queryByText(/we've automatically adjusted your results/i)
  35. ).not.toBeInTheDocument();
  36. });
  37. });