Skip to content

Commit 8da4c98

Browse files
committed
Advancements ++
1 parent 50f5273 commit 8da4c98

File tree

4 files changed

+33
-55
lines changed

4 files changed

+33
-55
lines changed

src/lib/version-resolver.ts

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,7 @@
33
* Else if exact match, returns that
44
* Else picks the numerically closest (or first)
55
*/
6-
export function resolveVersion(requested: string, available: string[]): string {
7-
// strip duplicates & sort
8-
const uniq = Array.from(new Set(available));
9-
// pick min/max
10-
if (requested === "latest" || requested === "oldest") {
11-
// try numeric
12-
const nums = uniq
13-
.map((v) => ({ v, n: parseFloat(v) }))
14-
.filter((x) => !isNaN(x.n))
15-
.sort((a, b) => a.n - b.n);
16-
if (nums.length) {
17-
return requested === "latest" ? nums[nums.length - 1].v : nums[0].v;
18-
}
19-
// fallback lex
20-
const lex = uniq.slice().sort();
21-
return requested === "latest" ? lex[lex.length - 1] : lex[0];
22-
}
23-
24-
// exact?
25-
if (uniq.includes(requested)) {
26-
return requested;
27-
}
28-
29-
// try closest numeric
30-
const reqNum = parseFloat(requested);
31-
const nums = uniq
32-
.map((v) => ({ v, n: parseFloat(v) }))
33-
.filter((x) => !isNaN(x.n));
34-
if (!isNaN(reqNum) && nums.length) {
35-
let best = nums[0],
36-
bestDiff = Math.abs(nums[0].n - reqNum);
37-
for (const x of nums) {
38-
const d = Math.abs(x.n - reqNum);
39-
if (d < bestDiff) {
40-
best = x;
41-
bestDiff = d;
42-
}
43-
}
44-
return best.v;
45-
}
46-
47-
// final fallback
48-
return uniq[0];
49-
}
50-
51-
export function resolveVersionWithFuzzy(
6+
export function resolveVersion(
527
requested: string,
538
available: string[],
549
): string {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ export const SETUP_APP_AUTOMATE_SCHEMA = {
7575
]),
7676
)
7777
.max(3)
78-
.default([
79-
[AppSDKSupportedPlatformEnum.android, "Samsung Galaxy S24", "latest"],
80-
])
78+
.default([])
8179
.describe(
82-
"Preferred input: 1-3 tuples describing target mobile devices. Example: [['android', 'Samsung Galaxy S24', '14'], ['ios', 'iPhone 15', '17']]",
80+
"Tuples describing target mobile devices. Add device only when user asks explicitly for it. Defaults to [] . Example: [['android', 'Samsung Galaxy S24', '14'], ['ios', 'iPhone 15', '17']]",
8381
),
8482

8583
appPath: z

src/tools/appautomate-utils/native-execution/constants.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from "zod";
22
import { AppTestPlatform } from "./types.js";
3+
import { AppSDKSupportedPlatformEnum } from "../appium-sdk/types.js";
34

45
export const RUN_APP_AUTOMATE_DESCRIPTION = `Execute pre-built native mobile test suites (Espresso for Android, XCUITest for iOS) by direct upload to BrowserStack. ONLY for compiled .apk/.ipa test files. This is NOT for SDK integration or Appium tests. For Appium-based testing with SDK setup, use 'setupBrowserStackAppAutomateTests' instead.`;
56

@@ -28,10 +29,35 @@ export const RUN_APP_AUTOMATE_SCHEMA = {
2829
" zip -r Tests.zip *.xctestrun *-Runner.app\n\n" +
2930
"If in other directory, provide existing test file path",
3031
),
31-
devices: z
32-
.array(z.array(z.string()))
32+
devices: z
33+
.array(
34+
z.union([
35+
// Android: [android, deviceName, osVersion]
36+
z.tuple([
37+
z
38+
.literal(AppSDKSupportedPlatformEnum.android)
39+
.describe("Platform identifier: 'android'"),
40+
z
41+
.string()
42+
.describe(
43+
"Device name, e.g. 'Samsung Galaxy S24', 'Google Pixel 8'",
44+
),
45+
z.string().describe("Android version, e.g. '14', '16', 'latest'"),
46+
]),
47+
// iOS: [ios, deviceName, osVersion]
48+
z.tuple([
49+
z
50+
.literal(AppSDKSupportedPlatformEnum.ios)
51+
.describe("Platform identifier: 'ios'"),
52+
z.string().describe("Device name, e.g. 'iPhone 15', 'iPhone 14 Pro'"),
53+
z.string().describe("iOS version, e.g. '17', '16', 'latest'"),
54+
]),
55+
]),
56+
)
57+
.max(3)
58+
.default([])
3359
.describe(
34-
"List of devices to run the test on, e.g., [['android', 'Samsung Galaxy S20', '10.0'], ['ios', 'iPhone 12 Pro', '16.0']].",
60+
"Tuples describing target mobile devices. Add device only when user asks explicitly for it. Defaults to [] . Example: [['android', 'Samsung Galaxy S24', '14'], ['ios', 'iPhone 15', '17']]",
3561
),
3662
project: z
3763
.string()

src/tools/sdk-utils/common/schema.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const WindowsPlatformEnum = {
1919
} as const;
2020

2121
export const MacOSPlatformEnum = {
22-
MAC: "mac",
2322
MACOS: "macos",
2423
} as const;
2524

@@ -99,7 +98,7 @@ export const RunTestsOnBrowserStackParamsShape = {
9998
.max(3)
10099
.default([])
101100
.describe(
102-
"Preferred input: 1-3 tuples describing target devices.Example: [['windows', '11', 'chrome', 'latest'], ['android', 'Samsung Galaxy S24', '14', 'chrome'], ['ios', 'iPhone 15', '17', 'safari']]",
101+
"Preferred tuples of target devices.Add device only when user asks explicitly for it. Defaults to [] . Example: [['windows', '11', 'chrome', 'latest']]",
103102
),
104103
};
105104

0 commit comments

Comments
 (0)