userFeedbackEmpty.spec.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {ProjectFixture} from 'sentry-fixture/project';
  2. import {act, render, screen} from 'sentry-test/reactTestingLibrary';
  3. import ProjectsStore from 'sentry/stores/projectsStore';
  4. import {UserFeedbackEmpty} from 'sentry/views/userFeedback/userFeedbackEmpty';
  5. describe('UserFeedbackEmpty', function () {
  6. const project = ProjectFixture({id: '1'});
  7. const projectWithReports = ProjectFixture({id: '2', hasUserReports: true});
  8. const projectWithoutReports = ProjectFixture({id: '3'});
  9. it('renders empty', function () {
  10. render(<UserFeedbackEmpty />);
  11. });
  12. it('renders landing for project with no user feedback', function () {
  13. act(() => void ProjectsStore.loadInitialData([project]));
  14. render(<UserFeedbackEmpty />);
  15. expect(
  16. screen.getByRole('heading', {name: 'What do users think?'})
  17. ).toBeInTheDocument();
  18. });
  19. it('renders warning for project with any user feedback', function () {
  20. act(() => void ProjectsStore.loadInitialData([projectWithReports]));
  21. render(<UserFeedbackEmpty />);
  22. expect(
  23. screen.getByText('Sorry, no user reports match your filters.')
  24. ).toBeInTheDocument();
  25. });
  26. it('renders warning for projects with any user feedback', function () {
  27. act(() => void ProjectsStore.loadInitialData([project, projectWithReports]));
  28. render(<UserFeedbackEmpty />);
  29. expect(
  30. screen.getByText('Sorry, no user reports match your filters.')
  31. ).toBeInTheDocument();
  32. });
  33. it('renders warning for project query with user feedback', function () {
  34. act(() => void ProjectsStore.loadInitialData([project, projectWithReports]));
  35. render(<UserFeedbackEmpty projectIds={[projectWithReports.id]} />);
  36. expect(
  37. screen.getByText('Sorry, no user reports match your filters.')
  38. ).toBeInTheDocument();
  39. });
  40. it('renders landing for project query without any user feedback', function () {
  41. act(() => void ProjectsStore.loadInitialData([project, projectWithReports]));
  42. render(<UserFeedbackEmpty projectIds={[project.id]} />);
  43. expect(
  44. screen.getByRole('heading', {name: 'What do users think?'})
  45. ).toBeInTheDocument();
  46. });
  47. it('renders warning for multi project query with any user feedback', function () {
  48. act(() => void ProjectsStore.loadInitialData([project, projectWithReports]));
  49. render(<UserFeedbackEmpty projectIds={[project.id, projectWithReports.id]} />);
  50. expect(
  51. screen.getByText('Sorry, no user reports match your filters.')
  52. ).toBeInTheDocument();
  53. });
  54. it('renders landing for multi project query without any user feedback', function () {
  55. act(() => void ProjectsStore.loadInitialData([project, projectWithoutReports]));
  56. render(<UserFeedbackEmpty projectIds={[project.id, projectWithoutReports.id]} />);
  57. expect(
  58. screen.getByRole('heading', {name: 'What do users think?'})
  59. ).toBeInTheDocument();
  60. });
  61. });