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