{"draft":null,"from":28,"to":29,"files":[{"path":"client/test/attach.test.ts","added":38,"removed":1,"diff":"--- a/client/test/attach.test.ts\n+++ b/client/test/attach.test.ts\n@@ -3,7 +3,7 @@\n // here is a stand-in that keeps what it was sent.\n \n import assert from \"node:assert/strict\";\n-import { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\n+import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n import { createServer, type Server } from \"node:http\";\n import type { AddressInfo } from \"node:net\";\n import { tmpdir } from \"node:os\";\n@@ -43,6 +43,20 @@\n \t\t\t\t});\n \t\t\tif (req.url!.endsWith(\"/issue\")) return json({ id: 7 });\n \t\t\tif (/\\/issue\\/\\d+\\/comment$/.test(req.url!)) return json({ id: 3 });\n+\t\t\t// Issue 8 carries an svg-drawn image on itself and again on a comment, plus one more on the comment.\n+\t\t\tconst logo = { id: \"a00000000000b\", name: \"../shot one.png\", type: \"image/png\", size: 13 };\n+\t\t\tif (req.method === \"GET\" && /\\/issue\\/8$/.test(req.url!))\n+\t\t\t\treturn json({\n+\t\t\t\t\tissue: { id: 8, attachments: [{ ...logo, source: { name: \"logo.svg\", size: 20 } }] },\n+\t\t\t\t\tcomments: [{ attachments: [logo, { id: \"a00000000000c\", name: \"after.png\", type: \"image/png\", size: 13 }] }],\n+\t\t\t\t\tedits: [],\n+\t\t\t\t\tasks: [],\n+\t\t\t\t\tclaims: [],\n+\t\t\t\t\tchildren: [],\n+\t\t\t\t});\n+\t\t\tconst served = /\\/attachments\\/(a[0-9a-f]{12})(\\/source)?$/.exec(req.url!);\n+\t\t\tif (req.method === \"GET\" && served)\n+\t\t\t\treturn res.writeHead(200, { \"content-type\": \"image/png\" }).end(`${served[1]}${served[2] ?? \"\"}`);\n \t\t\tres.writeHead(404).end(\"{}\");\n \t\t});\n \t});\n@@ -142,6 +156,29 @@\n \t\tassert.equal(seen.length, from);\n \t});\n \n+\tit(\"--save-attachments saves each attachment once, an svg's own file too, outside the folder\", async () => {\n+\t\tconst dir = await folder();\n+\t\tconst out = mkdtempSync(join(tmpdir(), \"abso-saved-\"));\n+\t\tdirs.push(out);\n+\t\tconst r = await avcs(dir, [\"issue\", \"8\", \"--save-attachments\", join(out, \"images\")]);\n+\t\tassert.equal(r.exit, 0, r.out);\n+\t\tconst names = readdirSync(join(out, \"images\")).sort();\n+\t\tassert.deepEqual(names, [\"a00000000000b-logo.svg\", \"a00000000000b-shot_one.png\", \"a00000000000c-after.png\"]);\n+\t\tassert.equal(readFileSync(join(out, \"images\", \"a00000000000b-logo.svg\"), \"utf8\"), \"a00000000000b/source\");\n+\t\tassert.equal(readFileSync(join(out, \"images\", \"a00000000000c-after.png\"), \"utf8\"), \"a00000000000c\");\n+\t\tassert.equal((r.json as { files: unknown[] }).files.length, 3);\n+\t\t// Into the folder only where abso leaves files out, or they'd be recorded as edits.\n+\t\tconst inside = await avcs(dir, [\"issue\", \"8\", \"--save-attachments\", \"images\"]);\n+\t\tassert.equal(inside.exit, 1);\n+\t\tassert.match(inside.out, /inside this abso folder/);\n+\t\tassert.equal((await avcs(dir, [\"issue\", \"8\", \"--save-attachments\", \".\"])).exit, 1);\n+\t\twriteFileSync(join(dir, \".absoignore\"), \"saved/\\n\");\n+\t\tassert.equal((await avcs(dir, [\"issue\", \"8\", \"--save-attachments\", \"saved\"])).exit, 0);\n+\t\tconst mixed = await avcs(dir, [\"issue\", \"8\", \"--save-attachments\", out, \"--comment\", \"x\"]);\n+\t\tassert.equal(mixed.exit, 1);\n+\t\tassert.match(mixed.out, /--save-attachments goes alone/);\n+\t});\n+\n \tit(\"an issue's page lists its attachments and each comment's, with links\", () => {\n \t\tconst page = {\n \t\t\tissue: {"}],"unmatched":[]}