Skip to content

Commit df382b6

Browse files
author
Jamie Rothfeder
committed
Add support to specify devices.
1 parent d36742e commit df382b6

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/commands/apptesting-mobile-execute.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { FirebaseError, getError } from "../error";
99
import { marked } from "marked";
1010
import { AppDistributionClient } from "../appdistribution/client";
1111
import { Distribution, upload } from "../appdistribution/distribution";
12-
import { AIInstruction, ReleaseTest } from "../appdistribution/types";
13-
import { getAppName } from "../appdistribution/options-parser-util";
12+
import { AIInstruction, ReleaseTest, TestDevice } from "../appdistribution/types";
13+
import { getAppName, parseTestDevices } from "../appdistribution/options-parser-util";
1414

1515
// TODO rothbutter add ability to specify devices
1616
const defaultDevices = [
@@ -37,6 +37,14 @@ export const command = new Command("apptesting:mobile-execute <target>")
3737
"Test name pattern. Only tests with names that match this pattern will be executed.",
3838
)
3939
.option("--test-dir <test_dir>", "Directory where tests can be found.")
40+
.option(
41+
"--test-devices <string>",
42+
"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. Note: This feature is in beta.",
43+
)
44+
.option(
45+
"--test-devices-file <string>",
46+
"path to file containing a list of semicolon- or newline-separated 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. Note: This feature is in beta.",
47+
)
4048
.before(requireAuth)
4149
.action(async (target: string, options: any) => {
4250
const appName = getAppName(options);
@@ -48,6 +56,7 @@ export const command = new Command("apptesting:mobile-execute <target>")
4856
options.testFilePattern,
4957
options.testNamePattern,
5058
);
59+
const testDevices = parseTestDevices(options.testDevices, options.testDevicesFile);
5160

5261
if (!tests.length) {
5362
throw new FirebaseError("No tests found");
@@ -62,7 +71,12 @@ export const command = new Command("apptesting:mobile-execute <target>")
6271
releaseId = await upload(client, appName, new Distribution(target));
6372

6473
invokeSpinner.start();
65-
testInvocations = await invokeMataTests(client, releaseId, tests);
74+
testInvocations = await invokeMataTests(
75+
client,
76+
releaseId,
77+
tests,
78+
!testDevices.length ? defaultDevices : testDevices,
79+
);
6680
invokeSpinner.text = "Test execution requested";
6781
invokeSpinner.succeed();
6882
} catch (ex) {
@@ -84,16 +98,15 @@ async function invokeMataTests(
8498
client: AppDistributionClient,
8599
releaseName: string,
86100
testDefs: TestCaseInvocation[],
101+
devices: TestDevice[],
87102
) {
88103
try {
89104
const testInvocations: ReleaseTest[] = [];
90105
for (const testDef of testDefs) {
91106
const aiInstruction: AIInstruction = {
92107
steps: testDef.testCase.instructions.steps,
93108
};
94-
testInvocations.push(
95-
await client.createReleaseTest(releaseName, defaultDevices, aiInstruction),
96-
);
109+
testInvocations.push(await client.createReleaseTest(releaseName, devices, aiInstruction));
97110
}
98111
return testInvocations;
99112
} catch (err: unknown) {

0 commit comments

Comments
 (0)