-
-
Notifications
You must be signed in to change notification settings - Fork 47
add exec to ui5 controls to boost performance for data retrieval from many ui5 child controls #456
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
Merged
vobu
merged 13 commits into
ui5-community:main
from
philippthiele:add-evalOnControl-to-ui5-controls
May 9, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
837294e
add evalOnControl to ui5 controls to boost performance for data retri…
philippthiele cf8cc09
also test object return type for evalOnControl function
philippthiele 4434b25
Update evalOnControl.test.js
philippthiele 4dc898b
feat: add runtime measure
18bbccc
fix(core): run npm audit fix --force
e9f9345
rename evalOnControl to exec
philith 585c9fa
Merge branch 'main' into add-evalOnControl-to-ui5-controls
philippthiele f4fb8e1
revert changes to package json and lock files
philith ad67ec2
exec: accept arguments & make arrow function work
philith d117f62
update chromedriver in package lock
philippthiele dddb3b2
exec: propagate browserside errors to be logged in console
philippthiele bd7cfb3
Add documentation for exec
philippthiele 7c388a9
Merge branch 'main' into add-evalOnControl-to-ui5-controls
philippthiele File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,181 @@ | ||||||
| const Main = require("./pageObjects/Main") | ||||||
| const Other = require("./pageObjects/Other") | ||||||
| const marky = require("marky") | ||||||
| const { wdi5 } = require("wdio-ui5-service") | ||||||
|
|
||||||
| describe("ui5 eval on control", () => { | ||||||
| before(async () => { | ||||||
| await Main.open() | ||||||
| }) | ||||||
|
|
||||||
| it("should have the right title", async () => { | ||||||
| const title = await browser.getTitle() | ||||||
| expect(title).toEqual("Sample UI5 Application") | ||||||
| }) | ||||||
|
|
||||||
|
|
||||||
| it("should be able to propagate a browserside error", async () => { | ||||||
| //Log Output during this test should be 3 times: [wdi5] call of exec failed because of: TypeError: this.getTex is not a function | ||||||
| //Can't be reasonably verified programatically, only that returned result should be null | ||||||
| const button = await browser.asControl({ | ||||||
| selector: { | ||||||
| id: "openDialogButton", | ||||||
| viewName: "test.Sample.view.Main" | ||||||
| } | ||||||
| }) | ||||||
|
|
||||||
| //regular function | ||||||
| const resultRegularFunction = await button.exec(function () { | ||||||
| return this.getTex() | ||||||
| }) | ||||||
| expect(resultRegularFunction).toBeNull() | ||||||
|
|
||||||
| //arrow functions | ||||||
| const resultArrowFunction1 = await button.exec(() => this.getTex()) | ||||||
| expect(resultArrowFunction1).toBeNull() | ||||||
| const resultArrowFunction2 = await button.exec(() => { return this.getTex() }) | ||||||
| expect(resultArrowFunction2).toBeNull() | ||||||
| }) | ||||||
|
|
||||||
| it("execute function browserside on button to get its text, basic return type", async () => { | ||||||
| const button = await browser.asControl({ | ||||||
| selector: { | ||||||
| id: "openDialogButton", | ||||||
| viewName: "test.Sample.view.Main" | ||||||
| } | ||||||
| }) | ||||||
|
|
||||||
| const regularBtnText = await button.getText() | ||||||
| //regular function | ||||||
| const buttonText = await button.exec(function () { | ||||||
| return this.getText() | ||||||
| }) | ||||||
| expect(buttonText).toEqual("open Dialog") | ||||||
| expect(buttonText).toEqual(regularBtnText) | ||||||
|
|
||||||
| //arrow functions | ||||||
| const buttonTextArrow1 = await button.exec(() => this.getText()) | ||||||
| expect(buttonTextArrow1).toEqual("open Dialog") | ||||||
| expect(buttonTextArrow1).toEqual(regularBtnText) | ||||||
| const buttonTextArrow2 = await button.exec(() => { return this.getText() }) | ||||||
| expect(buttonTextArrow2).toEqual("open Dialog") | ||||||
| expect(buttonTextArrow2).toEqual(regularBtnText) | ||||||
| }) | ||||||
|
|
||||||
| it("execute function browserside on button to get its text with fluent sync api, basic return type", async () => { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small typo
Suggested change
|
||||||
| const buttonText = await browser.asControl({ | ||||||
| selector: { | ||||||
| id: "openDialogButton", | ||||||
| viewName: "test.Sample.view.Main" | ||||||
| } | ||||||
| }).exec(function () { | ||||||
| return this.getText() | ||||||
| }) | ||||||
| expect(buttonText).toEqual("open Dialog") | ||||||
| }) | ||||||
|
|
||||||
| it("execute function browserside on button and compare text there, boolean return type", async () => { | ||||||
| const button = await browser.asControl({ | ||||||
| selector: { | ||||||
| id: "openDialogButton", | ||||||
| viewName: "test.Sample.view.Main" | ||||||
| } | ||||||
| }) | ||||||
|
|
||||||
| const regularBtnText = await button.getText() | ||||||
| //regular function | ||||||
| const textIsEqual = await button.exec(function (dialogTextHardcoded, dialogTextFromUI) { | ||||||
| return this.getText() === dialogTextHardcoded && this.getText() === dialogTextFromUI | ||||||
| }, "open Dialog", regularBtnText) | ||||||
| expect(textIsEqual).toEqual(true) | ||||||
|
|
||||||
| //arrow functions | ||||||
| const textIsEqualArrow1 = await button.exec((dialogTextHardcoded, dialogTextFromUI) => this.getText() === dialogTextHardcoded && this.getText() === dialogTextFromUI, "open Dialog", regularBtnText) | ||||||
| expect(textIsEqualArrow1).toEqual(true) | ||||||
| const textIsEqualArrow2 = await button.exec((dialogTextHardcoded, dialogTextFromUI) => { | ||||||
| return this.getText() === dialogTextHardcoded && this.getText() === dialogTextFromUI | ||||||
| }, "open Dialog", regularBtnText) | ||||||
| expect(textIsEqualArrow2).toEqual(true) | ||||||
| }) | ||||||
|
|
||||||
| it("nav to other view and get people list names, array return type", async () => { | ||||||
| // click webcomponent button to trigger navigation | ||||||
| const navButton = await browser.asControl({ | ||||||
| selector: { | ||||||
| id: "NavFwdButton", | ||||||
| viewName: "test.Sample.view.Main" | ||||||
| } | ||||||
| }) | ||||||
| await navButton.press() | ||||||
|
|
||||||
| const listSelector = { | ||||||
| selector: { | ||||||
| id: "PeopleList", | ||||||
| viewName: "test.Sample.view.Other", | ||||||
| interaction: "root" | ||||||
| } | ||||||
| } | ||||||
| const list = await browser.asControl(listSelector) | ||||||
|
|
||||||
| /** | ||||||
| * need to set | ||||||
| * wdi5: {logLevel: "verbose"} | ||||||
| * in config.js | ||||||
| */ | ||||||
|
|
||||||
| // ********* | ||||||
| // new approach -> takes ~4.3sec | ||||||
| marky.mark("execForListItemTitles") | ||||||
| const peopleListNames = await list.exec(function () { | ||||||
| return this.getItems().map((item) => item.getTitle()) | ||||||
| }) | ||||||
| wdi5.getLogger().info(marky.stop("execForListItemTitles")) | ||||||
| // ********* | ||||||
|
|
||||||
| Other.allNames.forEach((name) => { | ||||||
| expect(peopleListNames).toContain(name) | ||||||
| }) | ||||||
|
|
||||||
| // ********* | ||||||
| // UI5 API straight forward approach -> takes ~8.1sec | ||||||
| marky.mark("regularGetAllItemTitles") | ||||||
| const regularPeopleListNames = await Promise.all( | ||||||
| // prettier-ignore | ||||||
| (await list.getItems()).map(async (e) => { | ||||||
| return await e.getTitle() | ||||||
| }) | ||||||
| ) | ||||||
| wdi5.getLogger().info(marky.stop("regularGetAllItemTitles")) | ||||||
| // ********* | ||||||
|
|
||||||
| Other.allNames.forEach((name) => { | ||||||
| expect(regularPeopleListNames).toContain(name) | ||||||
| }) | ||||||
|
|
||||||
| // compare results | ||||||
| regularPeopleListNames.forEach((name) => { | ||||||
| expect(peopleListNames).toContain(name) | ||||||
| }) | ||||||
| }) | ||||||
|
|
||||||
| it("get people list title and people names, object return type", async () => { | ||||||
| const listSelector = { | ||||||
| selector: { | ||||||
| id: "PeopleList", | ||||||
| viewName: "test.Sample.view.Other", | ||||||
| interaction: "root" | ||||||
| } | ||||||
| } | ||||||
| const peopleListData = await browser.asControl(listSelector).exec(function () { | ||||||
| return { | ||||||
| tableTitle: this.getHeaderText(), | ||||||
| peopleListNames: this.getItems().map((item) => item.getTitle()) | ||||||
| } | ||||||
| }) | ||||||
|
|
||||||
| expect(peopleListData.tableTitle).toEqual("...bites the dust!") | ||||||
| Other.allNames.forEach((name) => { | ||||||
| expect(peopleListData.peopleListNames).toContain(name) | ||||||
| }) | ||||||
| }) | ||||||
| }) | ||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional enhancement: you can validate error messages on the console in the Node.js scope with the help of
sinon.See
wdi5/examples/ui5-js-app/webapp/test/e2e/error-logging.test.js
Line 26 in 16d6984