Files
Netcatty/components/CloudSyncSettings.test.ts
T
Netcatty-Botandnetcatty-bot e9ef296974 fix(cloud-sync): keep-local overwrite skips remote decrypt (#2469)
* fix(#2466): automated Cursor CLI fix

* fix: address Codex review on PR #2469

---------

Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com>
2026-07-25 18:40:01 +08:00

26 lines
1.3 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
test("USE_LOCAL conflict resolution forces upload-local without decrypting remote", () => {
const source = readFileSync(new URL("./CloudSyncSettings.tsx", import.meta.url), "utf8");
const useLocalIndex = source.indexOf("} else if (resolution === 'USE_LOCAL') {");
const syncNowIndex = source.indexOf("results = await sync.syncNow(localPayload, {", useLocalIndex);
const overrideShrinkIndex = source.indexOf("overrideShrink: true,", syncNowIndex);
const uploadLocalIndex = source.indexOf("conflictActionOverride: 'upload-local',", syncNowIndex);
const nextBranchIndex = source.indexOf("toast.success(t('cloudSync.resolve.uploaded'));", syncNowIndex);
assert.notEqual(useLocalIndex, -1);
assert.notEqual(syncNowIndex, -1);
assert.notEqual(overrideShrinkIndex, -1);
assert.notEqual(uploadLocalIndex, -1);
assert.notEqual(nextBranchIndex, -1);
assert.ok(
useLocalIndex < syncNowIndex
&& syncNowIndex < overrideShrinkIndex
&& overrideShrinkIndex < uploadLocalIndex
&& uploadLocalIndex < nextBranchIndex,
"keep-local must re-sync with conflictActionOverride upload-local so a new master password can overwrite an undecryptable cloud backup",
);
});