refactor: register remote setup presentations

This commit is contained in:
vorotamoroz
2026-08-02 04:08:52 +00:00
parent c4419a837c
commit 4d6a794f9d
8 changed files with 420 additions and 230 deletions
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import {
DEFAULT_SETTINGS,
REMOTE_COUCHDB,
REMOTE_MINIO,
REMOTE_P2P,
type ObsidianLiveSyncSettings,
} from "@vrtmrz/livesync-commonlib/compat/common/types";
@@ -421,6 +422,40 @@ describe("SetupManager", () => {
expect(activeProfile?.uri).toContain("sls+s3://key:secret@storage.example");
});
it("uses the registered provider choices when configuring a Settings edit buffer", async () => {
const { manager, setting, dialogManager } = createSetupManager();
const bucketSettings = {
endpoint: "https://storage.example",
accessKey: "key",
secretKey: "secret",
bucket: "notes",
region: "auto",
bucketPrefix: "",
useCustomRequestHandler: false,
bucketCustomHeaders: "",
forcePathStyle: true,
};
dialogManager.openWithExplicitCancel.mockResolvedValueOnce("s3").mockResolvedValueOnce(bucketSettings);
const nextSettings = await manager.configureRemoteForSettings(setting.currentSettings());
expect(dialogManager.openWithExplicitCancel).toHaveBeenNthCalledWith(
1,
expect.anything(),
expect.arrayContaining([
expect.objectContaining({ type: "couchdb" }),
expect.objectContaining({ type: "s3" }),
expect.objectContaining({ type: "p2p" }),
])
);
expect(dialogManager.openWithExplicitCancel).toHaveBeenNthCalledWith(
2,
expect.anything(),
setting.currentSettings()
);
expect(nextSettings).toEqual(expect.objectContaining({ ...bucketSettings, remoteType: REMOTE_MINIO }));
});
it("creates and selects a P2P profile during fresh manual onboarding", async () => {
const { manager, setting, dialogManager } = createSetupManager();
setting.settings = {