Skip to content

Commit

Permalink
[ILM] Add warnings for managed system policies (elastic#132269)
Browse files Browse the repository at this point in the history
* Add warnings to system/managed policies

* Fix translations, policies

* Add jest tests

* Add jest tests to assert new toggle behavior

* Add jest tests for edit policy callout

* Fix snapshot

* [ML] Update jest tests with helper, rename helper for clarity

* [ML] Add hook for local storage to remember toggle setting

* [ML] Fix naming

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
qn895 and kibanamachine committed May 20, 2022
1 parent f70b4af commit d70ae0f
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 62 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ export const POLICY_WITH_KNOWN_AND_UNKNOWN_FIELDS = {
name: POLICY_NAME,
} as any as PolicyFromES;

export const POLICY_MANAGED_BY_ES: PolicyFromES = {
version: 1,
modifiedDate: Date.now().toString(),
policy: {
name: POLICY_NAME,
phases: {
hot: {
min_age: '0ms',
actions: {
rollover: {
max_age: '30d',
max_primary_shard_size: '50gb',
},
},
},
},
_meta: {
managed: true,
},
},
name: POLICY_NAME,
};

export const getGeneratedPolicies = (): PolicyFromES[] => {
const policy = {
phases: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils';
import { TestBed } from '@kbn/test-jest-helpers';
import { setupEnvironment } from '../../helpers';
import { initTestBed } from '../init_test_bed';
import { getDefaultHotPhasePolicy, POLICY_NAME } from '../constants';
import { getDefaultHotPhasePolicy, POLICY_NAME, POLICY_MANAGED_BY_ES } from '../constants';

describe('<EditPolicy /> edit warning', () => {
let testBed: TestBed;
Expand Down Expand Up @@ -54,6 +54,19 @@ describe('<EditPolicy /> edit warning', () => {
expect(exists('editWarning')).toBe(true);
});

test('an edit warning callout is shown for an existing, managed policy', async () => {
httpRequestsMockHelpers.setLoadPolicies([POLICY_MANAGED_BY_ES]);

await act(async () => {
testBed = await initTestBed(httpSetup);
});
const { exists, component } = testBed;
component.update();

expect(exists('editWarning')).toBe(true);
expect(exists('editManagedPolicyCallOut')).toBe(true);
});

test('no indices link if no indices', async () => {
httpRequestsMockHelpers.setLoadPolicies([
{ ...getDefaultHotPhasePolicy(POLICY_NAME), indices: [] },
Expand Down
Loading

0 comments on commit d70ae0f

Please sign in to comment.