mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-08-26 13:27:05 +00:00
Distinguish absent and unreadable remote settings during setup
Use typed Commonlib outcomes to guide Fetch and Rebuild without treating a new remote as a failed read. Preserve automatic synchronisation choices when scheduled initialisation is cancelled.
This commit is contained in:
@@ -54,6 +54,36 @@ function createModule(settingsOverride: Partial<typeof DEFAULT_SETTINGS> = {}) {
|
||||
}
|
||||
|
||||
describe("ModuleResolvingMismatchedTweaks", () => {
|
||||
it("returns an unconfigured remote result without a separate connection preflight", async () => {
|
||||
const { module, core } = createModule();
|
||||
const tryConnectRemote = vi.fn(async () => true);
|
||||
const getRemotePreferredTweakValues = vi.fn(async () => ({
|
||||
status: "not-configured" as const,
|
||||
reason: "milestone-missing" as const,
|
||||
}));
|
||||
core._services.replicator = {
|
||||
getNewReplicator: vi.fn(async () => ({ tryConnectRemote, getRemotePreferredTweakValues })),
|
||||
};
|
||||
|
||||
await expect(module._fetchRemotePreferredTweakValues(core.settings)).resolves.toEqual({
|
||||
status: "not-configured",
|
||||
reason: "milestone-missing",
|
||||
});
|
||||
expect(getRemotePreferredTweakValues).toHaveBeenCalledOnce();
|
||||
expect(tryConnectRemote).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns unsupported when no replicator implements the remote type", async () => {
|
||||
const { module, core } = createModule();
|
||||
core._services.replicator = {
|
||||
getNewReplicator: vi.fn(async () => undefined),
|
||||
};
|
||||
|
||||
await expect(module._fetchRemotePreferredTweakValues(core.settings)).resolves.toEqual({
|
||||
status: "unsupported",
|
||||
});
|
||||
});
|
||||
|
||||
it("should enable and auto-accept compatible mismatches when the preference is undefined", async () => {
|
||||
const { module, core, askSelectStringDialogue, applyPartial } = createModule({
|
||||
autoAcceptCompatibleTweak: undefined,
|
||||
|
||||
Reference in New Issue
Block a user