-
Notifications
You must be signed in to change notification settings - Fork 8
fix(automate): detect App Automate from appium:app capability for session name/status (SDK-7093) #100
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
Open
pri-gadhiya
wants to merge
6
commits into
main
Choose a base branch
from
fix/sdk-7093-appautomate-session-name
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(automate): detect App Automate from appium:app capability for session name/status (SDK-7093) #100
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bc30222
fix(automate): detect App Automate from appium:app capability for ses…
pri-gadhiya 4b19d7a
chore(changeset): auto-generate from PR template (patch)
github-actions[bot] dc27d93
fix(percy,automate): reuse shared hasAppCap App-Automate detector (SD…
pri-gadhiya 42b647e
chore(changeset): auto-generate from PR template (patch)
github-actions[bot] 993bb68
Merge branch 'main' into fix/sdk-7093-appautomate-session-name
pri-gadhiya f7619c6
test(automate,percy): mock hasAppCap + AutomationFramework caps acces…
pri-gadhiya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@wdio/browserstack-service": patch | ||
| --- | ||
|
|
||
| - Fixed App Automate session names not updating to the test title when the app is provided via the `appium:app` capability. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,8 @@ import { AutomationFrameworkState } from '../states/automationFrameworkState.js' | |||||||||
| import PercyHandler from '../../Percy/Percy-Handler.js' | ||||||||||
| import type { Capabilities } from '@wdio/types' | ||||||||||
| import { TestFrameworkConstants } from '../frameworks/constants/testFrameworkConstants.js' | ||||||||||
| import { AutomationFrameworkConstants } from '../frameworks/constants/automationFrameworkConstants.js' | ||||||||||
| import { hasAppCap, isTrue } from '../../util.js' | ||||||||||
| import type TestFrameworkInstance from '../instances/testFrameworkInstance.js' | ||||||||||
|
|
||||||||||
| export default class PercyModule extends BaseModule { | ||||||||||
|
|
@@ -35,6 +37,21 @@ export default class PercyModule extends BaseModule { | |||||||||
| return PercyModule.MODULE_NAME | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // App supplied via the service `app` option / skipAppOverride, OR via an appium:app-style driver | ||||||||||
| // capability (which this.config does not carry) — resolved from the caps via the shared hasAppCap | ||||||||||
| // detector so Percy routes to the App Automate screenshot path. Mirrors automateModule.isAppAutomate(). | ||||||||||
| private isAppAutomateSession(): boolean { | ||||||||||
| if ('app' in this.config || isTrue(this.config.skipAppOverride)) { | ||||||||||
| return true | ||||||||||
| } | ||||||||||
| if (hasAppCap(this.browser?.capabilities as WebdriverIO.Capabilities | undefined)) { | ||||||||||
| return true | ||||||||||
| } | ||||||||||
| const autoInstance = AutomationFramework.getTrackedInstance() | ||||||||||
| return [AutomationFrameworkConstants.KEY_INPUT_CAPABILITIES, AutomationFrameworkConstants.KEY_CAPABILITIES] | ||||||||||
| .some(key => hasAppCap(AutomationFramework.getState(autoInstance, key) as WebdriverIO.Capabilities | undefined)) | ||||||||||
|
Comment on lines
+50
to
+52
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| async onAfterCreate(args: Record<string, unknown>) { | ||||||||||
| this.browser = args.browser as WebdriverIO.Browser | ||||||||||
|
|
||||||||||
|
|
@@ -46,7 +63,7 @@ export default class PercyModule extends BaseModule { | |||||||||
| this.logger.warn('PercyModule: Percy capture mode is not defined in the configuration, skipping Percy initialization') | ||||||||||
| return | ||||||||||
| } | ||||||||||
| this.isAppAutomate = this.isAppAutomate || 'app' in this.config | ||||||||||
| this.isAppAutomate = this.isAppAutomate || this.isAppAutomateSession() | ||||||||||
| this.percyHandler = new PercyHandler( | ||||||||||
| (this.percyConfig as Record<string, unknown>).percyCaptureMode as string, | ||||||||||
| this.browser, | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -554,6 +554,24 @@ export const isAccessibilityAutomationSession = (accessibilityFlag?: boolean | s | |||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export const APP_AUTOMATE_CAP_KEYS = ['appium:app', 'appium:bundleId', 'appium:appPackage', 'appium:appActivity'] as const | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // An App Automate session is identified by an app capability on the driver caps | ||||||||||||||||||||||||||||||
| // (appium:app / appium:bundleId / appium:appPackage / appium:appActivity / appium:options.app). | ||||||||||||||||||||||||||||||
| // Shared by config-time detection and the CLI Automate/Percy modules so App-Automate | ||||||||||||||||||||||||||||||
| // endpoint routing stays consistent across every place that resolves it from capabilities. | ||||||||||||||||||||||||||||||
| export function hasAppCap(cap?: WebdriverIO.Capabilities): boolean { | ||||||||||||||||||||||||||||||
| if (!cap || typeof cap !== 'object') { | ||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| const record = cap as Record<string, unknown> | ||||||||||||||||||||||||||||||
| if (APP_AUTOMATE_CAP_KEYS.some(key => !isUndefined(record[key]))) { | ||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| const appiumOptions = record['appium:options'] as Record<string, unknown> | undefined | ||||||||||||||||||||||||||||||
| return !!(appiumOptions && !isUndefined(appiumOptions.app)) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can export another function here:
Suggested change
|
||||||||||||||||||||||||||||||
| export const isAppAccessibilityAutomationSession = (accessibilityFlag?: boolean | string, isAppAutomate?: boolean) => { | ||||||||||||||||||||||||||||||
| const accessibilityAutomation = isAccessibilityAutomationSession(accessibilityFlag) | ||||||||||||||||||||||||||||||
| return accessibilityAutomation && isAppAutomate | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.