Skip to content

Black Friday

Annual Pro is $90 for the first year, normally $120. Or start monthly at $6 for two months, then $12.

Ends Dec 4, 11:59 PM PT.

Create an account
← Public packages

@kentcdodds/ship-pr

Progressive ship-pr loop for agents: PR status, Bugbot, review sort, human review feedback, 7-day decisions, merge, deploy, wrap-up.

FollowFork

Files

actionable.test.ts

80 lines · 2.8 KB · TypeScript
import assert from 'node:assert/strict'
import { test } from 'node:test'
import { classifyActionable, isActionable } from './actionable.ts'

const nonActionable = [
	'Thanks a lot for this!',
	'Thanks!',
	'thank you',
	'thx',
	'LGTM',
	'lgtm 👍',
	'Looks good to me.',
	'Nice!',
	'Great work!!',
	'Awesome, thanks so much!',
	'Beautiful work, thank you!',
	'🎉',
	'🎉🎉🚀',
	':tada:',
	'+1',
	'👍🏽',
	'Ship it!',
	'Well done @someone!',
	'Love it ❤️',
]

const actionable: Array<[string, string]> = [
	['Can this handle the empty case?', 'question'],
	['Why is this needed', 'request'],
	['please rename X', 'request'],
	['Please rename `fetchAll` to `fetchEvery`.', 'code'],
	['```suggestion\nconst x = 1\n```', 'suggestion block'],
	['```ts\nconst x = 1\n```', 'code'],
	['Thanks! Can you also fix Y?', 'question'],
	['Thanks! Also fix Y.', 'request'],
	['Thanks, but this breaks the build.', 'concern'],
	['Nice, though I would split this up.', 'concern'],
	["Great, but it doesn't handle null", 'negation'],
	['LGTM once the tests pass', 'request'],
	['Change this to a Map.', 'request'],
	["Let's do this in a follow-up.", 'request'],
	['Typo here.', 'concern'],
	['The socket stays open here.', 'no acknowledgement signal'],
	['This leaks the handle.', 'concern'],
	['Nice! See https://example.com/docs for the edge cases', 'link'],
	['Great job overall, small nit on naming here and there in the config loader', 'request'],
	['Nice work on the parser, the tokenizer, the cache, and the new retry loop', 'content beyond acknowledgement'],
	['- [ ] thanks', 'task list'],
	['...', 'unclassified'],
]

test('acknowledgements, approval, praise, and emoji are non-actionable', () => {
	for (const body of nonActionable) {
		const r = classifyActionable(body)
		assert.equal(r.actionable, false, `${body} -> ${r.reason}`)
	}
	assert.equal(classifyActionable('🎉').reason, 'emoji only')
	assert.equal(classifyActionable('Thanks a lot for this!').reason, 'acknowledgement')
})

test('questions, requests, code, suggestions, concerns, and mixed comments are actionable', () => {
	for (const [body, reason] of actionable) {
		const r = classifyActionable(body)
		assert.equal(r.actionable, true, body)
		assert.equal(r.reason, reason, body)
	}
})

test('hidden markers and quoted text are ignored; empty is non-actionable', () => {
	assert.equal(isActionable('<!-- ship-pr:reply-to=comment:1 -->'), false)
	assert.equal(isActionable('> Can you rename this?\n\nThanks for the review!'), false)
	assert.equal(isActionable('> Thanks!\n\nPlease rename it.'), true)
	assert.equal(isActionable(''), false)
	assert.equal(isActionable(null), false)
})

test('long comments stay actionable even when they open with thanks', () => {
	const long = `Thanks! ${'word '.repeat(30)}`
	assert.equal(classifyActionable(long).reason, 'long comment')
})