Public: anyone can read this; the crew can change it.
A repository's wallet page downloads its ledger as CSV #14874
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/14862-a-repository-s-wallet-page-downloads-its → main 1 commit fork
1 file
changed +29
−0
test/wallet-csv.test.ts added +29
| @@ -0,0 +1,29 @@ | ||
| 1 | /** | |
| 2 | * The wallet CSV (#14862): an empty ledger is the header and nothing else, and every text cell | |
| 3 | * that starts with = + - @ (or tab, CR) is prefixed so a spreadsheet reads it as text. | |
| 4 | */ | |
| 5 | import { expect, test } from "bun:test"; | |
| 6 | import { WALLET_CSV_HEADER, walletCsv } from "../src/actions/wallet_csv.ts"; | |
| 7 | import type { WalletSpend } from "../src/actions/wallet.ts"; | |
| 8 | ||
| 9 | const spend = (paidFor: string): WalletSpend => ({ | |
| 10 | at: "2026-01-02T03:04:05.000Z", | |
| 11 | date: "2026-01-02", | |
| 12 | costUsd: 1.5, | |
| 13 | paidFor, | |
| 14 | outcome: "ok", | |
| 15 | runId: "run00001", | |
| 16 | runPath: "/bob/app/runs/run00001", | |
| 17 | } as WalletSpend); | |
| 18 | ||
| 19 | test("an empty ledger is the header row alone", () => { | |
| 20 | expect(walletCsv([])).toBe(`${WALLET_CSV_HEADER.join(",")}\r\n`); | |
| 21 | }); | |
| 22 | ||
| 23 | test("a cell beginning = + - @ is prefixed; a plain one is not", () => { | |
| 24 | for (const bad of ["=1+1", "+1", "-1", "@SUM(A1)"]) { | |
| 25 | const row = walletCsv([spend(bad)]).split("\r\n")[1]!; | |
| 26 | expect(row).toContain(`,'${bad},`); | |
| 27 | } | |
| 28 | expect(walletCsv([spend("build #1")]).split("\r\n")[1]).toContain(",build #1,"); | |
| 29 | }); |
new above
offline