groupUserFeedback.spec.tsx 1.8 KB

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