fix del api

This commit is contained in:
2026-08-03 15:53:07 +08:00
parent 5edb0b2d69
commit 1f356af022
3 changed files with 64 additions and 11 deletions
+12
View File
@@ -877,6 +877,14 @@ test("deleteProductionLine blocks active licenses and removes revoked data", asy
assert.equal(blocked.errCode, "ACTIVE_LICENSES_PRESENT");
await post({ type: "revokeLicense", licenseId, reason: "产线删除", adminToken: "test-token" });
const orphanModelDir = path.join(dataDirectory, "models", line.productionLine.deviceId);
const orphanFileDir = path.join(dataDirectory, "files", "ReinLoop_GUI", line.productionLine.deviceId);
await fs.promises.mkdir(orphanModelDir, { recursive: true });
await fs.promises.mkdir(orphanFileDir, { recursive: true });
await fs.promises.writeFile(path.join(orphanModelDir, "orphan.bin"), "orphan-model");
await fs.promises.writeFile(path.join(orphanFileDir, "orphan.json"), "orphan-file");
const deleted = await post({
type: "deleteProductionLine",
companyId: company.company.id,
@@ -886,6 +894,10 @@ test("deleteProductionLine blocks active licenses and removes revoked data", asy
assert.equal(deleted.success, true);
assert.ok(deleted.deletedFiles >= 1);
assert.ok(deleted.deletedLicenses >= 1);
assert.ok(deleted.deletedDirectories >= 1);
await assert.rejects(fs.promises.access(orphanModelDir));
await assert.rejects(fs.promises.access(orphanFileDir));
const organizations = await post({ type: "listOrganizations", adminToken: "test-token" });
const listedCompany = organizations.companies.find((item) => item.id === company.company.id);