userFeedbackEmpty.spec.tsx 3.9 KB

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