| 1 | { |
| 2 | "_note": "🤖 The card schema contract (web/static/cards.js normalizeCard ↔ LChatCore Card.normalize). Each vector's `card` is the decrypted payload.card as received off the wire; `want` is the canonical normalized form, or null when the card must FAIL CLOSED (the client renders the message's plain text instead). Both renderers must agree on every vector — a mismatch means web and native have drifted, which is a hard error.", |
| 3 | "schema": 1, |
| 4 | "vectors": [ |
| 5 | { |
| 6 | "name": "morning digest — the canonical full card", |
| 7 | "card": { |
| 8 | "schema": 1, |
| 9 | "blocks": [ |
| 10 | { "b": "heading", "text": "Tuesday 7 July", "sub": "NYT · RTÉ · The Guardian" }, |
| 11 | { "b": "section", "title": "Ireland", "blocks": [ |
| 12 | { "b": "item", "text": "Budget talks resume as coalition splits on USC cut", "source": "RTÉ", "url": "https://www.rte.ie/news/1" }, |
| 13 | { "b": "item", "text": "Dublin Airport cap ruling expected Thursday", "source": "The Guardian", "url": "https://www.theguardian.com/2" } |
| 14 | ] }, |
| 15 | { "b": "divider" }, |
| 16 | { "b": "kv", "rows": [["Reading time", "3 min"], ["Items", "9"]] }, |
| 17 | { "b": "chips", "chips": [{ "label": "Open RTÉ", "url": "https://www.rte.ie/news/" }] } |
| 18 | ] |
| 19 | }, |
| 20 | "want": { |
| 21 | "schema": 1, |
| 22 | "blocks": [ |
| 23 | { "b": "heading", "text": "Tuesday 7 July", "sub": "NYT · RTÉ · The Guardian" }, |
| 24 | { "b": "section", "title": "Ireland", "blocks": [ |
| 25 | { "b": "item", "text": "Budget talks resume as coalition splits on USC cut", "source": "RTÉ", "url": "https://www.rte.ie/news/1" }, |
| 26 | { "b": "item", "text": "Dublin Airport cap ruling expected Thursday", "source": "The Guardian", "url": "https://www.theguardian.com/2" } |
| 27 | ] }, |
| 28 | { "b": "divider" }, |
| 29 | { "b": "kv", "rows": [["Reading time", "3 min"], ["Items", "9"]] }, |
| 30 | { "b": "chips", "chips": [{ "label": "Open RTÉ", "url": "https://www.rte.ie/news/" }] } |
| 31 | ] |
| 32 | } |
| 33 | }, |
| 34 | { |
| 35 | "name": "minimal card — one text block", |
| 36 | "card": { "schema": 1, "blocks": [{ "b": "text", "text": "Hello." }] }, |
| 37 | "want": { "schema": 1, "blocks": [{ "b": "text", "text": "Hello." }] } |
| 38 | }, |
| 39 | { |
| 40 | "name": "optional fields omitted stay omitted", |
| 41 | "card": { "schema": 1, "blocks": [ |
| 42 | { "b": "heading", "text": "Plain heading" }, |
| 43 | { "b": "item", "text": "No source, no link" }, |
| 44 | { "b": "list", "items": ["one", "two"] } |
| 45 | ] }, |
| 46 | "want": { "schema": 1, "blocks": [ |
| 47 | { "b": "heading", "text": "Plain heading" }, |
| 48 | { "b": "item", "text": "No source, no link" }, |
| 49 | { "b": "list", "items": ["one", "two"] } |
| 50 | ] } |
| 51 | }, |
| 52 | { |
| 53 | "name": "unknown extra fields on a block are dropped, not fatal", |
| 54 | "card": { "schema": 1, "blocks": [{ "b": "text", "text": "hi", "future_hint": "compact" }] }, |
| 55 | "want": { "schema": 1, "blocks": [{ "b": "text", "text": "hi" }] } |
| 56 | }, |
| 57 | { |
| 58 | "name": "unknown schema major fails closed", |
| 59 | "card": { "schema": 2, "blocks": [{ "b": "text", "text": "from the future" }] }, |
| 60 | "want": null |
| 61 | }, |
| 62 | { |
| 63 | "name": "missing schema fails closed", |
| 64 | "card": { "blocks": [{ "b": "text", "text": "hi" }] }, |
| 65 | "want": null |
| 66 | }, |
| 67 | { |
| 68 | "name": "unknown block type fails the whole card closed", |
| 69 | "card": { "schema": 1, "blocks": [ |
| 70 | { "b": "text", "text": "fine" }, |
| 71 | { "b": "hologram", "text": "not yet" } |
| 72 | ] }, |
| 73 | "want": null |
| 74 | }, |
| 75 | { |
| 76 | "name": "nested sections fail closed (one level only)", |
| 77 | "card": { "schema": 1, "blocks": [ |
| 78 | { "b": "section", "blocks": [{ "b": "section", "blocks": [{ "b": "text", "text": "deep" }] }] } |
| 79 | ] }, |
| 80 | "want": null |
| 81 | }, |
| 82 | { |
| 83 | "name": "empty blocks fails closed", |
| 84 | "card": { "schema": 1, "blocks": [] }, |
| 85 | "want": null |
| 86 | }, |
| 87 | { |
| 88 | "name": "item with a non-https url fails closed", |
| 89 | "card": { "schema": 1, "blocks": [{ "b": "item", "text": "x", "url": "javascript:alert(1)" }] }, |
| 90 | "want": null |
| 91 | }, |
| 92 | { |
| 93 | "name": "chip without a url fails closed (v1 chips are links only)", |
| 94 | "card": { "schema": 1, "blocks": [{ "b": "chips", "chips": [{ "label": "Approve", "emit": { "type": "x" } }] }] }, |
| 95 | "want": null |
| 96 | }, |
| 97 | { |
| 98 | "name": "kv row that is not a pair fails closed", |
| 99 | "card": { "schema": 1, "blocks": [{ "b": "kv", "rows": [["k", "v", "extra"]] }] }, |
| 100 | "want": null |
| 101 | }, |
| 102 | { |
| 103 | "name": "empty text fails closed", |
| 104 | "card": { "schema": 1, "blocks": [{ "b": "text", "text": "" }] }, |
| 105 | "want": null |
| 106 | }, |
| 107 | { |
| 108 | "name": "list with a non-string item fails closed", |
| 109 | "card": { "schema": 1, "blocks": [{ "b": "list", "items": ["ok", 7] }] }, |
| 110 | "want": null |
| 111 | }, |
| 112 | { |
| 113 | "name": "card that is not an object fails closed", |
| 114 | "card": "just a string", |
| 115 | "want": null |
| 116 | } |
| 117 | ] |
| 118 | } |
| 119 | |