index.spec.tsx 2.1 KB

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