feat(FN-3403): add shell multi-profile support with connection manager onbo

Merges shell multi-profile support for desktop (FN-3403) — spanning new connection-manager flows, shell onboarding interoperability, mobile connection profiles, desktop IPC/shell-settings plumbing, and tokenized titlebar styles — with a secondary migration of the WhatsApp plugin to the Baileys pairi

Fusion-Task-Id: FN-3403
This commit is contained in:
Fusion
2026-05-07 18:32:09 -07:00
committed by gsxdsm
parent a3572156e3
commit 7b9e5259d3
22 changed files with 877 additions and 115 deletions

View File

@@ -0,0 +1,51 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const store = new Map<string, string>();
vi.mock("@capacitor/preferences", () => ({
Preferences: {
get: vi.fn(async ({ key }: { key: string }) => ({ value: store.get(key) ?? null })),
set: vi.fn(async ({ key, value }: { key: string; value: string }) => {
store.set(key, value);
}),
},
}));
describe("connection-profiles", () => {
beforeEach(() => {
store.clear();
vi.resetModules();
});
it("recovers from invalid payloads", async () => {
store.set("fusion.shell.connections.v1", "{bad-json");
const { loadShellProfiles } = await import("../connection-profiles.js");
await expect(loadShellProfiles()).resolves.toEqual({ activeProfileId: null, profiles: [] });
});
it("normalizes empty and duplicate names", async () => {
const { saveShellProfile, listShellProfiles } = await import("../connection-profiles.js");
const first = await saveShellProfile({ name: "", serverUrl: "https://fusion.example.com" });
const second = await saveShellProfile({ name: "Remote Server", serverUrl: "https://fusion-two.example.com" });
expect(first.name).toBe("Remote Server");
expect(second.name).toBe("Remote Server (2)");
const profiles = await listShellProfiles();
expect(profiles).toHaveLength(2);
});
it("deleting active profile picks a fallback and deleting final profile clears state", async () => {
const { saveShellProfile, setActiveShellProfile, deleteShellProfile, loadShellProfiles } = await import("../connection-profiles.js");
const first = await saveShellProfile({ name: "Prod", serverUrl: "https://fusion.example.com" });
const second = await saveShellProfile({ name: "Staging", serverUrl: "https://staging.example.com" });
await setActiveShellProfile(second.id);
await deleteShellProfile(second.id);
const afterFirstDelete = await loadShellProfiles();
expect(afterFirstDelete.activeProfileId).toBe(first.id);
await deleteShellProfile(first.id);
const afterSecondDelete = await loadShellProfiles();
expect(afterSecondDelete).toEqual({ activeProfileId: null, profiles: [] });
});
});