Skip to content

Commit 046f691

Browse files
joehanjakeouellettegemini-code-assist[bot]google-oss-botfredzqm
authored
Jules apps tests fix (#8942)
* Fix apptesting enablement (#8905) * Fix an issue with apptesting enablement Co-authored-by: Joe Hanley <[email protected]> * Fix issue where login didnt work as expected on studio (#8914) * Fix issue where login didnt work as expected on studio * Update src/commands/login.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * 14.11.2 * [firebase-release] Removed change log and reset repo after 14.11.2 release * Enable FDC API in `firebase init dataconnect` for Spark projects (#8927) * feat: address pr comments on app-* commands * Fetch active Firebase Project from Studio Workspace when running in Studio (#8904) * Disable broken VSCode integration tests (#8934) * Add userinfo.email scope when in studio (#8935) * Add userinfo.email scope when in studio * Update src/requireAuth.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update src/requireAuth.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * feat: Display Firestore database edition (#8926) * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. Also refactors the tests for `prettyPrintDatabase` to improve readability and maintainability. * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. Also refactors the tests for `prettyPrintDatabase` to improve readability and maintainability and adds a test case for the `STANDARD` edition. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> * Formatted --------- Co-authored-by: Jake Ouellette <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Google Open Source Bot <[email protected]> Co-authored-by: Fred Zhang <[email protected]> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Sam Edson <[email protected]> Co-authored-by: Ehsan <[email protected]>
1 parent c15e1b9 commit 046f691

22 files changed

+635
-106
lines changed

.github/workflows/node-test.yml

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -67,63 +67,63 @@ jobs:
6767
- uses: codecov/codecov-action@v3
6868
if: matrix.node-version == '20'
6969

70-
vscode_integration:
71-
runs-on: macos-latest
72-
strategy:
73-
matrix:
74-
node-version:
75-
- "20"
76-
77-
env:
78-
FIREBASE_EMULATORS_PATH: ${{ github.workspace }}/emulator-cache
79-
# This overrides the binary which runs firebase commands in the extension tasks such as emulator start.
80-
# Currently, CI fails to start with npx so we change it to the global firebase binary.
81-
FIREBASE_BINARY: firebase
82-
83-
steps:
84-
- name: Setup Java JDK
85-
uses: actions/[email protected]
86-
with:
87-
java-version: 17
88-
distribution: temurin
89-
90-
- uses: actions/checkout@v4
91-
- name: Setup Chrome
92-
uses: browser-actions/[email protected]
93-
with:
94-
install-dependencies: true
95-
install-chromedriver: true
96-
- uses: actions/setup-node@v3
97-
with:
98-
node-version: ${{ matrix.node-version }}
99-
cache: npm
100-
cache-dependency-path: firebase-vscode/package-lock.json
101-
102-
# TODO temporary workaround for GitHub Actions CI issue:
103-
# npm ERR! Your cache folder contains root-owned files, due to a bug in
104-
# npm ERR! previous versions of npm which has since been addressed.
105-
- run: sudo chown -R 501:20 "/Users/runner/.npm" || exit 1
106-
- run: npm ci
107-
- run: npm install
108-
working-directory: firebase-vscode
109-
- run: npm run build
110-
working-directory: firebase-vscode
111-
112-
- run: npm i -g firebase-tools@latest
113-
114-
- uses: GabrielBB/xvfb-action@v1
115-
with:
116-
run: npm run test:e2e
117-
working-directory: firebase-vscode
118-
119-
- uses: actions/upload-artifact@v4
120-
if: failure()
121-
with:
122-
name: screenshots
123-
path: firebase-vscode/src/test/screenshots
124-
125-
- uses: codecov/codecov-action@v3
126-
if: matrix.node-version == '20'
70+
# vscode_integration:
71+
# runs-on: macos-latest
72+
# strategy:
73+
# matrix:
74+
# node-version:
75+
# - "20"
76+
77+
# env:
78+
# FIREBASE_EMULATORS_PATH: ${{ github.workspace }}/emulator-cache
79+
# # This overrides the binary which runs firebase commands in the extension tasks such as emulator start.
80+
# # Currently, CI fails to start with npx so we change it to the global firebase binary.
81+
# FIREBASE_BINARY: firebase
82+
83+
# steps:
84+
# - name: Setup Java JDK
85+
# uses: actions/[email protected]
86+
# with:
87+
# java-version: 17
88+
# distribution: temurin
89+
90+
# - uses: actions/checkout@v4
91+
# - name: Setup Chrome
92+
# uses: browser-actions/[email protected]
93+
# with:
94+
# install-dependencies: true
95+
# install-chromedriver: true
96+
# - uses: actions/setup-node@v3
97+
# with:
98+
# node-version: ${{ matrix.node-version }}
99+
# cache: npm
100+
# cache-dependency-path: firebase-vscode/package-lock.json
101+
102+
# # TODO temporary workaround for GitHub Actions CI issue:
103+
# # npm ERR! Your cache folder contains root-owned files, due to a bug in
104+
# # npm ERR! previous versions of npm which has since been addressed.
105+
# - run: sudo chown -R 501:20 "/Users/runner/.npm" || exit 1
106+
# - run: npm ci
107+
# - run: npm install
108+
# working-directory: firebase-vscode
109+
# - run: npm run build
110+
# working-directory: firebase-vscode
111+
112+
# - run: npm i -g firebase-tools@latest
113+
114+
# - uses: GabrielBB/xvfb-action@v1
115+
# with:
116+
# run: npm run test:e2e
117+
# working-directory: firebase-vscode
118+
119+
# - uses: actions/upload-artifact@v4
120+
# if: failure()
121+
# with:
122+
# name: screenshots
123+
# path: firebase-vscode/src/test/screenshots
124+
125+
# - uses: codecov/codecov-action@v3
126+
# if: matrix.node-version == '20'
127127

128128
unit:
129129
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
- Fixed ext:export command so that it correctly returns system params in the .env file (#8881)
2-
- Fixed an issue where the MCP server could not successfully use Application Default Credentials. (#8896)
1+
- Fixed an issue where `firebase init dataconnect` didn't enable the Data Connect API by default (#8927).

npm-shrinkwrap.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firebase-tools",
3-
"version": "14.11.1",
3+
"version": "14.11.2",
44
"description": "Command-Line Interface for Firebase",
55
"main": "./lib/index.js",
66
"bin": {

src/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export const cloudRunApiOrigin = () =>
143143
utils.envOverride("CLOUD_RUN_API_URL", "https://run.googleapis.com");
144144
export const serviceUsageOrigin = () =>
145145
utils.envOverride("FIREBASE_SERVICE_USAGE_URL", "https://serviceusage.googleapis.com");
146+
export const studioApiOrigin = () =>
147+
utils.envOverride("FIREBASE_STUDIO_URL", "https://monospace-pa.googleapis.com");
146148

147149
export const githubOrigin = () => utils.envOverride("GITHUB_URL", "https://github.com");
148150
export const githubApiOrigin = () => utils.envOverride("GITHUB_API_URL", "https://api.github.com");

src/apptesting/ensureProjectConfigured.spec.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,29 @@ describe("ensureProjectConfigured", () => {
4141

4242
await apptesting.ensureProjectConfigured(projectId);
4343

44-
expect(ensureApiEnabledStub).to.be.calledThrice;
45-
expect(ensureApiEnabledStub).to.be.calledWith(projectId, sinon.match.any, "storage", false);
46-
expect(ensureApiEnabledStub).to.be.calledWith(projectId, sinon.match.any, "run", false);
44+
expect(ensureApiEnabledStub).to.be.callCount(4);
4745
expect(ensureApiEnabledStub).to.be.calledWith(
4846
projectId,
49-
sinon.match.any,
50-
"artifactregistry",
47+
"https://firebaseapptesting.googleapis.com",
48+
"Firebase App Testing",
49+
false,
50+
);
51+
expect(ensureApiEnabledStub).to.be.calledWith(
52+
projectId,
53+
"https://run.googleapis.com",
54+
"Cloud Run",
55+
false,
56+
);
57+
expect(ensureApiEnabledStub).to.be.calledWith(
58+
projectId,
59+
"https://storage.googleapis.com",
60+
"Cloud Storage",
61+
false,
62+
);
63+
expect(ensureApiEnabledStub).to.be.calledWith(
64+
projectId,
65+
"https://artifactregistry.googleapis.com",
66+
"Artifact Registry",
5167
false,
5268
);
5369
});

src/apptesting/ensureProjectConfigured.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addServiceAccountToRoles, serviceAccountHasRoles } from "../gcp/resourceManager";
22
import { ensure } from "../ensureApiEnabled";
3-
import { appTestingOrigin } from "../api";
3+
import { appTestingOrigin, artifactRegistryDomain, cloudRunApiOrigin, storageOrigin } from "../api";
44
import { logBullet, logWarning } from "../utils";
55
import { FirebaseError, getErrStatus } from "../error";
66
import * as iam from "../gcp/iam";
@@ -10,9 +10,10 @@ const TEST_RUNNER_ROLE = "roles/firebaseapptesting.testRunner";
1010
const TEST_RUNNER_SERVICE_ACCOUNT_NAME = "firebaseapptesting-test-runner";
1111

1212
export async function ensureProjectConfigured(projectId: string) {
13-
await ensure(projectId, appTestingOrigin(), "storage", false);
14-
await ensure(projectId, appTestingOrigin(), "run", false);
15-
await ensure(projectId, appTestingOrigin(), "artifactregistry", false);
13+
await ensure(projectId, appTestingOrigin(), "Firebase App Testing", false);
14+
await ensure(projectId, cloudRunApiOrigin(), "Cloud Run", false);
15+
await ensure(projectId, storageOrigin(), "Cloud Storage", false);
16+
await ensure(projectId, artifactRegistryDomain(), "Artifact Registry", false);
1617
const serviceAccount = runnerServiceAccount(projectId);
1718

1819
const serviceAccountExistsAndIsRunner = await serviceAccountHasRoles(

src/command.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import { detectProjectRoot } from "./detectProjectRoot";
1111
import { trackEmulator, trackGA4 } from "./track";
1212
import { selectAccount, setActiveAccount } from "./auth";
1313
import { getProject } from "./management/projects";
14+
import { reconcileStudioFirebaseProject } from "./management/studio";
1415
import { requireAuth } from "./requireAuth";
1516
import { Options } from "./options";
1617
import { useConsoleLoggers } from "./logger";
18+
import { isFirebaseStudio } from "./env";
1719

1820
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1921
type ActionFunction = (...args: any[]) => any;
@@ -338,7 +340,7 @@ export class Command {
338340
setActiveAccount(options, activeAccount);
339341
}
340342

341-
this.applyRC(options);
343+
await this.applyRC(options);
342344
if (options.project) {
343345
await this.resolveProjectIdentifiers(options);
344346
validateProjectId(options.projectId);
@@ -350,12 +352,22 @@ export class Command {
350352
* @param options the command options object.
351353
*/
352354
// eslint-disable-next-line @typescript-eslint/no-explicit-any
353-
private applyRC(options: Options): void {
355+
private async applyRC(options: Options) {
354356
const rc = loadRC(options);
355357
options.rc = rc;
356-
const activeProject = options.projectRoot
358+
let activeProject = options.projectRoot
357359
? (configstore.get("activeProjects") ?? {})[options.projectRoot]
358360
: undefined;
361+
362+
// Only fetch the Studio Workspace project if we're running in Firebase
363+
// Studio. If the user passes the project via --project, it should take
364+
// priority.
365+
// If this is the firebase use command, don't worry about reconciling - the user is changing it anyway
366+
const isUseCommand = process.argv.includes("use");
367+
if (isFirebaseStudio() && !options.project && !isUseCommand) {
368+
activeProject = await reconcileStudioFirebaseProject(options, activeProject);
369+
}
370+
359371
options.project = options.project ?? activeProject;
360372
// support deprecated "firebase" key in firebase.json
361373
if (options.config && !options.project) {

src/commands/apps-android-sha-create.spec.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,21 @@ describe("apps:android:sha:create", () => {
3535
describe("action", () => {
3636
it("should create a SHA certificate", async () => {
3737
const shaHash = "A1:B2:C3:D4:E5:F6:A1:B2:C3:D4:E5:F6:A1:B2:C3:D4:E5:F6:A1:B2"; // SHA-1
38-
await command.runner()("test-app-id", shaHash, {});
38+
const options = {
39+
user: { email: "[email protected]" },
40+
tokens: { access_token: "an_access_token" },
41+
};
42+
await command.runner()("test-app-id", shaHash, options);
3943

4044
expect(needProjectIdStub).to.have.been.calledOnce;
41-
expect(createAppAndroidShaStub).to.have.been.calledOnce;
45+
expect(createAppAndroidShaStub).to.have.been.calledOnceWith(
46+
"test-project-id",
47+
"test-app-id",
48+
{
49+
shaHash: shaHash,
50+
certType: ShaCertificateType.SHA_1,
51+
},
52+
);
4253
const spinnerText = promiseWithSpinnerStub.getCall(0).args[1];
4354
expect(spinnerText).to.include("Creating Android SHA certificate");
4455
});

src/commands/apps-android-sha-delete.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,18 @@ describe("apps:android:sha:delete", () => {
3131

3232
describe("action", () => {
3333
it("should delete a SHA certificate", async () => {
34-
await command.runner()("test-app-id", "test-sha-id", {});
34+
const options = {
35+
user: { email: "[email protected]" },
36+
tokens: { access_token: "an_access_token" },
37+
};
38+
await command.runner()("test-app-id", "test-sha-id", options);
3539

3640
expect(needProjectIdStub).to.have.been.calledOnce;
37-
expect(deleteAppAndroidShaStub).to.have.been.calledOnce;
41+
expect(deleteAppAndroidShaStub).to.have.been.calledOnceWith(
42+
"test-project-id",
43+
"test-app-id",
44+
"test-sha-id",
45+
);
3846
const spinnerText = promiseWithSpinnerStub.getCall(0).args[1];
3947
expect(spinnerText).to.include("Deleting Android SHA certificate hash");
4048
});

0 commit comments

Comments
 (0)