groupUserFeedback.spec.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {RouterFixture} from 'sentry-fixture/routerFixture';
  5. import {render, screen} from 'sentry-test/reactTestingLibrary';
  6. import ProjectsStore from 'sentry/stores/projectsStore';
  7. import GroupUserFeedback from './groupUserFeedback';
  8. describe('GroupUserFeedback', () => {
  9. const group = GroupFixture();
  10. const organization = OrganizationFixture();
  11. const project = ProjectFixture();
  12. const router = RouterFixture({
  13. params: {groupId: group.id},
  14. });
  15. beforeEach(() => {
  16. ProjectsStore.init();
  17. ProjectsStore.loadInitialData([project]);
  18. MockApiClient.clearMockResponses();
  19. MockApiClient.addMockResponse({
  20. url: `/organizations/${organization.slug}/issues/${group.id}/`,
  21. body: group,
  22. });
  23. });
  24. it('renders empty state', async () => {
  25. MockApiClient.addMockResponse({
  26. url: `/organizations/${organization.slug}/issues/${group.id}/user-reports/`,
  27. body: [],
  28. });
  29. render(<GroupUserFeedback />, {organization, router});
  30. expect(
  31. await screen.findByRole('heading', {
  32. name: 'What do users think?',
  33. })
  34. ).toBeInTheDocument();
  35. });
  36. it('renders user feedback', async () => {
  37. MockApiClient.addMockResponse({
  38. url: `/organizations/${organization.slug}/issues/${group.id}/user-reports/`,
  39. body: [
  40. {
  41. id: '1111',
  42. eventID: 'abc',
  43. name: 'Test User',
  44. email: 'test@example.com',
  45. comments: 'custom comment',
  46. dateCreated: '2024-10-24T01:22:30',
  47. user: {
  48. id: 'something',
  49. username: null,
  50. email: null,
  51. name: null,
  52. ipAddress: '127.0.0.1',
  53. avatarUrl: null,
  54. },
  55. event: {
  56. id: '123',
  57. eventID: 'abc',
  58. },
  59. },
  60. ],
  61. });
  62. render(<GroupUserFeedback />, {organization, router});
  63. expect(await screen.findByText('Test User')).toBeInTheDocument();
  64. expect(await screen.findByText('custom comment')).toBeInTheDocument();
  65. });
  66. });