userFeedbackEmpty.spec.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import {ProjectFixture} from 'sentry-fixture/project';
  2. import {reactHooks, 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. reactHooks.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. reactHooks.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. reactHooks.act(
  28. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  29. );
  30. render(<UserFeedbackEmpty />);
  31. expect(
  32. screen.getByText('Sorry, no user reports match your filters.')
  33. ).toBeInTheDocument();
  34. });
  35. it('renders warning for project query with user feedback', function () {
  36. reactHooks.act(
  37. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  38. );
  39. render(<UserFeedbackEmpty projectIds={[projectWithReports.id]} />);
  40. expect(
  41. screen.getByText('Sorry, no user reports match your filters.')
  42. ).toBeInTheDocument();
  43. });
  44. it('renders landing for project query without any user feedback', function () {
  45. reactHooks.act(
  46. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  47. );
  48. render(<UserFeedbackEmpty projectIds={[project.id]} />);
  49. expect(
  50. screen.getByRole('heading', {name: 'What do users think?'})
  51. ).toBeInTheDocument();
  52. });
  53. it('renders warning for multi project query with any user feedback', function () {
  54. reactHooks.act(
  55. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  56. );
  57. render(<UserFeedbackEmpty projectIds={[project.id, projectWithReports.id]} />);
  58. expect(
  59. screen.getByText('Sorry, no user reports match your filters.')
  60. ).toBeInTheDocument();
  61. });
  62. it('renders landing for multi project query without any user feedback', function () {
  63. reactHooks.act(
  64. () => void ProjectsStore.loadInitialData([project, projectWithoutReports])
  65. );
  66. render(<UserFeedbackEmpty projectIds={[project.id, projectWithoutReports.id]} />);
  67. expect(
  68. screen.getByRole('heading', {name: 'What do users think?'})
  69. ).toBeInTheDocument();
  70. });
  71. });