Skip to content

Commit

Permalink
refactor: wdi5.goTo(...) (#303)
Browse files Browse the repository at this point in the history
properly define overloads for different params supplied to .goTo(),
encouraging usage of a single one (`wdi5.goTo(param)`), 
with param being either 
- a string
- an object containing an sHash property or 
- a UI5 router object
the deprecated 2 parameter signature is still supported, but logged as a warning.
also, documentation was updated to reflect above change.
  • Loading branch information
vobu authored Jul 5, 2022
1 parent 16710f7 commit 1d12623
Show file tree
Hide file tree
Showing 7 changed files with 6,833 additions and 6,025 deletions.
6 changes: 3 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Under the hoode, this first retrieves the UI5 control, then feeds it to [Webdriv

### fluent async api

`wdi5` supports `async `method chaining. This means you can directly call a `UI5` control's methods after retrieveing it via `browser.asControl(selector)`:
`wdi5` supports `async` method chaining. This means you can directly call a `UI5` control's methods after retrieveing it via `browser.asControl(selector)`:

```javascript
// sap.m.List has .getItems()
Expand Down Expand Up @@ -346,7 +346,7 @@ await control.fireEvent("itemPress", {

## Assertions

Recommendation is to use the [`Webdriver.IO`](https://webdriver.io)-native extension to JEST's [expect](https://jestjs.io/docs/en/expect) and [matchers](https://jestjs.io/docs/en/using-matchers) as described in https://webdriver.io/docs/assertion.html.
Recommendation is to use the [`Webdriver.IO`](https://webdriver.io)-native extension to JEST's [expect](https://jestjs.io/docs/en/expect) and [matchers](https://jestjs.io/docs/en/using-matchers) as described in <https://webdriver.io/docs/assertion.html>.

## Screenshots

Expand Down Expand Up @@ -416,7 +416,7 @@ In the test, you can navigate the UI5 webapp via `goTo(options)` in one of two w
sComponentId: "container-Sample",
sName: "RouteOther"
}
await wdi5.goTo("", oRouteOptions)
await wdi5.goTo(oRouteOptions)
// or:
await wdi5.goTo("#/Other")
// or:
Expand Down
2 changes: 1 addition & 1 deletion examples/ui5-js-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"chromedriver": "latest",
"ui5-middleware-simpleproxy": "^0.8.4",
"wdio-chromedriver-service": "^7.3.2",
"wdio-ui5-service": "latest"
"wdio-ui5-service": "*"
},
"ui5": {
"dependencies": [
Expand Down
18 changes: 17 additions & 1 deletion examples/ui5-js-app/webapp/test/e2e/hash-nav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@ const listSelector = {
}

describe("hash-based nav", () => {
it('should allow the deep entry to "Other" view using wdi5 helper class and the UI5 router', async () => {
it("should still nav correctly w/ deprecated goTo() signature", async () => {
const oRouteOptions = {
sComponentId: "container-Sample",
sName: "RouteOther"
}
await wdi5.goTo("", oRouteOptions)

const list = await browser.asControl(listSelector)
expect(await list.getVisible()).toBeTruthy()

// only prep for subsequent test(s)
await wdi5.goTo("", {
sComponentId: "container-Sample",
sName: "RouteMain"
})
})
it('should allow the deep entry to "Other" view using wdi5 helper class and the UI5 router', async () => {
const oRouteOptions = {
sComponentId: "container-Sample",
sName: "RouteOther"
}
await wdi5.goTo(oRouteOptions)

const items = await browser.asControl(listSelector).getItems(true)
expect(items.length).toEqual(9)
})
Expand Down
2 changes: 1 addition & 1 deletion examples/ui5-ts-app/test/e2e/pageObjects/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { wdi5 } from "wdio-ui5-service"

export default class Page {
async open(path) {
wdi5.goTo(path, null)
wdi5.goTo(path)
}
}
Loading

0 comments on commit 1d12623

Please sign in to comment.