organizationApiKeysList.spec.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {
  3. render,
  4. renderGlobalModal,
  5. screen,
  6. userEvent,
  7. } from 'sentry-test/reactTestingLibrary';
  8. import OrganizationApiKeysList from 'sentry/views/settings/organizationApiKeys/organizationApiKeysList';
  9. jest.unmock('sentry/utils/recreateRoute');
  10. describe('OrganizationApiKeysList', function () {
  11. it('opens a modal when trying to delete a key', async function () {
  12. const routes = [
  13. {path: '/'},
  14. {path: '/:orgId/'},
  15. {path: '/organizations/:orgId/'},
  16. {path: 'api-keys/', name: 'API Key'},
  17. ];
  18. const {organization, router, route} = initializeOrg({
  19. router: {routes},
  20. });
  21. render(
  22. <OrganizationApiKeysList
  23. organization={organization}
  24. params={{}}
  25. routes={routes}
  26. keys={[TestStubs.ApiKey()]}
  27. router={router}
  28. routeParams={{}}
  29. route={route}
  30. busy={false}
  31. loading={false}
  32. location={router.location}
  33. onRemove={jest.fn()}
  34. onAddApiKey={jest.fn()}
  35. />
  36. );
  37. // Click remove button
  38. await userEvent.click(await screen.findByTitle('Remove API Key?'));
  39. // expect a modal
  40. renderGlobalModal();
  41. expect(screen.getByRole('dialog')).toBeInTheDocument();
  42. });
  43. });