fix(workflows): resolve QA blockers and protect case evidence

Fix registrar signing, reviewer re-entry, replacement evidence freshness, owner decision and rating races, multipart objections, vehicle serialization and product reporting.

Validate uploaded media with FFmpeg, serve evidence through expiring signed links, and add targeted regressions plus a dry-run repair for prematurely completed visit cases.
This commit is contained in:
SepehrYahyaee
2026-11-22 12:50:22 +03:30
parent abc40df199
commit 6b968c0952
37 changed files with 1118 additions and 211 deletions
@@ -0,0 +1,65 @@
import { EvidenceAccessService } from "./evidence-access.module";
describe("evidence read capabilities", () => {
const secret = process.env.JWT_SECRET;
beforeEach(() => {
process.env.JWT_SECRET = "test-only-evidence-key";
});
afterEach(() => {
if (secret == null) delete process.env.JWT_SECRET;
else process.env.JWT_SECRET = secret;
});
it("rejects bare, expired, altered and cross-path links but accepts its own signature", () => {
const service = new EvidenceAccessService();
const signed = new URL(
service.sign("https://example.test/car-damage/api/files/signs/a.jpg"),
);
const exp = signed.searchParams.get("expires")!;
const sig = signed.searchParams.get("signature")!;
expect(() => service.verify("signs/a.jpg", exp, sig)).not.toThrow();
expect(() => service.verify("signs/b.jpg", exp, sig)).toThrow();
expect(() => service.verify("signs/a.jpg", "1", sig)).toThrow();
expect(() => service.verify("signs/a.jpg", exp, "")).toThrow();
expect(() => service.verify("signs/a.jpg", exp, [sig] as any)).toThrow();
expect(() => service.verify("signs/a.jpg", exp, "0".repeat(64))).toThrow();
});
it("signs nested evidence without changing ordinary links, dates, or policy text", () => {
const service = new EvidenceAccessService();
const projected: any = service.project({
files: [
{ url: service.sign("files/car/a.jpg"), path: "files/car/a.jpg" },
],
reflected: { url: "files/car/private.jpg" },
site: "https://example.test/auth",
note: "files/car/private.jpg",
description: "https://example.test/files/signs/private.png",
});
expect(projected.files[0].url).toContain("?expires=");
expect(projected.files[0].path).toContain("?expires=");
expect(projected.reflected.url).toBe("files/car/private.jpg");
expect(projected.site).toBe("https://example.test/auth");
expect(projected.note).toBe("files/car/private.jpg");
expect(projected.description).toBe(
"https://example.test/files/signs/private.png",
);
expect(service.sign("See https://example.test/files/private.jpg")).toBe(
"See https://example.test/files/private.jpg",
);
});
});
it("mints links only while an authenticated request constructs them from stored media", () => {
const { evidenceRequestScope } = require("./evidence-access.service");
const { buildFileLink } = require("src/helpers/urlCreator");
const secret = process.env.JWT_SECRET;
process.env.JWT_SECRET = "qa-test-only";
try {
expect(buildFileLink("files/car/a.jpg")).not.toContain("signature=");
expect(
evidenceRequestScope.run(true, () => buildFileLink("files/car/a.jpg")),
).toContain("signature=");
expect(buildFileLink("files/car/a.jpg")).not.toContain("signature=");
} finally {
if (secret == null) delete process.env.JWT_SECRET;
else process.env.JWT_SECRET = secret;
}
});