Files
Netcatty/application/state/sftp/externalUploadCancel.test.ts
T
陈大猫 12d9913537 fix(sftp): cancel external uploads by transfer task id (#2495)
Track UploadController instances per transfer task so queue cancel of one
external upload does not abort another concurrent paste/drop upload.
Scope pending conflict prompts to the owning controller as well.
2026-07-25 22:05:37 +08:00

23 lines
993 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
test("external upload cancellation is keyed by transfer task id", () => {
const ops = readFileSync(new URL("./useSftpExternalOperations.ts", import.meta.url), "utf8");
assert.match(ops, /uploadControllersByTaskRef/);
assert.match(ops, /const cancelExternalUpload = useCallback\(async \(taskId\?: string\)/);
assert.match(ops, /bindUploadControllerCallbacks/);
const queue = readFileSync(
new URL("../../../components/sftp/SftpTransferQueue.tsx", import.meta.url),
"utf8",
);
assert.match(queue, /cancelExternalUpload\(task\.id\)/);
});
test("upload conflict cancel is scoped to owning controller", () => {
const ops = readFileSync(new URL("./useSftpExternalOperations.ts", import.meta.url), "utf8");
assert.match(ops, /uploadConflictOwnersRef/);
assert.match(ops, /cancelPendingUploadConflicts = useCallback\(\(controller\?: UploadController\)/);
});