Say which property a JMAP SetError rejected
"Send failed: Invalid property or value." is Stalwart's description for invalidProperties, and on its own it says nothing about what to fix. The SetError also carries a `properties` array naming the offending fields, which every call site was discarding. setErrorMessage appends them, and the 35 places that surfaced a SetError - send, save draft, mailboxes, calendars, contacts, sieve, files, signature images, sharing - now go through it.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { setErrorMessage } from "@/jmap/client";
|
||||
|
||||
describe("setErrorMessage", () => {
|
||||
it("names the offending properties, which is usually the whole answer", () => {
|
||||
expect(setErrorMessage({ type: "invalidProperties", description: "Invalid property or value.", properties: ["sentAt"] }))
|
||||
.toBe("Invalid property or value. (sentAt)");
|
||||
expect(setErrorMessage({ type: "invalidProperties", properties: ["to", "cc"] }))
|
||||
.toBe("invalidProperties (to, cc)");
|
||||
});
|
||||
|
||||
it("falls back cleanly when the server says less", () => {
|
||||
expect(setErrorMessage({ type: "forbidden" })).toBe("forbidden");
|
||||
expect(setErrorMessage({ type: "forbidden", description: "Not allowed" })).toBe("Not allowed");
|
||||
expect(setErrorMessage({ type: "x", properties: [] })).toBe("x");
|
||||
expect(setErrorMessage(null)).toBe("Unknown error");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user