Skip to content

Commit

Permalink
[ResponseOps][Cases] Fix SyncAlertsToggle flaky test (elastic#200870)
Browse files Browse the repository at this point in the history
Fixes elastic#190270

## Summary

We already wrap `SyncAlertsToggle` in `<FormTestComponent>` so I removed
`createAppMockRenderer` which wasn't necessary.
  • Loading branch information
adcoelho authored and CAWilson94 committed Dec 12, 2024
1 parent 0b24f77 commit 9beca40
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,15 +24,10 @@ describe.skip('SyncAlertsToggle', () => {

beforeEach(() => {
jest.clearAllMocks();
appMockRender = createAppMockRenderer();
});

afterEach(async () => {
await appMockRender.clearQueryCache();
});

it('it renders', async () => {
appMockRender.render(
render(
<FormTestComponent>
<SyncAlertsToggle isLoading={false} />
</FormTestComponent>
Expand All @@ -48,7 +39,7 @@ describe.skip('SyncAlertsToggle', () => {
});

it('it toggles the switch', async () => {
appMockRender.render(
render(
<FormTestComponent>
<SyncAlertsToggle isLoading={false} />
</FormTestComponent>
Expand All @@ -63,7 +54,7 @@ describe.skip('SyncAlertsToggle', () => {
});

it('calls onSubmit with correct data', async () => {
appMockRender.render(
render(
<FormTestComponent {...defaultFormProps}>
<SyncAlertsToggle isLoading={false} />
</FormTestComponent>
Expand All @@ -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(
Expand Down

0 comments on commit 9beca40

Please sign in to comment.