Skip to content

Commit da2cb9f

Browse files
committed
refactor: introduce DEFAULT_MOBILE_DEVICE for improved device handling in App Automate tools
1 parent ff9a638 commit da2cb9f

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/tools/appautomate-utils/appium-sdk/handler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getBrowserStackAuth } from "../../../lib/get-auth.js";
55
import {
66
validateAppAutomateDevices,
77
convertMobileDevicesToTuples,
8+
DEFAULT_MOBILE_DEVICE,
89
} from "../../sdk-utils/common/device-validator.js";
910

1011
import {
@@ -48,11 +49,10 @@ export async function setupAppAutomateHandler(
4849
validateSupportforAppAutomate(framework, language, testingFramework);
4950

5051
// Convert device objects to tuples for validator
51-
const inputDevices = input.devices || [];
5252
const devices: Array<Array<string>> =
53-
inputDevices.length === 0
54-
? [["android", "Samsung Galaxy S24", "latest"]]
55-
: convertMobileDevicesToTuples(inputDevices);
53+
input.devices.length === 0
54+
? DEFAULT_MOBILE_DEVICE
55+
: convertMobileDevicesToTuples(input.devices);
5656

5757
// Validate devices against real BrowserStack device data
5858
const validatedEnvironments = await validateAppAutomateDevices(devices);

src/tools/appautomate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { setupAppAutomateHandler } from "./appautomate-utils/appium-sdk/handler.
1212
import {
1313
validateAppAutomateDevices,
1414
convertMobileDevicesToTuples,
15+
DEFAULT_MOBILE_DEVICE,
1516
} from "./sdk-utils/common/device-validator.js";
1617

1718
import {
@@ -383,9 +384,9 @@ export default function addAppAutomationTools(
383384
);
384385
// Convert device objects to tuples for the handler
385386
const devices: Array<Array<string>> =
386-
(args.devices || []).length === 0
387-
? [["android", "Samsung Galaxy S24", "latest"]]
388-
: convertMobileDevicesToTuples(args.devices || []);
387+
args.devices.length === 0
388+
? DEFAULT_MOBILE_DEVICE
389+
: convertMobileDevicesToTuples(args.devices);
389390
return await runAppTestsOnBrowserStack(
390391
{ ...args, devices },
391392
config,

src/tools/sdk-utils/common/device-validator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ const DEFAULTS = {
7272
ios: { device: "iPhone 15", browser: "safari" },
7373
} as const;
7474

75+
// Default mobile device tuple for App Automate when no devices are provided
76+
export const DEFAULT_MOBILE_DEVICE: Array<Array<string>> = [
77+
["android", "Samsung Galaxy S24", "latest"],
78+
];
79+
7580
// Performance optimization: Indexed maps for faster lookups
7681
interface DesktopIndex {
7782
byOS: Map<string, DesktopBrowserEntry[]>;

0 commit comments

Comments
 (0)