Skip to content

Commit

Permalink
Fix test using waitFor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Jan 8, 2025
1 parent 1024b38 commit 7f9a2a2
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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';
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit 7f9a2a2

Please sign in to comment.