Skip to content

Commit

Permalink
[ResponseOps][Cases] Fixed sync alerts switch flaky tests (#200738)
Browse files Browse the repository at this point in the history
Fixes #192997

## Summary

I removed `createAppMockRenderer` because `SyncAlertsSwitch` is a really
simple component.
  • Loading branch information
adcoelho authored Nov 20, 2024
1 parent be8f93d commit d94f800
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(<SyncAlertsSwitch disabled={false} />);
render(<SyncAlertsSwitch disabled={false} />);

expect(await screen.findByTestId('sync-alerts-switch')).toBeInTheDocument();
});

it('it toggles the switch', async () => {
appMockRender.render(<SyncAlertsSwitch disabled={false} />);
render(<SyncAlertsSwitch disabled={false} />);

await userEvent.click(await screen.findByTestId('sync-alerts-switch'));

Expand All @@ -39,20 +30,20 @@ describe.skip('SyncAlertsSwitch', () => {
});

it('it disables the switch', async () => {
appMockRender.render(<SyncAlertsSwitch disabled={true} />);
render(<SyncAlertsSwitch disabled={true} />);

expect(await screen.findByTestId('sync-alerts-switch')).toHaveProperty('disabled', true);
});

it('it start as off', async () => {
appMockRender.render(<SyncAlertsSwitch disabled={false} isSynced={false} showLabel={true} />);
render(<SyncAlertsSwitch disabled={false} isSynced={false} showLabel={true} />);

expect(await screen.findByText('Off')).toBeInTheDocument();
expect(screen.queryByText('On')).not.toBeInTheDocument();
});

it('it shows the correct labels', async () => {
appMockRender.render(<SyncAlertsSwitch disabled={false} showLabel={true} />);
render(<SyncAlertsSwitch disabled={false} showLabel={true} />);

expect(await screen.findByText('On')).toBeInTheDocument();
expect(screen.queryByText('Off')).not.toBeInTheDocument();
Expand Down

0 comments on commit d94f800

Please sign in to comment.