Keep P2P consumers on the current transport

This commit is contained in:
vorotamoroz
2026-07-20 15:06:05 +00:00
parent 893c08ad2a
commit 6484a43e2f
34 changed files with 731 additions and 73 deletions
@@ -57,4 +57,38 @@ describe("useP2PReplicatorUI commands", () => {
label: "replication",
});
});
it("keeps the current replicator in the pane parameters after replacement", () => {
const first = { id: "first" };
const second = { id: "second" };
let current = first;
const p2p = {
get replicator() {
return current;
},
} as any;
const host = {
services: {
context: createServiceContext(),
API: {
showWindow: vi.fn(async () => undefined),
registerWindow: vi.fn(),
addCommand: vi.fn(),
addRibbonIcon: vi.fn(),
getPlatform: vi.fn(() => "obsidian"),
},
appLifecycle: {
onInitialise: { addHandler: vi.fn() },
onLayoutReady: { addHandler: vi.fn() },
},
setting: { currentSettings: vi.fn(() => ({ remoteType: "COUCHDB" })) },
replicator: { runFiniteReplicationActivity: vi.fn() },
},
} as any;
const paneParams = useP2PReplicatorUI(host, {} as any, p2p);
current = second;
expect(paneParams.replicator).toBe(second);
});
});