Skip to content

Commit

Permalink
fix: FE testLibrary initialization (#286)
Browse files Browse the repository at this point in the history
load the required resources for the testlib only when the testlib is specifically initialized  
hopefully aids in resolving #276
  • Loading branch information
Siolto authored Jun 21, 2022
1 parent 2aad7ea commit d5fddee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
12 changes: 1 addition & 11 deletions client-side-js/injectUI5.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,7 @@ async function clientSide_injectUI5(config, waitForUI5Timeout) {
// known side effect this call triggers the back to node scope, the other sap.ui.require continue to run in background in browser scope
done(true)
})
// see also /client-side-js/testLibrary.js
sap.ui.require(
["sap/fe/test/ListReport", "sap/fe/test/ObjectPage", "sap/fe/test/Shell"],
(ListReport, ObjectPage, Shell) => {
window.fe_bridge.ListReport = ListReport
window.fe_bridge.ObjectPage = ObjectPage
window.fe_bridge.Shell = Shell
// logs for the FE Testlib responses
window.fe_bridge.Log = []
}
)

// make sure the resources are required
// TODO: "sap/ui/test/matchers/Sibling",
sap.ui.require(
Expand Down
19 changes: 18 additions & 1 deletion client-side-js/testLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,25 @@ async function addToQueue(type, target, aMethods) {
)
}

async function loadFELibraries() {
return await browser.executeAsync((done) => {
sap.ui.require(
["sap/fe/test/ListReport", "sap/fe/test/ObjectPage", "sap/fe/test/Shell"],
(ListReport, ObjectPage, Shell) => {
window.fe_bridge.ListReport = ListReport
window.fe_bridge.ObjectPage = ObjectPage
window.fe_bridge.Shell = Shell
// logs for the FE Testlib responses
window.fe_bridge.Log = []
done()
}
)
})
}

module.exports = {
emptyQueue,
initOPA,
addToQueue
addToQueue,
loadFELibraries
}
3 changes: 2 additions & 1 deletion src/lib/wdi5-fe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { initOPA, addToQueue, emptyQueue } from "../../client-side-js/testLibrary"
import { initOPA, addToQueue, emptyQueue, loadFELibraries } from "../../client-side-js/testLibrary"
import { Logger as _Logger } from "./Logger"
const Logger = _Logger.getInstance()

Expand All @@ -25,6 +25,7 @@ function createProxy(myObj: any, type: string, methodCalls: any[], pageKeys: str
export class WDI5FE {
constructor(private appConfig: any) {}
static async initialize(appConfig) {
await loadFELibraries()
await initOPA(appConfig)
return new WDI5FE(appConfig)
}
Expand Down

0 comments on commit d5fddee

Please sign in to comment.