|
| 1 | +// import { expect } from "chai"; |
| 2 | +import * as mockfs from "mock-fs"; |
| 3 | +import sinon from "sinon"; |
| 4 | +// import { McpContext } from "../../types"; |
| 5 | +// import { Config } from "../../../config"; |
| 6 | +// import { FirebaseMcpServer } from "../.."; |
| 7 | +// import { RC } from "../../../rc"; |
| 8 | +import * as ensureApiEnabled from "../../../ensureApiEnabled"; |
| 9 | +import { FirebaseMcpServer } from "../.."; |
| 10 | +import { RC } from "../../../rc"; |
| 11 | +import { Config } from "../../../config"; |
| 12 | +import { McpContext } from "../../types"; |
| 13 | +import { isAppTestingAvailable } from "./availability"; |
| 14 | +import { expect } from "chai"; |
| 15 | +// import { isAppTestingAvailable } from "./availability"; |
| 16 | + |
| 17 | +describe.only("isAppTestingAvailable", () => { |
| 18 | + const sandbox: sinon.SinonSandbox = sinon.createSandbox(); |
| 19 | + let checkStub: sinon.SinonStub; |
| 20 | + |
| 21 | + beforeEach(() => { |
| 22 | + checkStub = sandbox.stub(ensureApiEnabled, "check"); |
| 23 | + }); |
| 24 | + |
| 25 | + afterEach(() => { |
| 26 | + sandbox.restore(); |
| 27 | + mockfs.restore(); |
| 28 | + }); |
| 29 | + |
| 30 | + const mockContext = (projectDir: string): McpContext => ({ |
| 31 | + projectId: "test-project", |
| 32 | + accountEmail: null, |
| 33 | + config: { |
| 34 | + projectDir: projectDir, |
| 35 | + } as Config, |
| 36 | + host: new FirebaseMcpServer({}), |
| 37 | + rc: {} as RC, |
| 38 | + firebaseCliCommand: "firebase", |
| 39 | + }); |
| 40 | + |
| 41 | + it("returns false for non mobile project", async () => { |
| 42 | + checkStub.resolves(true); |
| 43 | + mockfs({ |
| 44 | + "/test-dir": { |
| 45 | + "package.json": '{ "name": "web-app" }', |
| 46 | + "index.html": "<html></html>", |
| 47 | + }, |
| 48 | + }); |
| 49 | + const result = await isAppTestingAvailable(mockContext("/test-dir")); |
| 50 | + expect(result).to.be.false; |
| 51 | + }); |
| 52 | + |
| 53 | + it("returns false if App Distribution API isn't enabled", async () => { |
| 54 | + checkStub.resolves(false); |
| 55 | + mockfs({ |
| 56 | + "/test-dir": { |
| 57 | + android: { |
| 58 | + "build.gradle": "", |
| 59 | + src: { main: {} }, |
| 60 | + }, |
| 61 | + }, |
| 62 | + }); |
| 63 | + const result = await isAppTestingAvailable(mockContext("/test-dir")); |
| 64 | + expect(result).to.be.false; |
| 65 | + }); |
| 66 | + |
| 67 | + it("returns true for an Android project with API enabled", async () => { |
| 68 | + checkStub.resolves(true); |
| 69 | + mockfs({ |
| 70 | + "/test-dir": { |
| 71 | + android: { |
| 72 | + "build.gradle": "", |
| 73 | + src: { main: {} }, |
| 74 | + }, |
| 75 | + }, |
| 76 | + }); |
| 77 | + const result = await isAppTestingAvailable(mockContext("/test-dir")); |
| 78 | + expect(result).to.be.true; |
| 79 | + }); |
| 80 | + |
| 81 | + it("returns true for an iOS project with API enabled", async () => { |
| 82 | + checkStub.resolves(true); |
| 83 | + mockfs({ |
| 84 | + "/test-dir": { |
| 85 | + ios: { |
| 86 | + Podfile: "", |
| 87 | + "Project.xcodeproj": {}, |
| 88 | + }, |
| 89 | + }, |
| 90 | + }); |
| 91 | + const result = await isAppTestingAvailable(mockContext("/test-dir")); |
| 92 | + expect(result).to.be.true; |
| 93 | + }); |
| 94 | + |
| 95 | + it("returns true for an Flutter project with API enabled", async () => { |
| 96 | + checkStub.resolves(true); |
| 97 | + mockfs({ |
| 98 | + "/test-dir": { |
| 99 | + "pubspec.yaml": "", |
| 100 | + ios: { "Runner.xcodeproj": {} }, |
| 101 | + android: { src: { main: {} } }, |
| 102 | + }, |
| 103 | + }); |
| 104 | + const result = await isAppTestingAvailable(mockContext("/test-dir")); |
| 105 | + expect(result).to.be.true; |
| 106 | + }); |
| 107 | +}); |
0 commit comments