Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 37 additions & 23 deletions src/mcp/tools/apptesting/tests.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,54 @@
import { z } from "zod";
import { ApplicationIdSchema } from "../../../crashlytics/filters";
import { distribute, Distribution } from "../../../appdistribution/distribution";

import { tool } from "../../tool";
import { mcpError, toContent } from "../../util";
import {
parseIntoStringArray,
parseTestDevices,
toAppName,
} from "../../../appdistribution/options-parser-util";
import { toContent } from "../../util";
import { parseIntoStringArray, toAppName } from "../../../appdistribution/options-parser-util";

const TestDeviceSchema = z
.object({
model: z.string(),
version: z.string(),
locale: z.string(),
orientation: z.enum(["portrait", "landscape"]),
Comment on lines +11 to +14
Copy link
Contributor

Choose a reason for hiding this comment

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

Are any of these fields optional because there are default values? If so you may want to use .optional() and/or .default() methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, these fields aren't optional.

})
.describe(
`Device to run automated test on. Can run 'gcloud firebase test android|ios models list' to see available devices.`,
);

export const run_tests = tool(
{
name: "run_test",
description: `Upload an APK and run an existing test against it.`,
description: "Upload a binary and run automated tests.",
inputSchema: z.object({
appId: ApplicationIdSchema,
releaseBinaryFile: z.string().describe("Path to the binary release (APK)."),
testDevices: z.string().describe(
`Semicolon-separated list of devices to run automated tests on, in the format
'model=<model-id>,version=<os-version-id>,locale=<locale>,orientation=<orientation>'. Run 'gcloud firebase test android|ios models list' to see
available devices.`,
),
testDevices: z.array(TestDeviceSchema).default([
{
model: "tokay",
version: "36",
locale: "en",
orientation: "portrait",
},
{
model: "e1q",
version: "34",
locale: "en",
orientation: "portrait",
},
]),
testCaseIds: z.string().describe(`A comma-separated list of test case IDs.`),
}),
},
async ({ appId, releaseBinaryFile, testDevices, testCaseIds }) => {
if (!appId) return mcpError(`Must specify 'appId' parameter.`);
if (!releaseBinaryFile) return mcpError(`Must specify 'releaseBinaryFile' parameter.`);
if (!testDevices) return mcpError(`Must specify 'testDevices' parameter.`);
if (!testCaseIds) return mcpError(`Must specify 'testCaseIds' parmeter.`);
Comment on lines -28 to -31
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove these errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Github's AI reviewer said they could be removed because the schema's default is "required".


const appName = toAppName(appId);
const distribution = new Distribution(releaseBinaryFile);
const testCases = parseIntoStringArray(testCaseIds);
const devices = parseTestDevices(testDevices);

return toContent(await distribute(appName, distribution, testCases, devices));
return toContent(
await distribute(
toAppName(appId),
new Distribution(releaseBinaryFile),
parseIntoStringArray(testCaseIds),
testDevices,

Check failure on line 50 in src/mcp/tools/apptesting/tests.ts

View workflow job for this annotation

GitHub Actions / unit (20)

Argument of type '{ version?: string; locale?: string; model?: string; orientation?: "portrait" | "landscape"; }[]' is not assignable to parameter of type 'TestDevice[]'.

Check failure on line 50 in src/mcp/tools/apptesting/tests.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Argument of type '{ version?: string; locale?: string; model?: string; orientation?: "portrait" | "landscape"; }[]' is not assignable to parameter of type 'TestDevice[]'.

Check failure on line 50 in src/mcp/tools/apptesting/tests.ts

View workflow job for this annotation

GitHub Actions / unit (20)

Argument of type '{ version?: string; locale?: string; model?: string; orientation?: "portrait" | "landscape"; }[]' is not assignable to parameter of type 'TestDevice[]'.
),
);
},
);
Loading