[ILM] Split edit policy test helpers into separate files (#100807) (#101514)

* Refactored edit policy actions into separate files

* Fixed types errors

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Yulia Čech 2021-06-07 21:32:37 +02:00 committed by GitHub
parent 43092adc4a
commit a900693f03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 770 additions and 745 deletions

View file

@ -121,7 +121,7 @@ export interface TestBed<T = string> {
*
* @param switchTestSubject The test subject of the EuiSwitch (can be a nested path. e.g. "myForm.mySwitch").
*/
toggleEuiSwitch: (switchTestSubject: T, isChecked?: boolean) => void;
toggleEuiSwitch: (switchTestSubject: T) => void;
/**
* The EUI ComboBox is a special input as it needs the ENTER key to be pressed
* in order to register the value set. This helpers automatically does that.

View file

@ -5,20 +5,29 @@
* 2.0.
*/
import { act } from 'react-dom/test-utils';
import { TestBedConfig } from '@kbn/test/jest';
import { AppServicesContext } from '../../../public/types';
import {
Phase,
createEnablePhaseAction,
createNodeAllocationActions,
createFormToggleAction,
createFormSetValueAction,
setReplicas,
savePolicy,
createSearchableSnapshotActions,
createTogglePhaseAction,
createSavePolicyAction,
createErrorsActions,
createRolloverActions,
createSetWaitForSnapshotAction,
createMinAgeActions,
createShrinkActions,
createFreezeActions,
createForceMergeActions,
createReadonlyActions,
createIndexPriorityActions,
} from '../helpers';
import { initTestBed } from './init_test_bed';
type SetupReturn = ReturnType<typeof setup>;
@ -30,242 +39,57 @@ export const setup = async (arg?: {
}) => {
const testBed = await initTestBed(arg);
const { find, component, form, exists } = testBed;
const createFormCheckboxAction = (dataTestSubject: string) => async (checked: boolean) => {
await act(async () => {
form.selectCheckBox(dataTestSubject, checked);
});
component.update();
};
const setWaitForSnapshotPolicy = async (snapshotPolicyName: string) => {
act(() => {
find('snapshotPolicyCombobox').simulate('change', [{ label: snapshotPolicyName }]);
});
component.update();
};
const toggleDefaultRollover = createFormToggleAction(testBed, 'useDefaultRolloverSwitch');
const toggleRollover = createFormToggleAction(testBed, 'rolloverSwitch');
const setMaxPrimaryShardSize = async (value: string, units?: string) => {
await act(async () => {
find('hot-selectedMaxPrimaryShardSize').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxPrimaryShardSize.select').simulate('change', {
target: { value: units },
});
}
});
component.update();
};
const setMaxSize = async (value: string, units?: string) => {
await act(async () => {
find('hot-selectedMaxSizeStored').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxSizeStoredUnits.select').simulate('change', {
target: { value: units },
});
}
});
component.update();
};
const setMaxDocs = createFormSetValueAction(testBed, 'hot-selectedMaxDocuments');
const setMaxAge = async (value: string, units?: string) => {
await act(async () => {
find('hot-selectedMaxAge').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxAgeUnits.select').simulate('change', { target: { value: units } });
}
});
component.update();
};
const createForceMergeActions = (phase: Phase) => {
const toggleSelector = `${phase}-forceMergeSwitch`;
return {
forceMergeFieldExists: () => exists(toggleSelector),
toggleForceMerge: createFormToggleAction(testBed, toggleSelector),
setForcemergeSegmentsCount: createFormSetValueAction(
testBed,
`${phase}-selectedForceMergeSegments`
),
setBestCompression: createFormCheckboxAction(`${phase}-bestCompression`),
};
};
const createIndexPriorityActions = (phase: Phase) => {
const toggleSelector = `${phase}-indexPrioritySwitch`;
return {
indexPriorityExists: () => exists(toggleSelector),
toggleIndexPriority: createFormToggleAction(testBed, toggleSelector),
setIndexPriority: createFormSetValueAction(testBed, `${phase}-indexPriority`),
};
};
const createMinAgeActions = (phase: Phase) => {
return {
hasMinAgeInput: () => exists(`${phase}-selectedMinimumAge`),
setMinAgeValue: createFormSetValueAction(testBed, `${phase}-selectedMinimumAge`),
setMinAgeUnits: createFormSetValueAction(testBed, `${phase}-selectedMinimumAgeUnits`),
hasRolloverTipOnMinAge: () => exists(`${phase}-rolloverMinAgeInputIconTip`),
};
};
const createShrinkActions = (phase: Phase) => {
const toggleSelector = `${phase}-shrinkSwitch`;
return {
shrinkExists: () => exists(toggleSelector),
toggleShrink: createFormToggleAction(testBed, toggleSelector),
setShrink: createFormSetValueAction(testBed, `${phase}-primaryShardCount`),
};
};
const createSetFreeze = (phase: Phase) =>
createFormToggleAction(testBed, `${phase}-freezeSwitch`);
const createFreezeExists = (phase: Phase) => () => exists(`${phase}-freezeSwitch`);
const createReadonlyActions = (phase: Phase) => {
const toggleSelector = `${phase}-readonlySwitch`;
return {
readonlyExists: () => exists(toggleSelector),
toggleReadonly: createFormToggleAction(testBed, toggleSelector),
};
};
const createSearchableSnapshotActions = (phase: Phase) => {
const fieldSelector = `searchableSnapshotField-${phase}`;
const licenseCalloutSelector = `${fieldSelector}.searchableSnapshotDisabledDueToLicense`;
const toggleSelector = `${fieldSelector}.searchableSnapshotToggle`;
const toggleSearchableSnapshot = createFormToggleAction(testBed, toggleSelector);
return {
searchableSnapshotDisabled: () =>
exists(licenseCalloutSelector) && find(licenseCalloutSelector).props().disabled === true,
searchableSnapshotsExists: () => exists(fieldSelector),
findSearchableSnapshotToggle: () => find(toggleSelector),
searchableSnapshotDisabledDueToLicense: () =>
exists(`${fieldSelector}.searchableSnapshotDisabledDueToLicense`),
toggleSearchableSnapshot,
setSearchableSnapshot: async (value: string) => {
if (!exists(`searchableSnapshotField-${phase}.searchableSnapshotCombobox`)) {
await toggleSearchableSnapshot(true);
}
act(() => {
find(`searchableSnapshotField-${phase}.searchableSnapshotCombobox`).simulate('change', [
{ label: value },
]);
});
component.update();
},
};
};
const enableDeletePhase = async (isEnabled: boolean) => {
const buttonSelector = isEnabled ? 'enableDeletePhaseButton' : 'disableDeletePhaseButton';
await act(async () => {
find(buttonSelector).simulate('click');
});
component.update();
};
const hasRolloverSettingRequiredCallout = (): boolean => exists('rolloverSettingsRequired');
const expectErrorMessages = (expectedMessages: string[]) => {
const errorMessages = component.find('.euiFormErrorText');
expect(errorMessages.length).toBe(expectedMessages.length);
expectedMessages.forEach((expectedErrorMessage) => {
let foundErrorMessage;
for (let i = 0; i < errorMessages.length; i++) {
if (errorMessages.at(i).text() === expectedErrorMessage) {
foundErrorMessage = true;
}
}
expect(foundErrorMessage).toBe(true);
});
};
/*
* We rely on a setTimeout (dedounce) to display error messages under the form fields.
* This handler runs all the timers so we can assert for errors in our tests.
*/
const runTimers = () => {
act(() => {
jest.runAllTimers();
});
component.update();
};
const { exists } = testBed;
return {
...testBed,
runTimers,
actions: {
saveAsNewPolicy: createFormToggleAction(testBed, 'saveAsNewSwitch'),
togglePhase: createTogglePhaseAction(testBed),
savePolicy: createSavePolicyAction(testBed),
toggleSaveAsNewPolicy: createFormToggleAction(testBed, 'saveAsNewSwitch'),
setPolicyName: createFormSetValueAction(testBed, 'policyNameField'),
setWaitForSnapshotPolicy,
savePolicy: () => savePolicy(testBed),
hasGlobalErrorCallout: () => exists('policyFormErrorsCallout'),
expectErrorMessages,
errors: {
...createErrorsActions(testBed),
},
timeline: {
hasHotPhase: () => exists('ilmTimelineHotPhase'),
hasWarmPhase: () => exists('ilmTimelineWarmPhase'),
hasColdPhase: () => exists('ilmTimelineColdPhase'),
hasFrozenPhase: () => exists('ilmTimelineFrozenPhase'),
hasDeletePhase: () => exists('ilmTimelineDeletePhase'),
hasPhase: (phase: Phase) => exists(`ilmTimelinePhase-${phase}`),
},
rollover: {
...createRolloverActions(testBed),
},
hot: {
setMaxSize,
setMaxDocs,
setMaxAge,
setMaxPrimaryShardSize,
toggleRollover,
toggleDefaultRollover,
hasRolloverSettingRequiredCallout,
hasErrorIndicator: () => exists('phaseErrorIndicator-hot'),
...createForceMergeActions('hot'),
...createIndexPriorityActions('hot'),
...createShrinkActions('hot'),
...createReadonlyActions('hot'),
...createSearchableSnapshotActions('hot'),
...createForceMergeActions(testBed, 'hot'),
...createIndexPriorityActions(testBed, 'hot'),
...createShrinkActions(testBed, 'hot'),
...createReadonlyActions(testBed, 'hot'),
...createSearchableSnapshotActions(testBed, 'hot'),
},
warm: {
enable: createEnablePhaseAction(testBed, 'warm'),
...createMinAgeActions('warm'),
...createMinAgeActions(testBed, 'warm'),
setReplicas: (value: string) => setReplicas(testBed, 'warm', value),
hasErrorIndicator: () => exists('phaseErrorIndicator-warm'),
...createShrinkActions('warm'),
...createForceMergeActions('warm'),
...createReadonlyActions('warm'),
...createIndexPriorityActions('warm'),
...createShrinkActions(testBed, 'warm'),
...createForceMergeActions(testBed, 'warm'),
...createReadonlyActions(testBed, 'warm'),
...createIndexPriorityActions(testBed, 'warm'),
...createNodeAllocationActions(testBed, 'warm'),
},
cold: {
enable: createEnablePhaseAction(testBed, 'cold'),
...createMinAgeActions('cold'),
...createMinAgeActions(testBed, 'cold'),
setReplicas: (value: string) => setReplicas(testBed, 'cold', value),
setFreeze: createSetFreeze('cold'),
freezeExists: createFreezeExists('cold'),
...createReadonlyActions('cold'),
hasErrorIndicator: () => exists('phaseErrorIndicator-cold'),
...createIndexPriorityActions('cold'),
...createSearchableSnapshotActions('cold'),
...createFreezeActions(testBed, 'cold'),
...createReadonlyActions(testBed, 'cold'),
...createIndexPriorityActions(testBed, 'cold'),
...createSearchableSnapshotActions(testBed, 'cold'),
...createNodeAllocationActions(testBed, 'cold'),
},
frozen: {
enable: createEnablePhaseAction(testBed, 'frozen'),
...createMinAgeActions('frozen'),
hasErrorIndicator: () => exists('phaseErrorIndicator-frozen'),
...createSearchableSnapshotActions('frozen'),
...createMinAgeActions(testBed, 'frozen'),
...createSearchableSnapshotActions(testBed, 'frozen'),
},
delete: {
isShown: () => exists('delete-phaseContent'),
enable: enableDeletePhase,
...createMinAgeActions('delete'),
isShown: () => exists('delete-phase'),
...createMinAgeActions(testBed, 'delete'),
setWaitForSnapshotPolicy: createSetWaitForSnapshotAction(testBed),
},
},
};

View file

@ -8,7 +8,6 @@
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('<EditPolicy /> cold phase', () => {
let testBed: EditPolicyTestBed;
@ -24,16 +23,7 @@ describe('<EditPolicy /> cold phase', () => {
});
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([]);
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -46,7 +36,7 @@ describe('<EditPolicy /> cold phase', () => {
test('shows timing only when enabled', async () => {
const { actions } = testBed;
expect(actions.cold.hasMinAgeInput()).toBeFalsy();
await actions.cold.enable(true);
await actions.togglePhase('cold');
expect(actions.cold.hasMinAgeInput()).toBeTruthy();
});
});

View file

@ -50,8 +50,10 @@ describe('<EditPolicy /> delete phase', () => {
component.update();
expect(actions.delete.isShown()).toBeFalsy();
await actions.delete.enable(true);
await actions.togglePhase('delete');
expect(actions.delete.isShown()).toBeTruthy();
await actions.togglePhase('delete');
expect(actions.delete.isShown()).toBeFalsy();
});
test('shows timing after it was enabled', async () => {
@ -65,7 +67,7 @@ describe('<EditPolicy /> delete phase', () => {
component.update();
expect(actions.delete.hasMinAgeInput()).toBeFalsy();
await actions.delete.enable(true);
await actions.togglePhase('delete');
expect(actions.delete.hasMinAgeInput()).toBeTruthy();
});
@ -81,7 +83,7 @@ describe('<EditPolicy /> delete phase', () => {
test('updates snapshot policy name', async () => {
const { actions } = testBed;
await actions.setWaitForSnapshotPolicy(NEW_SNAPSHOT_POLICY_NAME);
await actions.delete.setWaitForSnapshotPolicy(NEW_SNAPSHOT_POLICY_NAME);
await actions.savePolicy();
const expected = {
@ -109,7 +111,7 @@ describe('<EditPolicy /> delete phase', () => {
test('shows a callout when the input is not an existing policy', async () => {
const { actions } = testBed;
await actions.setWaitForSnapshotPolicy('my_custom_policy');
await actions.delete.setWaitForSnapshotPolicy('my_custom_policy');
expect(testBed.find('noPoliciesCallout').exists()).toBeFalsy();
expect(testBed.find('policiesErrorCallout').exists()).toBeFalsy();
expect(testBed.find('customPolicyCallout').exists()).toBeTruthy();
@ -118,7 +120,7 @@ describe('<EditPolicy /> delete phase', () => {
test('removes the action if field is empty', async () => {
const { actions } = testBed;
await actions.setWaitForSnapshotPolicy('');
await actions.delete.setWaitForSnapshotPolicy('');
await actions.savePolicy();
const expected = {

View file

@ -10,7 +10,6 @@ import { act } from 'react-dom/test-utils';
import { licensingMock } from '../../../../../licensing/public/mocks';
import { setupEnvironment } from '../../helpers/setup_environment';
import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
import { getDefaultHotPhasePolicy } from '../constants';
describe('<EditPolicy /> frozen phase', () => {
let testBed: EditPolicyTestBed;
@ -26,16 +25,7 @@ describe('<EditPolicy /> frozen phase', () => {
});
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([]);
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -50,19 +40,13 @@ describe('<EditPolicy /> frozen phase', () => {
expect(exists('frozen-phase')).toBe(true);
expect(actions.frozen.hasMinAgeInput()).toBeFalsy();
await actions.frozen.enable(true);
await actions.togglePhase('frozen');
expect(actions.frozen.hasMinAgeInput()).toBeTruthy();
});
describe('on non-enterprise license', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setListNodes({
isUsingDeprecatedDataRoleConfig: false,
nodesByAttributes: { test: ['123'] },
nodesByRoles: { data: ['123'] },
});
httpRequestsMockHelpers.setListSnapshotRepos({ repositories: ['my-repo'] });
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup({

View file

@ -8,7 +8,7 @@
import { TestBedConfig } from '@kbn/test/jest';
import { AppServicesContext } from '../../../../../public/types';
import { createEnablePhaseAction, createNodeAllocationActions } from '../../../helpers';
import { createTogglePhaseAction, createNodeAllocationActions } from '../../../helpers';
import { initTestBed } from '../../init_test_bed';
type SetupReturn = ReturnType<typeof setupCloudNodeAllocation>;
@ -24,12 +24,11 @@ export const setupCloudNodeAllocation = async (arg?: {
return {
...testBed,
actions: {
togglePhase: createTogglePhaseAction(testBed),
warm: {
enable: createEnablePhaseAction(testBed, 'warm'),
...createNodeAllocationActions(testBed, 'warm'),
},
cold: {
enable: createEnablePhaseAction(testBed, 'cold'),
...createNodeAllocationActions(testBed, 'cold'),
},
},

View file

@ -67,7 +67,7 @@ describe('<EditPolicy /> node allocation cloud-aware behavior', () => {
const { actions, component, exists } = testBed;
component.update();
await actions.warm.enable(true);
await actions.togglePhase('warm');
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();
// Assert that default, custom and 'none' options exist
@ -91,7 +91,7 @@ describe('<EditPolicy /> node allocation cloud-aware behavior', () => {
const { actions, component, exists, find } = testBed;
component.update();
await actions.warm.enable(true);
await actions.togglePhase('warm');
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();
// Assert that custom and 'none' options exist
@ -115,7 +115,7 @@ describe('<EditPolicy /> node allocation cloud-aware behavior', () => {
testBed.component.update();
const { actions, component, exists, find } = testBed;
await actions.warm.enable(true);
await actions.togglePhase('warm');
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();
await actions.warm.openNodeAttributesSection();
@ -137,8 +137,8 @@ describe('<EditPolicy /> node allocation cloud-aware behavior', () => {
testBed.component.update();
const { actions, component, exists } = testBed;
await actions.warm.enable(true);
await actions.cold.enable(true);
await actions.togglePhase('warm');
await actions.togglePhase('cold');
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();
expect(exists('cloudDataTierCallout')).toBeFalsy();

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { createEnablePhaseAction, createNodeAllocationActions } from '../../../helpers';
import { createNodeAllocationActions, createTogglePhaseAction } from '../../../helpers';
import { initTestBed } from '../../init_test_bed';
type SetupReturn = ReturnType<typeof setupColdPhaseNodeAllocation>;
@ -18,7 +18,7 @@ export const setupColdPhaseNodeAllocation = async () => {
return {
...testBed,
actions: {
enable: createEnablePhaseAction(testBed, 'cold'),
toggleColdPhase: () => createTogglePhaseAction(testBed)('cold'),
...createNodeAllocationActions(testBed, 'cold'),
},
};

View file

@ -56,7 +56,7 @@ describe('<EditPolicy /> node allocation in the cold phase', () => {
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.toggleColdPhase();
expect(actions.isAllocationLoading()).toBeFalsy();
expect(actions.hasWillUseFallbackTierNotice()).toBeFalsy();
@ -67,7 +67,7 @@ describe('<EditPolicy /> node allocation in the cold phase', () => {
server.respondImmediately = false;
const { actions } = testBed;
await actions.enable(true);
await actions.toggleColdPhase();
expect(actions.isAllocationLoading()).toBeTruthy();
expect(actions.hasDataTierAllocationControls()).toBeTruthy();
@ -83,7 +83,7 @@ describe('<EditPolicy /> node allocation in the cold phase', () => {
describe('and some are defined', () => {
test('shows the node attributes input', async () => {
const { actions } = testBed;
await actions.enable(true);
await actions.toggleColdPhase();
expect(actions.isAllocationLoading()).toBeFalsy();
await actions.setDataAllocation('node_attrs');
@ -95,7 +95,7 @@ describe('<EditPolicy /> node allocation in the cold phase', () => {
test('shows view node attributes link when an attribute is selected and shows flyout when clicked', async () => {
const { actions } = testBed;
await actions.enable(true);
await actions.toggleColdPhase();
expect(actions.isAllocationLoading()).toBeFalsy();
await actions.setDataAllocation('node_attrs');
@ -116,7 +116,7 @@ describe('<EditPolicy /> node allocation in the cold phase', () => {
await setup();
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.toggleColdPhase();
expect(actions.isAllocationLoading()).toBeFalsy();
await actions.setDataAllocation('node_attrs');
@ -186,7 +186,7 @@ describe('<EditPolicy /> node allocation in the cold phase', () => {
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.toggleColdPhase();
expect(actions.isAllocationLoading()).toBeFalsy();
expect(actions.hasNoTiersAvailableNotice()).toBeTruthy();
@ -213,7 +213,7 @@ describe('<EditPolicy /> node allocation in the cold phase', () => {
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.toggleColdPhase();
expect(actions.isAllocationLoading()).toBeFalsy();
expect(actions.hasWillUseFallbackTierNotice()).toBeTruthy();

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { createNodeAllocationActions, savePolicy, setReplicas } from '../../../helpers';
import { createNodeAllocationActions, createSavePolicyAction, setReplicas } from '../../../helpers';
import { initTestBed } from '../../init_test_bed';
type SetupReturn = ReturnType<typeof setupGeneralNodeAllocation>;
@ -19,7 +19,7 @@ export const setupGeneralNodeAllocation = async () => {
...testBed,
actions: {
...createNodeAllocationActions(testBed, 'warm'),
savePolicy: () => savePolicy(testBed),
savePolicy: createSavePolicyAction(testBed),
setReplicas: (value: string) => setReplicas(testBed, 'warm', value),
},
};

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { createNodeAllocationActions, createEnablePhaseAction } from '../../../helpers';
import { createNodeAllocationActions, createTogglePhaseAction } from '../../../helpers';
import { initTestBed } from '../../init_test_bed';
type SetupReturn = ReturnType<typeof setupWarmPhaseNodeAllocation>;
@ -18,7 +18,7 @@ export const setupWarmPhaseNodeAllocation = async () => {
return {
...testBed,
actions: {
enable: createEnablePhaseAction(testBed, 'warm'),
togglePhase: () => createTogglePhaseAction(testBed)('warm'),
...createNodeAllocationActions(testBed, 'warm'),
},
};

View file

@ -56,7 +56,7 @@ describe('<EditPolicy /> node allocation in the warm phase', () => {
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.togglePhase();
expect(actions.isAllocationLoading()).toBeFalsy();
expect(actions.hasDefaultAllocationBehaviorNotice()).toBeFalsy();
@ -67,7 +67,7 @@ describe('<EditPolicy /> node allocation in the warm phase', () => {
server.respondImmediately = false;
const { actions } = testBed;
await actions.enable(true);
await actions.togglePhase();
expect(actions.isAllocationLoading()).toBeTruthy();
expect(actions.hasDataTierAllocationControls()).toBeTruthy();
@ -83,7 +83,7 @@ describe('<EditPolicy /> node allocation in the warm phase', () => {
describe('and some are defined', () => {
test('shows the node attributes input', async () => {
const { actions } = testBed;
await actions.enable(true);
await actions.togglePhase();
expect(actions.isAllocationLoading()).toBeFalsy();
await actions.setDataAllocation('node_attrs');
@ -94,7 +94,7 @@ describe('<EditPolicy /> node allocation in the warm phase', () => {
test('shows view node attributes link when an attribute is selected and shows flyout when clicked', async () => {
const { actions } = testBed;
await actions.enable(true);
await actions.togglePhase();
expect(actions.isAllocationLoading()).toBeFalsy();
await actions.setDataAllocation('node_attrs');
@ -115,7 +115,7 @@ describe('<EditPolicy /> node allocation in the warm phase', () => {
await setup();
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.togglePhase();
expect(actions.isAllocationLoading()).toBeFalsy();
await actions.setDataAllocation('node_attrs');
@ -185,7 +185,7 @@ describe('<EditPolicy /> node allocation in the warm phase', () => {
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.togglePhase();
expect(actions.isAllocationLoading()).toBeFalsy();
expect(actions.hasNoTiersAvailableNotice()).toBeTruthy();
@ -202,7 +202,7 @@ describe('<EditPolicy /> node allocation in the warm phase', () => {
const { actions, component } = testBed;
component.update();
await actions.enable(true);
await actions.togglePhase();
expect(actions.isAllocationLoading()).toBeFalsy();
expect(actions.hasWillUseFallbackTierNotice()).toBeTruthy();

View file

@ -8,7 +8,6 @@
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('<EditPolicy /> request flyout', () => {
let testBed: EditPolicyTestBed;
@ -24,7 +23,7 @@ describe('<EditPolicy /> request flyout', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();

View file

@ -5,11 +5,10 @@
* 2.0.
*/
import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
import { setupEnvironment } from '../../helpers/setup_environment';
import { getDefaultHotPhasePolicy } from '../constants';
import { act } from 'react-dom/test-utils';
import { licensingMock } from '../../../../../licensing/public/mocks';
import { setupEnvironment } from '../../helpers/setup_environment';
import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
describe('<EditPolicy /> rollover', () => {
let testBed: EditPolicyTestBed;
@ -20,14 +19,7 @@ describe('<EditPolicy /> rollover', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setListSnapshotRepos({ repositories: ['abc'] });
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup({
@ -48,8 +40,8 @@ describe('<EditPolicy /> rollover', () => {
test('hides forcemerge when rollover is disabled', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.rollover.toggleDefault();
await actions.rollover.toggle();
expect(actions.hot.forceMergeFieldExists()).toBeFalsy();
});
@ -60,8 +52,8 @@ describe('<EditPolicy /> rollover', () => {
test('hides shrink input when rollover is disabled', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.rollover.toggleDefault();
await actions.rollover.toggle();
expect(actions.hot.shrinkExists()).toBeFalsy();
});
@ -72,16 +64,16 @@ describe('<EditPolicy /> rollover', () => {
test('hides readonly input when rollover is disabled', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.rollover.toggleDefault();
await actions.rollover.toggle();
expect(actions.hot.readonlyExists()).toBeFalsy();
});
test('hides and disables searchable snapshot field', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.cold.enable(true);
await actions.rollover.toggleDefault();
await actions.rollover.toggle();
await actions.togglePhase('cold');
expect(actions.hot.searchableSnapshotsExists()).toBeFalsy();
});
@ -89,10 +81,10 @@ describe('<EditPolicy /> rollover', () => {
test('shows rollover tip on minimum age', async () => {
const { actions } = testBed;
await actions.warm.enable(true);
await actions.cold.enable(true);
await actions.frozen.enable(true);
await actions.delete.enable(true);
await actions.togglePhase('warm');
await actions.togglePhase('cold');
await actions.togglePhase('frozen');
await actions.togglePhase('delete');
expect(actions.warm.hasRolloverTipOnMinAge()).toBeTruthy();
expect(actions.cold.hasRolloverTipOnMinAge()).toBeTruthy();
@ -102,13 +94,13 @@ describe('<EditPolicy /> rollover', () => {
test('hiding rollover tip on minimum age', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.rollover.toggleDefault();
await actions.rollover.toggle();
await actions.warm.enable(true);
await actions.cold.enable(true);
await actions.frozen.enable(true);
await actions.delete.enable(true);
await actions.togglePhase('warm');
await actions.togglePhase('cold');
await actions.togglePhase('frozen');
await actions.togglePhase('delete');
expect(actions.warm.hasRolloverTipOnMinAge()).toBeFalsy();
expect(actions.cold.hasRolloverTipOnMinAge()).toBeFalsy();

View file

@ -20,13 +20,7 @@ describe('<EditPolicy /> searchable snapshots', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -39,8 +33,8 @@ describe('<EditPolicy /> searchable snapshots', () => {
test('enabling searchable snapshot should hide force merge, freeze, readonly and shrink in subsequent phases', async () => {
const { actions } = testBed;
await actions.warm.enable(true);
await actions.cold.enable(true);
await actions.togglePhase('warm');
await actions.togglePhase('cold');
expect(actions.warm.forceMergeFieldExists()).toBeTruthy();
expect(actions.warm.shrinkExists()).toBeTruthy();
@ -62,9 +56,9 @@ describe('<EditPolicy /> searchable snapshots', () => {
test('disabling rollover toggle, but enabling default rollover', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.hot.toggleDefaultRollover(true);
await actions.rollover.toggleDefault();
await actions.rollover.toggle();
await actions.rollover.toggleDefault();
expect(actions.hot.forceMergeFieldExists()).toBeTruthy();
expect(actions.hot.shrinkExists()).toBeTruthy();
@ -76,10 +70,10 @@ describe('<EditPolicy /> searchable snapshots', () => {
const repository = 'myRepo';
await actions.hot.setSearchableSnapshot(repository);
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setMinAgeValue('10');
await actions.cold.toggleSearchableSnapshot(true);
await actions.frozen.enable(true);
await actions.cold.toggleSearchableSnapshot();
await actions.togglePhase('frozen');
await actions.frozen.setMinAgeValue('15');
await actions.savePolicy();
@ -97,10 +91,10 @@ describe('<EditPolicy /> searchable snapshots', () => {
const { actions } = testBed;
await actions.hot.setSearchableSnapshot('myRepo');
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setMinAgeValue('10');
await actions.cold.toggleSearchableSnapshot(true);
await actions.frozen.enable(true);
await actions.cold.toggleSearchableSnapshot();
await actions.togglePhase('frozen');
await actions.frozen.setMinAgeValue('15');
// We update the repository in one phase
@ -137,7 +131,7 @@ describe('<EditPolicy /> searchable snapshots', () => {
test('defaults searchable snapshot to true on cloud', async () => {
const { find, actions } = testBed;
await actions.cold.enable(true);
await actions.togglePhase('cold');
expect(
find('searchableSnapshotField-cold.searchableSnapshotToggle').props()['aria-checked']
).toBe(true);
@ -164,9 +158,9 @@ describe('<EditPolicy /> searchable snapshots', () => {
test('correctly sets snapshot repository default to "found-snapshots"', async () => {
const { actions } = testBed;
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setMinAgeValue('10');
await actions.cold.toggleSearchableSnapshot(true);
await actions.cold.toggleSearchableSnapshot();
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
expect(latestRequest.method).toBe('POST');
@ -208,7 +202,7 @@ describe('<EditPolicy /> searchable snapshots', () => {
expect(actions.cold.searchableSnapshotsExists()).toBeFalsy();
expect(actions.frozen.searchableSnapshotsExists()).toBeFalsy();
await actions.cold.enable(true);
await actions.togglePhase('cold');
// Still hidden in hot
expect(actions.hot.searchableSnapshotsExists()).toBeFalsy();

View file

@ -7,7 +7,6 @@
import { act } from 'react-dom/test-utils';
import { setupEnvironment } from '../../helpers/setup_environment';
import { getDefaultHotPhasePolicy } from '../constants';
import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
describe('<EditPolicy /> timeline', () => {
@ -19,13 +18,7 @@ describe('<EditPolicy /> timeline', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -38,27 +31,27 @@ describe('<EditPolicy /> timeline', () => {
test('showing all phases on the timeline', async () => {
const { actions } = testBed;
// This is how the default policy should look
expect(actions.timeline.hasHotPhase()).toBe(true);
expect(actions.timeline.hasWarmPhase()).toBe(false);
expect(actions.timeline.hasColdPhase()).toBe(false);
expect(actions.timeline.hasDeletePhase()).toBe(false);
expect(actions.timeline.hasPhase('hot')).toBe(true);
expect(actions.timeline.hasPhase('warm')).toBe(false);
expect(actions.timeline.hasPhase('cold')).toBe(false);
expect(actions.timeline.hasPhase('delete')).toBe(false);
await actions.warm.enable(true);
expect(actions.timeline.hasHotPhase()).toBe(true);
expect(actions.timeline.hasWarmPhase()).toBe(true);
expect(actions.timeline.hasColdPhase()).toBe(false);
expect(actions.timeline.hasDeletePhase()).toBe(false);
await actions.togglePhase('warm');
expect(actions.timeline.hasPhase('hot')).toBe(true);
expect(actions.timeline.hasPhase('warm')).toBe(true);
expect(actions.timeline.hasPhase('cold')).toBe(false);
expect(actions.timeline.hasPhase('delete')).toBe(false);
await actions.cold.enable(true);
expect(actions.timeline.hasHotPhase()).toBe(true);
expect(actions.timeline.hasWarmPhase()).toBe(true);
expect(actions.timeline.hasColdPhase()).toBe(true);
expect(actions.timeline.hasDeletePhase()).toBe(false);
await actions.togglePhase('cold');
expect(actions.timeline.hasPhase('hot')).toBe(true);
expect(actions.timeline.hasPhase('warm')).toBe(true);
expect(actions.timeline.hasPhase('cold')).toBe(true);
expect(actions.timeline.hasPhase('delete')).toBe(false);
await actions.delete.enable(true);
expect(actions.timeline.hasHotPhase()).toBe(true);
expect(actions.timeline.hasWarmPhase()).toBe(true);
expect(actions.timeline.hasColdPhase()).toBe(true);
expect(actions.timeline.hasDeletePhase()).toBe(true);
await actions.togglePhase('delete');
expect(actions.timeline.hasPhase('hot')).toBe(true);
expect(actions.timeline.hasPhase('warm')).toBe(true);
expect(actions.timeline.hasPhase('cold')).toBe(true);
expect(actions.timeline.hasPhase('delete')).toBe(true);
});
});

View file

@ -8,7 +8,6 @@
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('<EditPolicy /> warm phase', () => {
let testBed: EditPolicyTestBed;
@ -24,16 +23,7 @@ describe('<EditPolicy /> warm phase', () => {
});
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([]);
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -46,7 +36,7 @@ describe('<EditPolicy /> warm phase', () => {
test('shows timing only when enabled', async () => {
const { actions } = testBed;
expect(actions.warm.hasMinAgeInput()).toBeFalsy();
await actions.warm.enable(true);
await actions.togglePhase('warm');
expect(actions.warm.hasMinAgeInput()).toBeTruthy();
});
});

View file

@ -12,7 +12,6 @@ import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
describe('<EditPolicy /> cold phase validation', () => {
let testBed: EditPolicyTestBed;
let runTimers: () => void;
const { server, httpRequestsMockHelpers } = setupEnvironment();
beforeAll(() => {
@ -42,9 +41,7 @@ describe('<EditPolicy /> cold phase validation', () => {
const { component, actions } = testBed;
component.update();
await actions.setPolicyName('mypolicy');
await actions.cold.enable(true);
({ runTimers } = testBed);
await actions.togglePhase('cold');
});
describe('replicas', () => {
@ -53,9 +50,9 @@ describe('<EditPolicy /> cold phase validation', () => {
await actions.cold.setReplicas('-1');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
});
test(`allows 0 for replicas`, async () => {
@ -63,9 +60,9 @@ describe('<EditPolicy /> cold phase validation', () => {
await actions.cold.setReplicas('0');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([]);
actions.errors.expectMessages([]);
});
});
@ -75,9 +72,9 @@ describe('<EditPolicy /> cold phase validation', () => {
await actions.cold.setIndexPriority('-1');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
});
test(`allows 0 for index priority`, async () => {
@ -85,9 +82,9 @@ describe('<EditPolicy /> cold phase validation', () => {
await actions.cold.setIndexPriority('0');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([]);
actions.errors.expectMessages([]);
});
});
});

View file

@ -7,12 +7,10 @@
import { act } from 'react-dom/test-utils';
import { setupEnvironment } from '../../helpers/setup_environment';
import { getDefaultHotPhasePolicy } from '../constants';
import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
describe('<EditPolicy /> error indicators', () => {
let testBed: EditPolicyTestBed;
let runTimers: () => void;
const { server, httpRequestsMockHelpers } = setupEnvironment();
beforeAll(() => {
@ -25,13 +23,7 @@ describe('<EditPolicy /> error indicators', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -39,8 +31,6 @@ describe('<EditPolicy /> error indicators', () => {
const { component } = testBed;
component.update();
({ runTimers } = testBed);
});
test('shows phase error indicators correctly', async () => {
// This test simulates a user configuring a policy phase by phase. The flow is the following:
@ -56,99 +46,98 @@ describe('<EditPolicy /> error indicators', () => {
const { actions } = testBed;
// 0. No validation issues
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(false);
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(false);
// 1. Hot phase validation issue
await actions.hot.toggleForceMerge(true);
await actions.hot.toggleForceMerge();
await actions.hot.setForcemergeSegmentsCount('-22');
runTimers();
expect(actions.hot.hasErrorIndicator()).toBe(true);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(false);
actions.errors.waitForValidation();
expect(actions.errors.havePhaseCallout('hot')).toBe(true);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(false);
// 2. Warm phase validation issue
await actions.warm.enable(true);
await actions.warm.toggleForceMerge(true);
await actions.togglePhase('warm');
await actions.warm.toggleForceMerge();
await actions.warm.setForcemergeSegmentsCount('-22');
runTimers();
expect(actions.hot.hasErrorIndicator()).toBe(true);
expect(actions.warm.hasErrorIndicator()).toBe(true);
expect(actions.cold.hasErrorIndicator()).toBe(false);
actions.errors.waitForValidation();
expect(actions.errors.havePhaseCallout('hot')).toBe(true);
expect(actions.errors.havePhaseCallout('warm')).toBe(true);
expect(actions.errors.havePhaseCallout('cold')).toBe(false);
// 3. Cold phase validation issue
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setReplicas('-33');
runTimers();
expect(actions.hot.hasErrorIndicator()).toBe(true);
expect(actions.warm.hasErrorIndicator()).toBe(true);
expect(actions.cold.hasErrorIndicator()).toBe(true);
actions.errors.waitForValidation();
expect(actions.errors.havePhaseCallout('hot')).toBe(true);
expect(actions.errors.havePhaseCallout('warm')).toBe(true);
expect(actions.errors.havePhaseCallout('cold')).toBe(true);
// 4. Fix validation issue in hot
await actions.hot.setForcemergeSegmentsCount('1');
runTimers();
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(true);
expect(actions.cold.hasErrorIndicator()).toBe(true);
actions.errors.waitForValidation();
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(true);
expect(actions.errors.havePhaseCallout('cold')).toBe(true);
// 5. Fix validation issue in warm
await actions.warm.setForcemergeSegmentsCount('1');
runTimers();
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(true);
actions.errors.waitForValidation();
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(true);
// 6. Fix validation issue in cold
await actions.cold.setReplicas('1');
runTimers();
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(false);
actions.errors.waitForValidation();
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(false);
});
test('global error callout should show, after clicking the "Save" button, if there are any form errors', async () => {
const { actions } = testBed;
expect(actions.hasGlobalErrorCallout()).toBe(false);
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(false);
expect(actions.errors.haveGlobalCallout()).toBe(false);
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(false);
await actions.saveAsNewPolicy(true);
await actions.toggleSaveAsNewPolicy();
await actions.setPolicyName('');
runTimers();
actions.errors.waitForValidation();
await actions.savePolicy();
expect(actions.hasGlobalErrorCallout()).toBe(true);
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(false);
expect(actions.errors.haveGlobalCallout()).toBe(true);
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(false);
});
test('clears all error indicators if last erroring field is unmounted', async () => {
test('clears all error indicators if last erring field is unmounted', async () => {
const { actions } = testBed;
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setMinAgeValue('7');
// introduce validation error
await actions.cold.setSearchableSnapshot('');
runTimers();
await actions.savePolicy();
runTimers();
actions.errors.waitForValidation();
expect(actions.hasGlobalErrorCallout()).toBe(true);
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(true);
expect(actions.errors.haveGlobalCallout()).toBe(true);
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(true);
// unmount the field
await actions.cold.toggleSearchableSnapshot(false);
await actions.cold.toggleSearchableSnapshot();
expect(actions.hasGlobalErrorCallout()).toBe(false);
expect(actions.hot.hasErrorIndicator()).toBe(false);
expect(actions.warm.hasErrorIndicator()).toBe(false);
expect(actions.cold.hasErrorIndicator()).toBe(false);
expect(actions.errors.haveGlobalCallout()).toBe(false);
expect(actions.errors.havePhaseCallout('hot')).toBe(false);
expect(actions.errors.havePhaseCallout('warm')).toBe(false);
expect(actions.errors.havePhaseCallout('cold')).toBe(false);
});
});

View file

@ -12,7 +12,7 @@ import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
describe('<EditPolicy /> hot phase validation', () => {
let testBed: EditPolicyTestBed;
let runTimers: () => void;
let actions: EditPolicyTestBed['actions'];
const { server, httpRequestsMockHelpers } = setupEnvironment();
beforeAll(() => {
@ -30,190 +30,159 @@ describe('<EditPolicy /> hot phase validation', () => {
testBed = await setup();
});
const { component, actions } = testBed;
const { component } = testBed;
component.update();
({ actions } = testBed);
await actions.setPolicyName('mypolicy');
({ runTimers } = testBed);
});
describe('rollover', () => {
test(`doesn't allow no max primary shard size, no max index size, no max age, no max docs`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
expect(actions.rollover.hasSettingRequiredCallout()).toBeFalsy();
await actions.hot.toggleDefaultRollover(false);
expect(actions.hot.hasRolloverSettingRequiredCallout()).toBeFalsy();
await actions.rollover.setMaxPrimaryShardSize('');
await actions.rollover.setMaxAge('');
await actions.rollover.setMaxDocs('');
await actions.rollover.setMaxSize('');
await actions.hot.setMaxPrimaryShardSize('');
await actions.hot.setMaxAge('');
await actions.hot.setMaxDocs('');
await actions.hot.setMaxSize('');
actions.errors.waitForValidation();
runTimers();
expect(actions.hot.hasRolloverSettingRequiredCallout()).toBeTruthy();
expect(actions.rollover.hasSettingRequiredCallout()).toBeTruthy();
});
test(`doesn't allow -1 for max primary shard size`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxPrimaryShardSize('-1');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxPrimaryShardSize('-1');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow 0 for max primary shard size`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxPrimaryShardSize('0');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxPrimaryShardSize('0');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow -1 for max size`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxSize('-1');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxSize('-1');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow 0 for max size`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxSize('0');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxSize('0');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow -1 for max age`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxAge('-1');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxAge('-1');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow 0 for max age`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxAge('0');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxAge('0');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow decimals for max age`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxAge('5.5');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxAge('5.5');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.integerRequired]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.integerRequired]);
});
test(`doesn't allow -1 for max docs`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxDocs('-1');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxDocs('-1');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow 0 for max docs`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxDocs('0');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxDocs('0');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow decimals for max docs`, async () => {
const { actions } = testBed;
await actions.rollover.toggleDefault();
await actions.rollover.setMaxDocs('5.5');
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxDocs('5.5');
actions.errors.waitForValidation();
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.integerRequired]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.integerRequired]);
});
});
describe('forcemerge', () => {
test(`doesn't allow 0 for forcemerge`, async () => {
const { actions } = testBed;
await actions.hot.toggleForceMerge(true);
await actions.hot.toggleForceMerge();
await actions.hot.setForcemergeSegmentsCount('0');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow -1 for forcemerge`, async () => {
const { actions } = testBed;
await actions.hot.toggleForceMerge(true);
await actions.hot.toggleForceMerge();
await actions.hot.setForcemergeSegmentsCount('-1');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
});
describe('shrink', () => {
test(`doesn't allow 0 for shrink`, async () => {
const { actions } = testBed;
await actions.hot.toggleShrink(true);
await actions.hot.toggleShrink();
await actions.hot.setShrink('0');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow -1 for shrink`, async () => {
const { actions } = testBed;
await actions.hot.toggleShrink(true);
await actions.hot.toggleShrink();
await actions.hot.setShrink('-1');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
});
describe('index priority', () => {
test(`doesn't allow -1 for index priority`, async () => {
const { actions } = testBed;
await actions.hot.setIndexPriority('-1');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
});
test(`allows 0 for index priority`, async () => {
const { actions } = testBed;
await actions.hot.setIndexPriority('0');
runTimers();
actions.expectErrorMessages([]);
actions.errors.waitForValidation();
actions.errors.expectMessages([]);
});
});
});

View file

@ -13,7 +13,7 @@ import { getGeneratedPolicies } from '../constants';
describe('<EditPolicy /> policy name validation', () => {
let testBed: EditPolicyTestBed;
let runTimers: () => void;
let actions: EditPolicyTestBed['actions'];
const { server, httpRequestsMockHelpers } = setupEnvironment();
beforeAll(() => {
@ -34,28 +34,24 @@ describe('<EditPolicy /> policy name validation', () => {
const { component } = testBed;
component.update();
({ runTimers } = testBed);
({ actions } = testBed);
});
test(`doesn't allow empty policy name`, async () => {
const { actions } = testBed;
await actions.savePolicy();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.policyNameRequiredMessage]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.policyNameRequiredMessage]);
});
test(`doesn't allow policy name with space`, async () => {
const { actions } = testBed;
await actions.setPolicyName('my policy');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.policyNameContainsInvalidChars]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.policyNameContainsInvalidChars]);
});
test(`doesn't allow policy name that is already used`, async () => {
const { actions } = testBed;
await actions.setPolicyName('testy0');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.policyNameAlreadyUsedErrorMessage]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.policyNameAlreadyUsedErrorMessage]);
});
test(`doesn't allow to save as new policy but using the same name`, async () => {
@ -69,31 +65,28 @@ describe('<EditPolicy /> policy name validation', () => {
},
});
});
const { component, actions } = testBed;
const { component } = testBed;
component.update();
({ actions } = testBed);
({ runTimers } = testBed);
await actions.saveAsNewPolicy(true);
runTimers();
await actions.toggleSaveAsNewPolicy();
actions.errors.waitForValidation();
await actions.savePolicy();
actions.expectErrorMessages([
actions.errors.expectMessages([
i18nTexts.editPolicy.errors.policyNameMustBeDifferentErrorMessage,
]);
});
test(`doesn't allow policy name with comma`, async () => {
const { actions } = testBed;
await actions.setPolicyName('my,policy');
runTimers();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.policyNameContainsInvalidChars]);
actions.errors.waitForValidation();
actions.errors.expectMessages([i18nTexts.editPolicy.errors.policyNameContainsInvalidChars]);
});
test(`doesn't allow policy name starting with underscore`, async () => {
const { actions } = testBed;
await actions.setPolicyName('_mypolicy');
runTimers();
actions.expectErrorMessages([
actions.errors.waitForValidation();
actions.errors.expectMessages([
i18nTexts.editPolicy.errors.policyNameStartsWithUnderscoreErrorMessage,
]);
});

View file

@ -13,7 +13,7 @@ import { setupEnvironment } from '../../helpers/setup_environment';
describe('<EditPolicy /> timing validation', () => {
let testBed: EditPolicyTestBed;
let runTimers: () => void;
let actions: EditPolicyTestBed['actions'];
const { server, httpRequestsMockHelpers } = setupEnvironment();
beforeAll(() => {
@ -26,27 +26,17 @@ describe('<EditPolicy /> timing validation', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setDefaultResponses();
httpRequestsMockHelpers.setLoadPolicies([]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: { data: ['node1'] },
nodesByAttributes: { 'attribute:true': ['node1'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setListSnapshotRepos({ repositories: ['my-repo'] });
await act(async () => {
testBed = await setup();
});
const { component, actions } = testBed;
const { component } = testBed;
component.update();
({ actions } = testBed);
await actions.setPolicyName('mypolicy');
({ runTimers } = testBed);
});
[
@ -79,66 +69,68 @@ describe('<EditPolicy /> timing validation', () => {
['warm', 'cold', 'delete', 'frozen'].forEach((phase: string) => {
const { name, value, error } = testConfig;
test(`${phase}: ${name}`, async () => {
const { actions } = testBed;
await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].enable(true);
await actions.togglePhase(phase as 'warm' | 'cold' | 'delete' | 'frozen');
// 1. We first set as dummy value to have a starting min_age value
await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].setMinAgeValue('111');
// 2. At this point we are sure there will be a change of value and that any validation
// will be displayed under the field.
await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].setMinAgeValue(value);
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages(error);
actions.errors.expectMessages(error);
});
});
});
test('should validate that min_age is equal or greater than previous phase min_age', async () => {
const { actions, form } = testBed;
await actions.warm.enable(true);
await actions.cold.enable(true);
await actions.frozen.enable(true);
await actions.delete.enable(true);
await actions.togglePhase('warm');
await actions.togglePhase('cold');
await actions.togglePhase('frozen');
await actions.togglePhase('delete');
await actions.warm.setMinAgeValue('10');
await actions.cold.setMinAgeValue('9');
runTimers();
expect(form.getErrorsMessages('cold-phase')).toEqual([
'Must be greater or equal than the warm phase value (10d)',
]);
actions.errors.waitForValidation();
actions.errors.expectMessages(
['Must be greater or equal than the warm phase value (10d)'],
'cold'
);
await actions.frozen.setMinAgeValue('8');
runTimers();
expect(form.getErrorsMessages('frozen-phase')).toEqual([
'Must be greater or equal than the cold phase value (9d)',
]);
actions.errors.waitForValidation();
actions.errors.expectMessages(
['Must be greater or equal than the cold phase value (9d)'],
'frozen'
);
await actions.delete.setMinAgeValue('7');
runTimers();
expect(form.getErrorsMessages('delete-phaseContent')).toEqual([
'Must be greater or equal than the frozen phase value (8d)',
]);
actions.errors.waitForValidation();
actions.errors.expectMessages(
['Must be greater or equal than the frozen phase value (8d)'],
'delete'
);
// Disable the warm phase
await actions.warm.enable(false);
await actions.togglePhase('warm');
// No more error for the cold phase
expect(form.getErrorsMessages('cold-phase')).toEqual([]);
actions.errors.expectMessages([], 'cold');
// Change to smaller unit for cold phase
await actions.cold.setMinAgeUnits('h');
// No more error for the frozen phase...
expect(form.getErrorsMessages('frozen-phase')).toEqual([]);
actions.errors.expectMessages([], 'frozen');
// ...but the delete phase has still the error
expect(form.getErrorsMessages('delete-phaseContent')).toEqual([
'Must be greater or equal than the frozen phase value (8d)',
]);
actions.errors.expectMessages(
['Must be greater or equal than the frozen phase value (8d)'],
'delete'
);
await actions.delete.setMinAgeValue('9');
// No more error for the delete phase
expect(form.getErrorsMessages('delete-phaseContent')).toEqual([]);
actions.errors.expectMessages([], 'delete');
});
});

View file

@ -12,7 +12,6 @@ import { EditPolicyTestBed, setup } from '../edit_policy.helpers';
describe('<EditPolicy /> warm phase validation', () => {
let testBed: EditPolicyTestBed;
let runTimers: () => void;
const { server, httpRequestsMockHelpers } = setupEnvironment();
beforeAll(() => {
@ -25,15 +24,8 @@ describe('<EditPolicy /> warm phase validation', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setDefaultResponses();
httpRequestsMockHelpers.setLoadPolicies([]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: { data: ['node1'] },
nodesByAttributes: { 'attribute:true': ['node1'] },
isUsingDeprecatedDataRoleConfig: true,
});
httpRequestsMockHelpers.setNodesDetails('attribute:true', [
{ nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } },
]);
await act(async () => {
testBed = await setup();
@ -42,98 +34,88 @@ describe('<EditPolicy /> warm phase validation', () => {
const { component, actions } = testBed;
component.update();
await actions.setPolicyName('mypolicy');
await actions.warm.enable(true);
({ runTimers } = testBed);
await actions.togglePhase('warm');
});
describe('replicas', () => {
test(`doesn't allow -1 for replicas`, async () => {
const { actions } = testBed;
await actions.warm.setReplicas('-1');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
});
test(`allows 0 for replicas`, async () => {
const { actions } = testBed;
await actions.warm.setReplicas('0');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([]);
actions.errors.expectMessages([]);
});
});
describe('shrink', () => {
test(`doesn't allow 0 for shrink`, async () => {
const { actions } = testBed;
await actions.warm.toggleShrink(true);
await actions.warm.toggleShrink();
await actions.warm.setShrink('0');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow -1 for shrink`, async () => {
const { actions } = testBed;
await actions.warm.toggleShrink(true);
await actions.warm.toggleShrink();
await actions.warm.setShrink('-1');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
});
describe('forcemerge', () => {
test(`doesn't allow 0 for forcemerge`, async () => {
const { actions } = testBed;
await actions.warm.toggleForceMerge(true);
await actions.warm.toggleForceMerge();
await actions.warm.setForcemergeSegmentsCount('0');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
test(`doesn't allow -1 for forcemerge`, async () => {
const { actions } = testBed;
await actions.warm.toggleForceMerge(true);
await actions.warm.toggleForceMerge();
await actions.warm.setForcemergeSegmentsCount('-1');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.numberGreatThan0Required]);
});
});
describe('index priority', () => {
test(`doesn't allow -1 for index priority`, async () => {
const { actions } = testBed;
await actions.warm.setIndexPriority('-1');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
actions.errors.expectMessages([i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
});
test(`allows 0 for index priority`, async () => {
const { actions } = testBed;
await actions.warm.setIndexPriority('0');
runTimers();
actions.errors.waitForValidation();
actions.expectErrorMessages([]);
actions.errors.expectMessages([]);
});
});
});

View file

@ -24,13 +24,7 @@ describe('<EditPolicy /> serialization', () => {
});
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -57,9 +51,9 @@ describe('<EditPolicy /> serialization', () => {
component.update();
// Set max docs to test whether we keep the unknown fields in that object after serializing
await actions.hot.setMaxDocs('1000');
await actions.rollover.setMaxDocs('1000');
// Remove the delete phase to ensure that we also correctly remove data
await actions.delete.enable(false);
await actions.togglePhase('delete');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
@ -170,17 +164,17 @@ describe('<EditPolicy /> serialization', () => {
test('setting all values', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.setMaxSize('123', 'mb');
await actions.hot.setMaxDocs('123');
await actions.hot.setMaxAge('123', 'h');
await actions.hot.toggleForceMerge(true);
await actions.rollover.toggleDefault();
await actions.rollover.setMaxSize('123', 'mb');
await actions.rollover.setMaxDocs('123');
await actions.rollover.setMaxAge('123', 'h');
await actions.hot.toggleForceMerge();
await actions.hot.setForcemergeSegmentsCount('123');
await actions.hot.setBestCompression(true);
await actions.hot.toggleShrink(true);
await actions.hot.toggleShrink();
await actions.hot.setShrink('2');
await actions.hot.toggleReadonly(true);
await actions.hot.toggleIndexPriority(true);
await actions.hot.toggleReadonly();
await actions.hot.toggleIndexPriority();
await actions.hot.setIndexPriority('123');
await actions.savePolicy();
@ -232,8 +226,8 @@ describe('<EditPolicy /> serialization', () => {
test('disabling rollover', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.rollover.toggleDefault();
await actions.rollover.toggle();
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
const policy = JSON.parse(JSON.parse(latestRequest.requestBody).body);
@ -246,13 +240,7 @@ describe('<EditPolicy /> serialization', () => {
describe('warm phase', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -264,7 +252,7 @@ describe('<EditPolicy /> serialization', () => {
test('default values', async () => {
const { actions } = testBed;
await actions.warm.enable(true);
await actions.togglePhase('warm');
await actions.warm.setMinAgeValue('11');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
@ -283,17 +271,17 @@ describe('<EditPolicy /> serialization', () => {
test('setting all values', async () => {
const { actions } = testBed;
await actions.warm.enable(true);
await actions.togglePhase('warm');
await actions.warm.setMinAgeValue('11');
await actions.warm.setDataAllocation('node_attrs');
await actions.warm.setSelectedNodeAttribute('test:123');
await actions.warm.setReplicas('123');
await actions.warm.toggleShrink(true);
await actions.warm.toggleShrink();
await actions.warm.setShrink('123');
await actions.warm.toggleForceMerge(true);
await actions.warm.toggleForceMerge();
await actions.warm.setForcemergeSegmentsCount('123');
await actions.warm.setBestCompression(true);
await actions.warm.toggleReadonly(true);
await actions.warm.toggleReadonly();
await actions.warm.setIndexPriority('123');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
@ -384,13 +372,7 @@ describe('<EditPolicy /> serialization', () => {
describe('cold phase', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);
httpRequestsMockHelpers.setDefaultResponses();
await act(async () => {
testBed = await setup();
@ -403,7 +385,7 @@ describe('<EditPolicy /> serialization', () => {
test('default values', async () => {
const { actions } = testBed;
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setMinAgeValue('11');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
@ -423,14 +405,14 @@ describe('<EditPolicy /> serialization', () => {
test('setting all values, excluding searchable snapshot', async () => {
const { actions } = testBed;
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setMinAgeValue('123');
await actions.cold.setMinAgeUnits('s');
await actions.cold.setDataAllocation('node_attrs');
await actions.cold.setSelectedNodeAttribute('test:123');
await actions.cold.setReplicas('123');
await actions.cold.setFreeze(true);
await actions.cold.toggleReadonly(true);
await actions.cold.setFreeze();
await actions.cold.toggleReadonly();
await actions.cold.setIndexPriority('123');
await actions.savePolicy();
@ -474,7 +456,7 @@ describe('<EditPolicy /> serialization', () => {
// Setting searchable snapshot field disables setting replicas so we test this separately
test('setting searchable snapshot', async () => {
const { actions } = testBed;
await actions.cold.enable(true);
await actions.togglePhase('cold');
await actions.cold.setMinAgeValue('10');
await actions.cold.setSearchableSnapshot('my-repo');
await actions.savePolicy();
@ -489,7 +471,7 @@ describe('<EditPolicy /> serialization', () => {
describe('frozen phase', () => {
test('default value', async () => {
const { actions } = testBed;
await actions.frozen.enable(true);
await actions.togglePhase('frozen');
await actions.frozen.setMinAgeValue('13');
await actions.frozen.setSearchableSnapshot('myRepo');
@ -551,8 +533,8 @@ describe('<EditPolicy /> serialization', () => {
describe('delete phase', () => {
test('default value', async () => {
const { actions } = testBed;
await actions.delete.enable(true);
await actions.setWaitForSnapshotPolicy('test');
await actions.togglePhase('delete');
await actions.delete.setWaitForSnapshotPolicy('test');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
const entirePolicy = JSON.parse(JSON.parse(latestRequest.requestBody).body);

View file

@ -0,0 +1,40 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { Phase } from '../types';
const createWaitForValidationAction = (testBed: TestBed) => () => {
const { component } = testBed;
act(() => {
jest.runAllTimers();
});
component.update();
};
const createExpectMessagesAction = (testBed: TestBed) => (
expectedMessages: string[],
phase?: Phase
) => {
const { form } = testBed;
if (phase) {
expect(form.getErrorsMessages(`${phase}-phase`)).toEqual(expectedMessages);
} else {
expect(form.getErrorsMessages()).toEqual(expectedMessages);
}
};
export const createErrorsActions = (testBed: TestBed) => {
const { exists } = testBed;
return {
waitForValidation: createWaitForValidationAction(testBed),
haveGlobalCallout: () => exists('policyFormErrorsCallout'),
havePhaseCallout: (phase: Phase) => exists(`phaseErrorIndicator-${phase}`),
expectMessages: createExpectMessagesAction(testBed),
};
};

View file

@ -0,0 +1,36 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { createFormToggleAction } from './form_toggle_action';
import { createFormSetValueAction } from './form_set_value_action';
import { Phase } from '../types';
const createFormCheckboxAction = (testBed: TestBed, dataTestSubject: string) => async (
checked: boolean
) => {
const { form, component } = testBed;
await act(async () => {
form.selectCheckBox(dataTestSubject, checked);
});
component.update();
};
export const createForceMergeActions = (testBed: TestBed, phase: Phase) => {
const { exists } = testBed;
const toggleSelector = `${phase}-forceMergeSwitch`;
return {
forceMergeFieldExists: () => exists(toggleSelector),
toggleForceMerge: createFormToggleAction(testBed, toggleSelector),
setForcemergeSegmentsCount: createFormSetValueAction(
testBed,
`${phase}-selectedForceMergeSegments`
),
setBestCompression: createFormCheckboxAction(testBed, `${phase}-bestCompression`),
};
};

View file

@ -8,13 +8,11 @@
import { act } from 'react-dom/test-utils';
import { TestBed } from '@kbn/test/jest';
export const createFormToggleAction = (testBed: TestBed, dataTestSubject: string) => async (
checked: boolean
) => {
export const createFormToggleAction = (testBed: TestBed, dataTestSubject: string) => async () => {
const { form, component } = testBed;
await act(async () => {
form.toggleEuiSwitch(dataTestSubject, checked);
form.toggleEuiSwitch(dataTestSubject);
});
component.update();

View file

@ -0,0 +1,18 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { createFormToggleAction } from './form_toggle_action';
import { Phase } from '../types';
export const createFreezeActions = (testBed: TestBed, phase: Phase) => {
const { exists } = testBed;
return {
setFreeze: createFormToggleAction(testBed, `${phase}-freezeSwitch`),
freezeExists: (): boolean => exists(`${phase}-freezeSwitch`),
};
};

View file

@ -0,0 +1,23 @@
/*
* 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.
*/
export { createNodeAllocationActions } from './node_allocation_actions';
export { createTogglePhaseAction } from './toggle_phase_action';
export { setReplicas } from './set_replicas_action';
export { createSavePolicyAction } from './save_policy_action';
export { createFormToggleAction } from './form_toggle_action';
export { createFormSetValueAction } from './form_set_value_action';
export { createSearchableSnapshotActions } from './searchable_snapshot_actions';
export { createErrorsActions } from './errors_actions';
export { createRolloverActions } from './rollover_actions';
export { createSetWaitForSnapshotAction } from './set_wait_for_snapshot_action';
export { createMinAgeActions } from './min_age_actions';
export { createForceMergeActions } from './forcemerge_actions';
export { createReadonlyActions } from './readonly_actions';
export { createIndexPriorityActions } from './index_priority_actions';
export { createShrinkActions } from './shrink_actions';
export { createFreezeActions } from './freeze_actions';

View file

@ -0,0 +1,21 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { createFormToggleAction } from './form_toggle_action';
import { createFormSetValueAction } from './form_set_value_action';
import { Phase } from '../types';
export const createIndexPriorityActions = (testBed: TestBed, phase: Phase) => {
const { exists } = testBed;
const toggleSelector = `${phase}-indexPrioritySwitch`;
return {
indexPriorityExists: () => exists(toggleSelector),
toggleIndexPriority: createFormToggleAction(testBed, toggleSelector),
setIndexPriority: createFormSetValueAction(testBed, `${phase}-indexPriority`),
};
};

View file

@ -0,0 +1,20 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { createFormSetValueAction } from './form_set_value_action';
import { Phase } from '../types';
export const createMinAgeActions = (testBed: TestBed, phase: Phase) => {
const { exists } = testBed;
return {
hasMinAgeInput: () => exists(`${phase}-selectedMinimumAge`),
setMinAgeValue: createFormSetValueAction(testBed, `${phase}-selectedMinimumAge`),
setMinAgeUnits: createFormSetValueAction(testBed, `${phase}-selectedMinimumAgeUnits`),
hasRolloverTipOnMinAge: () => exists(`${phase}-rolloverMinAgeInputIconTip`),
};
};

View file

@ -8,9 +8,9 @@
import { act } from 'react-dom/test-utils';
import { TestBed } from '@kbn/test/jest';
import { Phase } from './types';
import { DataTierAllocationType } from '../../../public/application/sections/edit_policy/types';
import { createFormSetValueAction } from './create_form_set_value_action';
import { DataTierAllocationType } from '../../../../public/application/sections/edit_policy/types';
import { Phase } from '../types';
import { createFormSetValueAction } from './form_set_value_action';
export const createNodeAllocationActions = (testBed: TestBed, phase: Phase) => {
const { component, find, exists } = testBed;

View file

@ -0,0 +1,19 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { createFormToggleAction } from './form_toggle_action';
import { Phase } from '../types';
export const createReadonlyActions = (testBed: TestBed, phase: Phase) => {
const { exists } = testBed;
const toggleSelector = `${phase}-readonlySwitch`;
return {
readonlyExists: () => exists(toggleSelector),
toggleReadonly: createFormToggleAction(testBed, toggleSelector),
};
};

View file

@ -0,0 +1,64 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { createFormToggleAction } from './form_toggle_action';
import { createFormSetValueAction } from './form_set_value_action';
const createSetPrimaryShardSizeAction = (testBed: TestBed) => async (
value: string,
units?: string
) => {
const { find, component } = testBed;
await act(async () => {
find('hot-selectedMaxPrimaryShardSize').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxPrimaryShardSize.select').simulate('change', {
target: { value: units },
});
}
});
component.update();
};
const createSetMaxAgeAction = (testBed: TestBed) => async (value: string, units?: string) => {
const { find, component } = testBed;
await act(async () => {
find('hot-selectedMaxAge').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxAgeUnits.select').simulate('change', { target: { value: units } });
}
});
component.update();
};
const createSetMaxSizeAction = (testBed: TestBed) => async (value: string, units?: string) => {
const { find, component } = testBed;
await act(async () => {
find('hot-selectedMaxSizeStored').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxSizeStoredUnits.select').simulate('change', {
target: { value: units },
});
}
});
component.update();
};
export const createRolloverActions = (testBed: TestBed) => {
const { exists } = testBed;
return {
toggle: createFormToggleAction(testBed, 'rolloverSwitch'),
toggleDefault: createFormToggleAction(testBed, 'useDefaultRolloverSwitch'),
setMaxPrimaryShardSize: createSetPrimaryShardSizeAction(testBed),
setMaxDocs: createFormSetValueAction(testBed, 'hot-selectedMaxDocuments'),
setMaxAge: createSetMaxAgeAction(testBed),
setMaxSize: createSetMaxSizeAction(testBed),
hasSettingRequiredCallout: (): boolean => exists('rolloverSettingsRequired'),
};
};

View file

@ -8,7 +8,7 @@
import { act } from 'react-dom/test-utils';
import { TestBed } from '@kbn/test/jest';
export const savePolicy = async (testBed: TestBed) => {
export const createSavePolicyAction = (testBed: TestBed) => async () => {
const { find, component } = testBed;
await act(async () => {

View file

@ -0,0 +1,37 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { Phase } from '../types';
import { createFormToggleAction } from './form_toggle_action';
export const createSearchableSnapshotActions = (testBed: TestBed, phase: Phase) => {
const { exists, find, component } = testBed;
const fieldSelector = `searchableSnapshotField-${phase}`;
const licenseCalloutSelector = `${fieldSelector}.searchableSnapshotDisabledDueToLicense`;
const toggleSelector = `${fieldSelector}.searchableSnapshotToggle`;
const toggleSearchableSnapshot = createFormToggleAction(testBed, toggleSelector);
return {
searchableSnapshotDisabledDueToLicense: () =>
exists(licenseCalloutSelector) && find(toggleSelector).props().disabled === true,
searchableSnapshotsExists: () => exists(fieldSelector),
toggleSearchableSnapshot,
setSearchableSnapshot: async (value: string) => {
if (!exists(`searchableSnapshotField-${phase}.searchableSnapshotCombobox`)) {
await toggleSearchableSnapshot();
}
act(() => {
find(`searchableSnapshotField-${phase}.searchableSnapshotCombobox`).simulate('change', [
{ label: value },
]);
});
component.update();
},
};
};

View file

@ -7,15 +7,15 @@
import { TestBed } from '@kbn/test/jest';
import { Phase } from './types';
import { createFormToggleAction } from './create_form_toggle_action';
import { createFormSetValueAction } from './create_form_set_value_action';
import { Phase } from '../types';
import { createFormToggleAction } from './form_toggle_action';
import { createFormSetValueAction } from './form_set_value_action';
export const setReplicas = async (testBed: TestBed, phase: Phase, value: string) => {
const { exists } = testBed;
if (!exists(`${phase}-selectedReplicaCount`)) {
await createFormToggleAction(testBed, `${phase}-setReplicasSwitch`)(true);
await createFormToggleAction(testBed, `${phase}-setReplicasSwitch`)();
}
await createFormSetValueAction(testBed, `${phase}-selectedReplicaCount`)(value);
};

View file

@ -0,0 +1,19 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
export const createSetWaitForSnapshotAction = (testBed: TestBed) => async (
snapshotPolicyName: string
) => {
const { find, component } = testBed;
act(() => {
find('snapshotPolicyCombobox').simulate('change', [{ label: snapshotPolicyName }]);
});
component.update();
};

View file

@ -0,0 +1,21 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { createFormToggleAction } from './form_toggle_action';
import { createFormSetValueAction } from './form_set_value_action';
import { Phase } from '../types';
export const createShrinkActions = (testBed: TestBed, phase: Phase) => {
const { exists } = testBed;
const toggleSelector = `${phase}-shrinkSwitch`;
return {
shrinkExists: () => exists(toggleSelector),
toggleShrink: createFormToggleAction(testBed, toggleSelector),
setShrink: createFormSetValueAction(testBed, `${phase}-primaryShardCount`),
};
};

View file

@ -0,0 +1,45 @@
/*
* 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 { TestBed } from '@kbn/test/jest';
import { act } from 'react-dom/test-utils';
import { Phase } from '../types';
const toggleDeletePhase = async (testBed: TestBed) => {
const { find, component } = testBed;
let button = find('disableDeletePhaseButton');
if (!button.length) {
button = find('enableDeletePhaseButton');
}
if (!button.length) {
throw new Error(`Button to enable/disable delete phase was not found.`);
}
await act(async () => {
button.simulate('click');
});
component.update();
};
const togglePhase = async (testBed: TestBed, phase: Phase) => {
const { form, component } = testBed;
await act(async () => {
form.toggleEuiSwitch(`enablePhaseSwitch-${phase}`);
});
component.update();
};
export const createTogglePhaseAction = (testBed: TestBed) => async (phase: Phase) => {
if (phase === 'delete') {
await toggleDeletePhase(testBed);
} else {
await togglePhase(testBed, phase);
}
};

View file

@ -1,15 +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 { TestBed } from '@kbn/test/jest';
import { Phase } from './types';
import { createFormToggleAction } from './create_form_toggle_action';
export const createEnablePhaseAction = (testBed: TestBed, phase: Phase) => {
return createFormToggleAction(testBed, `enablePhaseSwitch-${phase}`);
};

View file

@ -12,6 +12,7 @@ import {
ListSnapshotReposResponse,
NodesDetailsResponse,
} from '../../../common/types';
import { getDefaultHotPhasePolicy } from '../edit_policy/constants';
export const init = () => {
const server = fakeServer.create();
@ -68,11 +69,23 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => {
]);
};
const setDefaultResponses = () => {
setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]);
setLoadSnapshotPolicies([]);
setListSnapshotRepos({ repositories: ['abc'] });
setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
};
return {
setLoadPolicies,
setLoadSnapshotPolicies,
setListNodes,
setNodesDetails,
setListSnapshotRepos,
setDefaultResponses,
};
};

View file

@ -7,9 +7,4 @@
export { Phase } from './types';
export { createNodeAllocationActions } from './create_node_allocation_actions';
export { createEnablePhaseAction } from './create_enable_phase_action';
export { setReplicas } from './set_replicas_action';
export { savePolicy } from './save_policy_action';
export { createFormToggleAction } from './create_form_toggle_action';
export { createFormSetValueAction } from './create_form_set_value_action';
export * from './actions';

View file

@ -73,7 +73,7 @@ export const DeletePhase: FunctionComponent = () => {
<>
<EuiSpacer />
<EuiComment
data-test-subj="delete-phaseContent"
data-test-subj="delete-phase"
username={phaseTitle}
actions={<MinAgeField phase={'delete'} />}
className="ilmDeletePhase ilmPhase"

View file

@ -178,7 +178,7 @@ export const Timeline: FunctionComponent<Props> = memo(
<div className="ilmTimeline__phasesContainer">
{/* These are the actual color bars for the timeline */}
<div
data-test-subj="ilmTimelineHotPhase"
data-test-subj="ilmTimelinePhase-hot"
className="ilmTimeline__phasesContainer__phase ilmTimeline__hotPhase"
>
<div className="ilmTimeline__colorBar ilmTimeline__hotPhase__colorBar" />
@ -189,7 +189,7 @@ export const Timeline: FunctionComponent<Props> = memo(
</div>
{exists(phaseAgeInMilliseconds.phases.warm) && (
<div
data-test-subj="ilmTimelineWarmPhase"
data-test-subj="ilmTimelinePhase-warm"
className="ilmTimeline__phasesContainer__phase ilmTimeline__warmPhase"
>
<div className="ilmTimeline__colorBar ilmTimeline__warmPhase__colorBar" />
@ -201,7 +201,7 @@ export const Timeline: FunctionComponent<Props> = memo(
)}
{exists(phaseAgeInMilliseconds.phases.cold) && (
<div
data-test-subj="ilmTimelineColdPhase"
data-test-subj="ilmTimelinePhase-cold"
className="ilmTimeline__phasesContainer__phase ilmTimeline__coldPhase"
>
<div className="ilmTimeline__colorBar ilmTimeline__coldPhase__colorBar" />
@ -213,7 +213,7 @@ export const Timeline: FunctionComponent<Props> = memo(
)}
{exists(phaseAgeInMilliseconds.phases.frozen) && (
<div
data-test-subj="ilmTimelineFrozenPhase"
data-test-subj="ilmTimelinePhase-frozen"
className="ilmTimeline__phasesContainer__phase ilmTimeline__frozenPhase"
>
<div className="ilmTimeline__colorBar ilmTimeline__frozenPhase__colorBar" />
@ -228,7 +228,7 @@ export const Timeline: FunctionComponent<Props> = memo(
{hasDeletePhase && (
<EuiFlexItem grow={false}>
<div
data-test-subj="ilmTimelineDeletePhase"
data-test-subj="ilmTimelinePhase-delete"
className="ilmTimeline__deleteIconContainer"
>
<EuiIconTip type="trash" content={i18nTexts.deleteIcon.toolTipContent} />

View file

@ -140,7 +140,7 @@ describe('<PolicyAdd />', () => {
await act(async () => {
// Toggle "All indices" switch
form.toggleEuiSwitch('allIndicesToggle', false);
form.toggleEuiSwitch('allIndicesToggle');
await nextTick();
component.update();
});
@ -158,7 +158,7 @@ describe('<PolicyAdd />', () => {
await act(async () => {
// Toggle "All indices" switch
form.toggleEuiSwitch('allIndicesToggle', false);
form.toggleEuiSwitch('allIndicesToggle');
await nextTick();
});
component.update();