Skip to content

Commit

Permalink
[ILM][Accessibility] Added A11y test for ILM new policy form. (#92570)
Browse files Browse the repository at this point in the history
* Added A11y test for ILM new policy form.

* Separated out the takeSnapshot calls to separate tests.
  • Loading branch information
John Dorlus authored Feb 25, 2021
1 parent 9d2a7b8 commit f0f7fea
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
31 changes: 30 additions & 1 deletion x-pack/test/accessibility/apps/index_lifecycle_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const TEST_POLICY_ALL_PHASES = {
};

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const { common } = getPageObjects(['common']);
const { common, indexLifecycleManagement } = getPageObjects([
'common',
'indexLifecycleManagement',
]);
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const esClient = getService('es');
Expand All @@ -55,6 +58,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await esClient.ilm.deleteLifecycle({ policy: TEST_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 () => {
await common.navigateToApp('indexLifecycleManagement');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FtrProviderContext } from '../ftr_provider_context';

export function IndexLifecycleManagementPageProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');

return {
async sectionHeadingText() {
Expand All @@ -17,5 +18,40 @@ export function IndexLifecycleManagementPageProvider({ getService }: FtrProvider
async createPolicyButton() {
return await testSubjects.find('createPolicyButton');
},
async fillNewPolicyForm(
policyName: string,
warmEnabled: boolean = false,
coldEnabled: boolean = false,
deletePhaseEnabled: boolean = false
) {
await testSubjects.setValue('policyNameField', policyName);
if (warmEnabled) {
await retry.try(async () => {
await testSubjects.click('enablePhaseSwitch-warm');
});
}
if (coldEnabled) {
await retry.try(async () => {
await testSubjects.click('enablePhaseSwitch-cold');
});
}
if (deletePhaseEnabled) {
await retry.try(async () => {
await testSubjects.click('enableDeletePhaseButton');
});
}
},
async saveNewPolicy() {
await testSubjects.click('savePolicyButton');
},
async createNewPolicyAndSave(
policyName: string,
warmEnabled: boolean = false,
coldEnabled: boolean = false,
deletePhaseEnabled: boolean = false
) {
await this.fillNewPolicyForm(policyName, warmEnabled, coldEnabled, deletePhaseEnabled);
await this.saveNewPolicy();
},
};
}

0 comments on commit f0f7fea

Please sign in to comment.