Skip to content

Commit

Permalink
[Index Patterns] Cover field editor with a11y tests (elastic#101888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Jun 14, 2021
1 parent b1c0975 commit 3137a72
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
22 changes: 22 additions & 0 deletions test/accessibility/apps/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const a11y = getService('a11y');
const testSubjects = getService('testSubjects');

describe('Management', () => {
before(async () => {
Expand Down Expand Up @@ -43,6 +44,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await a11y.testAppSnapshot();
});

it('Index pattern field editor - initial view', async () => {
await PageObjects.settings.clickAddField();
await a11y.testAppSnapshot();
});

it('Index pattern field editor - all options shown', async () => {
await PageObjects.settings.setFieldName('test');
await PageObjects.settings.setFieldType('Keyword');
await PageObjects.settings.setFieldScript("emit('hello world')");
await PageObjects.settings.toggleRow('formatRow');
await PageObjects.settings.setFieldFormat('string');
await PageObjects.settings.toggleRow('customLabelRow');
await PageObjects.settings.setCustomLabel('custom label');
await testSubjects.click('toggleAdvancedSetting');

await a11y.testAppSnapshot();

await testSubjects.click('euiFlyoutCloseButton');
await PageObjects.settings.closeIndexPatternFieldEditor();
});

it('Open create index pattern wizard', async () => {
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickAddNewIndexPatternButton();
Expand Down
29 changes: 22 additions & 7 deletions test/functional/page_objects/settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,8 @@ export class SettingsPageObject extends FtrService {

async setFieldScript(script: string) {
this.log.debug('set script = ' + script);
const formatRow = await this.testSubjects.find('valueRow');
const formatRowToggle = (await formatRow.findAllByCssSelector('[data-test-subj="toggle"]'))[0];

await formatRowToggle.click();
const getMonacoTextArea = async () => (await formatRow.findAllByCssSelector('textarea'))[0];
const valueRow = await this.toggleRow('valueRow');
const getMonacoTextArea = async () => (await valueRow.findAllByCssSelector('textarea'))[0];
this.retry.waitFor('monaco editor is ready', async () => !!(await getMonacoTextArea()));
const monacoTextArea = await getMonacoTextArea();
await monacoTextArea.focus();
Expand All @@ -576,8 +573,8 @@ export class SettingsPageObject extends FtrService {

async changeFieldScript(script: string) {
this.log.debug('set script = ' + script);
const formatRow = await this.testSubjects.find('valueRow');
const getMonacoTextArea = async () => (await formatRow.findAllByCssSelector('textarea'))[0];
const valueRow = await this.testSubjects.find('valueRow');
const getMonacoTextArea = async () => (await valueRow.findAllByCssSelector('textarea'))[0];
this.retry.waitFor('monaco editor is ready', async () => !!(await getMonacoTextArea()));
const monacoTextArea = await getMonacoTextArea();
await monacoTextArea.focus();
Expand Down Expand Up @@ -622,6 +619,24 @@ export class SettingsPageObject extends FtrService {
);
}

async toggleRow(rowTestSubj: string) {
this.log.debug('toggling tow = ' + rowTestSubj);
const row = await this.testSubjects.find(rowTestSubj);
const rowToggle = (await row.findAllByCssSelector('[data-test-subj="toggle"]'))[0];
await rowToggle.click();
return row;
}

async setCustomLabel(label: string) {
this.log.debug('set custom label = ' + label);
await (
await this.testSubjects.findDescendant(
'input',
await this.testSubjects.find('customLabelRow')
)
).type(label);
}

async setScriptedFieldUrlType(type: string) {
this.log.debug('set scripted field Url type = ' + type);
await this.find.clickByCssSelector(
Expand Down

0 comments on commit 3137a72

Please sign in to comment.