Skip to content

Commit

Permalink
[8.x] [ResponseOps][Cases] Fix `SyncAlertsToggle` flaky test (
Browse files Browse the repository at this point in the history
#200870) (#201093)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Cases] Fix `SyncAlertsToggle` flaky test
(#200870)](#200870)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Antonio","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-21T09:26:10Z","message":"[ResponseOps][Cases]
Fix `SyncAlertsToggle` flaky test (#200870)\n\nFixes #190270\r\n\r\n##
Summary\r\n\r\nWe already wrap `SyncAlertsToggle` in
`<FormTestComponent>` so I removed\r\n`createAppMockRenderer` which
wasn't
necessary.","sha":"d91d82c2b9581821cf5ee30e8987a13f2d33b907","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["technical
debt","release_note:skip","Team:ResponseOps","v9.0.0","Feature:Cases","backport:prev-minor"],"title":"[ResponseOps][Cases]
Fix `SyncAlertsToggle` flaky
test","number":200870,"url":"https://github.com/elastic/kibana/pull/200870","mergeCommit":{"message":"[ResponseOps][Cases]
Fix `SyncAlertsToggle` flaky test (#200870)\n\nFixes #190270\r\n\r\n##
Summary\r\n\r\nWe already wrap `SyncAlertsToggle` in
`<FormTestComponent>` so I removed\r\n`createAppMockRenderer` which
wasn't
necessary.","sha":"d91d82c2b9581821cf5ee30e8987a13f2d33b907"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200870","number":200870,"mergeCommit":{"message":"[ResponseOps][Cases]
Fix `SyncAlertsToggle` flaky test (#200870)\n\nFixes #190270\r\n\r\n##
Summary\r\n\r\nWe already wrap `SyncAlertsToggle` in
`<FormTestComponent>` so I removed\r\n`createAppMockRenderer` which
wasn't necessary.","sha":"d91d82c2b9581821cf5ee30e8987a13f2d33b907"}}]}]
BACKPORT-->

Co-authored-by: Antonio <[email protected]>
  • Loading branch information
kibanamachine and adcoelho authored Nov 21, 2024
1 parent 8719a91 commit 4e2dec9
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 4e2dec9

Please sign in to comment.