refactor(FN-1240): remove dashboard Capacitor coupling in favor of @fusion/mobile

- Remove legacy dashboard Capacitor config, scripts, and package dependencies now managed by @fusion/mobile
- Rewrite network, splash-screen, and status-bar plugin managers to use guarded global Capacitor plugin adapters without direct @capacitor imports
- Update plugin tests to stub Capacitor globals and drop obsolete capacitor config test coverage
- Simplify dashboard mobile README guidance and add a @gsxdsm/fusion patch changeset documenting the migration
This commit is contained in:
gsxdsm
2026-04-08 08:10:17 -07:00
parent be204d6c52
commit b8672cf792
13 changed files with 185 additions and 274 deletions

View File

@@ -1,24 +1,14 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { Network } from "@capacitor/network";
import { NetworkManager } from "../plugins/network.js";
const { getStatusMock, addListenerMock, removeListenerMock } = vi.hoisted(() => ({
getStatusMock: vi.fn(),
addListenerMock: vi.fn(),
removeListenerMock: vi.fn(),
}));
const getStatusMock = vi.fn();
const addListenerMock = vi.fn();
const removeListenerMock = vi.fn();
let networkStatusChangeHandler:
| ((status: { connected: boolean; connectionType: "wifi" | "cellular" | "none" | "unknown" }) => void)
| null = null;
vi.mock("@capacitor/network", () => ({
Network: {
getStatus: getStatusMock,
addListener: addListenerMock,
},
}));
describe("NetworkManager", () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -40,6 +30,15 @@ describe("NetworkManager", () => {
}
return { remove: removeListenerMock };
});
vi.stubGlobal("Capacitor", {
Plugins: {
Network: {
getStatus: getStatusMock,
addListener: addListenerMock,
},
},
});
});
it("initialize() queries current network status", async () => {
@@ -47,7 +46,7 @@ describe("NetworkManager", () => {
await manager.initialize();
expect(Network.getStatus).toHaveBeenCalledTimes(1);
expect(getStatusMock).toHaveBeenCalledTimes(1);
expect(manager.getStatus()).toEqual({ connected: true, connectionType: "wifi" });
});
@@ -56,8 +55,8 @@ describe("NetworkManager", () => {
await manager.startMonitoring();
expect(Network.addListener).toHaveBeenCalledTimes(1);
expect(Network.addListener).toHaveBeenCalledWith("networkStatusChange", expect.any(Function));
expect(addListenerMock).toHaveBeenCalledTimes(1);
expect(addListenerMock).toHaveBeenCalledWith("networkStatusChange", expect.any(Function));
expect(manager.isMonitoring).toBe(true);
});