index.spec.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {ActivityFeedFixture} from 'sentry-fixture/activityFeed';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import {GroupActivityType} from 'sentry/types';
  5. import OrganizationActivity from 'sentry/views/organizationActivity';
  6. describe('OrganizationActivity', function () {
  7. const {router, organization, routerContext} = initializeOrg();
  8. let params = {};
  9. beforeEach(function () {
  10. MockApiClient.addMockResponse({
  11. url: '/organizations/org-slug/activity/',
  12. body: [
  13. ActivityFeedFixture(),
  14. ActivityFeedFixture({
  15. id: '49',
  16. data: {},
  17. type: GroupActivityType.SET_PUBLIC,
  18. }),
  19. ],
  20. });
  21. params = {
  22. ...router,
  23. params: {
  24. orgId: organization.slug,
  25. },
  26. };
  27. });
  28. it('renders', async function () {
  29. render(<OrganizationActivity {...params} />, {context: routerContext});
  30. expect(await screen.findAllByTestId('activity-feed-item')).toHaveLength(2);
  31. });
  32. it('renders empty', async function () {
  33. MockApiClient.addMockResponse({
  34. url: '/organizations/org-slug/activity/',
  35. body: [],
  36. });
  37. render(<OrganizationActivity {...params} />, {context: routerContext});
  38. expect(screen.queryByTestId('activity-feed-item')).not.toBeInTheDocument();
  39. expect(await screen.findByTestId('empty-state')).toBeInTheDocument();
  40. });
  41. it('renders not found', async function () {
  42. MockApiClient.addMockResponse({
  43. url: '/organizations/org-slug/activity/',
  44. body: [],
  45. statusCode: 404,
  46. });
  47. render(<OrganizationActivity {...params} />, {context: routerContext});
  48. expect(screen.queryByTestId('activity-feed-item')).not.toBeInTheDocument();
  49. expect(await screen.findByTestId('empty-state')).toBeInTheDocument();
  50. });
  51. });