systemApplicationBreakdown.spec.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import type {Location} from 'history';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
  5. import {useLocation} from 'sentry/utils/useLocation';
  6. import usePageFilters from 'sentry/utils/usePageFilters';
  7. import SystemApplicationBreakdown from 'sentry/views/insights/mobile/appStarts/components/systemApplicationBreakdown';
  8. jest.mock('sentry/utils/useLocation');
  9. jest.mock('sentry/utils/usePageFilters');
  10. describe('SystemApplicationBreakdown', function () {
  11. const organization = OrganizationFixture();
  12. const project = ProjectFixture();
  13. beforeEach(function () {
  14. jest.mocked(useLocation).mockReturnValue({
  15. action: 'PUSH',
  16. hash: '',
  17. key: '',
  18. pathname: '/organizations/org-slug/performance/mobile/screens/spans/',
  19. query: {
  20. project: project.id,
  21. transaction: 'MainActivity',
  22. primaryRelease: 'com.example.vu.android@2.10.5',
  23. secondaryRelease: 'com.example.vu.android@2.10.3+42',
  24. },
  25. search: '',
  26. state: undefined,
  27. } as Location);
  28. jest.mocked(usePageFilters).mockReturnValue({
  29. isReady: true,
  30. desyncedFilters: new Set(),
  31. pinnedFilters: new Set(),
  32. shouldPersist: true,
  33. selection: {
  34. datetime: {
  35. period: '10d',
  36. start: null,
  37. end: null,
  38. utc: false,
  39. },
  40. environments: [],
  41. projects: [parseInt(project.id, 10)],
  42. },
  43. });
  44. MockApiClient.addMockResponse({
  45. url: `/organizations/${organization.slug}/releases/`,
  46. body: [
  47. {
  48. id: 970136705,
  49. version: 'com.example.vu.android@2.10.5',
  50. dateCreated: '2023-12-19T21:37:53.895495Z',
  51. },
  52. {
  53. id: 969902997,
  54. version: 'com.example.vu.android@2.10.3+42',
  55. dateCreated: '2023-12-19T18:04:06.953025Z',
  56. },
  57. ],
  58. });
  59. MockApiClient.addMockResponse({
  60. url: `/organizations/${organization.slug}/events/`,
  61. body: {
  62. data: [
  63. {
  64. release: 'com.example.vu.android@2.10.5',
  65. 'span.description': 'io.sentry.samples.android.ContentProvider.onStart',
  66. 'span.op': 'contentprovider.load',
  67. 'sum(span.self_time)': 10,
  68. },
  69. {
  70. release: 'com.example.vu.android@2.10.5',
  71. 'span.description': '',
  72. 'span.op': 'activity.load',
  73. 'sum(span.self_time)': 10,
  74. },
  75. {
  76. release: 'com.example.vu.android@2.10.5',
  77. 'span.description': 'Initial Frame Render',
  78. 'span.op': 'app.warm.start',
  79. 'sum(span.self_time)': 10,
  80. },
  81. {
  82. release: 'com.example.vu.android@2.10.5',
  83. 'span.description': 'Runtime Init to Pre Main Initializers',
  84. 'span.op': 'app.warm.start',
  85. 'sum(span.self_time)': 70,
  86. },
  87. {
  88. release: 'com.example.vu.android@2.10.3+42',
  89. 'span.description': 'Runtime Init to Pre Main Initializers',
  90. 'span.op': 'app.warm.start',
  91. 'sum(span.self_time)': 70,
  92. },
  93. ],
  94. },
  95. });
  96. });
  97. it('aggregates spans data into system and application', async function () {
  98. render(<SystemApplicationBreakdown additionalFilters={[]} />);
  99. await userEvent.hover(await screen.findByTestId('primary-release-breakdown'));
  100. expect(await screen.findByTestId('breakdown-tooltip-content')).toHaveTextContent(
  101. 'System7070%Application3030%'
  102. );
  103. await userEvent.unhover(screen.getByTestId('primary-release-breakdown'));
  104. await waitFor(() => {
  105. expect(screen.queryByTestId('breakdown-tooltip-content')).not.toBeInTheDocument();
  106. });
  107. await userEvent.hover(screen.getByTestId('secondary-release-breakdown'));
  108. expect(await screen.findByTestId('breakdown-tooltip-content')).toHaveTextContent(
  109. 'System70100%Application00%'
  110. );
  111. });
  112. });