Skip to content

Commit

Permalink
feat(service): expose injectUI5()
Browse files Browse the repository at this point in the history
... for late injecting wdio-ui5-service
  • Loading branch information
vobu committed Feb 13, 2022
1 parent e66189f commit 4f3097a
Showing 1 changed file with 8 additions and 51 deletions.
59 changes: 8 additions & 51 deletions src/service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Capabilities, Options, Services } from "@wdio/types"

import { start, injectUI5, setup } from "./lib/wdi5-bridge"
import { start, injectUI5, setup, checkForUI5Page } from "./lib/wdi5-bridge"
import { wdi5Config } from "./types/wdi5.types"

import { Logger as _Logger } from "./lib/Logger"
Expand Down Expand Up @@ -51,54 +51,11 @@ export default class Service implements Services.ServiceInstance {

onReload(oldSessionId, newSessionId) {}

// async startWDI5(browser) {
// // UI5 bridge setup
// const wdi5config = (browser.config as wdi5Config).wdi5

// // set sapui5 version constant to browser for later switches
// // Before version 1.60, the only available criteria is binding browser path.
// // As of version 1.72, it is available as a declarative matcher
// // TODO: do we still need to support this?
// // browser._oldAPIVersion = 1.6

// Logger.setLogLevel(wdi5config?.logLevel || "error")

// // this is only to run in browser
// if (wdi5config && typeof wdi5config.url === "string") {
// if (wdi5config.url.length > 0) {
// Logger.info(`open url: ${wdi5config.url}`)
// browser.url(wdi5config.url)
// } else if (wdi5config.url === "") {
// Logger.info(
// "open url with fallback (this is not causing any issues since its is removed for navigation): #"
// )
// browser.url("#")
// } else {
// // just for error logging
// Logger.error("not opening any url, wdi5 config contains errors")
// }
// } else {
// // just for error logging
// Logger.error("not opening any url, no url was supplied in wdi5 config")
// }

// Logger.info("wdio-ui5-service before hook")

// wdioUI5.setup(browser) // use wdio hooks for setting up wdio<->ui5 bridge

// // skip UI5 initialization on startup
// if (wdi5config && !wdi5config.skipInjectUI5OnStart) {
// await this.injectUI5()
// } else {
// Logger.warn("wdio-ui5-service skipped injecting UI5")
// }
// }

// /**
// * inject the wdio-ui5-service sources to the UI5 app after launch
// */
// async injectUI5() {
// await wdioUI5.checkForUI5Page()
// await wdioUI5.injectUI5(browser) // needed to let the instance know that UI5 is now available for work
// }
async injectUI5() {
if (await checkForUI5Page()) {
await injectUI5(this._config)
} else {
throw new Error("wdi5: not UI5 page/app present to work on :(")
}
}
}

0 comments on commit 4f3097a

Please sign in to comment.