Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] [ResponseOps][Cases] Fixed `sync alerts switch` flaky tests (#200738) #200865

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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