Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x-pack/test] convert PO to typescript, improve find/testSubject usage #77389

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

dmlemeshko
Copy link
Member

Summary

  • tsfy PO under x-pack
  • improve usage of find/testSubject services

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@@ -17,7 +17,6 @@
* under the License.
*/

import { Key } from 'selenium-webdriver';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using browser service instead so that we can easily migrate to other test library

import { parse } from 'url';
import { FtrProviderContext } from '../ftr_provider_context';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing import

await testSubjects.click('upgrade_assistant');
});
}

async expectUpgradeAssistant() {
return await retry.try(async () => {
log.debug(`expectUpgradeAssistant()`);
expect(testSubjects.exists('upgradeAssistantRoot')).to.be.true;
expect(await testSubjects.exists('upgradeAssistantRoot')).to.equal(true);
Copy link
Member Author

@dmlemeshko dmlemeshko Sep 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing await could be a reason of flakiness

@@ -27,7 +27,7 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr
*/
async findFirstActionsButton() {
await this.ensureIsOnPolicyPage();
return (await testSubjects.findAll('policyActionsButton'))[0];
return await testSubjects.find('policyActionsButton');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testSubjects.find wraps driver.findElement that will return the first element in DOM with specified locator and throw exception in case it is not in DOM. It is better than searching for an array and selecting by index when array can be empty.

@dmlemeshko dmlemeshko added v7.10 v7.11.0 v7.9.2 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes labels Sep 14, 2020
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dmlemeshko dmlemeshko marked this pull request as ready for review September 14, 2020 20:29
@dmlemeshko dmlemeshko requested review from a team as code owners September 14, 2020 20:29
@jen-huang jen-huang added v7.10.0 and removed v7.10 labels Sep 14, 2020
@@ -36,8 +36,7 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr
async launchAndFindDeleteModal() {
const actionsButton = await this.findFirstActionsButton();
await actionsButton.click();
const deleteAction = await testSubjects.find('policyDeleteButton');
await deleteAction.click();
await testSubjects.click('policyDeleteButton');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmlemeshko will testSubjects.click() wait for the test subject to appear before it attempts the click?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes @charlie-pichette, it will. If you need to change default timeout, you can pass it this way:

await testSubjects.click('policyDeleteButton', 25000);

Copy link
Contributor

@charlie-pichette charlie-pichette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the security solution files look good to me. Thanks for making the changes @dmlemeshko. 👍

@dmlemeshko dmlemeshko merged commit 1ab229a into elastic:master Sep 15, 2020
dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Sep 15, 2020
dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Sep 15, 2020
elastic#77389)

# Conflicts:
#	test/functional/page_objects/vega_chart_page.ts
#	x-pack/test/functional/page_objects/gis_page.ts
#	x-pack/test/functional/page_objects/uptime_page.ts
#	x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_package_policy_page.ts
@achuguy achuguy mentioned this pull request Sep 15, 2020
7 tasks
dmlemeshko added a commit that referenced this pull request Sep 16, 2020
…t usage (#77389) (#77491)

* [x-pack/test] convert PO to typescript, improve find/testSubject usage (#77382)

* fix lint error

* rremove file

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@dmlemeshko dmlemeshko deleted the ts-fy-xpack-page-objects branch January 31, 2022 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.9.2 v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants