-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add custom auto-enablement for app testing #9373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tagboola
merged 4 commits into
feature-branch/mcp/mobile-testing
from
tagboola/apptesting-enablement
Oct 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| // import { expect } from "chai"; | ||
| import * as mockfs from "mock-fs"; | ||
| import sinon from "sinon"; | ||
| // import { McpContext } from "../../types"; | ||
| // import { Config } from "../../../config"; | ||
| // import { FirebaseMcpServer } from "../.."; | ||
| // import { RC } from "../../../rc"; | ||
| import * as ensureApiEnabled from "../../../ensureApiEnabled"; | ||
| import { FirebaseMcpServer } from "../.."; | ||
| import { RC } from "../../../rc"; | ||
| import { Config } from "../../../config"; | ||
| import { McpContext } from "../../types"; | ||
| import { isAppTestingAvailable } from "./availability"; | ||
| import { expect } from "chai"; | ||
| // import { isAppTestingAvailable } from "./availability"; | ||
|
|
||
| describe.only("isAppTestingAvailable", () => { | ||
tagboola marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const sandbox: sinon.SinonSandbox = sinon.createSandbox(); | ||
| let checkStub: sinon.SinonStub; | ||
|
|
||
| beforeEach(() => { | ||
| checkStub = sandbox.stub(ensureApiEnabled, "check"); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| sandbox.restore(); | ||
| mockfs.restore(); | ||
| }); | ||
|
|
||
| const mockContext = (projectDir: string): McpContext => ({ | ||
| projectId: "test-project", | ||
| accountEmail: null, | ||
| config: { | ||
| projectDir: projectDir, | ||
| } as Config, | ||
| host: new FirebaseMcpServer({}), | ||
| rc: {} as RC, | ||
| firebaseCliCommand: "firebase", | ||
| }); | ||
|
|
||
| it("returns false for non mobile project", async () => { | ||
| checkStub.resolves(true); | ||
| mockfs({ | ||
| "/test-dir": { | ||
| "package.json": '{ "name": "web-app" }', | ||
| "index.html": "<html></html>", | ||
| }, | ||
| }); | ||
| const result = await isAppTestingAvailable(mockContext("/test-dir")); | ||
| expect(result).to.be.false; | ||
| }); | ||
|
|
||
| it("returns false if App Distribution API isn't enabled", async () => { | ||
| checkStub.resolves(false); | ||
| mockfs({ | ||
| "/test-dir": { | ||
| android: { | ||
| "build.gradle": "", | ||
| src: { main: {} }, | ||
| }, | ||
| }, | ||
| }); | ||
| const result = await isAppTestingAvailable(mockContext("/test-dir")); | ||
| expect(result).to.be.false; | ||
| }); | ||
|
|
||
| it("returns true for an Android project with API enabled", async () => { | ||
| checkStub.resolves(true); | ||
| mockfs({ | ||
| "/test-dir": { | ||
| android: { | ||
| "build.gradle": "", | ||
| src: { main: {} }, | ||
| }, | ||
| }, | ||
| }); | ||
| const result = await isAppTestingAvailable(mockContext("/test-dir")); | ||
| expect(result).to.be.true; | ||
| }); | ||
|
|
||
| it("returns true for an iOS project with API enabled", async () => { | ||
| checkStub.resolves(true); | ||
| mockfs({ | ||
| "/test-dir": { | ||
| ios: { | ||
| Podfile: "", | ||
| "Project.xcodeproj": {}, | ||
| }, | ||
| }, | ||
| }); | ||
| const result = await isAppTestingAvailable(mockContext("/test-dir")); | ||
| expect(result).to.be.true; | ||
| }); | ||
|
|
||
| it("returns true for an Flutter project with API enabled", async () => { | ||
| checkStub.resolves(true); | ||
| mockfs({ | ||
| "/test-dir": { | ||
| "pubspec.yaml": "", | ||
| ios: { "Runner.xcodeproj": {} }, | ||
| android: { src: { main: {} } }, | ||
| }, | ||
| }); | ||
| const result = await isAppTestingAvailable(mockContext("/test-dir")); | ||
| expect(result).to.be.true; | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { appDistributionOrigin } from "../../../api"; | ||
| import { getPlatformsFromFolder, Platform } from "../../../appUtils"; | ||
| import { check } from "../../../ensureApiEnabled"; | ||
| import { timeoutFallback } from "../../../timeout"; | ||
| import { McpContext } from "../../types"; | ||
|
|
||
| /** | ||
| * Returns whether or not App Testing should be enabled | ||
| */ | ||
| export async function isAppTestingAvailable(ctx: McpContext): Promise<boolean> { | ||
| const host = ctx.host; | ||
| const projectDir = ctx.config.projectDir; | ||
| const platforms = await getPlatformsFromFolder(projectDir); | ||
|
|
||
| // If this is not a mobile app, then App Testing won't be enabled | ||
| if ( | ||
| !platforms.includes(Platform.FLUTTER) && | ||
| !platforms.includes(Platform.ANDROID) && | ||
| !platforms.includes(Platform.IOS) | ||
| ) { | ||
| host.log("debug", `Found no supported App Testing platforms.`); | ||
| return false; | ||
| } | ||
tagboola marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Checkf if App Distribution API is active | ||
| try { | ||
| return await timeoutFallback( | ||
| check(ctx.projectId, appDistributionOrigin(), "", true), | ||
| true, | ||
| 3000, | ||
| ); | ||
| } catch (e) { | ||
| // If there was a network error, default to enabling the feature | ||
| return true; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.