[DataViews] Improve management functional tests for serverless (#177146)

* improving code to prevent occasional flakiness in serverless
This commit is contained in:
Matthias Wilhelm 2024-02-20 10:52:48 +01:00 committed by GitHub
parent e1748f9368
commit a2268131b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 72 deletions

View file

@ -150,6 +150,7 @@ export const TimestampField = ({ options$, isLoadingOptions$, matchedIndices$ }:
}
)}
isLoading={isLoadingOptions}
data-is-loading={isLoadingOptions ? '1' : '0'}
fullWidth
/>
<EuiFormHelpText>

View file

@ -22,10 +22,6 @@ export class SettingsPageObject extends FtrService {
private readonly savedObjects = this.ctx.getPageObject('savedObjects');
private readonly monacoEditor = this.ctx.getService('monacoEditor');
async clickNavigation() {
await this.find.clickDisplayedByCssSelector('.app-link:nth-child(5) a');
}
async clickLinkText(text: string) {
await this.find.clickByDisplayedLinkText(text);
}
@ -127,22 +123,6 @@ export class SettingsPageObject extends FtrService {
await this.header.waitUntilLoadingHasFinished();
}
async setAdvancedSettingsTextArea(propertyName: string, propertyValue: string) {
const wrapper = await this.testSubjects.find(`management-settings-editField-${propertyName}`);
const textarea = await wrapper.findByTagName('textarea');
await textarea.focus();
// only way to properly replace the value of the ace editor is via the JS api
await this.browser.execute(
(editor: string, value: string) => {
return (window as any).ace.edit(editor).setValue(value);
},
`management-settings-editField-${propertyName}-editor`,
propertyValue
);
await this.testSubjects.click(`settings-save-button`);
await this.header.waitUntilLoadingHasFinished();
}
async setAdvancedSettingsImage(propertyName: string, path: string) {
const input = await this.testSubjects.find(`management-settings-editField-${propertyName}`);
await input.type(path);
@ -172,34 +152,28 @@ export class SettingsPageObject extends FtrService {
return this.testSubjects.find('createIndexPatternTitleInput');
}
async getTimeFieldNameField() {
const wrapperElement = await this.testSubjects.find('timestampField');
return wrapperElement.findByTestSubject('comboBoxSearchInput');
}
async selectTimeFieldOption(selection: string) {
// open dropdown
const timefield = await this.getTimeFieldNameField();
const prevValue = await timefield.getAttribute('value');
const enabled = await timefield.isEnabled();
const testSubj = 'timestampField';
const timefield = await this.testSubjects.find(testSubj);
if (prevValue === selection || !enabled) {
await this.retry.waitFor('loading the timefield options should be finished', async () => {
const isLoading = await timefield.getAttribute('data-is-loading');
return isLoading === '0';
});
const isEnabled = await (await timefield.findByTestSubject('comboBoxSearchInput')).isEnabled();
if (!isEnabled) {
return;
}
const isSelected = await this.comboBox.isOptionSelected(timefield, selection);
if (isSelected) {
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;
await this.comboBox.set(testSubj, selection);
return await this.comboBox.isOptionSelected(timefield, selection);
});
}
async getTimeFieldOption(selection: string) {
return await this.find.displayedByCssSelector('option[value="' + selection + '"]');
}
async getNameField() {
return this.testSubjects.find('createIndexPatternNameInput');
}
@ -227,15 +201,6 @@ export class SettingsPageObject extends FtrService {
return await this.testSubjects.find('saveIndexPatternButton');
}
async getCreateButton() {
return await this.find.displayedByCssSelector('[type="submit"]');
}
async clickDefaultIndexButton() {
await this.testSubjects.click('setDefaultIndexPatternButton');
await this.header.waitUntilLoadingHasFinished();
}
async clickEditIndexButton() {
await this.testSubjects.click('editIndexPatternButton');
await this.retry.waitFor('flyout', async () => {
@ -251,10 +216,6 @@ export class SettingsPageObject extends FtrService {
return await this.testSubjects.getVisibleText('indexPatternTitle');
}
async getConfigureHeader() {
return await this.find.byCssSelector('h1');
}
async getTableHeader() {
return await this.find.allByCssSelector('table.euiTable thead tr th');
}
@ -452,10 +413,6 @@ export class SettingsPageObject extends FtrService {
await this.header.waitUntilLoadingHasFinished();
}
async hasIndexPattern(name: string) {
return await this.find.existsByLinkText(name);
}
async clickIndexPatternByName(name: string) {
const indexLink = await this.find.byXPath(`//a[text()='${name}']`);
await indexLink.click();
@ -509,7 +466,7 @@ export class SettingsPageObject extends FtrService {
await this.header.waitUntilLoadingHasFinished();
if (
options.ignoreMissing &&
(await this.testSubjects.exists(`detail-link-${dataViewName}`)) === false
!(await this.testSubjects.exists(`detail-link-${dataViewName}`))
) {
return;
}
@ -567,7 +524,6 @@ export class SettingsPageObject extends FtrService {
await this.setIndexPatternField(indexPatternName);
});
await this.common.sleep(2000);
if (timefield) {
await this.selectTimeFieldOption(timefield);
}
@ -719,10 +675,6 @@ export class SettingsPageObject extends FtrService {
});
}
async getCreateIndexPatternGoToStep2Button() {
return await this.testSubjects.find('createIndexPatternGoToStep2Button');
}
async removeIndexPattern() {
let alertText;
await this.retry.try(async () => {
@ -746,11 +698,6 @@ export class SettingsPageObject extends FtrService {
return alertText;
}
async clickFieldsTab() {
this.log.debug('click Fields tab');
await this.testSubjects.click('tab-indexedFields');
}
async clickScriptedFieldsTab() {
this.log.debug('click Scripted Fields tab');
await this.testSubjects.click('tab-scriptedFields');
@ -1103,8 +1050,4 @@ export class SettingsPageObject extends FtrService {
[data-test-subj="indexPatternOption-${newIndexPatternTitle}"]`
);
}
async clickChangeIndexConfirmButton() {
await this.testSubjects.click('changeIndexConfirmButton');
}
}