datasetSelector.spec.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import {DatasetSelector} from 'sentry/views/discover/savedQuery/datasetSelector';
  4. describe('Discover DatasetSelector', function () {
  5. const {router} = initializeOrg({
  6. organization: {features: ['performance-view']},
  7. });
  8. it('renders selector and options', async function () {
  9. render(<DatasetSelector isHomepage={false} savedQuery={undefined} />, {
  10. router,
  11. });
  12. await userEvent.click(screen.getByText('Dataset'));
  13. const menuOptions = await screen.findAllByRole('option');
  14. expect(menuOptions.map(e => e.textContent)).toEqual(['Errors', 'Transactions']);
  15. });
  16. it('pushes new event view', async function () {
  17. render(<DatasetSelector isHomepage={false} savedQuery={undefined} />, {
  18. router,
  19. });
  20. await userEvent.click(screen.getByText('Dataset'));
  21. await userEvent.click(screen.getByRole('option', {name: 'Transactions'}));
  22. expect(router.push).toHaveBeenCalledWith(
  23. expect.objectContaining({
  24. query: expect.objectContaining({
  25. project: [],
  26. field: ['title', 'project', 'user.display', 'timestamp'],
  27. query: 'event.type:transaction',
  28. queryDataset: 'transaction-like',
  29. }),
  30. })
  31. );
  32. });
  33. });