index.spec.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {DetailedEventsFixture} from 'sentry-fixture/events';
  2. import {GroupFixture} from 'sentry-fixture/group';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {act, render, screen} from 'sentry-test/reactTestingLibrary';
  5. import GroupingStore from 'sentry/stores/groupingStore';
  6. import GroupMergedView from 'sentry/views/issueDetails/groupMerged';
  7. describe('Issues -> Merged View', function () {
  8. const events = DetailedEventsFixture();
  9. const group = GroupFixture();
  10. const mockData = {
  11. merged: [
  12. {
  13. latestEvent: events[0],
  14. state: 'unlocked',
  15. id: '2c4887696f708c476a81ce4e834c4b02',
  16. },
  17. {
  18. latestEvent: events[1],
  19. state: 'unlocked',
  20. id: 'e05da55328a860b21f62e371f0a7507d',
  21. },
  22. ],
  23. };
  24. beforeEach(function () {
  25. GroupingStore.init();
  26. MockApiClient.clearMockResponses();
  27. MockApiClient.addMockResponse({
  28. url: `/organizations/org-slug/issues/${group.id}/hashes/?limit=50&query=`,
  29. body: mockData.merged,
  30. });
  31. });
  32. it('renders initially with loading component', async function () {
  33. const {organization, project, router} = initializeOrg({
  34. router: {
  35. params: {groupId: 'groupId'},
  36. },
  37. });
  38. render(
  39. <GroupMergedView
  40. organization={organization}
  41. project={project}
  42. groupId={group.id}
  43. location={router.location}
  44. />,
  45. {router, organization}
  46. );
  47. expect(screen.getByTestId('loading-indicator')).toBeInTheDocument();
  48. await act(tick);
  49. });
  50. it('renders with mocked data', async function () {
  51. const {organization, project, router} = initializeOrg({
  52. router: {
  53. params: {groupId: 'groupId'},
  54. },
  55. });
  56. render(
  57. <GroupMergedView
  58. organization={organization}
  59. project={project}
  60. groupId={group.id}
  61. location={router.location}
  62. />,
  63. {router, organization}
  64. );
  65. expect(await screen.findByText(mockData.merged[0].id)).toBeInTheDocument();
  66. const title = await screen.findByText('Fingerprints included in this issue');
  67. expect(title.parentElement).toHaveTextContent(
  68. 'Fingerprints included in this issue (2)'
  69. );
  70. });
  71. });