organizationApiKeysList.spec.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {DeprecatedApiKeyFixture} from 'sentry-fixture/deprecatedApiKey';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {
  4. render,
  5. renderGlobalModal,
  6. screen,
  7. userEvent,
  8. } from 'sentry-test/reactTestingLibrary';
  9. import OrganizationApiKeysList from 'sentry/views/settings/organizationApiKeys/organizationApiKeysList';
  10. jest.unmock('sentry/utils/recreateRoute');
  11. describe('OrganizationApiKeysList', function () {
  12. it('opens a modal when trying to delete a key', async function () {
  13. const routes = [
  14. {path: '/'},
  15. {path: '/:orgId/'},
  16. {path: '/organizations/:orgId/'},
  17. {path: 'api-keys/', name: 'API Key'},
  18. ];
  19. const {organization, router, route} = initializeOrg({
  20. router: {routes},
  21. });
  22. render(
  23. <OrganizationApiKeysList
  24. organization={organization}
  25. params={{}}
  26. routes={routes}
  27. keys={[DeprecatedApiKeyFixture()]}
  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. });