Skip to content

Commit

Permalink
[Cases]: fix flaky tests for case view alerts (#175034)
Browse files Browse the repository at this point in the history
## Summary

Fixes #174819


### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
js-jankisalvi authored Jan 18, 2024
1 parent 7f0e3d4 commit 541174a
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { waitFor } from '@testing-library/react';
import { waitFor, screen } from '@testing-library/react';
import { OBSERVABILITY_OWNER } from '../../../../common/constants';
import { alertCommentWithIndices, basicCase } from '../../../containers/mock';
import type { AppMockRenderer } from '../../../common/mock';
Expand All @@ -23,8 +23,7 @@ const caseData: CaseUI = {
comments: [...basicCase.comments, alertCommentWithIndices],
};

// FLAKY: https://github.com/elastic/kibana/issues/174819
describe.skip('CaseUI View Page activity tab', () => {
describe('CaseUI View Page activity tab', () => {
const getAlertsStateTableMock = jest.fn();
let appMockRender: AppMockRenderer;

Expand All @@ -38,15 +37,15 @@ describe.skip('CaseUI View Page activity tab', () => {
ruleTypeIds: ['log-threshold'],
});
});

afterEach(() => {
jest.clearAllMocks();
});

it('should render the alerts table', async () => {
const result = appMockRender.render(<CaseViewAlerts caseData={caseData} />);
await waitFor(async () => {
expect(result.getByTestId('alerts-table')).toBeTruthy();
});
appMockRender.render(<CaseViewAlerts caseData={caseData} />);

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

it('should call the alerts table with correct props for security solution', async () => {
Expand Down Expand Up @@ -124,16 +123,15 @@ describe.skip('CaseUI View Page activity tab', () => {
});

it('should show an empty prompt when the cases has no alerts', async () => {
const result = appMockRender.render(
appMockRender.render(
<CaseViewAlerts
caseData={{
...caseData,
comments: [],
}}
/>
);
await waitFor(async () => {
expect(result.getByTestId('caseViewAlertsEmpty')).toBeTruthy();
});

expect(await screen.findByTestId('caseViewAlertsEmpty')).toBeInTheDocument();
});
});

0 comments on commit 541174a

Please sign in to comment.