Skip to content

(@wdio/utils): better transform function command arguments#11403

Merged
christian-bromann merged 2 commits intomainfrom
cb/param-transcoding
Oct 12, 2023
Merged

(@wdio/utils): better transform function command arguments#11403
christian-bromann merged 2 commits intomainfrom
cb/param-transcoding

Conversation

@christian-bromann
Copy link
Member

Proposed changes

Transforming wdio logs from:

[0-0] 2023-10-11T16:58:28.712Z INFO webdriver: COMMAND executeAsyncScript(<fn>, <object>)
[0-0] 2023-10-11T16:58:28.712Z INFO webdriver: [POST] http://0.0.0.0:64805/session/1ffbe34ea246724a15b2970af1de2447/execute/async
[0-0] 2023-10-11T16:58:28.713Z INFO webdriver: DATA {
[0-0]   script: 'return (async function callApi(bridgePropName, args, done) {\n' +
[0-0]     '    if (window.wdioElectron === undefined) {\n' +
[0-0]     '        throw new Error(`ContextBridge not available for invocation of "${bridgePropName}" API`);\n' +
[0-0]     '    }\n' +
[0-0]     '    if (window.wdioElectron[bridgePropName] === undefined) {\n' +
[0-0]     '        throw new Error(`"${bridgePropName}" API not found on ContextBridge`);\n' +
[0-0]     '    }\n' +
[0-0]     '    return done(await window.wdioElectron[bridgePropName].invoke(...args));\n' +
[0-0]     '}).apply(null, arguments)',
[0-0]   args: [ 'app', [ 'getName' ] ]
[0-0] }
[0-0] 2023-10-11T16:58:28.718Z INFO webdriver: RESULT electron-boilerplate
[0-0] 2023-10-11T16:58:28.718Z INFO webdriver: COMMAND executeAsyncScript(<fn>, <object>)
[0-0] 2023-10-11T16:58:28.719Z INFO webdriver: [POST] http://0.0.0.0:64805/session/1ffbe34ea246724a15b2970af1de2447/execute/async
[0-0] 2023-10-11T16:58:28.719Z INFO webdriver: DATA {
[0-0]   script: 'return (async function callApi(bridgePropName, args, done) {\n' +
[0-0]     '    if (window.wdioElectron === undefined) {\n' +
[0-0]     '        throw new Error(`ContextBridge not available for invocation of "${bridgePropName}" API`);\n' +
[0-0]     '    }\n' +
[0-0]     '    if (window.wdioElectron[bridgePropName] === undefined) {\n' +
[0-0]     '        throw new Error(`"${bridgePropName}" API not found on ContextBridge`);\n' +
[0-0]     '    }\n' +
[0-0]     '    return done(await window.wdioElectron[bridgePropName].invoke(...args));\n' +
[0-0]     '}).apply(null, arguments)',
[0-0]   args: [ 'app', [ 'getVersion' ] ]
[0-0] }
[0-0] 2023-10-11T16:58:28.739Z INFO webdriver: RESULT 1.0.0
[0-0] 2023-10-11T16:58:28.740Z INFO webdriver: COMMAND deleteSession()

to:

[0-0] 2023-10-11T17:00:29.825Z INFO webdriver: COMMAND executeAsyncScript(<fn>, <object>)
[0-0] 2023-10-11T17:00:29.826Z INFO webdriver: [POST] http://0.0.0.0:64849/session/d1adf37b0ade572f98161fce1347cac4/execute/async
[0-0] 2023-10-11T17:00:29.826Z INFO webdriver: DATA { script: 'callApi(...) [457 bytes]', args: [ 'app', [ 'getName' ] ] }
[0-0] 2023-10-11T17:00:29.830Z INFO webdriver: RESULT electron-boilerplate
[0-0] 2023-10-11T17:00:29.831Z INFO webdriver: COMMAND executeAsyncScript(<fn>, <object>)
[0-0] 2023-10-11T17:00:29.831Z INFO webdriver: [POST] http://0.0.0.0:64849/session/d1adf37b0ade572f98161fce1347cac4/execute/async
[0-0] 2023-10-11T17:00:29.831Z INFO webdriver: DATA {
[0-0]   script: 'callApi(...) [457 bytes]',
[0-0]   args: [ 'app', [ 'getVersion' ] ]
[0-0] }
[0-0] 2023-10-11T17:00:29.850Z INFO webdriver: RESULT 1.0.0
[0-0] 2023-10-11T17:00:29.851Z INFO webdriver: COMMAND deleteSession()

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

n/a

Reviewers: @webdriverio/project-committers

@christian-bromann christian-bromann added the PR: Polish 💅 PRs that contain improvements on existing features label Oct 11, 2023
Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this change! I left a suggestion and a question

@christian-bromann christian-bromann merged commit a9162ca into main Oct 12, 2023
@christian-bromann christian-bromann deleted the cb/param-transcoding branch October 12, 2023 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Polish 💅 PRs that contain improvements on existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants