Skip to content

Commit

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

Fixes elastic#192997

## Summary

I removed `createAppMockRenderer` because `SyncAlertsSwitch` is a really
simple component.
  • Loading branch information
adcoelho authored and CAWilson94 committed Dec 12, 2024
1 parent 23ea83f commit 7a872b1
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 7a872b1

Please sign in to comment.