Skip to content

fix(automate): detect App Automate from appium:app capability for session name/status (SDK-7093) - #100

Open
pri-gadhiya wants to merge 6 commits into
mainfrom
fix/sdk-7093-appautomate-session-name
Open

fix(automate): detect App Automate from appium:app capability for session name/status (SDK-7093)#100
pri-gadhiya wants to merge 6 commits into
mainfrom
fix/sdk-7093-appautomate-session-name

Conversation

@pri-gadhiya

@pri-gadhiya pri-gadhiya commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

What is this about?

Fixes App Automate session names showing the static sessionName capability instead of the per-test title.

automateModule's markSessionName / markSessionStatus derived App-Automate-ness from this.config.app (the top-level browserstack service app option) alone. When the app is supplied only via the appium:app capability, this.config.app is undefined, so isAppAutomate resolved false and the session name/status PUT was routed to the web Automate endpoint (automate/sessions/{id}.json) for an App-Automate session — returning a 404 that is silently swallowed, leaving the static capability name on the dashboard.

Both call sites now go through a new isAppAutomate() helper that also inspects the input + resolved capabilities for appium:app / appium:options.app (checks both KEY_INPUT_CAPABILITIES and KEY_CAPABILITIES, since the resolved caps BrowserStack echoes back drop appium:app), mirroring accessibilityModule.isAppAutomateSession. Strictly additive — the existing top-level app / skipAppOverride path is unchanged.

Verified on App-Automate iOS (own account): broken build kept the static name + logged the 404; after the fix, sessions get their per-test titles and the PUT hits the App-Automate endpoint with a 200.

Related Jira task/s

https://browserstack.atlassian.net/browse/SDK-7093

Release (mandatory for every PR — required for the ready-for-review label)

Version bump: (required — tick exactly one)

  • minor (backwards-compatible feature)
  • patch (bug fix or other small change)

Release notes type: (optional)

  • New Feature
  • Bug Fix
  • Other Improvement

Release notes (customer-facing): (optional but encouraged)

  • Fixed App Automate session names not updating to the test title when the app is provided via the appium:app capability.

Release notes (internal): (required — engineer-facing; what actually changed / why)

  • automateModule.isAppAutomate() now detects App Automate from the appium:app / appium:options.app capability (input + resolved) in addition to the top-level service app / skipAppOverride, so session name/status PUTs are routed to the App-Automate endpoint instead of silently 404-ing against the web Automate endpoint.

Checklist

  • Ready to review
  • Has it been tested locally?

PR Validations

Run Tests: Comment RUN_TESTS to trigger sanity tests.

pri-gadhiya and others added 2 commits July 27, 2026 16:00
…sion name/status (SDK-7093)

When the app is supplied only via the appium:app capability (not the
top-level browserstack service `app` option), this.config.app is undefined,
so isAppAutomate resolved false and the session name/status PUT was routed to
the web Automate endpoint for an App Automate session — returning a swallowed
404, leaving the static sessionName capability on the dashboard.

Route both markSessionName and markSessionStatus through a new isAppAutomate()
helper that also inspects the input + resolved capabilities for
appium:app / appium:options.app, mirroring accessibilityModule.isAppAutomateSession.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pri-gadhiya
pri-gadhiya marked this pull request as ready for review July 27, 2026 10:34
@pri-gadhiya
pri-gadhiya requested a review from a team as a code owner July 27, 2026 10:34
@github-actions

Copy link
Copy Markdown
Contributor

🔴 SDK PR Review gate is red. Pending:

  • The SDK PR Review Agent has not reviewed the current head commit yet — run the SDK PR Review Agent.

It turns green once the latest SDK PR Review Agent run reports GTG on the current head commit. A native reviewer approval is separately required by branch protection before merge.

@pri-gadhiya

Copy link
Copy Markdown
Collaborator Author

🔴 Blocking findings — fix required

See the SDK PR Review Agent's report from your local run.

↻ This verdict comment is the review anchor — it's updated in place on each run (the gate posts its status separately).

— SDK PR Review Agent

@github-actions

Copy link
Copy Markdown
Contributor

🔴 SDK PR Review gate is red. Pending:

  • The SDK PR Review Agent reported blocking findings (🔴) on the current head commit — fix them and re-run the agent.

It turns green once the latest SDK PR Review Agent run reports GTG on the current head commit. A native reviewer approval is separately required by branch protection before merge.

pri-gadhiya and others added 2 commits July 27, 2026 17:45
…K-7093)

Address SDK PR review findings on #100:
- Promote hasAppCap + APP_AUTOMATE_CAP_KEYS from config.ts (file-local) to
  util.ts as a shared export; config.ts reuses it (no behavior change).
- automateModule.isAppAutomate() reuses hasAppCap — now covers all app-cap
  keys (appium:app / appium:bundleId / appium:appPackage / appium:appActivity /
  appium:options.app) instead of only appium:app.
- percyModule: fix the same service-config-only detection (`'app' in this.config`)
  that misrouted Percy screenshots to the web Automate path for appium:app
  sessions — now resolves App Automate via hasAppCap over browser + input caps.
- changeset: note now covers session name, status, and Percy routing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🔴 SDK PR Review gate is red. Pending:

  • The SDK PR Review Agent has not reviewed the current head commit yet — run the SDK PR Review Agent.

It turns green once the latest SDK PR Review Agent run reports GTG on the current head commit. A native reviewer approval is separately required by branch protection before merge.

@github-actions

Copy link
Copy Markdown
Contributor

🔴 SDK PR Review gate is red. Pending:

  • The SDK PR Review Agent has not reviewed the current head commit yet — run the SDK PR Review Agent.

It turns green once the latest SDK PR Review Agent run reports GTG on the current head commit. A native reviewer approval is separately required by branch protection before merge.

…sors (SDK-7093)

The reuse refactor made automateModule + percyModule depend on the shared
util.hasAppCap and (for the capability fallback) AutomationFramework
getTrackedInstance/getState. Update the unit-test mocks accordingly:
- automateModule.test: add hasAppCap to the wholesale util.js mock (was
  undefined → threw → swallowed → fetch never called).
- percyModules.test: add getTrackedInstance/getState to the AutomationFramework
  mock so onAfterCreate's isAppAutomateSession() no longer throws.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🔴 SDK PR Review gate is red. Pending:

  • The SDK PR Review Agent has not reviewed the current head commit yet — run the SDK PR Review Agent.

It turns green once the latest SDK PR Review Agent run reports GTG on the current head commit. A native reviewer approval is separately required by branch protection before merge.

Comment on lines +207 to +209
const autoInstance = AutomationFramework.getTrackedInstance()
return [AutomationFrameworkConstants.KEY_INPUT_CAPABILITIES, AutomationFrameworkConstants.KEY_CAPABILITIES]
.some(key => hasAppCap(AutomationFramework.getState(autoInstance, key) as WebdriverIO.Capabilities | undefined))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const autoInstance = AutomationFramework.getTrackedInstance()
return [AutomationFrameworkConstants.KEY_INPUT_CAPABILITIES, AutomationFrameworkConstants.KEY_CAPABILITIES]
.some(key => hasAppCap(AutomationFramework.getState(autoInstance, key) as WebdriverIO.Capabilities | undefined))
return hasAppCapInFrameworkState()

const appiumOptions = record['appium:options'] as Record<string, unknown> | undefined
return !!(appiumOptions && !isUndefined(appiumOptions.app))
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can export another function here:

Suggested change
import AutomationFramework from './cli/frameworks/automationFramework.js'
import { AutomationFrameworkConstants } from './cli/frameworks/constants/automationFrameworkConstants.js'
export function hasAppCapInFrameworkState(): boolean {
const autoInstance = AutomationFramework.getTrackedInstance()
const keys = [
AutomationFrameworkConstants.KEY_INPUT_CAPABILITIES,
AutomationFrameworkConstants.KEY_CAPABILITIES
]
return keys.some(key =>
hasAppCap(AutomationFramework.getState(autoInstance, key) as WebdriverIO.Capabilities | undefined)
)
}

Comment on lines +50 to +52
const autoInstance = AutomationFramework.getTrackedInstance()
return [AutomationFrameworkConstants.KEY_INPUT_CAPABILITIES, AutomationFrameworkConstants.KEY_CAPABILITIES]
.some(key => hasAppCap(AutomationFramework.getState(autoInstance, key) as WebdriverIO.Capabilities | undefined))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const autoInstance = AutomationFramework.getTrackedInstance()
return [AutomationFrameworkConstants.KEY_INPUT_CAPABILITIES, AutomationFrameworkConstants.KEY_CAPABILITIES]
.some(key => hasAppCap(AutomationFramework.getState(autoInstance, key) as WebdriverIO.Capabilities | undefined))
return hasAppCapInFrameworkState()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants