organizationAuditLog.spec.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. rows: [
  22. {
  23. id: '4500000',
  24. actor: TestStubs.User(),
  25. event: 'project.remove',
  26. ipAddress: '127.0.0.1',
  27. note: 'removed project test',
  28. targetObject: 5466660,
  29. targetUser: null,
  30. data: {},
  31. dateCreated: '2021-09-28T00:29:33.940848Z',
  32. },
  33. {
  34. id: '430000',
  35. actor: TestStubs.User(),
  36. event: 'org.create',
  37. ipAddress: '127.0.0.1',
  38. note: 'created the organization',
  39. targetObject: 54215,
  40. targetUser: null,
  41. data: {},
  42. dateCreated: '2016-11-21T04:02:45.929313Z',
  43. },
  44. ],
  45. options: TestStubs.AuditLogsApiEventNames(),
  46. },
  47. });
  48. const {routerContext, organization} = initializeOrg({
  49. projects: [],
  50. router: {
  51. params: {orgId: 'org-slug'},
  52. },
  53. });
  54. const mockLocation = {query: {}};
  55. render(
  56. <OrganizationAuditLog
  57. organization={organization}
  58. params={{orgId: organization.slug}}
  59. location={mockLocation}
  60. />,
  61. {
  62. context: routerContext,
  63. }
  64. );
  65. expect(await screen.findByText('project.remove')).toBeInTheDocument();
  66. expect(screen.getByText('org.create')).toBeInTheDocument();
  67. expect(screen.getAllByText('127.0.0.1')).toHaveLength(2);
  68. expect(screen.getByText('17:29 PDT')).toBeInTheDocument();
  69. });
  70. });