Skip to content

test: improve coverage for init emulators#10386

Open
joehan wants to merge 9 commits intomainfrom
test/init-emulators
Open

test: improve coverage for init emulators#10386
joehan wants to merge 9 commits intomainfrom
test/init-emulators

Conversation

@joehan
Copy link
Copy Markdown
Member

@joehan joehan commented Apr 20, 2026

Description\nImplement unit tests for init emulators feature.\n\n### Scenarios Tested\n- Configuration with no emulators\n- Port configuration\n- UI enablement\n- Download prompts

falahat and others added 7 commits April 16, 2026 09:35
* Enable secret resolution during local App Hosting builds

* fix build error

* Handle env vars (especially secrets) with a Promise.all so it can be parallelized
…al builds (#10337)

* Enable secret resolution during local App Hosting builds

* fix build error

* Handle env vars (especially secrets) with a Promise.all so it can be parallelized

* Add a warning so that we do not use build-available secrets unless the user confirms

* fix undefined boolean flag behavior

* fix tests, address some review comments

* fix test mocking
…#10352)

* Consolidate the ABIU prompts in the CLI so it matches the UI more closely

* Address linter errors
* feat: add SSE mode support for MCP server

### Description
Adds support for running the MCP server in SSE (HTTP) mode, in addition to the default Stdio transport. This allows clients to connect over network or via tools that support SSE.

### Scenarios Tested
- Started server in SSE mode and verified log output.

* fix: add progressToken to McpContext interface to fix build error

### Description
Fixes a type error where progressToken was not defined on McpContext.

### Scenarios Tested
- Verified build succeeds.

* refactor: address PR comments on SSE support

### Description
Addresses PR comments by:
- Moving inline require calls to top-level imports.
- Replacing any types with specific interfaces or unknown.

### Scenarios Tested
- Verified build succeeds.

* fix: address remaining review comments on SSE support

### Description
- Reverts accidental GA4 tracking change in mcpListResources.
- Replaces console.error with this.logger calls for better logging.
- Changes default server binding from 0.0.0.0 to 127.0.0.1 for security.

### Scenarios Tested
- Verified build succeeds.

* style: lint and format fixes for SSE support

### Description
- Applied auto-formatting fixes from npm run format.

### Scenarios Tested
- Verified build succeeds.

* feat: add infrastructure for MCP Apps (#10259)

* feat: add infrastructure for MCP Apps

### Description
Adds support for returning structured content from tools, which is used by MCP Apps to pass complex data to the host. Also updates the resource index.

### Scenarios Tested
- Verified build and file changes.

* fix: resolve build errors and address review comments on infra

### Description
- Removes imports and registry entries for UI resources that are not yet available in this branch (login, update_environment, deploy, init).
- Replaces as any in toContent with an intersection type for better type safety.

### Scenarios Tested
- Verified build succeeds.

* chore: avoid any for sessionId in SSE transport

### Description
- Defines a local interface extending SSEServerTransport to avoid using  when accessing .

### Scenarios Tested
- Build succeeds.
- Lint passes for modified lines.

* feat: change sse flag to mode flag and fix build errors

### Description
- Replaced  boolean flag with  string flag (defaults to 'stdio').
- Added validation for  to accept only 'stdio' or 'sse'.
- Fixed build errors by adding  to  interface and removing missing  resource.

### Scenarios Tested
- Build succeeds.
- Lint passes with no new errors.

* feat: add Update Environment MCP App (#10260)

* feat: add mcpapps experiment flag and helper

### Description
- Adds mcpapps experiment flag to src/experiments.ts.
- Adds applyAppMeta helper function to src/mcp/util.ts to conditionally add UI metadata.
- Adds unit tests for applyAppMeta in src/mcp/util.spec.ts.

### Scenarios Tested
- Unit tests passed.
- Build succeeds.

* chore: address PR comments on experiments and util

### Description
- Fixes applyAppMeta to preserve existing metadata.
- Moves mcpapps flag to be grouped with other MCP experiments.
- Removes as any in util.spec.ts by importing CallToolResult.

### Scenarios Tested
- Build succeeds.
- Lint passes for modified files (ignoring pre-existing warnings).
- Unit tests for applyAppMeta pass.

* feat: add infrastructure for MCP Apps

Adds support for returning structured content from tools, which is used by MCP Apps to pass complex data to the host. Also updates the resource index.

- Verified build and file changes.

* feat: add Update Environment MCP App

### Description
Adds the Update Environment MCP App, allowing users to switch projects and directories from the UI.

### Scenarios Tested
- Verified build and file changes.

* fix: resolve compilation errors in mcp-update-env-app

* fix: resolve remaining lint errors in mcp-update-env-app

* refactor: extract app MIME type shared constant

* added changelog'
* fix: prevent hosting deploy to site in wrong project

### Description
Prevent accidental deployments to a hosting site that does not belong to the active project.
The CLI now verifies that the site belongs to the project before creating a version.

Fixes #10376

### Scenarios Tested
- Verified that error is thrown when site does not belong to project.
- Verified that deploy passes when site belongs to project.
- Verified that check is skipped for demo projects.

### Sample Commands
`firebase deploy --project project-b` (where site in firebase.json belongs to project-a) -> should fail.

* chore: remove excessive site validation check and update tests

* Comment

* chore: remove demo project check and corresponding test

* chore: remove unused Constants import in prepare.ts
* test: improve coverage for appdistribution distribution

### Description
Add hermetic uploading and mock polling asserts for app distribution workflows.

### Scenarios Tested
- Extracting sequential binary structures

* test: fix unused imports in distribution tests
Copy link
Copy Markdown
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 pull request adds a comprehensive test suite for the emulator initialization logic in src/init/features/emulators.spec.ts. The tests verify emulator selection, port assignment, UI configuration, and download triggers. Feedback was provided to replace the use of the any type for the setup object with the formal Setup type imported from the module's index, aligning with the project's TypeScript style guidelines.

@@ -0,0 +1,81 @@
import { expect } from "chai";
import * as sinon from "sinon";
import { doSetup } from "./emulators";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To avoid using any for the setup variable in the tests, you should import the Setup type from the parent directory.

Suggested change
import { doSetup } from "./emulators";
import { doSetup } from "./emulators";
import { Setup } from "../index";
References
  1. Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)

Comment thread src/init/features/emulators.spec.ts Outdated

it("should do nothing if no emulators are selected", async () => {
checkboxStub.resolves([]);
const setup: any = { config: {} };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The use of any as an escape hatch is prohibited by the repository style guide. Please use the proper Setup type. If the full object is too complex to mock, consider using a type-safe mock or a partial type with a type assertion if absolutely necessary, but avoid any.

Suggested change
const setup: any = { config: {} };
const setup = { config: {} } as unknown as Setup;
References
  1. Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)

Comment thread src/init/features/emulators.spec.ts Outdated
confirmStub.onFirstCall().resolves(false); // UI
confirmStub.onSecondCall().resolves(false); // Download

const setup: any = { config: {} };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The use of any as an escape hatch is prohibited by the repository style guide. Please use the proper Setup type.

Suggested change
const setup: any = { config: {} };
const setup = { config: {} } as unknown as Setup;
References
  1. Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)

Comment thread src/init/features/emulators.spec.ts Outdated
numberStub.onSecondCall().resolves(4000); // UI port
confirmStub.onSecondCall().resolves(false); // Download

const setup: any = { config: {} };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The use of any as an escape hatch is prohibited by the repository style guide. Please use the proper Setup type.

Suggested change
const setup: any = { config: {} };
const setup = { config: {} } as unknown as Setup;
References
  1. Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)

Comment thread src/init/features/emulators.spec.ts Outdated
confirmStub.onFirstCall().resolves(false); // UI
confirmStub.onSecondCall().resolves(true); // Download

const setup: any = { config: {} };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The use of any as an escape hatch is prohibited by the repository style guide. Please use the proper Setup type.

Suggested change
const setup: any = { config: {} };
const setup = { config: {} } as unknown as Setup;
References
  1. Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)

joehan added 2 commits April 21, 2026 09:07
### Description\nImplement unit tests for init emulators feature.\n\n### Scenarios Tested\n- Configuration with no emulators\n- Port configuration\n- UI enablement\n- Download prompts
@joehan joehan force-pushed the test/init-emulators branch from 2b97dfd to 4e1b655 Compare April 21, 2026 16:07
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.

3 participants