organizationAuditLog.spec.jsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import ConfigStore from 'sentry/stores/configStore';
  4. import OrganizationAuditLog from 'sentry/views/settings/organizationAuditLog';
  5. describe('OrganizationAuditLog', () => {
  6. const user = {
  7. ...TestStubs.User(),
  8. options: {
  9. clock24Hours: true,
  10. timezone: 'America/Los_Angeles',
  11. },
  12. };
  13. beforeEach(() => {
  14. ConfigStore.loadInitialData({user});
  15. });
  16. it('renders', async () => {
  17. MockApiClient.addMockResponse({
  18. url: `/organizations/org-slug/audit-logs/`,
  19. method: 'GET',
  20. body: [
  21. {
  22. id: '4500000',
  23. actor: TestStubs.User(),
  24. event: 'project.remove',
  25. ipAddress: '127.0.0.1',
  26. note: 'removed project test',
  27. targetObject: 5466660,
  28. targetUser: null,
  29. data: {},
  30. dateCreated: '2021-09-28T00:29:33.940848Z',
  31. },
  32. {
  33. id: '430000',
  34. actor: TestStubs.User(),
  35. event: 'org.create',
  36. ipAddress: '127.0.0.1',
  37. note: 'created the organization',
  38. targetObject: 54215,
  39. targetUser: null,
  40. data: {},
  41. dateCreated: '2016-11-21T04:02:45.929313Z',
  42. },
  43. ],
  44. });
  45. const {router, routerContext, organization} = initializeOrg({
  46. projects: [],
  47. router: {
  48. location: {query: {}},
  49. params: {orgId: 'org-slug'},
  50. },
  51. });
  52. render(
  53. <OrganizationAuditLog
  54. organization={organization}
  55. params={{orgId: organization.slug}}
  56. location={router.location}
  57. />,
  58. {
  59. context: routerContext,
  60. }
  61. );
  62. expect(await screen.findByText('project.remove')).toBeInTheDocument();
  63. expect(screen.getByText('org.create')).toBeInTheDocument();
  64. expect(screen.getAllByText('127.0.0.1')).toHaveLength(2);
  65. expect(screen.getByText('17:29 PDT')).toBeInTheDocument();
  66. });
  67. });