diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/cold_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/cold_phase.test.ts
new file mode 100644
index 0000000000000..dfb7411eb941f
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/cold_phase.test.ts
@@ -0,0 +1,52 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { act } from 'react-dom/test-utils';
+import { setupEnvironment } from '../../helpers/setup_environment';
+import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
+import { getDefaultHotPhasePolicy } from '../constants';
+
+describe(' cold phase', () => {
+ let testBed: EditPolicyTestBed;
+ const { server, httpRequestsMockHelpers } = setupEnvironment();
+
+ beforeAll(() => {
+ jest.useFakeTimers();
+ });
+
+ afterAll(() => {
+ jest.useRealTimers();
+ server.restore();
+ });
+
+ beforeEach(async () => {
+ httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
+ httpRequestsMockHelpers.setListNodes({
+ nodesByRoles: { data: ['node1'] },
+ nodesByAttributes: { 'attribute:true': ['node1'] },
+ isUsingDeprecatedDataRoleConfig: true,
+ });
+ httpRequestsMockHelpers.setNodesDetails('attribute:true', [
+ { nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } },
+ ]);
+ httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
+
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ const { component } = testBed;
+ component.update();
+ });
+
+ test('shows timing only when enabled', async () => {
+ const { actions } = testBed;
+ expect(actions.cold.hasMinAgeInput()).toBeFalsy();
+ await actions.cold.enable(true);
+ expect(actions.cold.hasMinAgeInput()).toBeTruthy();
+ });
+});
diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts
new file mode 100644
index 0000000000000..0fb4951e4a4a6
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts
@@ -0,0 +1,169 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import {
+ DELETE_PHASE_POLICY,
+ getDefaultHotPhasePolicy,
+ NEW_SNAPSHOT_POLICY_NAME,
+ SNAPSHOT_POLICY_NAME,
+} from '../constants';
+import { act } from 'react-dom/test-utils';
+import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
+import { API_BASE_PATH } from '../../../../common/constants';
+import { setupEnvironment } from '../../helpers/setup_environment';
+
+describe(' delete phase', () => {
+ let testBed: EditPolicyTestBed;
+ const { server, httpRequestsMockHelpers } = setupEnvironment();
+
+ afterAll(() => {
+ server.restore();
+ });
+
+ beforeEach(async () => {
+ httpRequestsMockHelpers.setLoadPolicies([DELETE_PHASE_POLICY]);
+ httpRequestsMockHelpers.setLoadSnapshotPolicies([
+ SNAPSHOT_POLICY_NAME,
+ NEW_SNAPSHOT_POLICY_NAME,
+ ]);
+
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ const { component } = testBed;
+ component.update();
+ });
+
+ test('is hidden when disabled', async () => {
+ httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
+
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ const { component, actions } = testBed;
+ component.update();
+
+ expect(actions.delete.isShown()).toBeFalsy();
+ await actions.delete.enablePhase();
+ expect(actions.delete.isShown()).toBeTruthy();
+ });
+
+ test('shows timing after it was enabled', async () => {
+ httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
+
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ const { component, actions } = testBed;
+ component.update();
+
+ expect(actions.delete.hasMinAgeInput()).toBeFalsy();
+ await actions.delete.enablePhase();
+ expect(actions.delete.hasMinAgeInput()).toBeTruthy();
+ });
+
+ describe('wait for snapshot', () => {
+ test('shows snapshot policy name', () => {
+ expect(testBed.find('snapshotPolicyCombobox').prop('data-currentvalue')).toEqual([
+ {
+ label: DELETE_PHASE_POLICY.policy.phases.delete?.actions.wait_for_snapshot?.policy,
+ },
+ ]);
+ });
+
+ test('updates snapshot policy name', async () => {
+ const { actions } = testBed;
+
+ await actions.setWaitForSnapshotPolicy(NEW_SNAPSHOT_POLICY_NAME);
+ await actions.savePolicy();
+
+ const expected = {
+ name: DELETE_PHASE_POLICY.name,
+ phases: {
+ ...DELETE_PHASE_POLICY.policy.phases,
+ delete: {
+ ...DELETE_PHASE_POLICY.policy.phases.delete,
+ actions: {
+ ...DELETE_PHASE_POLICY.policy.phases.delete?.actions,
+ wait_for_snapshot: {
+ policy: NEW_SNAPSHOT_POLICY_NAME,
+ },
+ },
+ },
+ },
+ };
+
+ const latestRequest = server.requests[server.requests.length - 1];
+ expect(latestRequest.url).toBe(`${API_BASE_PATH}/policies`);
+ expect(latestRequest.method).toBe('POST');
+ expect(JSON.parse(JSON.parse(latestRequest.requestBody).body)).toEqual(expected);
+ });
+
+ test('shows a callout when the input is not an existing policy', async () => {
+ const { actions } = testBed;
+
+ await actions.setWaitForSnapshotPolicy('my_custom_policy');
+ expect(testBed.find('noPoliciesCallout').exists()).toBeFalsy();
+ expect(testBed.find('policiesErrorCallout').exists()).toBeFalsy();
+ expect(testBed.find('customPolicyCallout').exists()).toBeTruthy();
+ });
+
+ test('removes the action if field is empty', async () => {
+ const { actions } = testBed;
+
+ await actions.setWaitForSnapshotPolicy('');
+ await actions.savePolicy();
+
+ const expected = {
+ name: DELETE_PHASE_POLICY.name,
+ phases: {
+ ...DELETE_PHASE_POLICY.policy.phases,
+ delete: {
+ ...DELETE_PHASE_POLICY.policy.phases.delete,
+ actions: {
+ ...DELETE_PHASE_POLICY.policy.phases.delete?.actions,
+ },
+ },
+ },
+ };
+
+ delete expected.phases.delete.actions.wait_for_snapshot;
+
+ const latestRequest = server.requests[server.requests.length - 1];
+ expect(JSON.parse(JSON.parse(latestRequest.requestBody).body)).toEqual(expected);
+ });
+
+ test('shows a callout when there are no snapshot policies', async () => {
+ // need to call setup on testBed again for it to use a newly defined snapshot policies response
+ httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ testBed.component.update();
+ expect(testBed.find('customPolicyCallout').exists()).toBeFalsy();
+ expect(testBed.find('policiesErrorCallout').exists()).toBeFalsy();
+ expect(testBed.find('noPoliciesCallout').exists()).toBeTruthy();
+ });
+
+ test('shows a callout when there is an error loading snapshot policies', async () => {
+ // need to call setup on testBed again for it to use a newly defined snapshot policies response
+ httpRequestsMockHelpers.setLoadSnapshotPolicies([], { status: 500, body: 'error' });
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ testBed.component.update();
+ expect(testBed.find('customPolicyCallout').exists()).toBeFalsy();
+ expect(testBed.find('noPoliciesCallout').exists()).toBeFalsy();
+ expect(testBed.find('policiesErrorCallout').exists()).toBeTruthy();
+ });
+ });
+});
diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/json_flyout.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/json_flyout.test.ts
new file mode 100644
index 0000000000000..6584c19c85be3
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/json_flyout.test.ts
@@ -0,0 +1,66 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { act } from 'react-dom/test-utils';
+import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
+import { setupEnvironment } from '../../helpers/setup_environment';
+import { getDefaultHotPhasePolicy } from '../constants';
+
+describe(' request flyout', () => {
+ let testBed: EditPolicyTestBed;
+ const { server, httpRequestsMockHelpers } = setupEnvironment();
+
+ beforeAll(() => {
+ jest.useFakeTimers();
+ });
+
+ afterAll(() => {
+ jest.useRealTimers();
+ server.restore();
+ });
+
+ beforeEach(async () => {
+ httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
+
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ const { component } = testBed;
+ component.update();
+ });
+
+ test('renders a json in flyout for a default policy', async () => {
+ const { find, component } = testBed;
+ await act(async () => {
+ find('requestButton').simulate('click');
+ });
+ component.update();
+
+ const json = component.find(`code`).text();
+ const expected = `PUT _ilm/policy/my_policy\n${JSON.stringify(
+ {
+ policy: {
+ phases: {
+ hot: {
+ min_age: '0ms',
+ actions: {
+ rollover: {
+ max_age: '30d',
+ max_size: '50gb',
+ },
+ },
+ },
+ },
+ },
+ },
+ null,
+ 2
+ )}`;
+ expect(json).toBe(expected);
+ });
+});
diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/reactive_form.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/reactive_form.test.ts
deleted file mode 100644
index 10e66a4836260..0000000000000
--- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/reactive_form.test.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { act } from 'react-dom/test-utils';
-import { setupEnvironment } from '../../helpers/setup_environment';
-import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
-import { getDefaultHotPhasePolicy } from '../constants';
-
-describe(' reactive form', () => {
- let testBed: EditPolicyTestBed;
- const { server, httpRequestsMockHelpers } = setupEnvironment();
-
- beforeAll(() => {
- jest.useFakeTimers();
- });
-
- afterAll(() => {
- jest.useRealTimers();
- server.restore();
- });
-
- beforeEach(async () => {
- httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
- httpRequestsMockHelpers.setListNodes({
- nodesByRoles: { data: ['node1'] },
- nodesByAttributes: { 'attribute:true': ['node1'] },
- isUsingDeprecatedDataRoleConfig: true,
- });
- httpRequestsMockHelpers.setNodesDetails('attribute:true', [
- { nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } },
- ]);
- httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
-
- await act(async () => {
- testBed = await setup();
- });
-
- const { component } = testBed;
- component.update();
- });
-
- describe('timing', () => {
- test('warm phase shows timing only when enabled', async () => {
- const { actions } = testBed;
- expect(actions.warm.hasMinAgeInput()).toBeFalsy();
- await actions.warm.enable(true);
- expect(actions.warm.hasMinAgeInput()).toBeTruthy();
- });
-
- test('cold phase shows timing only when enabled', async () => {
- const { actions } = testBed;
- expect(actions.cold.hasMinAgeInput()).toBeFalsy();
- await actions.cold.enable(true);
- expect(actions.cold.hasMinAgeInput()).toBeTruthy();
- });
-
- test('delete phase shows timing after it was enabled', async () => {
- const { actions } = testBed;
- expect(actions.delete.hasMinAgeInput()).toBeFalsy();
- await actions.delete.enablePhase();
- expect(actions.delete.hasMinAgeInput()).toBeTruthy();
- });
- });
-
- describe('delete phase', () => {
- test('is hidden when disabled', async () => {
- const { actions } = testBed;
- expect(actions.delete.isShown()).toBeFalsy();
- await actions.delete.enablePhase();
- expect(actions.delete.isShown()).toBeTruthy();
- });
- });
-
- describe('json in flyout', () => {
- test('renders a json in flyout for a default policy', async () => {
- const { find, component } = testBed;
- await act(async () => {
- find('requestButton').simulate('click');
- });
- component.update();
-
- const json = component.find(`code`).text();
- const expected = `PUT _ilm/policy/my_policy\n${JSON.stringify(
- {
- policy: {
- phases: {
- hot: {
- min_age: '0ms',
- actions: {
- rollover: {
- max_age: '30d',
- max_size: '50gb',
- },
- },
- },
- },
- },
- },
- null,
- 2
- )}`;
- expect(json).toBe(expected);
- });
- });
-});
diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/wait_for_snapshot.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/wait_for_snapshot.test.ts
deleted file mode 100644
index ff19559185f92..0000000000000
--- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/wait_for_snapshot.test.ts
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { DELETE_PHASE_POLICY, NEW_SNAPSHOT_POLICY_NAME, SNAPSHOT_POLICY_NAME } from '../constants';
-import { act } from 'react-dom/test-utils';
-import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
-import { API_BASE_PATH } from '../../../../common/constants';
-import { setupEnvironment } from '../../helpers/setup_environment';
-
-describe(' delete phase: wait for snapshot action', () => {
- let testBed: EditPolicyTestBed;
- const { server, httpRequestsMockHelpers } = setupEnvironment();
-
- afterAll(() => {
- server.restore();
- });
-
- beforeEach(async () => {
- httpRequestsMockHelpers.setLoadPolicies([DELETE_PHASE_POLICY]);
- httpRequestsMockHelpers.setLoadSnapshotPolicies([
- SNAPSHOT_POLICY_NAME,
- NEW_SNAPSHOT_POLICY_NAME,
- ]);
-
- await act(async () => {
- testBed = await setup();
- });
-
- const { component } = testBed;
- component.update();
- });
-
- test('wait for snapshot policy field should correctly display snapshot policy name', () => {
- expect(testBed.find('snapshotPolicyCombobox').prop('data-currentvalue')).toEqual([
- {
- label: DELETE_PHASE_POLICY.policy.phases.delete?.actions.wait_for_snapshot?.policy,
- },
- ]);
- });
-
- test('wait for snapshot field should correctly update snapshot policy name', async () => {
- const { actions } = testBed;
-
- await actions.setWaitForSnapshotPolicy(NEW_SNAPSHOT_POLICY_NAME);
- await actions.savePolicy();
-
- const expected = {
- name: DELETE_PHASE_POLICY.name,
- phases: {
- ...DELETE_PHASE_POLICY.policy.phases,
- delete: {
- ...DELETE_PHASE_POLICY.policy.phases.delete,
- actions: {
- ...DELETE_PHASE_POLICY.policy.phases.delete?.actions,
- wait_for_snapshot: {
- policy: NEW_SNAPSHOT_POLICY_NAME,
- },
- },
- },
- },
- };
-
- const latestRequest = server.requests[server.requests.length - 1];
- expect(latestRequest.url).toBe(`${API_BASE_PATH}/policies`);
- expect(latestRequest.method).toBe('POST');
- expect(JSON.parse(JSON.parse(latestRequest.requestBody).body)).toEqual(expected);
- });
-
- test('wait for snapshot field should display a callout when the input is not an existing policy', async () => {
- const { actions } = testBed;
-
- await actions.setWaitForSnapshotPolicy('my_custom_policy');
- expect(testBed.find('noPoliciesCallout').exists()).toBeFalsy();
- expect(testBed.find('policiesErrorCallout').exists()).toBeFalsy();
- expect(testBed.find('customPolicyCallout').exists()).toBeTruthy();
- });
-
- test('wait for snapshot field should delete action if field is empty', async () => {
- const { actions } = testBed;
-
- await actions.setWaitForSnapshotPolicy('');
- await actions.savePolicy();
-
- const expected = {
- name: DELETE_PHASE_POLICY.name,
- phases: {
- ...DELETE_PHASE_POLICY.policy.phases,
- delete: {
- ...DELETE_PHASE_POLICY.policy.phases.delete,
- actions: {
- ...DELETE_PHASE_POLICY.policy.phases.delete?.actions,
- },
- },
- },
- };
-
- delete expected.phases.delete.actions.wait_for_snapshot;
-
- const latestRequest = server.requests[server.requests.length - 1];
- expect(JSON.parse(JSON.parse(latestRequest.requestBody).body)).toEqual(expected);
- });
-
- test('wait for snapshot field should display a callout when there are no snapshot policies', async () => {
- // need to call setup on testBed again for it to use a newly defined snapshot policies response
- httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
- await act(async () => {
- testBed = await setup();
- });
-
- testBed.component.update();
- expect(testBed.find('customPolicyCallout').exists()).toBeFalsy();
- expect(testBed.find('policiesErrorCallout').exists()).toBeFalsy();
- expect(testBed.find('noPoliciesCallout').exists()).toBeTruthy();
- });
-
- test('wait for snapshot field should display a callout when there is an error loading snapshot policies', async () => {
- // need to call setup on testBed again for it to use a newly defined snapshot policies response
- httpRequestsMockHelpers.setLoadSnapshotPolicies([], { status: 500, body: 'error' });
- await act(async () => {
- testBed = await setup();
- });
-
- testBed.component.update();
- expect(testBed.find('customPolicyCallout').exists()).toBeFalsy();
- expect(testBed.find('noPoliciesCallout').exists()).toBeFalsy();
- expect(testBed.find('policiesErrorCallout').exists()).toBeTruthy();
- });
-});
diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts
new file mode 100644
index 0000000000000..2252f8d1f5fa8
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts
@@ -0,0 +1,52 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { act } from 'react-dom/test-utils';
+import { setupEnvironment } from '../../helpers/setup_environment';
+import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
+import { getDefaultHotPhasePolicy } from '../constants';
+
+describe(' warm phase', () => {
+ let testBed: EditPolicyTestBed;
+ const { server, httpRequestsMockHelpers } = setupEnvironment();
+
+ beforeAll(() => {
+ jest.useFakeTimers();
+ });
+
+ afterAll(() => {
+ jest.useRealTimers();
+ server.restore();
+ });
+
+ beforeEach(async () => {
+ httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
+ httpRequestsMockHelpers.setListNodes({
+ nodesByRoles: { data: ['node1'] },
+ nodesByAttributes: { 'attribute:true': ['node1'] },
+ isUsingDeprecatedDataRoleConfig: true,
+ });
+ httpRequestsMockHelpers.setNodesDetails('attribute:true', [
+ { nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } },
+ ]);
+ httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
+
+ await act(async () => {
+ testBed = await setup();
+ });
+
+ const { component } = testBed;
+ component.update();
+ });
+
+ test('shows timing only when enabled', async () => {
+ const { actions } = testBed;
+ expect(actions.warm.hasMinAgeInput()).toBeFalsy();
+ await actions.warm.enable(true);
+ expect(actions.warm.hasMinAgeInput()).toBeTruthy();
+ });
+});