From d91d82c2b9581821cf5ee30e8987a13f2d33b907 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 21 Nov 2024 10:26:10 +0100 Subject: [PATCH] [ResponseOps][Cases] Fix `SyncAlertsToggle` flaky test (#200870) Fixes #190270 ## Summary We already wrap `SyncAlertsToggle` in `` so I removed `createAppMockRenderer` which wasn't necessary. --- .../sync_alerts_toggle.test.tsx | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx b/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx index e783e81800f3e..fbe7eca218391 100644 --- a/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx +++ b/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx @@ -6,17 +6,13 @@ */ import React from 'react'; -import { screen, within, waitFor } from '@testing-library/react'; +import { screen, within, waitFor, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { SyncAlertsToggle } from './sync_alerts_toggle'; import { schema } from '../create/schema'; import { FormTestComponent } from '../../common/test_utils'; -import type { AppMockRenderer } from '../../common/mock'; -import { createAppMockRenderer } from '../../common/mock'; -// Failing: https://github.com/elastic/kibana/issues/190270 -describe.skip('SyncAlertsToggle', () => { - let appMockRender: AppMockRenderer; +describe('SyncAlertsToggle', () => { const onSubmit = jest.fn(); const defaultFormProps = { onSubmit, @@ -28,15 +24,10 @@ describe.skip('SyncAlertsToggle', () => { beforeEach(() => { jest.clearAllMocks(); - appMockRender = createAppMockRenderer(); - }); - - afterEach(async () => { - await appMockRender.clearQueryCache(); }); it('it renders', async () => { - appMockRender.render( + render( @@ -48,7 +39,7 @@ describe.skip('SyncAlertsToggle', () => { }); it('it toggles the switch', async () => { - appMockRender.render( + render( @@ -63,7 +54,7 @@ describe.skip('SyncAlertsToggle', () => { }); it('calls onSubmit with correct data', async () => { - appMockRender.render( + render( @@ -73,7 +64,7 @@ describe.skip('SyncAlertsToggle', () => { await userEvent.click(within(synAlerts).getByRole('switch')); - await userEvent.click(screen.getByText('Submit')); + await userEvent.click(await screen.findByText('Submit')); await waitFor(() => { expect(onSubmit).toBeCalledWith(