From 572b4819c89d5e8ecdfd8d3503781da30dd7071b Mon Sep 17 00:00:00 2001 From: Volker Buzek Date: Wed, 8 Feb 2023 14:45:00 +0100 Subject: [PATCH 1/6] fix: rm obsolete design time artifacts - constructor - type import --- src/service.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/service.ts b/src/service.ts index 0657a916..0c57585f 100644 --- a/src/service.ts +++ b/src/service.ts @@ -1,4 +1,4 @@ -import { Capabilities, Services } from "@wdio/types" +import { Services } from "@wdio/types" import { MultiRemoteDriver } from "webdriverio/build/multiremote" import { start, injectUI5, setup, checkForUI5Page, authenticate } from "./lib/wdi5-bridge" @@ -8,11 +8,8 @@ import { Logger as _Logger } from "./lib/Logger" 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 _config: any + private _capabilities: any async before(/*capabilities* , specs*/) { // if no wdi5 config is available we add it manually From 3c377d46e5435e6b8ccc208c8e0a8d0f6ceae238 Mon Sep 17 00:00:00 2001 From: Volker Buzek Date: Wed, 8 Feb 2023 14:54:37 +0100 Subject: [PATCH 2/6] refactor: init private props --- src/service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/service.ts b/src/service.ts index 0c57585f..77bdeee4 100644 --- a/src/service.ts +++ b/src/service.ts @@ -11,6 +11,11 @@ export default class Service implements Services.ServiceInstance { private _config: any private _capabilities: any + constructor() { + this._config = {} + this._capabilities = {} + } + async before(/*capabilities* , specs*/) { // if no wdi5 config is available we add it manually if (!this._config.wdi5) { From 67bdff744d59c2551dcdc16a1026093a096fccee Mon Sep 17 00:00:00 2001 From: Volker Buzek Date: Wed, 8 Feb 2023 19:31:35 +0100 Subject: [PATCH 3/6] revert: wdio inits the service but make props optional for proper devx --- src/service.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/service.ts b/src/service.ts index 77bdeee4..5b62291e 100644 --- a/src/service.ts +++ b/src/service.ts @@ -1,4 +1,4 @@ -import { Services } from "@wdio/types" +import { Capabilities, Services } from "@wdio/types" import { MultiRemoteDriver } from "webdriverio/build/multiremote" import { start, injectUI5, setup, checkForUI5Page, authenticate } from "./lib/wdi5-bridge" @@ -8,13 +8,11 @@ import { Logger as _Logger } from "./lib/Logger" const Logger = _Logger.getInstance() export default class Service implements Services.ServiceInstance { - private _config: any - private _capabilities: any - - constructor() { - this._config = {} - this._capabilities = {} - } + constructor( + 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 From df4e70fca32d1d1e2cc82cc47db483697da1b622 Mon Sep 17 00:00:00 2001 From: Volker Buzek Date: Wed, 8 Feb 2023 19:32:30 +0100 Subject: [PATCH 4/6] test(ts): for late injecting wdi5 --- examples/ui5-ts-app/test/e2e/ui5-late.test.ts | 32 +++++++++++++++++++ examples/ui5-ts-app/wdio-ui5-late.conf.ts | 7 ++++ examples/ui5-ts-app/wdio-ui5.conf.ts | 3 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 examples/ui5-ts-app/test/e2e/ui5-late.test.ts create mode 100644 examples/ui5-ts-app/wdio-ui5-late.conf.ts diff --git a/examples/ui5-ts-app/test/e2e/ui5-late.test.ts b/examples/ui5-ts-app/test/e2e/ui5-late.test.ts new file mode 100644 index 00000000..8e631a54 --- /dev/null +++ b/examples/ui5-ts-app/test/e2e/ui5-late.test.ts @@ -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") + }) +}) diff --git a/examples/ui5-ts-app/wdio-ui5-late.conf.ts b/examples/ui5-ts-app/wdio-ui5-late.conf.ts new file mode 100644 index 00000000..a5c8dec8 --- /dev/null +++ b/examples/ui5-ts-app/wdio-ui5-late.conf.ts @@ -0,0 +1,7 @@ +import { config } from "./wdio-ui5.conf" + +config.wdi5 = { skipInjectUI5OnStart: true } +config.specs = ["./test/e2e/ui5-late.test.ts"] +config.baseUrl = "https://github.com/ui5-community/wdi5/" + +exports.config = config diff --git a/examples/ui5-ts-app/wdio-ui5.conf.ts b/examples/ui5-ts-app/wdio-ui5.conf.ts index 64387eb1..ef34f673 100644 --- a/examples/ui5-ts-app/wdio-ui5.conf.ts +++ b/examples/ui5-ts-app/wdio-ui5.conf.ts @@ -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, From 04111d5d77598cf2c5d07455160356c0525521ab Mon Sep 17 00:00:00 2001 From: Volker Buzek Date: Wed, 8 Feb 2023 19:33:41 +0100 Subject: [PATCH 5/6] ci: npm script for running late inject test --- .github/workflows/wdi5-tests_ts-app.yml | 1 + examples/ui5-ts-app/package.json | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wdi5-tests_ts-app.yml b/.github/workflows/wdi5-tests_ts-app.yml index 50b8cae0..cf6438d0 100644 --- a/.github/workflows/wdi5-tests_ts-app.yml +++ b/.github/workflows/wdi5-tests_ts-app.yml @@ -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 diff --git a/examples/ui5-ts-app/package.json b/examples/ui5-ts-app/package.json index 140f1f0b..7b707942 100644 --- a/examples/ui5-ts-app/package.json +++ b/examples/ui5-ts-app/package.json @@ -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", diff --git a/package.json b/package.json index fa67b509..3825a00c 100644 --- a/package.json +++ b/package.json @@ -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", From 4918bbe98b292e1fd205d2cf644f02518ffdb991 Mon Sep 17 00:00:00 2001 From: Volker Buzek Date: Wed, 8 Feb 2023 19:45:31 +0100 Subject: [PATCH 6/6] ci(ts-app): fix excludes of merged config --- examples/ui5-ts-app/wdio-ui5-late.conf.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/ui5-ts-app/wdio-ui5-late.conf.ts b/examples/ui5-ts-app/wdio-ui5-late.conf.ts index a5c8dec8..95440511 100644 --- a/examples/ui5-ts-app/wdio-ui5-late.conf.ts +++ b/examples/ui5-ts-app/wdio-ui5-late.conf.ts @@ -2,6 +2,7 @@ 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