[ILM] Add missing a11y tests (#102887) (#103641)

* [ILM] Added missing a11y tests

* Fixed ILM functional tests, added after tests cleanup

* Added review suggestions

* Fixed section header renaming

* Fixed section header renaming

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-29 15:06:49 +02:00 committed by GitHub
parent 36f8ae1c0e
commit b45a561fa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 162 additions and 82 deletions

View file

@ -205,6 +205,7 @@ export const TableContent: React.FunctionComponent<Props> = ({
onClick: () => {
setConfirmModal(renderAddPolicyToTemplateConfirmModal(policy));
},
'data-test-subj': 'addPolicyToTemplate',
});
items.push({
name: deletePolicyLabel,
@ -214,6 +215,7 @@ export const TableContent: React.FunctionComponent<Props> = ({
onClick: () => {
setConfirmModal(renderDeleteConfirmModal(policy));
},
'data-test-subj': 'deletePolicy',
});
const panelTree = {
id: 0,

View file

@ -152,7 +152,7 @@ export const PolicyTable: React.FunctionComponent<Props> = ({
<EuiPageHeader
pageTitle={
<span data-test-subj="sectionHeading">
<span data-test-subj="ilmPageHeader">
<FormattedMessage
id="xpack.indexLifecycleMgmt.policyTable.sectionHeading"
defaultMessage="Index Lifecycle Policies"

View file

@ -7,8 +7,8 @@
import { FtrProviderContext } from '../ftr_provider_context';
const TEST_POLICY_NAME = 'ilm-a11y-test';
const TEST_POLICY_ALL_PHASES = {
const POLICY_NAME = 'ilm-a11y-test';
const POLICY_ALL_PHASES = {
policy: {
phases: {
hot: {
@ -20,6 +20,13 @@ const TEST_POLICY_ALL_PHASES = {
cold: {
actions: {},
},
frozen: {
actions: {
searchable_snapshot: {
snapshot_repository: 'test',
},
},
},
delete: {
actions: {},
},
@ -48,61 +55,114 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
throw new Error(`Could not find ${policyName} in policy table`);
};
const clickPolicyActionsButton = async (policyName: string) => {
const actionsCell = await testSubjects.find(`policyTableCell-actions-${policyName}`);
const actionsButton = await actionsCell.findByTestSubject('policyActionsContextMenuButton');
await actionsButton.click();
};
describe('Index Lifecycle Management', async () => {
before(async () => {
await esClient.ilm.putLifecycle({ policy: TEST_POLICY_NAME, body: TEST_POLICY_ALL_PHASES });
await common.navigateToApp('indexLifecycleManagement');
await esClient.ilm.putLifecycle({ policy: POLICY_NAME, body: POLICY_ALL_PHASES });
});
after(async () => {
// @ts-expect-error @elastic/elasticsearch DeleteSnapshotLifecycleRequest.policy_id is required
await esClient.ilm.deleteLifecycle({ policy: TEST_POLICY_NAME });
await esClient.ilm.deleteLifecycle({ policy: POLICY_NAME });
});
it('Create Policy Form', async () => {
await retry.waitFor('Index Lifecycle Policy create/edit view to be present', async () => {
return testSubjects.isDisplayed('createPolicyButton');
});
// Navigate to create policy page and take snapshot
await testSubjects.click('createPolicyButton');
await retry.waitFor('Index Lifecycle Policy create/edit view to be present', async () => {
return (await testSubjects.getVisibleText('policyTitle')) === 'Create policy';
});
// Fill out form after enabling all phases and take snapshot.
await indexLifecycleManagement.fillNewPolicyForm('testPolicy', true, true, false);
await a11y.testAppSnapshot();
});
it('Send Request Flyout on New Policy Page', async () => {
// Take snapshot of the show request panel
await testSubjects.click('requestButton');
await a11y.testAppSnapshot();
// Close panel and save policy
await testSubjects.click('euiFlyoutCloseButton');
await indexLifecycleManagement.saveNewPolicy();
});
it('List policies view', async () => {
await retry.waitFor('Index Lifecycle Policy create/edit view to be present', async () => {
beforeEach(async () => {
await retry.waitFor('ILM app', async () => {
await common.navigateToApp('indexLifecycleManagement');
return testSubjects.exists('policyTablePolicyNameLink') ? true : false;
return testSubjects.exists('ilmPageHeader');
});
});
describe('Edit policy form', () => {
it('Create policy', async () => {
const createButtonTestSubject = 'createPolicyButton';
await retry.waitFor('ILM create policy button', async () => {
return testSubjects.isDisplayed(createButtonTestSubject);
});
// Navigate to create policy page and take snapshot
await testSubjects.click(createButtonTestSubject);
await retry.waitFor('ILM create policy form', async () => {
return (await testSubjects.getVisibleText('policyTitle')) === 'Create policy';
});
// Fill out form after enabling all phases and take snapshot.
await indexLifecycleManagement.fillNewPolicyForm({
policyName: 'testPolicy',
warmEnabled: true,
coldEnabled: true,
frozenEnabled: true,
deleteEnabled: true,
});
await a11y.testAppSnapshot();
});
it('Edit policy', async () => {
const link = await findPolicyLinkInListView(POLICY_NAME);
await link.click();
await retry.waitFor('ILM edit form', async () => {
return (
(await testSubjects.getVisibleText('policyTitle')) === `Edit policy ${POLICY_NAME}`
);
});
await a11y.testAppSnapshot();
});
it('Request flyout', async () => {
const link = await findPolicyLinkInListView(POLICY_NAME);
await link.click();
await retry.waitFor('ILM request button', async () => {
return testSubjects.exists('requestButton');
});
// Take snapshot of the show request panel
await testSubjects.click('requestButton');
await a11y.testAppSnapshot();
});
});
describe('Policies list', () => {
it('List policies view', async () => {
await a11y.testAppSnapshot();
});
});
it('Add policy to index template modal', async () => {
await clickPolicyActionsButton(POLICY_NAME);
const buttonSelector = 'addPolicyToTemplate';
await retry.waitFor('ILM add policy to index template button', async () => {
return testSubjects.isDisplayed(buttonSelector);
});
await testSubjects.click(buttonSelector);
await retry.waitFor('ILM add policy to index template modal to be present', async () => {
return testSubjects.isDisplayed('confirmModalTitleText');
});
await a11y.testAppSnapshot();
});
it('Edit policy with all phases view', async () => {
await retry.waitFor('Index Lifecycle Policy create/edit view to be present', async () => {
await common.navigateToApp('indexLifecycleManagement');
return testSubjects.exists('policyTablePolicyNameLink');
it('Delete policy modal', async () => {
await clickPolicyActionsButton(POLICY_NAME);
const buttonSelector = 'deletePolicy';
await retry.waitFor('ILM delete policy button', async () => {
return testSubjects.isDisplayed(buttonSelector);
});
const link = await findPolicyLinkInListView(TEST_POLICY_NAME);
await link.click();
await retry.waitFor('Index Lifecycle Policy create/edit view to be present', async () => {
return testSubjects.exists('policyTitle');
await testSubjects.click(buttonSelector);
await retry.waitFor('ILM delete policy modal to be present', async () => {
return testSubjects.isDisplayed('confirmModalTitleText');
});
await a11y.testAppSnapshot();
});
});

View file

@ -8,37 +8,46 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
const policyName = 'testPolicy1';
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'indexLifecycleManagement']);
const log = getService('log');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const esClient = getService('es');
describe('Home page', function () {
before(async () => {
await pageObjects.common.navigateToApp('indexLifecycleManagement');
});
after(async () => {
// @ts-expect-error @elastic/elasticsearch DeleteSnapshotLifecycleRequest.policy_id is required
await esClient.ilm.deleteLifecycle({ policy: policyName });
});
it('Loads the app', async () => {
await log.debug('Checking for section header');
const headerText = await pageObjects.indexLifecycleManagement.sectionHeadingText();
await log.debug('Checking for page header');
const headerText = await pageObjects.indexLifecycleManagement.pageHeaderText();
expect(headerText).to.be('Index Lifecycle Policies');
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(
it('Create new policy with all Phases', async () => {
await pageObjects.indexLifecycleManagement.createNewPolicyAndSave({
policyName,
true,
true,
false
);
warmEnabled: true,
coldEnabled: true,
frozenEnabled: true,
deleteEnabled: true,
});
await retry.waitFor('navigation back to home page.', async () => {
return (await testSubjects.getVisibleText('sectionHeading')) === 'Index Lifecycle Policies';
return (
(await pageObjects.indexLifecycleManagement.pageHeaderText()) ===
'Index Lifecycle Policies'
);
});
await pageObjects.indexLifecycleManagement.increasePolicyListPageSize();

View file

@ -7,28 +7,42 @@
import { map as mapAsync } from 'bluebird';
import { FtrProviderContext } from '../ftr_provider_context';
interface Policy {
policyName: string;
warmEnabled?: boolean;
coldEnabled?: boolean;
frozenEnabled?: boolean;
deleteEnabled?: boolean;
snapshotRepository?: string;
minAges?: { [key: string]: { value: string; unit: string } };
}
export function IndexLifecycleManagementPageProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
return {
async sectionHeadingText() {
return await testSubjects.getVisibleText('sectionHeading');
async pageHeaderText() {
return await testSubjects.getVisibleText('ilmPageHeader');
},
async createPolicyButton() {
return await testSubjects.find('createPolicyButton');
},
async fillNewPolicyForm(
policyName: string,
warmEnabled: boolean = false,
coldEnabled: boolean = false,
deletePhaseEnabled: boolean = false,
minAges: { [key: string]: { value: string; unit: string } } = {
warm: { value: '10', unit: 'd' },
cold: { value: '15', unit: 'd' },
frozen: { value: '20', unit: 'd' },
}
) {
async fillNewPolicyForm(policy: Policy) {
const {
policyName,
warmEnabled = false,
coldEnabled = false,
frozenEnabled = false,
deleteEnabled = false,
snapshotRepository = 'test',
minAges = {
warm: { value: '10', unit: 'd' },
cold: { value: '15', unit: 'd' },
frozen: { value: '20', unit: 'd' },
},
} = policy;
await testSubjects.setValue('policyNameField', policyName);
if (warmEnabled) {
await retry.try(async () => {
@ -42,7 +56,14 @@ export function IndexLifecycleManagementPageProvider({ getService }: FtrProvider
});
await testSubjects.setValue('cold-selectedMinimumAge', minAges.cold.value);
}
if (deletePhaseEnabled) {
if (frozenEnabled) {
await retry.try(async () => {
await testSubjects.click('enablePhaseSwitch-frozen');
});
await testSubjects.setValue('frozen-selectedMinimumAge', minAges.frozen.value);
await testSubjects.setValue('searchableSnapshotCombobox', snapshotRepository);
}
if (deleteEnabled) {
await retry.try(async () => {
await testSubjects.click('enableDeletePhaseButton');
});
@ -51,21 +72,9 @@ export function IndexLifecycleManagementPageProvider({ getService }: FtrProvider
async saveNewPolicy() {
await testSubjects.click('savePolicyButton');
},
async createNewPolicyAndSave(
policyName: string,
warmEnabled: boolean = false,
coldEnabled: boolean = false,
deletePhaseEnabled: boolean = false,
minAges?: { [key: string]: { value: string; unit: string } }
) {
async createNewPolicyAndSave(policy: Policy) {
await testSubjects.click('createPolicyButton');
await this.fillNewPolicyForm(
policyName,
warmEnabled,
coldEnabled,
deletePhaseEnabled,
minAges
);
await this.fillNewPolicyForm(policy);
await this.saveNewPolicy();
},