Skip to content

Commit

Permalink
fix: rm obsolete design time artifacts (#422)
Browse files Browse the repository at this point in the history
- make the constructor parameters for the service implementation itself optional   
- add late-inject test in TS scope   
fixes #421
  • Loading branch information
vobu authored Feb 8, 2023
1 parent eb44619 commit f9bf300
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/wdi5-tests_ts-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ jobs:
run: npm run build

# run wdi5 tests within app(s)
# this includes test for late-injecting wdi5
- name: test ts-app
run: npm run test-h:ts-app
1 change: 1 addition & 0 deletions examples/ui5-ts-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test": "wdio run wdio-ui5.conf.ts",
"test:authentication": "run-s authentication:*",
"test-h:authentication": "run-s \"authentication:* -- --headless\"",
"test:lateInject": "wdio run wdio-ui5-late.conf.ts",
"authentication:btp": "wdio run test/e2e/authentication/wdio-btp-authentication.conf.ts",
"authentication:basic-auth": "wdio run test/e2e/authentication/wdio-basic-auth-authentication.conf.ts",
"authentication:custom": "wdio run test/e2e/authentication/wdio-custom-authentication.conf.ts",
Expand Down
32 changes: 32 additions & 0 deletions examples/ui5-ts-app/test/e2e/ui5-late.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// only requiring the service for late inject/init
import Input from "sap/ui/webc/main/Input"
import { default as _wdi5 } from "wdio-ui5-service"
const wdi5 = new _wdi5()

describe("late inject wdi5", () => {
it('should show a non UI5 page, then advance to a UI5 page and late init "wdi5"', async () => {
// native wdio functionality - navigates to the wdi5 github page
await browser.$("#user-content-wdi5-").waitForDisplayed()
// open local app
await browser.url("http://localhost:8080/index.html")
// do the late injection
await wdi5.injectUI5()
})

it("wdi5 should subsequently work with UI5 enablement", async () => {
const webcomponentValue = await (
browser.asControl({
selector: {
bindingPath: {
modelName: "",
propertyPath: "/Customers('TRAIH')/ContactName"
},
viewName: "test.Sample.tsapp.view.Main",
controlType: "sap.ui.webc.main.Input"
}
}) as unknown as Input
).getValue()

expect(webcomponentValue).toEqual("Helvetius Nagy")
})
})
8 changes: 8 additions & 0 deletions examples/ui5-ts-app/wdio-ui5-late.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { config } from "./wdio-ui5.conf"

config.wdi5 = { skipInjectUI5OnStart: true }
config.specs = ["./test/e2e/ui5-late.test.ts"]
delete config.exclude
config.baseUrl = "https://github.com/ui5-community/wdi5/"

exports.config = config
3 changes: 2 additions & 1 deletion examples/ui5-ts-app/wdio-ui5.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const config: wdi5Config = {
"./test/e2e/Custom.test.ts",
"./test/e2e/multiremote.test.ts",
"./test/e2e/BasicMultiRemoteAuthentication.test.ts",
"./test/e2e/Authentication.test.ts"
"./test/e2e/Authentication.test.ts",
"./test/e2e/ui5-late.test.ts"
],

maxInstances: 10,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"_test:js-app": "wait-on tcp:8888 && wait-on tcp:8080 && npm run test --workspace=examples/ui5-js-app",
"_test:ts-app": "wait-on tcp:8080 && npm run test --workspace=examples/ui5-ts-app",
"_test-h:js-app": "wait-on tcp:8888 && wait-on tcp:8080 && npm run test-h --workspace=examples/ui5-js-app",
"_test-h:ts-app": "wait-on tcp:8080 && npm run test -w examples/ui5-ts-app -- --headless",
"_test-h:ts-app": "wait-on tcp:8080 && npm run test -w examples/ui5-ts-app -- --headless && npm run test:lateInject -w examples/ui5-ts-app -- --headless",
"test-h:js-app": "run-p -r _startApp:js _startApp:js-tooling _test-h:js-app",
"test:ts-app": "run-p -r _startApp:ts _test:ts-app",
"test:cucumber": "npm run test --workspace=examples/cucumber",
Expand Down
8 changes: 4 additions & 4 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const Logger = _Logger.getInstance()

export default class Service implements Services.ServiceInstance {
constructor(
private _options: wdi5Config,
private _capabilities: Capabilities.RemoteCapability,
private _config: wdi5Config // an enhanced version of the regular wdio config
) {}
private _options?: wdi5Config, // TODO: this is the successor to _config in wdio^8
private _capabilities?: Capabilities.RemoteCapability,
private _config?: wdi5Config // an enhanced version of the regular wdio config
) {} // the Service is instantiated by wdio with the capabilites and config passed on to

async before(/*capabilities* , specs*/) {
// if no wdi5 config is available we add it manually
Expand Down

0 comments on commit f9bf300

Please # to comment.