Skip to content

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

Merged
dmlemeshko merged 1 commit intoelastic:masterfrom
dmlemeshko:ts-fy-xpack-page-objects
Sep 15, 2020
Merged

[x-pack/test] convert PO to typescript, improve find/testSubject usage#77389
dmlemeshko merged 1 commit intoelastic:masterfrom
dmlemeshko:ts-fy-xpack-page-objects

Conversation

@dmlemeshko
Copy link
Copy Markdown
Contributor

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

* under the License.
*/

import { Key } from 'selenium-webdriver';
Copy link
Copy Markdown
Contributor 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 http, { IncomingMessage } from 'http';
import { FtrProviderContext } from 'test/functional/ftr_provider_context';
import { parse } from 'url';
import { FtrProviderContext } from '../ftr_provider_context';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixing import

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
Copy Markdown
Contributor 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

async findFirstActionsButton() {
await this.ensureIsOnPolicyPage();
return (await testSubjects.findAll('policyActionsButton'))[0];
return await testSubjects.find('policyActionsButton');
Copy link
Copy Markdown
Contributor 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
Copy Markdown
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
await actionsButton.click();
const deleteAction = await testSubjects.find('policyDeleteButton');
await deleteAction.click();
await testSubjects.click('policyDeleteButton');
Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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