"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.
19 lines
896 B
TypeScript
19 lines
896 B
TypeScript
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");
|
|
});
|
|
});
|