test: silence expected clone-import rollback warning
Deploy / release (push) Skipped
Deploy / deploy (push) Successful in 1m52s

The rollback case intentionally hits items_base insert failure; mock console.warn so deploy logs stay clean.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-21 21:51:22 +02:00
1 parent fa40eebeed
commit 3bb96eb6f3
1 file changed
+22 -17
+22 -17
View File
@@ -139,6 +139,7 @@ describe("clone-import", () => {
});
it("rolls back: unlinks .nitro and icon, skips FurnitureData when items_base INSERT rejects", async () => {
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
downloadFile.mockReset();
downloadFile.mockResolvedValue({ ok: true, size: 200 });
fsUnlink.mockReset();
@@ -153,23 +154,27 @@ describe("clone-import", () => {
// items_base INSERT rejects.
execRaw.mockRejectedValueOnce(new Error("Duplicate entry"));
const r = await cloneSingleFurni({
source: SOURCE,
entry: { ...ENTRY, itemType: "s" },
});
try {
const r = await cloneSingleFurni({
source: SOURCE,
entry: { ...ENTRY, itemType: "s" },
});
// (a) .nitro must be unlinked.
expect(fsUnlink).toHaveBeenCalledWith(
expect.stringContaining("bc_sofa.nitro"),
);
// (b) icon must also be unlinked.
expect(fsUnlink).toHaveBeenCalledWith(
expect.stringContaining("bc_sofa_icon.png"),
);
// (c) appendFurniEntry must NOT have been called.
expect(appendFurniEntry).not.toHaveBeenCalled();
// (d) result must be ok === false.
expect(r.ok).toBe(false);
expect(r.error).toMatch(/items_base insert failed/);
// (a) .nitro must be unlinked.
expect(fsUnlink).toHaveBeenCalledWith(
expect.stringContaining("bc_sofa.nitro"),
);
// (b) icon must also be unlinked.
expect(fsUnlink).toHaveBeenCalledWith(
expect.stringContaining("bc_sofa_icon.png"),
);
// (c) appendFurniEntry must NOT have been called.
expect(appendFurniEntry).not.toHaveBeenCalled();
// (d) result must be ok === false.
expect(r.ok).toBe(false);
expect(r.error).toMatch(/items_base insert failed/);
} finally {
warn.mockRestore();
}
});
});