diff --git a/web/packages/teleport/src/Discover/Kubernetes/EnrollEKSCluster/EnrollEKSCluster.test.tsx b/web/packages/teleport/src/Discover/Kubernetes/EnrollEKSCluster/EnrollEKSCluster.test.tsx index 7cfb7dfd93b7d..bc13ff57fbf46 100644 --- a/web/packages/teleport/src/Discover/Kubernetes/EnrollEKSCluster/EnrollEKSCluster.test.tsx +++ b/web/packages/teleport/src/Discover/Kubernetes/EnrollEKSCluster/EnrollEKSCluster.test.tsx @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { act, fireEvent, render, screen } from 'design/utils/testing'; +import { act, fireEvent, render, screen, waitFor } from 'design/utils/testing'; +import { wait } from 'shared/utils/wait'; import cfg from 'teleport/config'; import { ComponentWrapper } from 'teleport/Discover/Fixtures/kubernetes'; @@ -179,6 +180,7 @@ describe('test EnrollEksCluster.tsx', () => { expect(integrationService.enrollEksClusters).not.toHaveBeenCalled(); }); + test('auto enroll disabled, enrolls cluster', async () => { jest.spyOn(integrationService, 'fetchEksClusters').mockResolvedValue({ clusters: mockEKSClusters, @@ -197,7 +199,9 @@ describe('test EnrollEksCluster.tsx', () => { act(() => screen.getByRole('radio').click()); - act(() => screen.getByText('Enroll EKS Cluster').click()); + await waitFor(() => { + screen.getByText('Enroll EKS Cluster').click(); + }); expect(discoveryService.createDiscoveryConfig).not.toHaveBeenCalled(); expect(KubeService.prototype.fetchKubernetes).toHaveBeenCalledTimes(1);