Skip to content

Commit

Permalink
[ILM] Added new functional test in ILM for creating a new policy (#92936
Browse files Browse the repository at this point in the history
)

* Added data-test-subj for ILM policies row and added a functional UI test to create a new ILM policy.

* Removed .only from test to allow entire test suite to run again.

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
John Dorlus and kibanamachine authored Mar 4, 2021
1 parent 3e98b10 commit 572f688
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ export const TableContent: React.FunctionComponent<Props> = ({

const rows = sortedPolicies.map((policy) => {
const { name } = policy;
return <EuiTableRow key={`${name}-row`}>{renderRowCells(policy)}</EuiTableRow>;
return (
<EuiTableRow data-test-subj="policyTableRow" key={`${name}-row`}>
{renderRowCells(policy)}
</EuiTableRow>
);
});

const renderAddPolicyToTemplateConfirmModal = (policy: PolicyFromES): ReactElement => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'indexLifecycleManagement']);
const log = getService('log');
const retry = getService('retry');
const testSubjects = getService('testSubjects');

describe('Home page', function () {
before(async () => {
Expand All @@ -25,5 +27,26 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const createPolicyButton = await pageObjects.indexLifecycleManagement.createPolicyButton();
expect(await createPolicyButton.isDisplayed()).to.be(true);
});

it('Create new policy with Warm and Cold Phases', async () => {
const policyName = 'testPolicy1';
await pageObjects.indexLifecycleManagement.createNewPolicyAndSave(
policyName,
true,
true,
false
);

await retry.waitFor('navigation back to home page.', async () => {
return (await testSubjects.getVisibleText('sectionHeading')) === 'Index Lifecycle Policies';
});

const allPolicies = await pageObjects.indexLifecycleManagement.getPolicyList();
const filteredPolicies = allPolicies.filter(function (policy) {
return policy.name === policyName;
});

expect(filteredPolicies.length).to.be(1);
});
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { map as mapAsync } from 'bluebird';
import { FtrProviderContext } from '../ftr_provider_context';

export function IndexLifecycleManagementPageProvider({ getService }: FtrProviderContext) {
Expand Down Expand Up @@ -50,8 +50,34 @@ export function IndexLifecycleManagementPageProvider({ getService }: FtrProvider
coldEnabled: boolean = false,
deletePhaseEnabled: boolean = false
) {
await testSubjects.click('createPolicyButton');
await this.fillNewPolicyForm(policyName, warmEnabled, coldEnabled, deletePhaseEnabled);
await this.saveNewPolicy();
},

async getPolicyList() {
const policies = await testSubjects.findAll('policyTableRow');
return mapAsync(policies, async (policy) => {
const policyNameElement = await policy.findByTestSubject('policyTableCell-name');
const policyLinkedIndicesElement = await policy.findByTestSubject(
'policyTableCell-linkedIndices'
);
const policyVersionElement = await policy.findByTestSubject('policyTableCell-version');
const policyModifiedDateElement = await policy.findByTestSubject(
'policyTableCell-modified_date'
);
const policyActionsButtonElement = await policy.findByTestSubject(
'policyActionsContextMenuButton'
);

return {
name: await policyNameElement.getVisibleText(),
linkedIndices: await policyLinkedIndicesElement.getVisibleText(),
version: await policyVersionElement.getVisibleText(),
modifiedDate: await policyModifiedDateElement.getVisibleText(),
actionsButton: policyActionsButtonElement,
};
});
},
};
}

0 comments on commit 572f688

Please sign in to comment.