[Index Patterns] Cover field editor with a11y tests (#101888) (#102074)

This commit is contained in:
Anton Dosov 2021-06-14 18:44:36 +02:00 committed by GitHub
parent 2c130bb8df
commit 99e7c9058e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 7 deletions

View file

@ -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 () => {
@ -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();

View file

@ -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();
@ -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();
@ -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(