From c9dafa618bbffe7b07ef38a09e8f90e0e6b175ac Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 20 Nov 2024 10:00:18 +0100 Subject: [PATCH] [ResponseOps][Cases] Fixed `sync alerts switch` flaky tests (#200738) Fixes #192997 ## Summary I removed `createAppMockRenderer` because `SyncAlertsSwitch` is a really simple component. (cherry picked from commit d94f8008a6b15da0358dd72b5897efe9b9e217e4) --- .../case_settings/sync_alerts_switch.test.tsx | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/cases/public/components/case_settings/sync_alerts_switch.test.tsx b/x-pack/plugins/cases/public/components/case_settings/sync_alerts_switch.test.tsx index 588c14a4ef51a..12c28a3930a99 100644 --- a/x-pack/plugins/cases/public/components/case_settings/sync_alerts_switch.test.tsx +++ b/x-pack/plugins/cases/public/components/case_settings/sync_alerts_switch.test.tsx @@ -6,29 +6,20 @@ */ import React from 'react'; -import { screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import type { AppMockRenderer } from '../../common/mock'; -import { createAppMockRenderer } from '../../common/mock'; import { SyncAlertsSwitch } from './sync_alerts_switch'; -// Failing: See https://github.com/elastic/kibana/issues/192997 -describe.skip('SyncAlertsSwitch', () => { - let appMockRender: AppMockRenderer; - - beforeEach(() => { - appMockRender = createAppMockRenderer(); - }); - +describe('SyncAlertsSwitch', () => { it('it renders', async () => { - appMockRender.render(); + render(); expect(await screen.findByTestId('sync-alerts-switch')).toBeInTheDocument(); }); it('it toggles the switch', async () => { - appMockRender.render(); + render(); await userEvent.click(await screen.findByTestId('sync-alerts-switch')); @@ -39,20 +30,20 @@ describe.skip('SyncAlertsSwitch', () => { }); it('it disables the switch', async () => { - appMockRender.render(); + render(); expect(await screen.findByTestId('sync-alerts-switch')).toHaveProperty('disabled', true); }); it('it start as off', async () => { - appMockRender.render(); + render(); expect(await screen.findByText('Off')).toBeInTheDocument(); expect(screen.queryByText('On')).not.toBeInTheDocument(); }); it('it shows the correct labels', async () => { - appMockRender.render(); + render(); expect(await screen.findByText('On')).toBeInTheDocument(); expect(screen.queryByText('Off')).not.toBeInTheDocument();