lint: fix biome issues in new test files and helpers
CI / check (push) Failing after 34s
CI / preflight (push) Skipped
CI / deploy (push) Skipped

This commit is contained in:
openhands committed 2026-09-21 18:19:39 +02:00
1 parent 99eb3af17b
commit 93862c2275
41 files changed
+488 -314

No files matched your search

+44 -13
View File
@@ -13,7 +13,12 @@ const actionErrorClass = vi.hoisted(
const state = vi.hoisted(() => ({
allowed: [] as string[],
tickets: [] as { id: number; assigneeId: number | null; status: string; priority: string }[],
tickets: [] as {
id: number;
assigneeId: number | null;
status: string;
priority: string;
}[],
insertCall: undefined as unknown,
updateCall: undefined as unknown,
rowsForSelect: [] as unknown[],
@@ -21,7 +26,10 @@ const state = vi.hoisted(() => ({
}));
vi.mock("@/lib/safe-action", () => ({
adminAction: (opts: { permission?: string | readonly string[]; schema?: z.ZodType }, handler: (ctx: any) => unknown) => {
adminAction: (
opts: { permission?: string | readonly string[]; schema?: z.ZodType },
handler: (ctx: any) => unknown,
) => {
return async (input: unknown) => {
const needed = Array.isArray(opts.permission)
? opts.permission
@@ -63,7 +71,10 @@ vi.mock("@/lib/safe-action-shared", () => ({
}));
vi.mock("@/lib/permissions", () => ({
PERMS: { TICKETS_EDIT: "admin.tickets.edit", MOD_TICKETS_EDIT: "mod.tickets.edit" },
PERMS: {
TICKETS_EDIT: "admin.tickets.edit",
MOD_TICKETS_EDIT: "mod.tickets.edit",
},
}));
vi.mock("@/lib/services/audit", () => ({ logAudit: vi.fn() }));
@@ -135,8 +146,13 @@ describe("adminReplyTicket", () => {
});
it("inserts a staff message and auto-assigns an unassigned ticket", async () => {
state.tickets = [{ id: 1, assigneeId: null, status: "open", priority: "low" }];
const res = await adminReplyTicket({ ticketId: 1, message: "Working on it" });
state.tickets = [
{ id: 1, assigneeId: null, status: "open", priority: "low" },
];
const res = await adminReplyTicket({
ticketId: 1,
message: "Working on it",
});
expect(res).toEqual({ ok: true, data: {} });
expect(state.insertCall.values).toMatchObject({
ticketId: 1,
@@ -154,7 +170,9 @@ describe("adminReplyTicket", () => {
});
it("does not clobber an existing assignee", async () => {
state.tickets = [{ id: 2, assigneeId: 55, status: "open", priority: "low" }];
state.tickets = [
{ id: 2, assigneeId: 55, status: "open", priority: "low" },
];
await adminReplyTicket({ ticketId: 2, message: "Already owned" });
expect(state.updateCall.values).toMatchObject({ status: "waiting" });
expect(state.updateCall.values.assigneeId).toBeUndefined();
@@ -163,7 +181,9 @@ describe("adminReplyTicket", () => {
describe("updateTicketStatus", () => {
it("sets closedAt when closing a ticket", async () => {
state.tickets = [{ id: 3, assigneeId: 55, status: "waiting", priority: "low" }];
state.tickets = [
{ id: 3, assigneeId: 55, status: "waiting", priority: "low" },
];
const res = await updateTicketStatus({ ticketId: 3, status: "closed" });
expect(res).toEqual({ ok: true, data: {} });
expect(state.updateCall.values).toMatchObject({ status: "closed" });
@@ -178,7 +198,9 @@ describe("updateTicketStatus", () => {
});
it("auto-assigns when moving an unowned ticket to in_progress", async () => {
state.tickets = [{ id: 4, assigneeId: null, status: "open", priority: "low" }];
state.tickets = [
{ id: 4, assigneeId: null, status: "open", priority: "low" },
];
await updateTicketStatus({ ticketId: 4, status: "in_progress" });
expect(state.updateCall.values).toMatchObject({
status: "in_progress",
@@ -203,7 +225,9 @@ describe("updateTicketStatus", () => {
describe("assignTicket", () => {
it("marks an assigned ticket in_progress", async () => {
state.tickets = [{ id: 6, assigneeId: null, status: "open", priority: "low" }];
state.tickets = [
{ id: 6, assigneeId: null, status: "open", priority: "low" },
];
const res = await assignTicket({ ticketId: 6, assigneeId: 42 });
expect(res).toEqual({ ok: true, data: {} });
expect(state.updateCall.values).toMatchObject({
@@ -220,7 +244,9 @@ describe("assignTicket", () => {
});
it("returns the ticket to open when unassigning", async () => {
state.tickets = [{ id: 7, assigneeId: 42, status: "in_progress", priority: "low" }];
state.tickets = [
{ id: 7, assigneeId: 42, status: "in_progress", priority: "low" },
];
await assignTicket({ ticketId: 7, assigneeId: null });
expect(state.updateCall.values).toMatchObject({
assigneeId: null,
@@ -254,14 +280,19 @@ describe("updateTicketPriority", () => {
it("throws when the ticket does not exist", async () => {
state.tickets = [];
expect(await updateTicketPriority({ ticketId: 1, priority: "high" })).toEqual({
expect(
await updateTicketPriority({ ticketId: 1, priority: "high" }),
).toEqual({
ok: false,
error: "Ticket not found",
});
});
it("rejects an unknown priority value", async () => {
const res = await updateTicketPriority({ ticketId: 1, priority: "max" as never });
const res = await updateTicketPriority({
ticketId: 1,
priority: "max" as never,
});
expect(res).toMatchObject({ ok: false, error: "Validation failed" });
});
});
});