Public: anyone can read this; the crew can change it.
A test pins variant votes: a dislike closes the pull with one comment and one ledger row, and a refused vote leaves nothing behind #6839
Check · Review · Land · Live done — Landed and live in production.
I added `test/variant-votes.test.ts`, which tests `voteVariant` directly. Its five tests pass, and `bun x tsc --noEmit` is clean. I ran only this file, not the full suite.
shipped production is serving it deploy eb43263
I added test/variant-votes.test.ts, which tests voteVariant directly. Its five tests pass, and bun x tsc --noEmit is clean. I ran only this file, not the full suite.
- Dislike: a writer's dislike closes the pull, adds exactly one comment starting "Closed: not chosen among its variants.", and records one
dislikerow with the reason. The reason's whitespace is collapsed. - Reason length: an empty reason records "Not this one.". A 500-character reason is cut to
REASON_MAX. - Like: a like records one
likerow, adds no comment, and leaves the pull open. - Refusals: a guest gets
unauthorized, a reader without write getsforbidden, and a pull with no variant group getsnot_variant. Each leaves the comment count, the ledger and the pull state unchanged. - Second dislike: a second dislike on the now-closed pull returns
not_openand adds no comment or ledger row.
I changed no source files. The fixture follows the one in test/variants-surfaces.test.ts.
Test-only change, matches the issue: one new file, no source or dependency touched. It covers dislike (one comment, one ledger row, whitespace collapsed), the default and capped reason, like (open, no comment), the three refusals (unauthorized, forbidden, not_variant) leaving nothing behind, and the second dislike returning not_open. Each assertion would fail if voteVariant lost its guards or its transaction. The fixture follows variants-surfaces. There is no user-facing surface here, so nothing to check in the preview.
Two things I would do next:
- Pin the transaction rollback: force addComment or the ledger write to fail and assert the pull stays open with no comment (the failed path is untested).
- Add a case for a pull whose repoId differs from the repo passed in, which should give not_variant.
I added
test/variant-votes.test.ts, which testsvoteVariantdirectly. Its five tests pass, andbun x tsc --noEmitis clean. I ran only this file, not the full suite.dislikerow with the reason. The reason's whitespace is collapsed.REASON_MAX.likerow, adds no comment, and leaves the pull open.unauthorized, a reader without write getsforbidden, and a pull with no variant group getsnot_variant. Each leaves the comment count, the ledger and the pull state unchanged.not_openand adds no comment or ledger row.I changed no source files. The fixture follows the one in
test/variants-surfaces.test.ts.Closes #6823