Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/appdistribution/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { logger } from "../logger";
import * as pathUtil from "path";
import * as utils from "../utils";
import { UploadReleaseResult, TestDevice, ReleaseTest } from "../appdistribution/types";
import { UploadReleaseResult, TestDevice, ReleaseTest, Release } from "../appdistribution/types";
import { AppDistributionClient } from "./client";
import { FirebaseError, getErrMsg, getErrStatus } from "../error";

Expand All @@ -20,7 +20,7 @@
requests: AppDistributionClient,
appName: string,
distribution: Distribution,
): Promise<string> {
): Promise<Release> {
utils.logBullet("uploading binary...");
try {
const operationName = await requests.uploadRelease(appName, distribution);
Expand Down Expand Up @@ -55,7 +55,7 @@
utils.logSuccess(
`Download the release binary (link expires in 1 hour): ${release.binaryDownloadUri}`,
);
return uploadResponse.release.name;
return uploadResponse.release;
} catch (err: unknown) {
if (getErrStatus(err) === 404) {
throw new FirebaseError(
Expand Down Expand Up @@ -150,17 +150,17 @@
continue;
case "FAILED":
throw new FirebaseError(
`Automated test failed for ${device}: ${execution.failedReason}`,

Check warning on line 153 in src/appdistribution/distribution.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "string | undefined" of template literal expression
{ exit: 1 },
);
case "INCONCLUSIVE":
throw new FirebaseError(
`Automated test inconclusive for ${device}: ${execution.inconclusiveReason}`,

Check warning on line 158 in src/appdistribution/distribution.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "string | undefined" of template literal expression
{ exit: 1 },
);
default:
throw new FirebaseError(
`Unsupported automated test state for ${device}: ${execution.state}`,

Check warning on line 163 in src/appdistribution/distribution.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "undefined" of template literal expression
{ exit: 1 },
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/commands/appdistribution-distribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
"path to file with a comma- or newline-separated list of test case IDs.",
)
.before(requireAuth)
.action(async (file: string, options: any) => {

Check warning on line 89 in src/commands/appdistribution-distribute.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const appName = getAppName(options);
const distribution = new Distribution(file);
const releaseNotes = getReleaseNotes(options.releaseNotes, options.releaseNotesFile);

Check warning on line 92 in src/commands/appdistribution-distribute.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .releaseNotesFile on an `any` value

Check warning on line 92 in src/commands/appdistribution-distribute.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`

Check warning on line 92 in src/commands/appdistribution-distribute.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .releaseNotes on an `any` value

Check warning on line 92 in src/commands/appdistribution-distribute.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
const testers = parseIntoStringArray(options.testers, options.testersFile);

Check warning on line 93 in src/commands/appdistribution-distribute.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .testers on an `any` value

Check warning on line 93 in src/commands/appdistribution-distribute.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
const groups = parseIntoStringArray(options.groups, options.groupsFile);
const testCases = parseIntoStringArray(options.testCaseIds, options.testCaseIdsFile);
const testDevices = parseTestDevices(options.testDevices, options.testDevicesFile);
Expand Down Expand Up @@ -180,7 +180,7 @@
}
}

const releaseName = await upload(requests, appName, distribution);
const release = await upload(requests, appName, distribution);

// If this is an app bundle and the certificate was originally blank fetch the updated
// certificate and print
Expand All @@ -200,8 +200,8 @@
}

// Add release notes and distribute to testers/groups
await requests.updateReleaseNotes(releaseName, releaseNotes);
await requests.distribute(releaseName, testers, groups);
await requests.updateReleaseNotes(release.name, releaseNotes);
await requests.distribute(release.name, testers, groups);

// Run automated tests
if (testDevices.length) {
Expand All @@ -210,13 +210,13 @@
if (!testCases.length) {
// fallback to basic automated test
releaseTestPromises.push(
requests.createReleaseTest(releaseName, testDevices, undefined, loginCredential),
requests.createReleaseTest(release.name, testDevices, undefined, loginCredential),
);
} else {
for (const testCaseId of testCases) {
releaseTestPromises.push(
requests.createReleaseTest(
releaseName,
release.name,
testDevices,
undefined,
loginCredential,
Expand Down
25 changes: 12 additions & 13 deletions src/commands/apptesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import { parseTestFiles } from "../apptesting/parseTestFiles";
import * as ora from "ora";
import { TestCaseInvocation } from "../apptesting/types";
import { FirebaseError, getError } from "../error";
import { marked } from "marked";
import { AppDistributionClient } from "../appdistribution/client";
import { Distribution, upload } from "../appdistribution/distribution";
import { AiInstructions, ReleaseTest, TestDevice } from "../appdistribution/types";
import { AiInstructions, ReleaseTest, TestDevice, Release } from "../appdistribution/types";
import { getAppName, parseTestDevices } from "../appdistribution/options-parser-util";

const defaultDevices = [
Expand Down Expand Up @@ -63,16 +62,16 @@ export const command = new Command("apptesting:execute <release-binary-file>")

const invokeSpinner = ora("Requesting test execution");

let testInvocations;
let releaseId;
let releaseTests: ReleaseTest[];
let release: Release;
try {
const client = new AppDistributionClient();
releaseId = await upload(client, appName, new Distribution(target));
release = await upload(client, appName, new Distribution(target));

invokeSpinner.start();
testInvocations = await invokeTests(
releaseTests = await invokeTests(
client,
releaseId,
release.name,
tests,
!testDevices.length ? defaultDevices : testDevices,
);
Expand All @@ -83,10 +82,10 @@ export const command = new Command("apptesting:execute <release-binary-file>")
throw ex;
}

logger.info(clc.bold(`\n${clc.white("===")} Running ${pluralizeTests(releaseTests.length)}`));
logger.info(
clc.bold(`\n${clc.white("===")} Running ${pluralizeTests(testInvocations.length)}`),
`View progress and results in the Firebase Console:\n${release.firebaseConsoleUri}`,
);
Comment thread
lfkellogg marked this conversation as resolved.
logger.info(await marked(`View progress and results in the Firebase Console`));
});

function pluralizeTests(numTests: number) {
Expand All @@ -98,14 +97,14 @@ async function invokeTests(
releaseName: string,
testDefs: TestCaseInvocation[],
devices: TestDevice[],
) {
): Promise<ReleaseTest[]> {
try {
const testInvocations: ReleaseTest[] = [];
const releaseTests: ReleaseTest[] = [];
for (const testDef of testDefs) {
const aiInstructions: AiInstructions = {
steps: testDef.testCase.steps,
};
testInvocations.push(
releaseTests.push(
await client.createReleaseTest(
releaseName,
devices,
Expand All @@ -116,7 +115,7 @@ async function invokeTests(
),
);
}
return testInvocations;
return releaseTests;
} catch (err: unknown) {
throw new FirebaseError("Test invocation failed", { original: getError(err) });
}
Expand Down
4 changes: 2 additions & 2 deletions src/mcp/tools/apptesting/tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("mcp/tools/apptesting/tests", () => {
displayName: "Test Run",
};

uploadStub.resolves(releaseName);
uploadStub.resolves({ name: releaseName });
clientStub.createReleaseTest.resolves(expectedResponse as any);

const result = await run_tests.fn(input, mockContext);
Expand All @@ -88,7 +88,7 @@ describe("mcp/tools/apptesting/tests", () => {
testCase: { steps: [{ goal: "test goal" }] },
};

uploadStub.resolves("release-name");
uploadStub.resolves({ name: "release-name" });
clientStub.createReleaseTest.resolves({} as any);

await run_tests.fn(input as any, mockContext);
Expand Down
4 changes: 2 additions & 2 deletions src/mcp/tools/apptesting/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const run_tests = tool(
// For some reason, testDevices can still be
const devices = testDevices || defaultDevices;
const client = new AppDistributionClient();
const releaseName = await upload(client, toAppName(appId), new Distribution(releaseBinaryFile));
return toContent(await client.createReleaseTest(releaseName, devices, testCase));
const release = await upload(client, toAppName(appId), new Distribution(releaseBinaryFile));
Comment thread
lfkellogg marked this conversation as resolved.
Comment thread
lfkellogg marked this conversation as resolved.
return toContent(await client.createReleaseTest(release.name, devices, testCase));
},
);

Expand Down
Loading