Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wdio v9 compat #645

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
39a90c9
chore: update version
Siolto Sep 10, 2024
0ed1dd9
wip: transpile issues
Siolto Sep 10, 2024
ddb76d9
refactor: rewrite _checkForUI5Ready
Siolto Oct 3, 2024
ed33d3f
refactor: rewrite _getAggregation
Siolto Oct 3, 2024
254f0bb
refactor: rework clientside scripts
Siolto Oct 3, 2024
83e7a66
wip: onward to v9 by promisyfying stuff
vobu Oct 22, 2024
4e8ef4b
wip: make it work
vobu Oct 23, 2024
40a55f2
wip: make more work
vobu Oct 23, 2024
bdf7ce4
wip: make .press and .fireEvent work
vobu Oct 23, 2024
d3dbfbd
wip: make work, but missing test
vobu Oct 23, 2024
18db6e0
fix: param sequence
vobu Oct 23, 2024
6a73168
wip: make thingies more work
vobu Oct 23, 2024
891dc75
fix: test for date value
vobu Oct 23, 2024
1c3e89c
refactor: cleanup
vobu Oct 23, 2024
9426149
wip: make it work
vobu Oct 23, 2024
466a367
fix: scoping of .catch
vobu Oct 23, 2024
923ad2e
fix: scoping of .catch in the client side scripts
Siolto Oct 24, 2024
d18fd91
wip: promisifying client side scripts
Siolto Oct 24, 2024
2beefec
wip: promisify injectUI5 client side script
Siolto Oct 24, 2024
db01afa
wip: migrate fe testlib to new execute syntax
Siolto Oct 24, 2024
ca4e71a
Merge remote-tracking branch 'origin/main' into v9-support
Siolto Oct 24, 2024
821f94f
fix: do not pass functions to the browser scope
Siolto Oct 24, 2024
334360b
docs: executeAsync -> execute
vobu Oct 24, 2024
1b2f27a
chore: make eslint v9 + husky work
vobu Oct 24, 2024
99b960c
chore: cleanup
vobu Oct 24, 2024
20f878e
ci: bump node version to 20 + 22
vobu Oct 24, 2024
9e7260a
ci: refactor to work with both node v20+22
vobu Oct 24, 2024
14c55ff
fix: eslint v9 + linting errors
vobu Oct 24, 2024
dfe2c19
fix: force webdriver protocol
vobu Oct 24, 2024
624932a
ci: disable devtools protocol
vobu Oct 24, 2024
f0720ea
fix: use correct cap-bookshop commit
Siolto Oct 24, 2024
7ae5c93
chore: commit
vobu Oct 25, 2024
d9ee3a7
docs: hint on migration
vobu Oct 25, 2024
8336ccb
chore(release): 3.0.0-rc.0
vobu Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- run: npm ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: tmp install prettier + eslint
run: npm i prettier eslint
- name: lint things
run: |
node_modules/.bin/prettier --debug-check client-side-js src docs
node_modules/.bin/eslint --ext .ts src
node_modules/.bin/eslint ./src/**/*.ts
# TODO: linting rules for client-side-js
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
token: ${{secrets.ADMIN_WDI5}}
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: "npm"
cache-dependency-path: "**/package-lock.json"
registry-url: https://registry.npmjs.org/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wdi5-tests_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

strategy:
matrix:
node-version: [18, 20]
node-version: [20, 22]

steps:
- name: check out repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wdi5-tests_fe-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

strategy:
matrix:
node-version: [18, 20]
node-version: [20, 22]

steps:
### no mas since wdio^8 allows for auto-download of matching chromedriver for the env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wdi5-tests_js-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

strategy:
matrix:
node-version: [18, 20]
node-version: [20, 22]

steps:
### no mas since wdio^8 allows for auto-download of matching chromedriver for the env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wdi5-tests_ts-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

strategy:
matrix:
node-version: [18, 20]
node-version: [20, 22]

steps:
### no mas since wdio^8 allows for auto-download of matching chromedriver for the env
Expand Down
2 changes: 0 additions & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit ""
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
8 changes: 7 additions & 1 deletion .retrofit-pkg-json.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// transmogrifying wdi5's package.json to a cjs version
import { promises as fs } from "fs"
import pkgJson from "./package.json" assert { type: "json" }
import { readFileSync } from "fs"
import { dirname, join } from "node:path"
import { fileURLToPath } from "node:url"

const pkgJsonPath = join(dirname(fileURLToPath(import.meta.url)), "./package.json")
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"))

;["type", "exports", "types", "files", "workspaces", "scripts", "lint-staged"].forEach((section) => {
delete pkgJson[section]
})
Expand Down
18 changes: 8 additions & 10 deletions client-side-js/_checkForUI5Ready.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
async function clientSide__checkForUI5Ready(browserInstance) {
return await browserInstance.executeAsync((done) => {
window.bridge
.waitForUI5(window.wdi5.waitForUI5Options)
.then(() => {
window.wdi5.Log.info("[browser wdi5] UI5 is ready")
done(true)
})
.catch((error) => {
console.error(error)
})
return await browserInstance.execute(async () => {
try {
await window.wdi5.waitForUI5(window.wdi5.waitForUI5Options)
} catch (error) {
return window.wdi5.errorHandling(error)
}
window.wdi5.Log.info("[browser wdi5] UI5 is ready")
return true
})
}

Expand Down
35 changes: 17 additions & 18 deletions client-side-js/_getAggregation.cjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
async function clientSide_getAggregation(webElement, aggregationName, browserInstance) {
webElement = await Promise.resolve(webElement) // to plug into fluent async api
browserInstance = await Promise.resolve(browserInstance)
return await browserInstance.executeAsync(
(webElement, aggregationName, done) => {
window.bridge.waitForUI5(window.wdi5.waitForUI5Options).then(() => {
// DOM to UI5
try {
let oControl = window.wdi5.getUI5CtlForWebObj(webElement)
let cAggregation = oControl.getAggregation(aggregationName)
// if getAggregation retrieves an element only it has to be transformed to an array
if (cAggregation && !Array.isArray(cAggregation)) {
cAggregation = [cAggregation]
}
// read classname eg. sap.m.ComboBox
controlType = oControl.getMetadata()._sClassName
let result = window.wdi5.createControlIdMap(cAggregation, controlType)
done({ status: 0, result: result })
} catch (e) {
done({ status: 1, message: e.toString() })
return await browserInstance.execute(
async (webElement, aggregationName) => {
try {
await window.bridge.waitForUI5(window.wdi5.waitForUI5Options)
let oControl = window.wdi5.getUI5CtlForWebObj(webElement)
let cAggregation = oControl.getAggregation(aggregationName)
// if getAggregation retrieves an element only it has to be transformed to an array
if (cAggregation && !Array.isArray(cAggregation)) {
cAggregation = [cAggregation]
}
})
// read classname eg. sap.m.ComboBox
controlType = oControl.getMetadata()._sClassName
let result = window.wdi5.createControlIdMap(cAggregation, controlType)
return { status: 0, result: result }
} catch (error) {
// also returns an object with a "status": 1 property
return window.wdi5.errorHandling(error)
}
},
webElement,
aggregationName
Expand Down
52 changes: 31 additions & 21 deletions client-side-js/_navTo.cjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
async function clientSide__navTo(sComponentId, sName, oParameters, oComponentTargetInfo, bReplace, browserInstance) {
return await browserInstance.executeAsync(
(sComponentId, sName, oParameters, oComponentTargetInfo, bReplace, done) => {
window.bridge.waitForUI5(window.wdi5.waitForUI5Options).then(() => {
window.wdi5.Log.info(`[browser wdi5] navigation to ${sName} triggered`)
return await browserInstance.execute(
async (sComponentId, sName, oParameters, oComponentTargetInfo, bReplace) => {

const router = sap.ui.getCore().getComponent(sComponentId).getRouter()
const hashChanger = window.compareVersions.compare("1.75.0", sap.ui.version, ">")
? sap.ui.core.routing.HashChanger.getInstance()
: router.getHashChanger()
try {
await window.bridge.waitForUI5(window.wdi5.waitForUI5Options)
} catch (error) {
return window.wdi5.errorHandling(error)
}

// on success result is the router
// FIXME: should this be changed to attach once?
hashChanger.attachEvent("hashChanged", (oEvent) => {
done({
status: 0,
result: window.compareVersions.compare("1.75.0", sap.ui.version, ">")
? hashChanger.getHash()
: hashChanger.hash
})
})
window.wdi5.Log.info(`[browser wdi5] navigation to ${sName} triggered`)

// TODO: get rid of deprectaed function
const router = sap.ui.getCore().getComponent(sComponentId).getRouter()
const hashChanger = window.compareVersions.compare("1.75.0", sap.ui.version, ">")
? sap.ui.core.routing.HashChanger.getInstance()
: router.getHashChanger()

// get component and trigger router
// sName, oParameters?, oComponentTargetInfo?, bReplace?
router.navTo(sName, oParameters, oComponentTargetInfo, bReplace)
// create hashChanged promise
const hashChangedPromise = new Promise((resolve) => {
hashChanger.attachEventOnce("hashChanged", () => {
resolve()
})
})

// get component and trigger router
// sName, oParameters?, oComponentTargetInfo?, bReplace?
router.navTo(sName, oParameters, oComponentTargetInfo, bReplace)
// wait for hashChanged event
await hashChangedPromise
return {
status: 0,
result: window.compareVersions.compare("1.75.0", sap.ui.version, ">")
? hashChanger.getHash()
: hashChanger.hash
}
},
sComponentId,
sName,
Expand Down
58 changes: 32 additions & 26 deletions client-side-js/allControls.cjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
async function clientSide_allControls(controlSelector, browserInstance) {
controlSelector = await Promise.resolve(controlSelector) // to plug into fluent async api
return await browserInstance.executeAsync((controlSelector, done) => {
return await browserInstance.execute(async (controlSelector) => {
const waitForUI5Options = Object.assign({}, window.wdi5.waitForUI5Options)
if (controlSelector.timeout) {
waitForUI5Options.timeout = controlSelector.timeout
}

window.wdi5.waitForUI5(
waitForUI5Options,
() => {
window.wdi5.Log.info("[browser wdi5] locating " + JSON.stringify(controlSelector))
controlSelector.selector = window.wdi5.createMatcher(controlSelector.selector)
window.bridge
.findAllDOMElementsByControlSelector(controlSelector)
.then((domElements) => {
// window.wdi5.Log.info('[browser wdi5] control located! - Message: ' + JSON.stringify(domElement));
// ui5 control
let returnElements = []
domElements.forEach((domElement) => {
const ui5Control = window.wdi5.getUI5CtlForWebObj(domElement)
const id = ui5Control.getId()
window.wdi5.Log.info(`[browser wdi5] control with id: ${id} located!`)
const aProtoFunctions = window.wdi5.retrieveControlMethods(ui5Control)
// @type [String, String?, String, "Array of Strings"]
returnElements.push({ domElement: domElement, id: id, aProtoFunctions: aProtoFunctions })
})
try {
await window.wdi5.waitForUI5(waitForUI5Options)
} catch (error) {
return window.wdi5.errorHandling(error)
}

window.wdi5.Log.info("[browser wdi5] locating " + JSON.stringify(controlSelector))
controlSelector.selector = window.wdi5.createMatcher(controlSelector.selector)
let domElements;

try {
domElements = await window.bridge.findAllDOMElementsByControlSelector(controlSelector)
} catch (error) {
return window.wdi5.errorHandling(error)
}

// ui5 control
let returnElements = []
domElements.forEach((domElement) => {
const ui5Control = window.wdi5.getUI5CtlForWebObj(domElement)
const id = ui5Control.getId()
window.wdi5.Log.info(`[browser wdi5] control with id: ${id} located!`)
const aProtoFunctions = window.wdi5.retrieveControlMethods(ui5Control)
// @type [String, String?, String, "Array of Strings"]
returnElements.push({
domElement: domElement,
id: id,
aProtoFunctions: aProtoFunctions
})
})

done({ status: 0, result: returnElements })
})
.catch(window.wdi5.errorHandling.bind(this, done))
},
window.wdi5.errorHandling.bind(this, done)
)
return { status: 0, result: returnElements }
}, controlSelector)
}

Expand Down
Loading
Loading