mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-27 23:13:03 +00:00
Stabilise configured Real Obsidian workflows
This commit is contained in:
@@ -10,6 +10,7 @@ vi.mock("./cli.ts", () => ({ evalObsidianJson }));
|
||||
import {
|
||||
assertE2eCompatibilityMarker,
|
||||
createE2eCouchDbPluginData,
|
||||
prepareRemote,
|
||||
waitForLiveSyncCoreReady,
|
||||
type CompatibilityMarkerState,
|
||||
} from "./liveSyncWorkflow.ts";
|
||||
@@ -77,3 +78,18 @@ describe("Real Obsidian core readiness", () => {
|
||||
expect(evalObsidianJson).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("remote fixture preparation", () => {
|
||||
it("waits for the remote Security Seed after resolving a new remote", async () => {
|
||||
evalObsidianJson.mockReset();
|
||||
evalObsidianJson.mockResolvedValueOnce({ status: "resolved", securitySeedReady: true });
|
||||
|
||||
await prepareRemote("obsidian-cli", {});
|
||||
|
||||
const evaluatedCode = String(evalObsidianJson.mock.calls[0]?.[1] ?? "");
|
||||
expect(evaluatedCode.indexOf("markRemoteResolved")).toBeLessThan(
|
||||
evaluatedCode.indexOf("ensurePBKDF2Salt")
|
||||
);
|
||||
expect(evaluatedCode).toContain("Timed out preparing the remote Security Seed");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -462,6 +462,7 @@ export function assertObsidianServiceContextContract(result: ObsidianServiceCont
|
||||
}
|
||||
|
||||
export async function prepareRemote(cliBinary: string, env: NodeJS.ProcessEnv): Promise<void> {
|
||||
const timeoutMs = Number(process.env.E2E_OBSIDIAN_REMOTE_PREPARE_TIMEOUT_MS ?? 20000);
|
||||
await evalObsidianJson<unknown>(
|
||||
cliBinary,
|
||||
[
|
||||
@@ -471,8 +472,16 @@ export async function prepareRemote(cliBinary: string, env: NodeJS.ProcessEnv):
|
||||
"const replicator=core.services.replicator.getActiveReplicator();",
|
||||
"await replicator.tryCreateRemoteDatabase(settings);",
|
||||
"await replicator.markRemoteResolved(settings);",
|
||||
`const deadline=Date.now()+${JSON.stringify(timeoutMs)};`,
|
||||
"let securitySeedReady=false;",
|
||||
"do{",
|
||||
"securitySeedReady=await replicator.ensurePBKDF2Salt(settings,false,false);",
|
||||
"if(securitySeedReady) break;",
|
||||
"await new Promise((resolve)=>setTimeout(resolve,250));",
|
||||
"}while(Date.now()<deadline);",
|
||||
"if(!securitySeedReady) throw new Error('Timed out preparing the remote Security Seed');",
|
||||
"const status=await replicator.getRemoteStatus(settings);",
|
||||
"return JSON.stringify({status});",
|
||||
"return JSON.stringify({status,securitySeedReady});",
|
||||
"})()",
|
||||
].join(""),
|
||||
env
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/**
|
||||
* Supplies the runner-owned CouchDB fixture operations for the Security Seed
|
||||
* reconnect scenario. Production code remains responsible for fetching,
|
||||
* caching, and applying the Seed; this helper only validates the managed
|
||||
* synchronisation-parameter document, replaces the one intended field, and
|
||||
* compares document snapshots.
|
||||
*
|
||||
* Callers expose only short SHA-256 fingerprints. The original and replacement
|
||||
* Seed values must stay inside the isolated test process and must not be
|
||||
* written to diagnostics, screenshots, or machine-readable results.
|
||||
*/
|
||||
import { createHash, randomBytes } from "node:crypto";
|
||||
import type { CouchDbDocument } from "./couchdb.ts";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user