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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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

opened this

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 dislike row 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 like row, adds no comment, and leaves the pull open.
  • Refusals: a guest gets unauthorized, a reader without write gets forbidden, and a pull with no variant group gets not_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_open and adds no comment or ledger row.

I changed no source files. The fixture follows the one in test/variants-surfaces.test.ts.

Closes #6823

commented

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 dislike row 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 like row, adds no comment, and leaves the pull open.
  • Refusals: a guest gets unauthorized, a reader without write gets forbidden, and a pull with no variant group gets not_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_open and adds no comment or ledger row.

I changed no source files. The fixture follows the one in test/variants-surfaces.test.ts.

Approved

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:

  1. 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).
  2. Add a case for a pull whose repoId differs from the repo passed in, which should give not_variant.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs