userFeedbackEmpty.spec.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {Organization} from 'fixtures/js-stubs/organization';
  2. import {Project} from 'fixtures/js-stubs/project';
  3. import {reactHooks, render, screen} from 'sentry-test/reactTestingLibrary';
  4. import ProjectsStore from 'sentry/stores/projectsStore';
  5. import {OrganizationContext} from 'sentry/views/organizationContext';
  6. import {UserFeedbackEmpty} from 'sentry/views/userFeedback/userFeedbackEmpty';
  7. describe('UserFeedbackEmpty', function () {
  8. const project = Project({id: '1'});
  9. const projectWithReports = Project({id: '2', hasUserReports: true});
  10. const projectWithoutReports = Project({id: '3'});
  11. const organization = Organization();
  12. it('renders empty', function () {
  13. render(
  14. <OrganizationContext.Provider value={organization}>
  15. <UserFeedbackEmpty />)
  16. </OrganizationContext.Provider>
  17. );
  18. });
  19. it('renders landing for project with no user feedback', function () {
  20. reactHooks.act(() => void ProjectsStore.loadInitialData([project]));
  21. render(
  22. <OrganizationContext.Provider value={organization}>
  23. <UserFeedbackEmpty />)
  24. </OrganizationContext.Provider>
  25. );
  26. expect(
  27. screen.getByRole('heading', {name: 'What do users think?'})
  28. ).toBeInTheDocument();
  29. });
  30. it('renders warning for project with any user feedback', function () {
  31. reactHooks.act(() => void ProjectsStore.loadInitialData([projectWithReports]));
  32. render(
  33. <OrganizationContext.Provider value={organization}>
  34. <UserFeedbackEmpty />)
  35. </OrganizationContext.Provider>
  36. );
  37. expect(
  38. screen.getByText('Sorry, no user reports match your filters.')
  39. ).toBeInTheDocument();
  40. });
  41. it('renders warning for projects with any user feedback', function () {
  42. reactHooks.act(
  43. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  44. );
  45. render(
  46. <OrganizationContext.Provider value={organization}>
  47. <UserFeedbackEmpty />)
  48. </OrganizationContext.Provider>
  49. );
  50. expect(
  51. screen.getByText('Sorry, no user reports match your filters.')
  52. ).toBeInTheDocument();
  53. });
  54. it('renders warning for project query with user feedback', function () {
  55. reactHooks.act(
  56. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  57. );
  58. render(
  59. <OrganizationContext.Provider value={organization}>
  60. <UserFeedbackEmpty projectIds={[projectWithReports.id]} />)
  61. </OrganizationContext.Provider>
  62. );
  63. expect(
  64. screen.getByText('Sorry, no user reports match your filters.')
  65. ).toBeInTheDocument();
  66. });
  67. it('renders landing for project query without any user feedback', function () {
  68. reactHooks.act(
  69. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  70. );
  71. render(
  72. <OrganizationContext.Provider value={organization}>
  73. <UserFeedbackEmpty projectIds={[project.id]} />)
  74. </OrganizationContext.Provider>
  75. );
  76. expect(
  77. screen.getByRole('heading', {name: 'What do users think?'})
  78. ).toBeInTheDocument();
  79. });
  80. it('renders warning for multi project query with any user feedback', function () {
  81. reactHooks.act(
  82. () => void ProjectsStore.loadInitialData([project, projectWithReports])
  83. );
  84. render(
  85. <OrganizationContext.Provider value={organization}>
  86. <UserFeedbackEmpty projectIds={[project.id, projectWithReports.id]} />)
  87. </OrganizationContext.Provider>
  88. );
  89. expect(
  90. screen.getByText('Sorry, no user reports match your filters.')
  91. ).toBeInTheDocument();
  92. });
  93. it('renders landing for multi project query without any user feedback', function () {
  94. reactHooks.act(
  95. () => void ProjectsStore.loadInitialData([project, projectWithoutReports])
  96. );
  97. render(
  98. <OrganizationContext.Provider value={organization}>
  99. <UserFeedbackEmpty projectIds={[project.id, projectWithoutReports.id]} />)
  100. </OrganizationContext.Provider>
  101. );
  102. expect(
  103. screen.getByRole('heading', {name: 'What do users think?'})
  104. ).toBeInTheDocument();
  105. });
  106. });