organizationApiKeysList.spec.jsx 914 B

1234567891011121314151617181920212223242526272829303132
  1. import {mountGlobalModal} from 'sentry-test/modal';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import OrganizationApiKeysList from 'sentry/views/settings/organizationApiKeys/organizationApiKeysList';
  4. jest.unmock('sentry/utils/recreateRoute');
  5. const routes = [
  6. {path: '/'},
  7. {path: '/:orgId/'},
  8. {path: '/organizations/:orgId/'},
  9. {path: 'api-keys/', name: 'API Key'},
  10. ];
  11. describe('OrganizationApiKeysList', function () {
  12. it('opens a modal when trying to delete a key', async function () {
  13. render(
  14. <OrganizationApiKeysList
  15. params={{orgId: 'org-slug'}}
  16. routes={routes}
  17. keys={[TestStubs.ApiKey()]}
  18. />
  19. );
  20. // Click remove button
  21. (await screen.findByTitle('Remove API Key?')).click();
  22. // expect a modal
  23. const modal = await mountGlobalModal();
  24. expect(modal.find('GlobalModal[visible=true]').exists()).toBe(true);
  25. });
  26. });