Skip to content

Commit dfbb0a9

Browse files
Added : app_url and test suits url support
1 parent bbd9da5 commit dfbb0a9

File tree

1 file changed

+60
-12
lines changed

1 file changed

+60
-12
lines changed

src/tools/appautomate.ts

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,52 @@ async function takeAppScreenshot(args: {
175175
//Runs AppAutomate tests on BrowserStack by uploading app and test suite, then triggering a test run.
176176
async function runAppTestsOnBrowserStack(
177177
args: {
178-
appPath: string;
179-
testSuitePath: string;
178+
appPath?: string;
179+
testSuitePath?: string;
180+
browserstack_app_url?: string;
181+
browserstack_test_suite_url?: string;
180182
devices: string[];
181183
project: string;
182184
detectedAutomationFramework: string;
183185
},
184186
config: BrowserStackConfig,
185187
): Promise<CallToolResult> {
188+
// Validate that either paths or URLs are provided for both app and test suite
189+
if (!args.browserstack_app_url && !args.appPath) {
190+
throw new Error(
191+
"appPath is required when browserstack_app_url is not provided",
192+
);
193+
}
194+
if (!args.browserstack_test_suite_url && !args.testSuitePath) {
195+
throw new Error(
196+
"testSuitePath is required when browserstack_test_suite_url is not provided",
197+
);
198+
}
199+
186200
switch (args.detectedAutomationFramework) {
187201
case AppTestPlatform.ESPRESSO: {
188202
try {
189-
const app_url = await uploadEspressoApp(args.appPath, config);
190-
const test_suite_url = await uploadEspressoTestSuite(
191-
args.testSuitePath,
192-
config,
193-
);
203+
let app_url: string;
204+
if (args.browserstack_app_url) {
205+
app_url = args.browserstack_app_url;
206+
logger.info(`Using provided BrowserStack app URL: ${app_url}`);
207+
} else {
208+
app_url = await uploadEspressoApp(args.appPath!, config);
209+
logger.info(`App uploaded. URL: ${app_url}`);
210+
}
211+
212+
let test_suite_url: string;
213+
if (args.browserstack_test_suite_url) {
214+
test_suite_url = args.browserstack_test_suite_url;
215+
logger.info(`Using provided BrowserStack test suite URL: ${test_suite_url}`);
216+
} else {
217+
test_suite_url = await uploadEspressoTestSuite(
218+
args.testSuitePath!,
219+
config,
220+
);
221+
logger.info(`Test suite uploaded. URL: ${test_suite_url}`);
222+
}
223+
194224
const build_id = await triggerEspressoBuild(
195225
app_url,
196226
test_suite_url,
@@ -213,11 +243,27 @@ async function runAppTestsOnBrowserStack(
213243
}
214244
case AppTestPlatform.XCUITEST: {
215245
try {
216-
const app_url = await uploadXcuiApp(args.appPath, config);
217-
const test_suite_url = await uploadXcuiTestSuite(
218-
args.testSuitePath,
219-
config,
220-
);
246+
let app_url: string;
247+
if (args.browserstack_app_url) {
248+
app_url = args.browserstack_app_url;
249+
logger.info(`Using provided BrowserStack app URL: ${app_url}`);
250+
} else {
251+
app_url = await uploadXcuiApp(args.appPath!, config);
252+
logger.info(`App uploaded. URL: ${app_url}`);
253+
}
254+
255+
let test_suite_url: string;
256+
if (args.browserstack_test_suite_url) {
257+
test_suite_url = args.browserstack_test_suite_url;
258+
logger.info(`Using provided BrowserStack test suite URL: ${test_suite_url}`);
259+
} else {
260+
test_suite_url = await uploadXcuiTestSuite(
261+
args.testSuitePath!,
262+
config,
263+
);
264+
logger.info(`Test suite uploaded. URL: ${test_suite_url}`);
265+
}
266+
221267
const build_id = await triggerXcuiBuild(
222268
app_url,
223269
test_suite_url,
@@ -310,6 +356,7 @@ export default function addAppAutomationTools(
310356
{
311357
appPath: z
312358
.string()
359+
.optional()
313360
.describe(
314361
"Path to your application file:\n" +
315362
"If in development IDE directory:\n" +
@@ -322,6 +369,7 @@ export default function addAppAutomationTools(
322369
),
323370
testSuitePath: z
324371
.string()
372+
.optional()
325373
.describe(
326374
"Path to your test suite file:\n" +
327375
"If in development IDE directory:\n" +

0 commit comments

Comments
 (0)