Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Mar 18, 2020
1 parent 8f17feb commit 40df400
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 40 deletions.
4 changes: 2 additions & 2 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
*/
private async loginIfPrompted(appUrl: string) {
let currentUrl = await browser.getCurrentUrl();
log.debug(`currentUrl = ${currentUrl}\n appUrl = ${appUrl}`); // 60 sec waiting
await testSubjects.find('kibanaChrome', 6 * defaultFindTimeout);
log.debug(`currentUrl = ${currentUrl}\n appUrl = ${appUrl}`);
await testSubjects.find('kibanaChrome', 6 * defaultFindTimeout); // 60 sec waiting
const loginPage = currentUrl.includes('/login');
const wantedLoginPage = appUrl.includes('/login') || appUrl.includes('/logout');

Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/newsfeed_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function NewsfeedPageProvider({ getService, getPageObjects }: FtrProvider

async getNewsfeedList() {
const list = await testSubjects.find('NewsfeedFlyout');
const cells = await list.findAll('newsHeadAlert');
const cells = await list.findAllByTestSubject('newsHeadAlert');

const objects = [];
for (const cell of cells) {
Expand Down
4 changes: 2 additions & 2 deletions test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
const labels = await testSubjects.findAll('aggRow');
const label = labels[aggNth];

return (await label.findAll('comboBoxInput'))[1];
return (await label.findAllByTestSubject('comboBoxInput'))[1];
}

public async clickColorPicker(): Promise<void> {
Expand Down Expand Up @@ -533,7 +533,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
*/
public async getAggregationCount(nth: number = 0): Promise<number> {
const series = await this.getSeries();
const aggregation = await series[nth].findAll('draggable');
const aggregation = await series[nth].findAllByTestSubject('draggable');
return aggregation.length;
}

Expand Down
9 changes: 6 additions & 3 deletions test/functional/services/combo_box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
return;
}

const clearBtn = await comboBox.find('comboBoxClearButton');
const clearBtn = await comboBox.findByTestSubject('comboBoxClearButton');
await clearBtn.click();

const clearButtonStillExists = await this.doesClearButtonExist(comboBox);
Expand All @@ -230,7 +230,10 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
}

public async doesClearButtonExist(comboBoxElement: WebElementWrapper): Promise<boolean> {
const found = await comboBoxElement.findAll('comboBoxClearButton', WAIT_FOR_EXISTS_TIME);
const found = await comboBoxElement.findAllByTestSubject(
'comboBoxClearButton',
WAIT_FOR_EXISTS_TIME
);
return found.length > 0;
}

Expand Down Expand Up @@ -261,7 +264,7 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
public async openOptionsList(comboBoxElement: WebElementWrapper): Promise<void> {
const isOptionsListOpen = await testSubjects.exists('~comboBoxOptionsList');
if (!isOptionsListOpen) {
const toggleBtn = await comboBoxElement.find('comboBoxToggleListButton');
const toggleBtn = await comboBoxElement.findByTestSubject('comboBoxToggleListButton');
await toggleBtn.click();
}
}
Expand Down
16 changes: 8 additions & 8 deletions test/functional/services/doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont

public async getBodyRows(): Promise<WebElementWrapper[]> {
const table = await this.getTable();
return await table.findAll('~docTableRow');
return await table.findAllByTestSubject('~docTableRow');
}

public async getAnchorRow(): Promise<WebElementWrapper> {
const table = await this.getTable();
return await table.find('~docTableAnchorRow');
return await table.findByTestSubject('~docTableAnchorRow');
}

public async getRow(options: SelectOptions): Promise<WebElementWrapper> {
Expand All @@ -73,7 +73,7 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
options: SelectOptions = { isAnchorRow: false, rowIndex: 0 }
): Promise<void> {
const row = await this.getRow(options);
const toggle = await row.find('~docTableExpandToggleColumn');
const toggle = await row.findByTestSubject('~docTableExpandToggleColumn');
await toggle.click();
}

Expand All @@ -90,7 +90,7 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
const detailsRow = options.isAnchorRow
? await this.getAnchorDetailsRow()
: (await this.getDetailsRows())[options.rowIndex];
return await detailsRow.findAll('~docTableRowAction');
return await detailsRow.findAllByTestSubject('~docTableRowAction');
}

public async getFields(options: { isAnchorRow: boolean } = { isAnchorRow: false }) {
Expand Down Expand Up @@ -122,13 +122,13 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
detailsRow: WebElementWrapper,
fieldName: WebElementWrapper
): Promise<WebElementWrapper> {
return await detailsRow.find(`~tableDocViewRow-${fieldName}`);
return await detailsRow.findByTestSubject(`~tableDocViewRow-${fieldName}`);
}

public async getAddInclusiveFilterButton(
tableDocViewRow: WebElementWrapper
): Promise<WebElementWrapper> {
return await tableDocViewRow.find(`~addInclusiveFilterButton`);
return await tableDocViewRow.findByTestSubject(`~addInclusiveFilterButton`);
}

public async addInclusiveFilter(
Expand All @@ -144,7 +144,7 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
public async getAddExistsFilterButton(
tableDocViewRow: WebElementWrapper
): Promise<WebElementWrapper> {
return await tableDocViewRow.find(`~addExistsFilterButton`);
return await tableDocViewRow.findByTestSubject(`~addExistsFilterButton`);
}

public async addExistsFilter(
Expand All @@ -169,7 +169,7 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
const detailsRow = await row.findByXpath(
'./following-sibling::*[@data-test-subj="docTableDetailsRow"]'
);
return detailsRow.find('~docViewer');
return detailsRow.findByTestSubject('~docViewer');
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export class WebElementWrapper {
* @param {string} selector
* @return {Promise<WebElementWrapper>}
*/
public async find(selector: string) {
public async findByTestSubject(selector: string) {
return await this.retryCall(async function find(wrapper) {
return wrapper._wrap(
await wrapper._webElement.findElement(wrapper.By.css(testSubjSelector(selector))),
Expand All @@ -559,7 +559,7 @@ export class WebElementWrapper {
* @param {number} timeout
* @return {Promise<WebElementWrapper[]>}
*/
public async findAll(selector: string, timeout?: number) {
public async findAllByTestSubject(selector: string, timeout?: number) {
return await this.retryCall(async function findAll(wrapper) {
return wrapper._wrapAll(
await wrapper._findWithCustomTimeout(
Expand Down
20 changes: 12 additions & 8 deletions x-pack/test/functional/page_objects/rollup_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,18 @@ export function RollupPageProvider({ getService, getPageObjects }) {
async getJobList() {
const jobs = await testSubjects.findAll('jobTableRow');
return mapAsync(jobs, async job => {
const jobNameElement = await job.find('jobTableCell-id');
const jobStatusElement = await job.find('jobTableCell-status');
const jobIndexPatternElement = await job.find('jobTableCell-indexPattern');
const jobRollUpIndexPatternElement = await job.find('jobTableCell-rollupIndex');
const jobDelayElement = await job.find('jobTableCell-rollupDelay');
const jobIntervalElement = await job.find('jobTableCell-dateHistogramInterval');
const jobGroupElement = await job.find('jobTableCell-groups');
const jobMetricsElement = await job.find('jobTableCell-metrics');
const jobNameElement = await job.findByTestSubject('jobTableCell-id');
const jobStatusElement = await job.findByTestSubject('jobTableCell-status');
const jobIndexPatternElement = await job.findByTestSubject('jobTableCell-indexPattern');
const jobRollUpIndexPatternElement = await job.findByTestSubject(
'jobTableCell-rollupIndex'
);
const jobDelayElement = await job.findByTestSubject('jobTableCell-rollupDelay');
const jobIntervalElement = await job.findByTestSubject(
'jobTableCell-dateHistogramInterval'
);
const jobGroupElement = await job.findByTestSubject('jobTableCell-groups');
const jobMetricsElement = await job.findByTestSubject('jobTableCell-metrics');

return {
jobName: await jobNameElement.getVisibleText(),
Expand Down
16 changes: 8 additions & 8 deletions x-pack/test/functional/page_objects/security_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
async getElasticsearchUsers() {
const users = await testSubjects.findAll('userRow');
return mapAsync(users, async user => {
const fullnameElement = await user.find('userRowFullName');
const usernameElement = await user.find('userRowUserName');
const emailElement = await user.find('userRowEmail');
const rolesElement = await user.find('userRowRoles');
const fullnameElement = await user.findByTestSubject('userRowFullName');
const usernameElement = await user.findByTestSubject('userRowUserName');
const emailElement = await user.findByTestSubject('userRowEmail');
const rolesElement = await user.findByTestSubject('userRowRoles');
// findAll is substantially faster than `find.descendantExistsByCssSelector for negative cases
const isUserReserved = (await user.findAll('userReserved', 1)).length > 0;
const isUserReserved = (await user.findAllByTestSubject('userReserved', 1)).length > 0;

return {
username: await usernameElement.getVisibleText(),
Expand All @@ -250,11 +250,11 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
const users = await testSubjects.findAll('roleRow');
return mapAsync(users, async role => {
const [rolename, reserved, deprecated] = await Promise.all([
role.find('roleRowName').then(el => el.getVisibleText()),
role.findByTestSubject('roleRowName').then(el => el.getVisibleText()),
// findAll is substantially faster than `find.descendantExistsByCssSelector for negative cases
role.findAll('roleReserved', 1).then(el => el.length > 0),
role.findAllByTestSubject('roleReserved', 1).then(el => el.length > 0),
// findAll is substantially faster than `find.descendantExistsByCssSelector for negative cases
role.findAll('roleDeprecated', 1).then(el => el.length > 0),
role.findAllByTestSubject('roleDeprecated', 1).then(el => el.length > 0),
]);

return {
Expand Down
12 changes: 6 additions & 6 deletions x-pack/test/functional/page_objects/snapshot_restore_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export function SnapshotRestorePageProvider({ getService }: FtrProviderContext)
},
async getRepoList() {
const table = await testSubjects.find('repositoryTable');
const rows = await table.findAll('row');
const rows = await table.findAllByTestSubject('row');
return await Promise.all(
rows.map(async row => {
return {
repoName: await (await row.find('Name_cell')).getVisibleText(),
repoLink: await (await row.find('Name_cell')).findByCssSelector('a'),
repoType: await (await row.find('Type_cell')).getVisibleText(),
repoEdit: await row.find('editRepositoryButton'),
repoDelete: await row.find('deleteRepositoryButton'),
repoName: await (await row.findByTestSubject('Name_cell')).getVisibleText(),
repoLink: await (await row.findByTestSubject('Name_cell')).findByCssSelector('a'),
repoType: await (await row.findByTestSubject('Type_cell')).getVisibleText(),
repoEdit: await row.findByTestSubject('editRepositoryButton'),
repoDelete: await row.findByTestSubject('deleteRepositoryButton'),
};
})
);
Expand Down

0 comments on commit 40df400

Please sign in to comment.