Skip to content

Commit

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

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Cases] Fixed `sync alerts switch` flaky tests
(#200738)](#200738)

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

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

<!--BACKPORT
[{"author":{"name":"Antonio","email":"antonio.coelho@elastic.co"},"sourceCommit":{"committedDate":"2024-11-20T09:00:18Z","message":"[ResponseOps][Cases]
Fixed `sync alerts switch` flaky tests (#200738)\n\nFixes
#192997\r\n\r\n## Summary\r\n\r\nI removed `createAppMockRenderer`
because `SyncAlertsSwitch` is a really\r\nsimple
component.","sha":"d94f8008a6b15da0358dd72b5897efe9b9e217e4","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","Feature:Cases","backport:prev-minor"],"title":"[ResponseOps][Cases]
Fixed `sync alerts switch` flaky
tests","number":200738,"url":"https://github.com/elastic/kibana/pull/200738","mergeCommit":{"message":"[ResponseOps][Cases]
Fixed `sync alerts switch` flaky tests (#200738)\n\nFixes
#192997\r\n\r\n## Summary\r\n\r\nI removed `createAppMockRenderer`
because `SyncAlertsSwitch` is a really\r\nsimple
component.","sha":"d94f8008a6b15da0358dd72b5897efe9b9e217e4"}},"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/200738","number":200738,"mergeCommit":{"message":"[ResponseOps][Cases]
Fixed `sync alerts switch` flaky tests (#200738)\n\nFixes
#192997\r\n\r\n## Summary\r\n\r\nI removed `createAppMockRenderer`
because `SyncAlertsSwitch` is a really\r\nsimple
component.","sha":"d94f8008a6b15da0358dd72b5897efe9b9e217e4"}}]}]
BACKPORT-->

Co-authored-by: Antonio <antonio.coelho@elastic.co>
  • Loading branch information
kibanamachine and adcoelho authored Nov 20, 2024
1 parent 98109e8 commit 0316b31
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 0316b31

Please sign in to comment.