fix config notice display

This commit is contained in:
2026-08-03 16:35:23 +08:00
parent 1f356af022
commit ac77d4db10
4 changed files with 236 additions and 98 deletions
+81 -8
View File
@@ -546,6 +546,13 @@ test("panel notifications and volume configuration stay isolated by device", asy
type: "ackPanelNotification", deviceId, notificationId: notification.notification.notificationId,
adminToken: "test-token"
})).success, true);
const duplicatedAck = await post({
type: "ackPanelNotification", deviceId, notificationId: notification.notification.notificationId,
adminToken: "test-token"
});
assert.equal(duplicatedAck.success, true);
assert.equal(duplicatedAck.idempotent, true);
assert.equal(duplicatedAck.deleted, 0);
async function uploadResult(folderName, fileName, content) {
const result = await post({ type: "uploadDataFile", fileName, folder: `${deviceId}/${folderName}` });
@@ -908,7 +915,7 @@ test("deleteProductionLine blocks active licenses and removes revoked data", asy
assert.deepEqual(models.fileList, []);
});
test("deleteCompany requires no child lines and no remaining licenses", async () => {
test("deleteCompany cascades revoked data cleanup", async () => {
const suffix = crypto.randomUUID().slice(0, 8);
const company = await post({
type: "createCompany", name: `删除公司-${suffix}`, code: `del-co-${suffix}`,
@@ -919,21 +926,87 @@ test("deleteCompany requires no child lines and no remaining licenses", async ()
name: "子产线", code: "line-1", adminToken: "test-token"
});
const blocked = await post({ type: "deleteCompany", companyId: company.company.id, adminToken: "test-token" });
assert.equal(blocked.success, false);
assert.equal(blocked.errCode, "PRODUCTION_LINES_PRESENT");
const modelIssued = await post({
type: "issueModelUpload", deviceId: line.productionLine.deviceId,
fileName: "company-cascade.bin", adminToken: "test-token"
});
const modelForm = new FormData();
modelForm.append("file", new Blob(["cascade-model"]), "company-cascade.bin");
assert.equal((await fetch(modelIssued.uploadMetadata.url, { method: "POST", body: modelForm })).status, 204);
const lineDeleted = await post({
type: "deleteProductionLine",
const licenseId = crypto.randomUUID();
const payload = {
license_id: licenseId,
company_id: company.company.id,
production_line_id: line.productionLine.id,
customer: company.company.name,
device_id: line.productionLine.deviceId,
issued: "2026-08-01 10:00",
expiry: "2028-08-01 10:00",
features: "*"
};
await post({
type: "createLicense", licenseId,
companyId: company.company.id,
productionLineId: line.productionLine.id,
customer: payload.customer,
issued: payload.issued,
expiry: payload.expiry,
features: payload.features,
license: signLicense(payload),
adminToken: "test-token"
});
assert.equal(lineDeleted.success, true);
await post({ type: "revokeLicense", licenseId, reason: "公司删除", adminToken: "test-token" });
const deleted = await post({ type: "deleteCompany", companyId: company.company.id, adminToken: "test-token" });
assert.deepEqual(deleted, { success: true, deletedCompanyId: company.company.id });
assert.equal(deleted.success, true);
assert.equal(deleted.deletedCompanyId, company.company.id);
assert.ok(deleted.deletedProductionLines >= 1);
assert.ok(deleted.deletedLicenses >= 1);
assert.ok(deleted.deletedFiles >= 1);
const organizations = await post({ type: "listOrganizations", adminToken: "test-token" });
assert.equal(organizations.companies.some((item) => item.id === company.company.id), false);
const models = await post({ type: "listModels", folder: `${line.productionLine.deviceId}/model_config` });
assert.deepEqual(models.fileList, []);
});
test("deleteCompany blocks when active licenses exist", async () => {
const suffix = crypto.randomUUID().slice(0, 8);
const company = await post({
type: "createCompany", name: `删除公司阻断-${suffix}`, code: `del-co-block-${suffix}`,
adminToken: "test-token"
});
const line = await post({
type: "createProductionLine", companyId: company.company.id,
name: "阻断产线", code: "line-1", adminToken: "test-token"
});
const licenseId = crypto.randomUUID();
const payload = {
license_id: licenseId,
company_id: company.company.id,
production_line_id: line.productionLine.id,
customer: company.company.name,
device_id: line.productionLine.deviceId,
issued: "2026-08-01 10:00",
expiry: "2028-08-01 10:00",
features: "*"
};
await post({
type: "createLicense", licenseId,
companyId: company.company.id,
productionLineId: line.productionLine.id,
customer: payload.customer,
issued: payload.issued,
expiry: payload.expiry,
features: payload.features,
license: signLicense(payload),
adminToken: "test-token"
});
const blocked = await post({ type: "deleteCompany", companyId: company.company.id, adminToken: "test-token" });
assert.equal(blocked.success, false);
assert.equal(blocked.errCode, "ACTIVE_LICENSES_PRESENT");
});