Skip to content

Commit

Permalink
Merge branch 'main' into use-discover-locator-for-alert-results
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 3, 2023
2 parents f54bca5 + 55f6006 commit eee2e1b
Show file tree
Hide file tree
Showing 63 changed files with 1,685 additions and 888 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"endpoint:user-artifact": "f94c250a52b30d0a2d32635f8b4c5bdabd1e25c0",
"endpoint:user-artifact-manifest": "8c14d49a385d5d1307d956aa743ec78de0b2be88",
"enterprise_search_telemetry": "fafcc8318528d34f721c42d1270787c52565bad5",
"epm-packages": "2915aee4302d4b00472ed05c21f59b7d498b5206",
"epm-packages": "7d80ba3f1fcd80316aa0b112657272034b66d5a8",
"epm-packages-assets": "9fd3d6726ac77369249e9a973902c2cd615fc771",
"event_loop_delays_daily": "d2ed39cf669577d90921c176499908b4943fb7bd",
"exception-list": "fe8cc004fd2742177cdb9300f4a67689463faf9c",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ async function createRoot({ logFileName }: CreateRootConfig) {
// suite is very long, the 10mins default can cause timeouts
jest.setTimeout(15 * 60 * 1000);

describe('migration v2', () => {
// FLAKY: https://github.com/elastic/kibana/issues/148263
describe.skip('migration v2', () => {
let esServer: TestElasticsearchUtils;
let rootA: Root;
let rootB: Root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,12 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
</EuiFlexItem>
</EuiFlexGroup>
)}
<EuiFlexGroup gutterSize="none" responsive={false} css={{ margin: 0 }} ref={containerRef}>
<EuiFlexGroup
gutterSize="none"
responsive={false}
css={{ margin: '0 0 1px 0' }}
ref={containerRef}
>
<EuiResizeObserver onResize={onResize}>
{(resizeRef) => (
<EuiOutsideClickDetector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import React, {
} from 'react';
import { type DataViewField } from '@kbn/data-views-plugin/public';
import { startWith } from 'rxjs';
import useMount from 'react-use/lib/useMount';
import type { Query, Filter } from '@kbn/es-query';
import { usePageUrlState } from '@kbn/ml-url-state';
import {
Expand Down Expand Up @@ -129,7 +128,7 @@ export const ChangePointDetectionContextProvider: FC = ({ children }) => {

const timeRange = useTimeRangeUpdates();

useMount(function updateIntervalOnTimeBoundsChange() {
useEffect(function updateIntervalOnTimeBoundsChange() {
const timeUpdateSubscription = timefilter
.getTimeUpdate$()
.pipe(startWith(timefilter.getTime()))
Expand All @@ -145,7 +144,8 @@ export const ChangePointDetectionContextProvider: FC = ({ children }) => {
return () => {
timeUpdateSubscription.unsubscribe();
};
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const metricFieldOptions = useMemo<DataViewField[]>(() => {
return dataView.fields.filter(({ aggregatable, type }) => aggregatable && type === 'number');
Expand Down Expand Up @@ -195,15 +195,16 @@ export const ChangePointDetectionContextProvider: FC = ({ children }) => {
[filterManager]
);

useMount(() => {
useEffect(() => {
setResultFilter(filterManager.getFilters());
const sub = filterManager.getUpdates$().subscribe(() => {
setResultFilter(filterManager.getFilters());
});
return () => {
sub.unsubscribe();
};
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(
function syncFilters() {
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/cases/common/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,11 @@ export type SingleCaseMetricsFeature =
| 'lifespan';

export enum SortFieldCase {
createdAt = 'createdAt',
closedAt = 'closedAt',
createdAt = 'createdAt',
severity = 'severity',
status = 'status',
title = 'title',
}

export type ElasticUser = SnakeToCamelCase<User>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { mount } from 'enzyme';
import moment from 'moment-timezone';
import { render, waitFor, screen, act } from '@testing-library/react';
import { render, waitFor, screen, act, within } from '@testing-library/react';
import { renderHook } from '@testing-library/react-hooks';
import userEvent from '@testing-library/user-event';
import { waitForEuiPopoverOpen } from '@elastic/eui/lib/test/rtl';
Expand Down Expand Up @@ -257,23 +257,28 @@ describe('AllCasesListGeneric', () => {
expect.objectContaining({
queryParams: {
...DEFAULT_QUERY_PARAMS,
sortOrder: 'asc',
},
})
);
});
});

it('renders the title column', async () => {
const res = appMockRenderer.render(<AllCasesList />);

expect(res.getByTestId('tableHeaderCell_title_0')).toBeInTheDocument();
});

it('renders the status column', async () => {
const res = appMockRenderer.render(<AllCasesList />);

expect(res.getByTestId('tableHeaderCell_Status_6')).toBeInTheDocument();
expect(res.getByTestId('tableHeaderCell_status_6')).toBeInTheDocument();
});

it('renders the severity column', async () => {
const res = appMockRenderer.render(<AllCasesList />);

expect(res.getByTestId('tableHeaderCell_Severity_7')).toBeInTheDocument();
expect(res.getByTestId('tableHeaderCell_severity_7')).toBeInTheDocument();
});

it('should render the case stats', () => {
Expand Down Expand Up @@ -393,6 +398,66 @@ describe('AllCasesListGeneric', () => {
});
});

it('should sort by status', async () => {
const result = appMockRenderer.render(<AllCasesList isSelectorView={false} />);

userEvent.click(
within(result.getByTestId('tableHeaderCell_status_6')).getByTestId('tableHeaderSortButton')
);

await waitFor(() => {
expect(useGetCasesMock).toHaveBeenLastCalledWith(
expect.objectContaining({
queryParams: {
...DEFAULT_QUERY_PARAMS,
sortField: SortFieldCase.status,
sortOrder: 'asc',
},
})
);
});
});

it('should sort by severity', async () => {
const result = appMockRenderer.render(<AllCasesList isSelectorView={false} />);

userEvent.click(
within(result.getByTestId('tableHeaderCell_severity_7')).getByTestId('tableHeaderSortButton')
);

await waitFor(() => {
expect(useGetCasesMock).toHaveBeenLastCalledWith(
expect.objectContaining({
queryParams: {
...DEFAULT_QUERY_PARAMS,
sortField: SortFieldCase.severity,
sortOrder: 'asc',
},
})
);
});
});

it('should sort by title', async () => {
const result = appMockRenderer.render(<AllCasesList isSelectorView={false} />);

userEvent.click(
within(result.getByTestId('tableHeaderCell_title_0')).getByTestId('tableHeaderSortButton')
);

await waitFor(() => {
expect(useGetCasesMock).toHaveBeenLastCalledWith(
expect.objectContaining({
queryParams: {
...DEFAULT_QUERY_PARAMS,
sortField: SortFieldCase.title,
sortOrder: 'asc',
},
})
);
});
});

it('should filter by status: closed', async () => {
const result = appMockRenderer.render(<AllCasesList isSelectorView={false} />);
userEvent.click(result.getByTestId('case-status-filter'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const ProgressLoader = styled(EuiProgress)`
`;

const getSortField = (field: string): SortFieldCase =>
field === SortFieldCase.closedAt ? SortFieldCase.closedAt : SortFieldCase.createdAt;
// @ts-ignore
SortFieldCase[field] ?? SortFieldCase.title;

export interface AllCasesListProps {
hiddenStatuses?: CaseStatusWithAllStatus[];
Expand Down
Loading

0 comments on commit eee2e1b

Please sign in to comment.