spanOpSelector.spec.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {ProjectFixture} from 'sentry-fixture/project';
  3. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import usePageFilters from 'sentry/utils/usePageFilters';
  5. import {SpanOpSelector} from 'sentry/views/insights/mobile/appStarts/components/spanOpSelector';
  6. jest.mock('sentry/utils/usePageFilters');
  7. describe('SpanOpSelector', function () {
  8. const organization = OrganizationFixture();
  9. const project = ProjectFixture();
  10. jest.mocked(usePageFilters).mockReturnValue({
  11. isReady: true,
  12. desyncedFilters: new Set(),
  13. pinnedFilters: new Set(),
  14. shouldPersist: true,
  15. selection: {
  16. datetime: {
  17. period: '10d',
  18. start: null,
  19. end: null,
  20. utc: false,
  21. },
  22. environments: [],
  23. projects: [parseInt(project.id, 10)],
  24. },
  25. });
  26. MockApiClient.addMockResponse({
  27. url: `/organizations/${organization.slug}/events/`,
  28. body: {
  29. meta: {
  30. fields: {
  31. 'span.op': 'string',
  32. 'count()': 'integer',
  33. },
  34. },
  35. data: [
  36. {
  37. 'span.op': 'app.start.cold',
  38. 'count()': 1,
  39. },
  40. {
  41. 'span.op': 'app.start.warm',
  42. 'count()': 2,
  43. },
  44. {
  45. 'span.op': 'contentprovider.load',
  46. 'count()': 3,
  47. },
  48. ],
  49. },
  50. });
  51. it('lists all span operations that are stored', async function () {
  52. render(
  53. <SpanOpSelector
  54. primaryRelease="release1"
  55. secondaryRelease="release2"
  56. transaction="foo-bar"
  57. />
  58. );
  59. expect(await screen.findByText('All')).toBeInTheDocument();
  60. await userEvent.click(screen.getByText('All'));
  61. // These options appear because the events request says we have spans stored
  62. expect(
  63. await screen.findByRole('option', {name: 'app.start.cold'})
  64. ).toBeInTheDocument();
  65. expect(screen.getByRole('option', {name: 'app.start.warm'})).toBeInTheDocument();
  66. expect(
  67. screen.getByRole('option', {name: 'contentprovider.load'})
  68. ).toBeInTheDocument();
  69. });
  70. });