fix(housekeeping): address task 14 review round 1

This commit is contained in:
Simo committed 2026-08-30 10:53:50 +02:00
1 parent fd68819d9b
commit d09eaa33d6
23 files changed
+2503 -488

No files matched your search

+18 -20
View File
@@ -1,30 +1,28 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { tryRemoveLocalPhotoFile } from "@/lib/admin/photo-files";
describe("admin-photos Content service contract", () => {
const wrapper = readFileSync("src/actions/admin-photos.ts", "utf8");
const runtime = readFileSync(
"src/features/housekeeping/domains/content/services/mutation-runtime-external.ts",
describe("setTradeLock database and live-sync contract", () => {
const wrapper = readFileSync("src/actions/bulk-users.ts", "utf8");
const service = readFileSync(
"src/features/housekeeping/domains/people/services/mutations.ts",
"utf8",
);
const rcon = readFileSync("src/lib/services/rcon.ts", "utf8");
it("delegates while the runtime deletes CameraWeb and purges local files", () => {
expect(wrapper).toContain("contentMutationService.execute");
expect(wrapper).toContain('"photo.delete"');
expect(wrapper).toContain('revalidatePath("/photos")');
expect(runtime).toContain("@/lib/db");
expect(runtime).toContain("CameraWeb");
expect(runtime).toContain("tryRemoveLocalPhotoFile");
it("retains the legacy action while the owning service writes both trade-lock stores", () => {
expect(wrapper).toMatch(/export async function setTradeLock/u);
expect(wrapper).toContain('"user.trade-lock"');
expect(service).toContain("UsersSettings");
expect(service).toContain("Sanctions");
expect(service).toContain("canTrade");
expect(service).toContain("tradeLockedUntil");
});
});
describe("tryRemoveLocalPhotoFile", () => {
it("rejects path traversal and remote CDN urls", async () => {
expect(await tryRemoveLocalPhotoFile("https://cdn.example/photo.png")).toBe(
false,
);
expect(await tryRemoveLocalPhotoFile("/../../etc/passwd")).toBe(false);
expect(await tryRemoveLocalPhotoFile("")).toBe(false);
it("keeps live RCON lock, alert, and disconnect behavior", () => {
expect(rcon).toContain("settradelock");
expect(rcon).toContain("setTradeLock(userId: number, locked: boolean)");
expect(service).toContain("rcon.setTradeLock");
expect(service).toContain("rcon.alertUser");
expect(service).toContain("rcon.disconnectUser");
});
});