test(housekeeping): finalize release evidence

This commit is contained in:
Simo committed 2026-08-30 21:06:40 +02:00
1 parent 222535e116
commit 4d0c8c7e65
1 file changed
+41 -5
@@ -234,7 +234,36 @@ describe("People production workflow adapter", () => {
expect(mocks.transaction).not.toHaveBeenCalled(); expect(mocks.transaction).not.toHaveBeenCalled();
}); });
it("checks every bulk target hierarchy before starting a mutation", async () => { it("assigns an existing configured rank above 7 for a super-admin", async () => {
mocks.resolveServerContext.mockResolvedValue({
...context(),
actor: { id: 42, username: "operator", rank: 8 },
isSuperAdmin: true,
});
mocks.selectQueue.push([target({ rank: 2 })]);
mocks.execute.mockResolvedValueOnce([[{ id: 9 }], []]);
const result = await peopleMutationService.execute(
invocation,
"user.update",
{ userId: 7, fields: { rank: 9 } },
);
expect(result).toMatchObject({ ok: true, data: { after: { rank: 9 } } });
expect(mocks.updateSet).toHaveBeenCalledWith(
expect.objectContaining({ rank: 9 }),
);
expect(mocks.transaction).toHaveBeenCalledTimes(1);
});
it.each([
["users.bulk-ban", { userIds: [7], duration: 3600, reason: "Denied" }],
["users.bulk-unban", { userIds: [7] }],
["users.bulk-currency", { userIds: [7], type: "credits", amount: 50 }],
["users.bulk-badge", { userIds: [7], badgeCode: "ADM" }],
] as const)(
"checks target hierarchy before starting %s",
async (operation, input) => {
mocks.resolveServerContext.mockResolvedValue({ mocks.resolveServerContext.mockResolvedValue({
...context(), ...context(),
actor: { id: 42, username: "operator", rank: 8 }, actor: { id: 42, username: "operator", rank: 8 },
@@ -244,13 +273,20 @@ describe("People production workflow adapter", () => {
const result = await peopleMutationService.execute( const result = await peopleMutationService.execute(
invocation, invocation,
"users.bulk-ban", operation,
{ userIds: [7], duration: 3600, reason: "Denied" }, input,
); );
expect(result).toMatchObject({ ok: false, error: { code: "FORBIDDEN" } }); expect(result).toMatchObject({
expect(mocks.transaction).not.toHaveBeenCalled(); ok: false,
error: { code: "FORBIDDEN" },
}); });
expect(mocks.transaction).not.toHaveBeenCalled();
expect(mocks.insertValues).not.toHaveBeenCalled();
expect(mocks.updateSet).not.toHaveBeenCalled();
expect(mocks.deleteWhere).not.toHaveBeenCalled();
},
);
it("preserves legacy bulk order, duplicates, totals, and StaffActivities", async () => { it("preserves legacy bulk order, duplicates, totals, and StaffActivities", async () => {
const ids = Array.from({ length: 101 }, (_, index) => (index % 2) + 1); const ids = Array.from({ length: 101 }, (_, index) => (index % 2) + 1);