WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@dackers86
Copy link
Member

No description provided.

kirstywilliams and others added 30 commits August 6, 2025 16:57
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dackers86, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a completely revamped integration test suite for Firebase Functions. The previous shell-script-driven, single-function-triggering approach has been replaced with a more robust, TypeScript-based, Vitest-powered framework. This new setup allows for comprehensive testing of both V1 and V2 Firebase Functions across various services like Realtime Database, Firestore, HTTPS, Pub/Sub, Remote Config, Storage, Tasks, Eventarc, Identity, and Scheduler, with a clear orchestration CLI for building, deploying, running, and cleaning up test environments. The changes aim to modernize the testing infrastructure and expand coverage for critical Firebase services.

Highlights

  • New Integration Test Framework: A comprehensive, TypeScript-based integration test framework has been introduced, replacing the previous shell-script-driven setup for Firebase Functions.
  • Vitest Integration: The new framework leverages Vitest for running tests, providing a modern and efficient testing experience across various Firebase services.
  • Orchestrated Test Runner: A new cli.ts script orchestrates the entire integration test lifecycle, including building the SDK, packing it, generating firebase.json, deploying functions, running tests, and cleaning up resources.
  • Expanded Test Coverage: New test files have been added to cover various Firebase services for both V1 and V2 functions, including Realtime Database, Firestore, HTTPS, Pub/Sub, Remote Config, Storage, Tasks, Eventarc, Identity, and Scheduler.
  • Structured Test Utilities: Dedicated directories for assertions/ and serializers/ have been added to provide reusable utilities for validating event data and serializing complex objects for testing.
  • Removal of Legacy Test Infrastructure: Old test scripts (run_tests.sh), configuration files (firebase.json, database.rules.json, firestore.rules, firestore.indexes.json), and test modules (*-tests.ts files) have been removed, streamlining the test setup.
  • Build Process Enhancement: A new pack-for-integration-tests script has been added to the root package.json to simplify the process of building and packing the Firebase Functions SDK for use in integration tests.
  • TypeScript Configuration Update: The tsconfig.json for the functions has been updated to use NodeNext module resolution and strict mode, improving code quality and type safety.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/postmerge.yaml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a great and significant refactoring of the integration test suite. The move to Vitest and a dedicated CLI script for orchestration is a major improvement for maintainability.

I've found one critical security issue regarding a hardcoded API key that must be addressed. I've also identified a couple of high-severity bugs in the test runner script (cli.ts) that would prevent it from working as intended, particularly around codebase handling and cleanup.

Additionally, I've left a few medium-severity comments on potential flakiness, a typo, and some inaccuracies in the planning document.

P.S. There's a small typo in the pull request title ('integratino').

Comment on lines 1 to 9
export const config = {
apiKey: "AIzaSyBBt77mpu6TV0IA2tcNSyf4OltsVu_Z1Zw",
authDomain: "cf3-integration-tests-v2-qa.firebaseapp.com",
databaseURL: "https://cf3-integration-tests-v2-qa-default-rtdb.firebaseio.com",
projectId: "cf3-integration-tests-v2-qa",
storageBucket: "cf3-integration-tests-v2-qa.firebasestorage.app",
messagingSenderId: "576826020291",
appId: "1:576826020291:web:488d568c5d4109df12ed76"
}; No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Hardcoded API keys and project configuration should not be committed to the repository. This is a significant security risk. These values should be loaded from environment variables or a configuration file that is not checked into version control.

Suggested change
export const config = {
apiKey: "AIzaSyBBt77mpu6TV0IA2tcNSyf4OltsVu_Z1Zw",
authDomain: "cf3-integration-tests-v2-qa.firebaseapp.com",
databaseURL: "https://cf3-integration-tests-v2-qa-default-rtdb.firebaseio.com",
projectId: "cf3-integration-tests-v2-qa",
storageBucket: "cf3-integration-tests-v2-qa.firebasestorage.app",
messagingSenderId: "576826020291",
appId: "1:576826020291:web:488d568c5d4109df12ed76"
};
export const config = {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.FIREBASE_DATABASE_URL,
projectId: process.env.GCLOUD_PROJECT,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_APP_ID
};

const firebaseJson = {
functions: [
{
source: "functions",
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The writeFirebaseJson function accepts a codebase parameter but doesn't use it when generating firebase.json. This will cause all functions to be deployed to the default codebase, and the cleanup logic, which seems to rely on a unique codebase per run, will likely fail. The codebase should be added to the function's definition in firebase.json.

Suggested change
source: "functions",
source: "functions",
codebase: codebase,

Comment on lines 131 to 135
async function cleanupFunctions(codebase: string): Promise<void> {
console.log(`Cleaning up functions with RUN_ID: ${runId}...`);
await execCommand("firebase", ["functions:delete", runId, "--force"], {}, integrationTestDir);
console.log("Functions cleaned up successfully");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The cleanupFunctions function incorrectly uses the global runId constant instead of its codebase parameter for logging and in the firebase functions:delete command. This should be corrected to use the codebase parameter to ensure the correct set of functions is deleted.

Suggested change
async function cleanupFunctions(codebase: string): Promise<void> {
console.log(`Cleaning up functions with RUN_ID: ${runId}...`);
await execCommand("firebase", ["functions:delete", runId, "--force"], {}, integrationTestDir);
console.log("Functions cleaned up successfully");
}
async function cleanupFunctions(codebase: string): Promise<void> {
console.log(`Cleaning up functions with RUN_ID: ${codebase}...`);
await execCommand("firebase", ["functions:delete", codebase, "--force"], {}, integrationTestDir);
console.log("Functions cleaned up successfully");
}

await writeEnvFile(runId);
await deployFunctions(runId);
console.log("Waiting 20 seconds for deployments fully provision before running tests...");
await new Promise((resolve) => setTimeout(resolve, 20_000));
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using a hardcoded setTimeout to wait for deployments can lead to flaky tests. If the deployment takes longer than 20 seconds, the tests will fail. A more robust approach would be to poll for the status of the functions until they are ready. For an internal integration test script, this might be an acceptable trade-off to avoid added complexity, but it's worth considering improving this if tests become flaky.

Comment on lines 21 to 56
exports.firestoreOnCreate = onDocumentCreate((event) => {
firestore.collection(...).doc(...).set(event)';
})
```

```ts
exports.firestoreOnCreate = onDocumentCreate((event) => {
await sendEvent(event);
})

let topic;

async function(name: string, event: any): Promise<void> {
topic ??= await pubsub.createTopic(process.env.RUN_ID);
await topic.publishMessage({ name, event })
}
```

# Test Files

```
describe('triggers the correct document event', () => {
beforeAll(() => {
let event = await new Promise((resolve) => {
setUpEventListener('firestoreOnCreate', (event) => {
resolve(event);
});

await admin().firestore().collection(process.env.RUN_ID).doc('foo');
});

});

test('whatever...');
});
```
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The code snippets in this plan contain a few syntax errors that could be misleading:

  • On line 22, there's a stray single quote: firestore.collection(...).doc(...).set(event)';
  • On line 33, async function(name: string, event: any): Promise<void> { is not a valid function declaration as it's missing a name.
  • On line 49, await is used inside a new Promise executor that is not async, which is a syntax error.

While this is a planning document, correcting these could prevent confusion.

},
})
.onDispatch(async (data, event) => {
await sendEvent("onTaskDispatchedV1 ", {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There appears to be a typo in the event name string passed to sendEvent. The string "onTaskDispatchedV1 " has a trailing space, which will likely cause the test waiting for the "onTaskDispatchedV1" event to time out.

Suggested change
await sendEvent("onTaskDispatchedV1 ", {
await sendEvent("onTaskDispatchedV1", {

@dackers86 dackers86 force-pushed the @invertase/integration-tests branch from 1de7c93 to 12a54d7 Compare December 19, 2025 11:15
@dackers86 dackers86 changed the title chore(*): add integratino tests chore(*): add integration tests Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants