-
Couldn't load subscription status.
- Fork 1.1k
Use a datastructure to represent test devices rather than a string. #9280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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"]), | ||
| }) | ||
| .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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove these errors? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
| ), | ||
| ); | ||
| }, | ||
| ); | ||
There was a problem hiding this comment.
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()methodsThere was a problem hiding this comment.
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.