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

Fix browser version in spec reporter #5390

Merged
merged 14 commits into from May 17, 2020
Merged

Fix browser version in spec reporter #5390

merged 14 commits into from May 17, 2020

Conversation

unickq
Copy link
Contributor

@unickq unickq commented May 12, 2020

Before:

[chrome  windows #0-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[chrome  windows #0-0] Running: chrome on windows
[chrome  windows #0-0] Session ID: 5afa1aa20220c2e4a26ca039c9149f33

After:

[chrome 81.0.4044.138 windows #0-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[chrome 81.0.4044.138 windows #0-0] Running: chrome (v81.0.4044.138) on windows
[chrome 81.0.4044.138 windows #0-0] Session ID: b4b86051d1fca73c0c2d3dca6f01f80c

Proposed changes

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

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

Reviewers: @webdriverio/project-committers

```
[chrome  windows #0-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[chrome  windows #0-0] Running: chrome on windows
[chrome  windows #0-0] Session ID: 5afa1aa20220c2e4a26ca039c9149f33
[chrome  windows #0-0]
[chrome  windows #0-0] A
[chrome  windows #0-0]    ✓ A
[chrome  windows #0-0]
[chrome  windows #0-0] 1 passing (239ms)
```

After:
```
[chrome 81.0.4044.138 windows #0-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[chrome 81.0.4044.138 windows #0-0] Running: chrome (v81.0.4044.138) on windows
[chrome 81.0.4044.138 windows #0-0] Session ID: b4b86051d1fca73c0c2d3dca6f01f80c
[chrome 81.0.4044.138 windows #0-0]
[chrome 81.0.4044.138 windows #0-0] A
[chrome 81.0.4044.138 windows #0-0]    ✓ A
[chrome 81.0.4044.138 windows #0-0]
[chrome 81.0.4044.138 windows #0-0] 1 passing (242ms)
```
@jsf-clabot
Copy link

jsf-clabot commented May 12, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

I would recommend to change the line to:

const version = capss.browserVersion || caps.version || '(unknown)'

packages/wdio-spec-reporter/src/index.js Outdated Show resolved Hide resolved
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.

I see some confusion, let's clear that up right away to prevent this in the future

packages/wdio-spec-reporter/src/index.js Show resolved Hide resolved
iOS - [iPhone XR iOS 12.0 #0-0] 
Android - [8CDX1MVLF Android 10 #1-0]
Firefox - [firefox 76.0 #2-0]
@unickq unickq requested a review from erwinheitzman May 12, 2020 09:34
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.

Left a question, if my suspicion is correct then we can simplify it a little further by always taking the OS except when a device is used, in which case it will take the platform or platformName :)

packages/wdio-spec-reporter/src/index.js Outdated Show resolved Hide resolved
@erwinheitzman
Copy link
Member

Great and easy fix btw, thanks for the contribution 👍

packages/wdio-spec-reporter/src/index.js Outdated Show resolved Hide resolved
packages/wdio-spec-reporter/src/index.js Outdated Show resolved Hide resolved

// Mobile capabilities
if (device) {
const program = (caps.app || '').replace('sauce-storage:', '') || caps.browserName
const executing = program ? `executing ${program}` : ''

version = caps.platformVersion
platform = caps.platformName
Copy link
Member

Choose a reason for hiding this comment

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

let's keep the definiton of platform and version at one place

Copy link
Member

Choose a reason for hiding this comment

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

fair enough, the comments you added add more value than this!

unickq and others added 3 commits May 12, 2020 13:57
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

I missed something in my suggestion. Also can we add a test to check support for BS invalid caps: browser_version and os

packages/wdio-spec-reporter/src/index.js Outdated Show resolved Hide resolved
unickq and others added 2 commits May 12, 2020 14:06
Co-authored-by: Christian Bromann <github@christian-bromann.com>
@unickq
Copy link
Contributor Author

unickq commented May 12, 2020

@christian-bromann updated your platform to:

const platform = caps.os ? (caps.os + ' ' + caps.osVersion) : caps.platformName || caps.platform

So no undefined in platform anymore

[safari 13605.3.8 macOS #3-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[safari 13605.3.8 macOS #3-0] Running: safari (v13605.3.8) on macOS
[safari 13605.3.8 macOS #3-0] Session ID: a2760e25cf7d172c5b77c45e4f0d62c4b2dab5fe
------------------------------------------------------------------
[firefox 76.0 windows #2-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[firefox 76.0 windows #2-0] Running: firefox (v76.0) on windows
[firefox 76.0 windows #2-0] Session ID: ec7089d90c1068233cad9e10252cef95c823b05e
------------------------------------------------------------------
[iPhone XR iOS 12.0 #0-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[iPhone XR iOS 12.0 #0-0] Running: iPhone XR on iOS 12.0 executing safari
[iPhone XR iOS 12.0 #0-0] Session ID: bda23c72821576a7670c43c6095efd710f6000cf
------------------------------------------------------------------
[8ATX0Z2CV Android 10 #1-0] Spec: C:\Git\integration-tests\bolt\integration-tests\checkout\specs\magento2\front\cart\xxx.ts
[8ATX0Z2CV Android 10 #1-0] Running: 8ATX0Z2CV on Android 10 executing chrome
[8ATX0Z2CV Android 10 #1-0] Session ID: f0ea886d9d3b4b3050fe71e9dc914b0dda5be0ab

@christian-bromann
Copy link
Member

@unickq would you mind to add a test where you use browser_version and os in your capabilities and snapshot the spec reporter output?

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.

last remark for me

packages/wdio-spec-reporter/src/index.js Outdated Show resolved Hide resolved
@erwinheitzman
Copy link
Member

erwinheitzman commented May 12, 2020

@unickq would you mind to add a test where you use browser_version and os in your capabilities and snapshot the spec reporter output?

@christian-bromann this test already exists here I think (all the way at the bottom)?
https://github.com/webdriverio/webdriverio/blob/master/packages/wdio-spec-reporter/tests/index.test.js

EDIT: those tests are actually failing atm since the version seems to be undefined

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.

tests are failing

packages/wdio-spec-reporter/src/index.js Outdated Show resolved Hide resolved
@erwinheitzman
Copy link
Member

And like Christian said, for any changed functionality we should add some tests

@unickq
Copy link
Contributor Author

unickq commented May 12, 2020

And like Christian said, for any changed functionality we should add some tests

Sure I'll try to do this when I get my mac.
Like I said can't make build/lint/test on Windows somehow 😞

@erwinheitzman
Copy link
Member

erwinheitzman commented May 12, 2020

@unickq that's strange, it worked fine last time I tried on my Windows machine using vscode. I have changed the integrated terminal to be git bash but that's about it.

then run:

npm i
npm run setup-full
npx jest ./packages/wdio-spec-reporter/tests

NOTE: make sure you have NodeJS 10 or 12 I'd say

@unickq
Copy link
Contributor Author

unickq commented May 12, 2020

Thanks for help @erwinheitzman

VS integrated powershell didn't work. But external did.
I updated tests with new (unknown) state. And like you said before - browserstack tests are already there.

Can you please confirm I'm doing right things with the tests?

@christian-bromann
Copy link
Member

I updated tests with new (unknown) state.

Can you please update the tests to use proper capabilities to actually test the change?

@unickq
Copy link
Contributor Author

unickq commented May 13, 2020

@christian-bromann

I checked coverage report:
image

And it looks like we can never reach that branch, because

const platform = caps.platformName || caps.platform || (caps.os ? caps.os + ' ' + caps.os_version : '(unknown)')

returns (unknown) if nothing else is available.

Doesn't it mean lines 417-421 needs to be updated to

        if (!verbose) {
            return (browser + ' ' + (version || '') + ' ' + (platform)).trim()
        }

        return browser + (version ? ` (v${version})` : '') + (` on ${platform}`)

and no additional coverage tests are needed?

@christian-bromann
Copy link
Member

@unickq please work with various capabilities to test different report outputs. Currently we only work with one capability but we could use multiple to ensure that these changes are included in the tests.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

can we not have unknown in the test snapshot and instead use an actual capability?

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thank you for your patience with us. I wanted to make sure we get this right.

@christian-bromann christian-bromann added the PR: Polish 💅 PRs that contain improvements on existing features label May 17, 2020
@christian-bromann christian-bromann merged commit ca130d8 into webdriverio:master May 17, 2020
@christian-bromann christian-bromann added backport-requested PRs with this label are considered to be applied to the last maintained version backported PRs with this label got backported to the last maintained version and removed backport-requested PRs with this label are considered to be applied to the last maintained version labels May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported PRs with this label got backported to the last maintained version PR: Polish 💅 PRs that contain improvements on existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants