Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elastic/kibana into fix/synthetics-…
Browse files Browse the repository at this point in the history
…overview-project-monitors
  • Loading branch information
dominiqueclarke committed Nov 21, 2022
2 parents 553690b + 40de9eb commit 2648dd1
Show file tree
Hide file tree
Showing 79 changed files with 1,214 additions and 318 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"compare-versions": "3.5.1",
"constate": "^3.3.2",
"copy-to-clipboard": "^3.0.8",
"core-js": "^3.26.0",
"core-js": "^3.26.1",
"cronstrue": "^1.51.0",
"cuid": "^2.1.8",
"cytoscape": "^3.10.0",
Expand Down Expand Up @@ -688,7 +688,7 @@
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1",
"@babel/eslint-plugin": "^7.19.1",
"@babel/generator": "^7.20.3",
"@babel/generator": "^7.20.4",
"@babel/helper-plugin-utils": "^7.20.2",
"@babel/parser": "^7.20.3",
"@babel/plugin-proposal-class-properties": "^7.18.6",
Expand Down Expand Up @@ -809,7 +809,7 @@
"@types/apidoc": "^0.22.3",
"@types/archiver": "^5.3.1",
"@types/async": "^3.2.3",
"@types/babel__core": "^7.1.19",
"@types/babel__core": "^7.1.20",
"@types/babel__generator": "^7.6.4",
"@types/babel__helper-plugin-utils": "^7.10.0",
"@types/base64-js": "^1.2.5",
Expand Down Expand Up @@ -922,7 +922,7 @@
"@types/redux-logger": "^3.0.8",
"@types/resolve": "^1.20.1",
"@types/seedrandom": ">=2.0.0 <4.0.0",
"@types/selenium-webdriver": "^4.1.6",
"@types/selenium-webdriver": "^4.1.9",
"@types/semver": "^7",
"@types/set-value": "^2.0.0",
"@types/sharp": "^0.30.4",
Expand Down Expand Up @@ -978,7 +978,7 @@
"callsites": "^3.1.0",
"chance": "1.0.18",
"chokidar": "^3.5.3",
"chromedriver": "^107.0.2",
"chromedriver": "^107.0.3",
"clean-webpack-plugin": "^3.0.0",
"compression-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^6.0.2",
Expand Down Expand Up @@ -1100,7 +1100,7 @@
"resolve": "^1.22.0",
"rxjs-marbles": "^7.0.1",
"sass-loader": "^10.3.1",
"selenium-webdriver": "^4.5.0",
"selenium-webdriver": "^4.6.0",
"simple-git": "^3.10.0",
"sinon": "^7.4.2",
"sort-package-json": "^1.53.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-babel-preset/node_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = (_, options = {}) => {
// Because of that we should use for that value the same version we install
// in the package.json in order to have the same polyfills between the environment
// and the tests
corejs: '3.26.0',
corejs: '3.26.1',
bugfixes: true,

...(options['@babel/preset-env'] || {}),
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-babel-preset/webpack_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = (_, options = {}) => {
modules: false,
// Please read the explanation for this
// in node_preset.js
corejs: '3.26.0',
corejs: '3.26.1',
bugfixes: true,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { i18n } from '@kbn/i18n';
export const EMPTY_VIEWER_STATE_EMPTY_TITLE = i18n.translate(
'exceptionList-components.empty.viewer.state.empty.title',
{
defaultMessage: 'Add exceptions to this rule',
defaultMessage: 'Add exceptions to this list',
}
);

export const EMPTY_VIEWER_STATE_EMPTY_BODY = i18n.translate(
'exceptionList-components.empty.viewer.state.empty.body',
{
defaultMessage: 'There is no exception in your rule. Create your first rule exception.',
defaultMessage: 'There is no exception in your list. Create your first exception.',
}
);
export const EMPTY_VIEWER_STATE_EMPTY_SEARCH_TITLE = i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export function GeneralSettings() {
return (
<>
<EuiCallOut
title={
title={i18n.translate('xpack.apm.apmSettings.callOutTitle', {
defaultMessage: 'Looking for all settings?',
})}
iconType="search"
>
<p>
<FormattedMessage
id="xpack.apm.apmSettings.kibanaLink"
defaultMessage="The full list of APM options can be found in {link}"
Expand All @@ -82,15 +87,14 @@ export function GeneralSettings() {
})}
>
{i18n.translate('xpack.apm.apmSettings.kibanaLink.label', {
defaultMessage: 'Kibana advanced settings',
defaultMessage: 'Kibana advanced settings.',
})}
</EuiLink>
),
}}
/>
}
iconType="iInCircle"
/>
</p>
</EuiCallOut>
<EuiSpacer />
{apmSettingsKeys.map((settingKey) => {
const editableConfig = settingsEditableConfig[settingKey];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,154 @@ describe('useTagsAction', () => {
);
});
});

it('do not update cases with no changes', async () => {
const updateSpy = jest.spyOn(api, 'updateCases');

const { result, waitFor } = renderHook(
() => useTagsAction({ onAction, onActionSuccess, isDisabled: false }),
{
wrapper: appMockRender.AppWrapper,
}
);

const action = result.current.getAction([{ ...basicCase, tags: [] }]);

act(() => {
action.onClick();
});

expect(onAction).toHaveBeenCalled();
expect(result.current.isFlyoutOpen).toBe(true);

act(() => {
result.current.onSaveTags({ selectedTags: [], unSelectedTags: ['pepsi'] });
});

await waitFor(() => {
expect(result.current.isFlyoutOpen).toBe(false);
expect(onActionSuccess).not.toHaveBeenCalled();
expect(updateSpy).not.toHaveBeenCalled();
});
});

it('do not update if the selected tags are the same but with different order', async () => {
const updateSpy = jest.spyOn(api, 'updateCases');

const { result, waitFor } = renderHook(
() => useTagsAction({ onAction, onActionSuccess, isDisabled: false }),
{
wrapper: appMockRender.AppWrapper,
}
);

const action = result.current.getAction([{ ...basicCase, tags: ['1', '2'] }]);

act(() => {
action.onClick();
});

expect(onAction).toHaveBeenCalled();
expect(result.current.isFlyoutOpen).toBe(true);

act(() => {
result.current.onSaveTags({ selectedTags: ['2', '1'], unSelectedTags: [] });
});

await waitFor(() => {
expect(result.current.isFlyoutOpen).toBe(false);
expect(onActionSuccess).not.toHaveBeenCalled();
expect(updateSpy).not.toHaveBeenCalled();
});
});

it('do not update if the selected tags are the same', async () => {
const updateSpy = jest.spyOn(api, 'updateCases');

const { result, waitFor } = renderHook(
() => useTagsAction({ onAction, onActionSuccess, isDisabled: false }),
{
wrapper: appMockRender.AppWrapper,
}
);

const action = result.current.getAction([{ ...basicCase, tags: ['1'] }]);

act(() => {
action.onClick();
});

expect(onAction).toHaveBeenCalled();
expect(result.current.isFlyoutOpen).toBe(true);

act(() => {
result.current.onSaveTags({ selectedTags: ['1'], unSelectedTags: [] });
});

await waitFor(() => {
expect(result.current.isFlyoutOpen).toBe(false);
expect(onActionSuccess).not.toHaveBeenCalled();
expect(updateSpy).not.toHaveBeenCalled();
});
});

it('do not update if selecting and unselecting the same tag', async () => {
const updateSpy = jest.spyOn(api, 'updateCases');

const { result, waitFor } = renderHook(
() => useTagsAction({ onAction, onActionSuccess, isDisabled: false }),
{
wrapper: appMockRender.AppWrapper,
}
);

const action = result.current.getAction([{ ...basicCase, tags: ['1'] }]);

act(() => {
action.onClick();
});

expect(onAction).toHaveBeenCalled();
expect(result.current.isFlyoutOpen).toBe(true);

act(() => {
result.current.onSaveTags({ selectedTags: ['1'], unSelectedTags: ['1'] });
});

await waitFor(() => {
expect(result.current.isFlyoutOpen).toBe(false);
expect(onActionSuccess).not.toHaveBeenCalled();
expect(updateSpy).not.toHaveBeenCalled();
});
});

it('do not update with empty tags and no selection', async () => {
const updateSpy = jest.spyOn(api, 'updateCases');

const { result, waitFor } = renderHook(
() => useTagsAction({ onAction, onActionSuccess, isDisabled: false }),
{
wrapper: appMockRender.AppWrapper,
}
);

const action = result.current.getAction([{ ...basicCase, tags: [] }]);

act(() => {
action.onClick();
});

expect(onAction).toHaveBeenCalled();
expect(result.current.isFlyoutOpen).toBe(true);

act(() => {
result.current.onSaveTags({ selectedTags: [], unSelectedTags: [] });
});

await waitFor(() => {
expect(result.current.isFlyoutOpen).toBe(false);
expect(onActionSuccess).not.toHaveBeenCalled();
expect(updateSpy).not.toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import { EuiIcon } from '@elastic/eui';
import React, { useCallback, useState } from 'react';
import { difference } from 'lodash';
import { difference, isEqual } from 'lodash';
import type { CaseUpdateRequest } from '../../../../common/ui';
import { useUpdateCases } from '../../../containers/use_bulk_update_case';
import type { Case } from '../../../../common';
import { useCasesContext } from '../../cases_context/use_cases_context';
Expand All @@ -33,20 +34,32 @@ export const useTagsAction = ({ onAction, onActionSuccess, isDisabled }: UseActi
[onAction]
);

const areTagsEqual = (originalTags: Set<string>, tagsToUpdate: Set<string>): boolean => {
return isEqual(originalTags, tagsToUpdate);
};

const onSaveTags = useCallback(
(tagsSelection: TagsSelectionState) => {
onAction();
onFlyoutClosed();
const casesToUpdate = selectedCasesToEditTags.map((theCase) => {
const tags = difference(theCase.tags, tagsSelection.unSelectedTags);
const uniqueTags = new Set([...tags, ...tagsSelection.selectedTags]);

return {
tags: Array.from(uniqueTags.values()),
id: theCase.id,
version: theCase.version,
};
});
const casesToUpdate = selectedCasesToEditTags.reduce((acc, theCase) => {
const tagsWithoutUnselectedTags = difference(theCase.tags, tagsSelection.unSelectedTags);
const uniqueTags = new Set([...tagsWithoutUnselectedTags, ...tagsSelection.selectedTags]);

if (areTagsEqual(new Set([...theCase.tags]), uniqueTags)) {
return acc;
}

return [
...acc,
{
tags: Array.from(uniqueTags.values()),
id: theCase.id,
version: theCase.version,
},
];
}, [] as CaseUpdateRequest[]);

updateCases(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ const waitForFormToRender = async (renderer: Screen) => {
});
};

describe('Create case', () => {
// FLAKY: https://github.com/elastic/kibana/issues/142284
describe.skip('Create case', () => {
const refetch = jest.fn();
const onFormSubmitSuccess = jest.fn();
const afterCaseCreated = jest.fn();
Expand Down Expand Up @@ -446,7 +447,9 @@ describe('Create case', () => {
});
});

describe('Step 2 - Connector Fields', () => {
// FLAKY: https://github.com/elastic/kibana/issues/143407
// FLAKY: https://github.com/elastic/kibana/issues/142282
describe.skip('Step 2 - Connector Fields', () => {
it(`should submit and push to Jira connector`, async () => {
useGetConnectorsMock.mockReturnValue({
...sampleConnectorData,
Expand Down
Loading

0 comments on commit 2648dd1

Please sign in to comment.