Skip to content

Commit 3a61131

Browse files
committed
Initial device validations
1 parent 3aebfeb commit 3a61131

File tree

8 files changed

+572
-20
lines changed

8 files changed

+572
-20
lines changed

src/lib/device-cache.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export enum BrowserStackProducts {
1313
LIVE = "live",
1414
APP_LIVE = "app_live",
1515
APP_AUTOMATE = "app_automate",
16+
SELENIUM_APP_AUTOMATE = "selenium_app_automate",
17+
PLAYWRIGHT_APP_AUTOMATE = "playwright_app_automate",
1618
}
1719

1820
const URLS: Record<BrowserStackProducts, string> = {
@@ -22,6 +24,10 @@ const URLS: Record<BrowserStackProducts, string> = {
2224
"https://www.browserstack.com/list-of-browsers-and-platforms/app_live.json",
2325
[BrowserStackProducts.APP_AUTOMATE]:
2426
"https://www.browserstack.com/list-of-browsers-and-platforms/app_automate.json",
27+
[BrowserStackProducts.SELENIUM_APP_AUTOMATE]:
28+
"https://www.browserstack.com/list-of-browsers-and-platforms/selenium_app_automate.json",
29+
[BrowserStackProducts.PLAYWRIGHT_APP_AUTOMATE]:
30+
"https://www.browserstack.com/list-of-browsers-and-platforms/playwright.json",
2531
};
2632

2733
/**

src/tools/appautomate.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
BrowserStackProducts,
2626
} from "../lib/device-cache.js";
2727

28+
import { validateAppAutomateDevices } from "./sdk-utils/common/device-validator.js";
29+
2830
import {
2931
findMatchingDevice,
3032
getDeviceVersions,
@@ -193,6 +195,9 @@ async function runAppTestsOnBrowserStack(
193195
);
194196
}
195197

198+
// Validate devices against real BrowserStack device data
199+
await validateAppAutomateDevices(args.devices);
200+
196201
switch (args.detectedAutomationFramework) {
197202
case AppTestPlatform.ESPRESSO: {
198203
try {

src/tools/sdk-utils/bstack/sdkHandler.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,32 @@ import { getSDKPrefixCommand } from "./commands.js";
66
import { generateBrowserStackYMLInstructions } from "./configUtils.js";
77
import { getInstructionsForProjectConfiguration } from "../common/instructionUtils.js";
88
import { BrowserStackConfig } from "../../../lib/types.js";
9+
import { validateDevices } from "../common/device-validator.js";
910
import {
1011
SDKSupportedBrowserAutomationFramework,
1112
SDKSupportedTestingFramework,
1213
SDKSupportedLanguage,
1314
} from "../common/types.js";
1415

15-
export function runBstackSDKOnly(
16+
export async function runBstackSDKOnly(
1617
input: RunTestsOnBrowserStackInput,
1718
config: BrowserStackConfig,
1819
isPercyAutomate = false,
19-
): RunTestsInstructionResult {
20+
): Promise<RunTestsInstructionResult> {
2021
const steps: RunTestsStep[] = [];
2122
const authString = getBrowserStackAuth(config);
2223
const [username, accessKey] = authString.split(":");
2324

25+
// Validate devices against real BrowserStack device data
26+
const tupleTargets = (input as any).devices as
27+
| Array<Array<string>>
28+
| undefined;
29+
30+
await validateDevices(
31+
tupleTargets || [],
32+
input.detectedBrowserAutomationFramework,
33+
);
34+
2435
// Handle frameworks with unique setup instructions that don't use browserstack.yml
2536
if (
2637
input.detectedBrowserAutomationFramework === "cypress" ||
@@ -76,7 +87,7 @@ export function runBstackSDKOnly(
7687
}
7788

7889
const ymlInstructions = generateBrowserStackYMLInstructions(
79-
input.desiredPlatforms as string[],
90+
(tupleTargets || []).map((tuple) => tuple.join(" ")),
8091
false,
8192
input.projectName,
8293
);

0 commit comments

Comments
 (0)