onboarding.spec.tsx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {ProjectFixture} from 'sentry-fixture/project';
  3. import {ProjectKeysFixture} from 'sentry-fixture/projectKeys';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import {textWithMarkupMatcher} from 'sentry-test/utils';
  6. import {LegacyOnboarding, Onboarding} from './onboarding';
  7. describe('Performance Onboarding View > Unsupported Banner', function () {
  8. const organization = OrganizationFixture();
  9. it('Displays unsupported banner for unsupported projects', function () {
  10. const project = ProjectFixture({
  11. platform: 'nintendo-switch',
  12. });
  13. render(<LegacyOnboarding organization={organization} project={project} />);
  14. expect(screen.getByTestId('unsupported-alert')).toBeInTheDocument();
  15. });
  16. it('Does not display unsupported banner for supported projects', function () {
  17. const project = ProjectFixture({
  18. platform: 'java',
  19. });
  20. render(<LegacyOnboarding organization={organization} project={project} />);
  21. expect(screen.queryByTestId('unsupported-alert')).not.toBeInTheDocument();
  22. });
  23. });
  24. describe('Testing new onboarding ui', function () {
  25. const organization = OrganizationFixture({
  26. features: ['tracing-onboarding-new-ui'],
  27. });
  28. it('Renders updated ui', async function () {
  29. MockApiClient.addMockResponse({
  30. url: `/projects/org-slug/project-slug/keys/`,
  31. method: 'GET',
  32. body: [ProjectKeysFixture()[0]],
  33. });
  34. MockApiClient.addMockResponse({
  35. url: `/projects/org-slug/project-slug/`,
  36. method: 'GET',
  37. body: ProjectFixture({platform: 'javascript-react', firstEvent: null}),
  38. });
  39. MockApiClient.addMockResponse({
  40. url: `/organizations/org-slug/sdks/`,
  41. method: 'GET',
  42. });
  43. render(
  44. <Onboarding
  45. organization={organization}
  46. project={ProjectFixture({platform: 'javascript-react'})}
  47. />
  48. );
  49. expect(await screen.findByText('Query for Traces, Get Answers')).toBeInTheDocument();
  50. expect(await screen.findByText('Preview a Sentry Trace')).toBeInTheDocument();
  51. expect(
  52. await screen.findByText(
  53. textWithMarkupMatcher('Add the Sentry SDK as a dependency using npm or yarn')
  54. )
  55. ).toBeInTheDocument();
  56. await userEvent.click(screen.getByRole('button', {name: 'Next'}));
  57. expect(
  58. await screen.findByText(
  59. textWithMarkupMatcher(
  60. "Configuration should happen as early as possible in your application's lifecycle."
  61. )
  62. )
  63. ).toBeInTheDocument();
  64. await userEvent.click(screen.getByRole('button', {name: 'Next'}));
  65. expect(await screen.findByText(/Add Distributed Tracing/)).toBeInTheDocument();
  66. await userEvent.click(screen.getByRole('button', {name: 'Next'}));
  67. expect(
  68. await screen.findByText(/Verify that performance monitoring is working correctly/)
  69. ).toBeInTheDocument();
  70. expect(
  71. await screen.findByText("Waiting for this project's first trace")
  72. ).toBeInTheDocument();
  73. expect(
  74. screen.getByRole('button', {name: 'Take me to an example'})
  75. ).toBeInTheDocument();
  76. });
  77. });