profilesTable.spec.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import {ReactElement, useEffect} from 'react';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import {ProfilesTable} from 'sentry/components/profiling/profilesTable';
  4. import ProjectsStore from 'sentry/stores/projectsStore';
  5. const project = TestStubs.Project();
  6. function TestContext({children}: {children: ReactElement}) {
  7. useEffect(() => {
  8. ProjectsStore.loadInitialData([project]);
  9. return () => ProjectsStore.reset();
  10. }, []);
  11. return children;
  12. }
  13. describe('ProfilesTable', function () {
  14. it('renders loading', function () {
  15. render(
  16. <TestContext>
  17. <ProfilesTable isLoading error={null} traces={[]} />
  18. </TestContext>
  19. );
  20. expect(screen.getByTestId('loading-indicator')).toBeInTheDocument();
  21. });
  22. it('renders empty data', function () {
  23. render(
  24. <TestContext>
  25. <ProfilesTable isLoading={false} error={null} traces={[]} />
  26. </TestContext>
  27. );
  28. expect(screen.getByText('No results found for your query')).toBeInTheDocument();
  29. });
  30. it('renders one trace', function () {
  31. const trace = {
  32. android_api_level: 0,
  33. device_classification: 'low',
  34. device_locale: 'en_US',
  35. device_manufacturer: 'Apple',
  36. device_model: 'iPhone7,2',
  37. device_os_build_number: '14F89',
  38. device_os_name: 'iOS',
  39. device_os_version: '10.3.2',
  40. failed: false,
  41. id: '75a32ee2e6ed44458f4647b024b615bb',
  42. project_id: '2',
  43. timestamp: 1653426810,
  44. trace_duration_ms: 931.404667,
  45. transaction_id: '6051e1bfb94349a88ead9ffec6910eb9',
  46. transaction_name: 'iOS_Swift.ViewController',
  47. version_code: '1',
  48. version_name: '7.16.0',
  49. };
  50. render(
  51. <TestContext>
  52. <ProfilesTable isLoading={false} error={null} traces={[trace]} />
  53. </TestContext>
  54. );
  55. expect(screen.getByText('Status')).toBeInTheDocument();
  56. expect(screen.getByText('Profile ID')).toBeInTheDocument();
  57. expect(screen.getByText('75a32ee2')).toBeInTheDocument();
  58. expect(screen.getByText('Project')).toBeInTheDocument();
  59. expect(screen.getByText('project-slug')).toBeInTheDocument();
  60. expect(screen.getByText('Transaction Name')).toBeInTheDocument();
  61. expect(screen.getByText('iOS_Swift.ViewController')).toBeInTheDocument();
  62. expect(screen.getByText('Version')).toBeInTheDocument();
  63. expect(screen.getByText('7.16.0 (build 1)')).toBeInTheDocument();
  64. expect(screen.getByText('Timestamp')).toBeInTheDocument();
  65. expect(screen.getByText('May 24, 2022 9:13:30 PM UTC')).toBeInTheDocument();
  66. expect(screen.getByText('Duration')).toBeInTheDocument();
  67. expect(screen.getByText('931.40ms')).toBeInTheDocument();
  68. expect(screen.getByText('Device Model')).toBeInTheDocument();
  69. expect(screen.getByText('iPhone7,2')).toBeInTheDocument();
  70. expect(screen.getByText('Device Classification')).toBeInTheDocument();
  71. expect(screen.getByText('low')).toBeInTheDocument();
  72. });
  73. });