Skip to content

Commit

Permalink
simplify functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Jun 25, 2020
1 parent 1e90270 commit 7ee99c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 32 deletions.
29 changes: 10 additions & 19 deletions test/functional/page_objects/management/saved_objects_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,23 @@ export function SavedObjectsPageProvider({ getService, getPageObjects }: FtrProv

async getTableSummary() {
const table = await testSubjects.find('savedObjectsTable');
const rows = await table.findAllByCssSelector('tbody tr');

const summary = [];
for (const row of rows) {
const titleCell = await row.findByCssSelector('td:nth-child(3)');
const title = await titleCell.getVisibleText();

const viewInAppButtons = await row.findAllByCssSelector('td:nth-child(3) a');
const canViewInApp = Boolean(viewInAppButtons.length);
summary.push({
title,
canViewInApp,
const $ = await table.parseDomContent();
return $('tbody tr')
.toArray()
.map((row) => {
return {
title: $(row).find('td:nth-child(3) *:not(:has(*)):visible').text(),
canViewInApp: Boolean($(row).find('td:nth-child(3) a').length),
};
});
}

return summary;
}

async clickTableSelectAll() {
const checkboxSelectAll = await testSubjects.find('checkboxSelectAll');
await checkboxSelectAll.click();
testSubjects.click('checkboxSelectAll');
}

async canBeDeleted() {
const deleteButton = await testSubjects.find('savedObjectsManagementDelete');
return await deleteButton.isEnabled();
return await testSubjects.isEnabled('savedObjectsManagementDelete');
}

async clickDelete() {
Expand Down
20 changes: 7 additions & 13 deletions test/functional/page_objects/settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider

async getAdvancedSettings(propertyName: string) {
log.debug('in getAdvancedSettings');
const setting = await testSubjects.find(`advancedSetting-editField-${propertyName}`);
return await setting.getAttribute('value');
return await testSubjects.getAttribute(`advancedSetting-editField-${propertyName}`, 'value');
}

async expectDisabledAdvancedSetting(propertyName: string) {
const setting = await testSubjects.find(`advancedSetting-editField-${propertyName}`);
expect(setting.getAttribute('disabled')).to.eql('');
expect(
await testSubjects.getAttribute(`advancedSetting-editField-${propertyName}`, 'disabled')
).to.eql('');
}

async getAdvancedSettingCheckbox(propertyName: string) {
Expand Down Expand Up @@ -274,9 +274,7 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider
}

async increasePopularity() {
const field = await testSubjects.find('editorFieldCount');
await field.clearValueWithKeyboard();
await field.type('1');
await testSubjects.setValue('editorFieldCount', '1', { clearWithKeyboard: true });
}

async getPopularity() {
Expand Down Expand Up @@ -499,9 +497,7 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider

async setScriptedFieldName(name: string) {
log.debug('set scripted field name = ' + name);
const field = await testSubjects.find('editorFieldName');
await field.clearValue();
await field.type(name);
await testSubjects.setValue('editorFieldName', name);
}

async setScriptedFieldLanguage(language: string) {
Expand Down Expand Up @@ -568,9 +564,7 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider

async setScriptedFieldPopularity(popularity: string) {
log.debug('set scripted field popularity = ' + popularity);
const field = await testSubjects.find('editorFieldCount');
await field.clearValue();
await field.type(popularity);
await testSubjects.setValue('editorFieldCount', popularity);
}

async setScriptedFieldScript(script: string) {
Expand Down

0 comments on commit 7ee99c1

Please sign in to comment.