[DataViews] Unskip and stabilize functional tests of dataviews management (#173900)

Improving data view related functional test code to reduce flakiness
This commit is contained in:
Matthias Wilhelm 2023-12-28 21:52:11 +01:00 committed by GitHub
parent 9ca9f73bf0
commit d67c0eff2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 62 additions and 26 deletions

View file

@ -257,6 +257,8 @@ const IndexPatternEditorFlyoutContentComponent = ({
className="indexPatternEditor__form"
error={form.getErrors()}
isInvalid={form.isSubmitted && !form.isValid && form.getErrors().length}
data-validation-error={form.getErrors().length ? '1' : '0'}
data-test-subj="indexPatternEditorForm"
>
<UseField path="isAdHoc" />
{indexPatternTypeSelect}

View file

@ -197,6 +197,7 @@ export const TitleField = ({
data-test-subj="createIndexPatternTitleInput"
append={<TitleDocsPopover />}
placeholder="example-*"
data-is-validating={field.isValidating ? '1' : '0'}
/>
</EuiFormRow>
);

View file

@ -308,8 +308,12 @@ export class DataViewEditorService {
getFieldsOptions: GetFieldsOptions,
requireTimestampField: boolean
) => {
const fields = await ensureMinimumTime(this.dataViews.getFieldsForWildcard(getFieldsOptions));
return extractTimeFields(fields as DataViewField[], requireTimestampField);
try {
const fields = await ensureMinimumTime(this.dataViews.getFieldsForWildcard(getFieldsOptions));
return extractTimeFields(fields as DataViewField[], requireTimestampField);
} catch (e) {
return [];
}
};
private getTimestampOptionsForWildcardCached = async (
@ -374,7 +378,7 @@ export class DataViewEditorService {
);
// necessary to get new observable value if the field hasn't changed
this.loadIndices();
await this.loadIndices();
// Wait until we have fetched the indices.
// The result will then be sent to the field validator(s) (when calling await provider(););

View file

@ -187,8 +187,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
// FLAKY: https://github.com/elastic/kibana/issues/173625
describe.skip('index pattern edit', function () {
describe('index pattern edit', function () {
it('should update field list', async function () {
await PageObjects.settings.editIndexPattern(
'kibana_sample_data_flights',

View file

@ -24,13 +24,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.clickKibanaIndexPatterns();
});
after(async function () {
await kibanaServer.savedObjects.cleanStandardList();
});
beforeEach(async function () {
await PageObjects.settings.createIndexPattern('logstash-*');
});
afterEach(async function () {
await PageObjects.settings.removeIndexPattern();
await kibanaServer.savedObjects.cleanStandardList();
});
it('should filter indexed fields by type', async function () {

View file

@ -61,6 +61,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('should modify runtime field', async function () {
await PageObjects.settings.filterField(fieldName);
await testSubjects.click('editFieldFormat');
await retry.try(async () => {
await testSubjects.existOrFail('flyoutTitle');
});
await PageObjects.settings.setFieldType('Long');
await PageObjects.settings.setFieldScriptWithoutToggle('emit(6);');
await PageObjects.settings.toggleRow('formatRow');

View file

@ -177,9 +177,20 @@ export class SettingsPageObject extends FtrService {
async selectTimeFieldOption(selection: string) {
// open dropdown
const timefield = await this.getTimeFieldNameField();
await timefield.click();
await this.browser.pressKeys(selection);
await this.browser.pressKeys(this.browser.keys.TAB);
const prevValue = await timefield.getAttribute('value');
const enabled = await timefield.isEnabled();
if (prevValue === selection || !enabled) {
return;
}
await this.retry.waitFor('time field dropdown have the right value', async () => {
await timefield.click();
await timefield.type(this.browser.keys.DELETE, { charByChar: true });
await this.browser.pressKeys(selection);
await this.browser.pressKeys(this.browser.keys.TAB);
const value = await timefield.getAttribute('value');
return value === selection;
});
}
async getTimeFieldOption(selection: string) {
@ -192,7 +203,7 @@ export class SettingsPageObject extends FtrService {
async setNameField(dataViewName: string) {
const field = await this.getNameField();
await field.clearValue();
await field.clearValueWithKeyboard();
await field.type(dataViewName);
}
@ -486,7 +497,7 @@ export class SettingsPageObject extends FtrService {
async allowHiddenClick() {
await this.testSubjects.click('toggleAdvancedSetting');
const allowHiddenField = await this.testSubjects.find('allowHiddenField');
(await allowHiddenField.findByTagName('button')).click();
await (await allowHiddenField.findByTagName('button')).click();
}
async createIndexPattern(
@ -567,19 +578,26 @@ export class SettingsPageObject extends FtrService {
throw new Error('No Data View name provided for edit');
}
this.clickEditIndexButton();
await this.clickEditIndexButton();
await this.header.waitUntilLoadingHasFinished();
await this.retry.try(async () => {
if (dataViewName) {
await this.setNameField(dataViewName);
}
await this.setIndexPatternField(indexPatternName);
await this.header.waitUntilLoadingHasFinished();
if (timefield) {
await this.selectTimeFieldOption(timefield);
}
const indexPatternSaveBtn = await this.getSaveIndexPatternButton();
await indexPatternSaveBtn.click();
const form = await this.testSubjects.findAll('indexPatternEditorForm');
const hasValidationErrors =
form.length !== 0 && (await form[0].getAttribute('data-validation-error')) === '1';
expect(hasValidationErrors).to.eql(false);
});
if (dataViewName) {
await this.setNameField(dataViewName);
}
if (timefield) {
await this.selectTimeFieldOption(timefield);
}
await (await this.getSaveIndexPatternButton()).click();
if (errorCheck) {
await this.retry.try(async () => {
@ -653,6 +671,10 @@ export class SettingsPageObject extends FtrService {
const currentName = await field.getAttribute('value');
this.log.debug(`setIndexPatternField set to ${currentName}`);
expect(currentName).to.eql(indexPatternName);
await this.retry.waitFor('validating the given index pattern should be finished', async () => {
const isValidating = await field.getAttribute('data-is-validating');
return isValidating === '0';
});
}
async getCreateIndexPatternGoToStep2Button() {

View file

@ -198,8 +198,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
// FLAKY: https://github.com/elastic/kibana/issues/173564
describe.skip('index pattern edit', function () {
describe('index pattern edit', function () {
it('should update field list', async function () {
await PageObjects.settings.editIndexPattern(
'kibana_sample_data_flights',

View file

@ -24,13 +24,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await testSubjects.click('app-card-dataViews');
});
after(async function () {
await kibanaServer.savedObjects.cleanStandardList();
});
beforeEach(async function () {
await PageObjects.settings.createIndexPattern('logstash-*');
});
afterEach(async function () {
await PageObjects.settings.removeIndexPattern();
await kibanaServer.savedObjects.cleanStandardList();
});
it('should filter indexed fields by type', async function () {

View file

@ -16,10 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['settings', 'common']);
const testSubjects = getService('testSubjects');
// Failing: See https://github.com/elastic/kibana/issues/173580
// FLAKY: https://github.com/elastic/kibana/issues/173558
// FLAKY: https://github.com/elastic/kibana/issues/173572
describe.skip('runtime fields', function () {
describe('runtime fields', function () {
this.tags(['skipFirefox']);
before(async function () {
@ -64,6 +61,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('should modify runtime field', async function () {
await PageObjects.settings.filterField(fieldName);
await testSubjects.click('editFieldFormat');
await retry.try(async () => {
await testSubjects.existOrFail('flyoutTitle');
});
await PageObjects.settings.setFieldType('Long');
await PageObjects.settings.setFieldScriptWithoutToggle('emit(6);');
await PageObjects.settings.toggleRow('formatRow');