userFeedbackEmpty.spec.tsx 2.9 KB

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