auditLogView.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import OrganizationAuditLog from 'sentry/views/settings/organizationAuditLog';
  4. // XXX(epurkhiser): This appears to also be tested by ./index.spec.tsx
  5. describe('OrganizationAuditLog', function () {
  6. const {routerContext, organization, router} = initializeOrg({
  7. ...initializeOrg(),
  8. projects: [],
  9. router: {
  10. params: {orgId: 'org-slug'},
  11. },
  12. });
  13. const ENDPOINT = `/organizations/${organization.slug}/audit-logs/`;
  14. beforeEach(function () {
  15. MockApiClient.clearMockResponses();
  16. MockApiClient.addMockResponse({
  17. url: ENDPOINT,
  18. body: {rows: TestStubs.AuditLogs(), options: TestStubs.AuditLogsApiEventNames()},
  19. });
  20. });
  21. it('renders', async function () {
  22. render(<OrganizationAuditLog location={router.location} />, {
  23. context: routerContext,
  24. });
  25. expect(await screen.findByRole('heading')).toHaveTextContent('Audit Log');
  26. expect(screen.getByRole('textbox')).toBeInTheDocument();
  27. expect(screen.getByText('Member')).toBeInTheDocument();
  28. expect(screen.getByText('Action')).toBeInTheDocument();
  29. expect(screen.getByText('IP')).toBeInTheDocument();
  30. expect(screen.getByText('Time')).toBeInTheDocument();
  31. expect(screen.queryByText('No audit entries available')).not.toBeInTheDocument();
  32. expect(screen.getByText('edited project ludic-science')).toBeInTheDocument();
  33. });
  34. it('renders empty', async function () {
  35. MockApiClient.clearMockResponses();
  36. MockApiClient.addMockResponse({
  37. url: ENDPOINT,
  38. body: {rows: [], options: TestStubs.AuditLogsApiEventNames()},
  39. });
  40. render(<OrganizationAuditLog location={router.location} />, {
  41. context: routerContext,
  42. });
  43. expect(await screen.findByText('No audit entries available')).toBeInTheDocument();
  44. });
  45. it('displays whether an action was done by a superuser', async () => {
  46. render(<OrganizationAuditLog location={router.location} />, {
  47. context: routerContext,
  48. });
  49. expect(await screen.findByText('Sentry Staff')).toBeInTheDocument();
  50. expect(screen.getAllByText('Foo Bar')).toHaveLength(2);
  51. });
  52. });