organizationApiKeysList.spec.tsx 1.2 KB

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