organizationApiKeysList.spec.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. ...initializeOrg(),
  20. router: {routes},
  21. });
  22. render(
  23. <OrganizationApiKeysList
  24. organization={organization}
  25. params={{}}
  26. routes={routes}
  27. keys={[TestStubs.ApiKey()]}
  28. router={router}
  29. routeParams={{}}
  30. route={route}
  31. busy={false}
  32. loading={false}
  33. location={router.location}
  34. onRemove={jest.fn()}
  35. onAddApiKey={jest.fn()}
  36. />
  37. );
  38. // Click remove button
  39. await userEvent.click(await screen.findByTitle('Remove API Key?'));
  40. // expect a modal
  41. renderGlobalModal();
  42. expect(screen.getByRole('dialog')).toBeInTheDocument();
  43. });
  44. });